Start Here
These are my recommended resources to start with, if you are planning to go down the same path and learn functional programming.
- โ Functional Programming Basics - Whatโs It All About? “Functional Programming is programming without assignment statements.” This means data in memory is (mostly) immutable and that makes parallelism for multiple CPU cores much easier to reason about. This article is a very high-level introduction into one of the core concepts of FP and ties it to one of the main benefits. I do think there’s more to it than that, but this should get you excited about it.
- โ Professor Frisby’s Mostly Adequate Guide to Functional Programming Thorough and practical introduction to functional programming concepts using JavaScript. Gets you up to speed quickly, and there’s no weird syntax to get used to. A great resource to start with.
- โ ๐บ (30m) Functional programming patterns for the non-mathematician (cut) Good introduction on how you can practically use composition, lenses, (which are built on monoids, functors, applicatives, and monads) for nesting (composition), null checking (Maybe), error handling (Either), and accumulation (reduce) in JavaScript.
- โ ๐ PureScript by Example PureScript’s syntax and libraries are almost identical to Haskell’s, and this book is much shorter and more practical. I’d recommend learning PureScript (and Haskell) by starting with this book.
- โ Getting started with Haskell โข Stack Overflow Gives you a high-level overview of what the journey of learning Haskell can look like. Several good pointers to articles and resources.
- โ ๐ Haskell Programming from First Principles Massive introduction into Haskell with lots of explanation and exercises. Some people find it too exhaustive, but I like this book much better than the free “Learn you a Haskell”, although it’s still very academic. It starts off with a very abstract introduction to lambda calculus, which I believe is an important basis to know about before diving into Haskell. It does make the first chapter a little strange โ keep reading and don’t judge the book until after chapter 2.
- Mapping the Monado Pragmatic and honest introduction to monads. Also includes an excellent list of resources at the end.
- โ Monoids, Functors, Applicatives, and Monads: 10 Main Ideas Great summary of the key points on the four algebras that show up everywhere in Haskell (and are hiding in other languages as well).
- Conal Elliott - Denotational Design: From Meanings To Programs Conal shows how he designs a simple, functional API for a graphics manipulation framework from scratch and iterates on it to make use of already available algebraic structures that maximize reusability and minimize implementation effort.
- โ Haskell Typeclassopedia Given how important it is to understand types in Haskell, this article explains the most abstract (read: used everywhere) type classes in great detail and helps form an intuitive understanding of functor, applicative, and monad.
- โ Diehl: What I Wish I Knew While Learning Haskell The first two sections Basics and Monads are packed with great practical tips and a solid foundation for understanding monads, an abstract concept that shows up everywhere in Haskell and functional programming.
General
- Can Programming Be Liberated from the von Neumann Style? A Functional Style and Its Algebra of Programs Influential article written in 1978 describing a functional system for computation which sounds a lot like what functional programming languages these days are built on.
- ๐บ (60m) “I See What You Mean” by Peter Alvaro Entertaining presentation about modeling state with declarative languages. Many applicable concepts although it is understandably a little heavy on the relational language this talk is about.
- From Higher-Order Functions to Libraries And Frameworks How higher-order functions influence the expressiveness and complexity of programs. This is part 1 of a series of 3 articles.
- Functional Programming is taking over UIs with Pure Views Why functional programming helps keeping the user interface layer simple and enables hot module replacement, time-travel debugging and similar features.
- A Beginner-Friendly Tour through Functional Programming in Scala Introduces benefits of functional programming by transforming a simple console program from imperative to declarative step by step. Even though it’s using Scala, it helps understanding the basic building blocks of FP and their benefits.
- Destroy All Ifs โ A Perspective from Functional Programming By replacing conditionals with lambdas, we can invert control and make our code both easier to reason about and more generic. Moving conditionals from places hidden in the deepest nested function up to the caller makes intent clear and prevents mistakes.
- Sum Types
- Evaluating cellular automata is comonadic
- Streaming Combinators and Extracting Flat Parallelism
- Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire
- ? ๐ Modeling Data with Functional Programming in R
JavaScript
- JavaScript without Loops Looks at how map, reduce, filter, and find help separate iteration logic from what we actually want to achieve when working with arrays in JavaScript.
- JavaScript. But less iffy. Simplifying conditionals by returning early, using ternaries, and replacing control structure with data in JavaScript.
- A Functional Programmerโs Introduction to JavaScript (Composing Software)
- Higher Order Functions (Composing Software)
- ? ๐บ Functional Programming in JavaScript
Haskell
- Learn Haskell the hard way Just as promised in the title, an introduction to Haskell from zero to monads in a rather short article. I don’t think this is a good tutorial to start with, but after reading about the concepts in other places, the additional examples and different ways of explaining monads in this article are very helpful.
- Let vs. Where Very helpful article to understand where it is appropriate to use let or where.
- ๐ก Scalable program architectures Explains the core concept of composition with monoids: combine several components together of type A to generate a new component of the same type A, indistinguishable in character from its substituent parts. These abstractions scale limitlessly because they always preserve combinability, therefore we never need to layer further abstractions on top.
- ๐ก The category design pattern
- ๐ก The functor design pattern Functors are adapters that bridge between categories. Instead of rewriting functions for a different category, a functor allows you to re-use the existing function to work in another category.
- Queer Types - Applicatives and Alternatives Practical introduction into how applicatives (and alternatives, which build on it) can be used.
- Foldable and Traversable
- Haskell/Understanding monads/State
- Scalable program architectures
- Equational reasoning at scale
- ๐บ (20m) George Wilson - When Less is More and More is Less: Trade-Offs in Algebra Great overview of abstract algebra structures in Haskell, their laws, and which power we can derive from them.
- ๐บ (1h:30m) C++Now 2017: Ryan Newton “Haskell taketh away: limiting side effects for parallel programming” Fascinating look into the direction and development of Haskell.
- ๐บ Tangible Functional Programming
- ๐บ (60m) Fastware - Andrei Alexandrescu
- ? EdX course: Introduction to Functional Programming (via Haskell)
- ? Haskell Communities and Activities Report โข 32nd Ed. May 2017
Practical Haskell
- ๐ Purely Functional Data Structures Proves that purely functional data structures can be as fast as imperative algorithms thanks to memoization and clever algorithm design.
- ๐ Real World Haskell โข Bryan O’Sullivan, Don Stewart, and John Goerzen This book promises to teach more practical Haskell, which makes it a welcome alternative to all the academic books out there. Haven’t read it yet, so I don’t know if that’s true.
- ๐ Parallel and Concurrent Programming in Haskell This book gets mentioned and referred to a lot, surprisingly not just for topics around the book’s title.
- The Fun of Programming โข Ch. 7 Functional Images Creating visual patterns with math based on transformation functions. Great example of how composing small components can yield complex effects.
- ๐บ (45m) Manuel Chakravarty - Haskell SpriteKit: A Case Study in Turning a Stateful into a Functional API
- Introduction to brick, a Haskell library for building terminal user interfaces
- Writing Video Games in a Functional Style A collection of articles exploring the implementation of arcade games and their game state and game loops in a functional style.
- Code Us Some Roguelike in Haskell (Part 2)
Haskell Resources
- Haskell Wiki
- Hoogle โ Enter a type signature and it will find you matching functions
- Hayoo โ Same but with support for third-party packages
- Vim and Haskell in 2016 โ How to set up your dev env with vim for Haskell
PureScript
- ๐บ Luka Jacobowitz - Reactive Programming in the Browser with Scala.js and PureScript
- ๐บ Intro to PureScript - Utah Haskell Meetup
- ๐บ PureScript & Pux ~ Front End Authority (Oct 2016)
- Pux
Swift
- ๐บ (45m) Brandon Williams - Finding Happiness in Functional Programming Exploring the benefits and downsides of functional concepts in practical use, from isolation of side (and co-)effects to coding for an interface we wish we had instead of the one we’re given. Great points about how to encapsulate state management with lenses using UIKit as an example.
- ๐บ (10 Talks) Functional Swift Conference 2017
- ๐ก ๐บ (25m) Brandon Kase: Composable Caching in Swift Using a monoidal structure to simplify layered caching with composable caches.
- ๐ก ๐บ (40m) Brandon Kase: Beyond Types in Swift
Adding functionality without adding complexity through abstract algebra:
- Magma: closed binary operators = composable operation
- Semi-group: + associativity = parallelization
- Monoid: + identity = dropping the optional
- Commutative Monoid: + commutativity = reorder
- Bounded Semilattice: + idempotence = no need for memory
- ๐ก ๐บ (40m) Monoids, Predicates and Sorting Functions This demonstrates the practical application of the other Brandon’s talk above with live coding in Swift Playgrounds. Impressive composability of the simplest components by building them up following the rules and laws.
- Swift Enums Are “sum” Types. That Makes Them Very Interesting Explains product and sum types and shows how they can be used to minimize possible use cases and define away potential error states. With examples for use cases for sum types (enums) like router and theme patterns and tree data structures.
- Algebraic Structure and Protocols This article takes a mathematical approach to introduce monads through semigroups.
- The Algebra of Predicates and Sorting Functions Extends the knowledge about semigroups and monoids to introduce predicate and sorting functions.
- ๐บ (30m) Brandon Williams - Lenses in Swift Using lenses and prisms to create getters and setters for immutable values.
- An aside about flatMap and monads Practical notes on Monads in Swift and Haskell, and how Swift’s flatMap sometimes is a proper monad and sometimes isn’t (and why that’s totally fine).
- Composable HTML Views in Swift Improving an eDSL for generating HTML in Swift with the powers of abstract algebra in form of Monoids.
- Swift โ memoize() walk through
- Functional Swift and Memoization
- ๐บ (20m) Optimizing Swift Collections โข Kรกroly Lลrentey at dotSwift 2017 Deep dive into performance characteristics of Swift Collection types.
- Apple Swift Ownership Manifesto
- The Elm Architecture in Swift
Category Theory
- Haskell/Category theory After being familiar with using functors, monoids, and monads in Haskell, this article introduces just enough category theory to understand the maths behind those concepts.
- ๐บ (60m) Category Theory for the Working Hacker by Philip Wadler If you want to take it an abstraction level higher, this surprisingly entertaining talk explains the math behind lambda calculus called category theory.
- Monads Made Difficult Explains monads coming from category theory. This is only helpful if you enjoy the math a lot.
- Duality for Haskellers Explains the concept of duality in category theory using sum/product, top/bottom, and fold/unfold on lists.
- Flipping arrows in coBurger King Explains co-monad and duality and the concept of “flipping arrows” in category theory.
- Data and Codata
Functional Patterns to Manage Complexity
- ๐ก ๐บ (60m) Gabriel Gonzales: Applied category theory and abstract algebra - ฮปC Winter Retreat 2017 “[We can] tackle software complexity by reusing standard interfaces that originate in the fields of category theory and abstract algebra.” Builds understanding for composition going from composable functions to composable values (monoids) to composable types (applicatives) and shows how powerful these concepts are to decompose programs into simple building blocks.
- ๐ก A Modern Architecture for FP “We shouldnโt write programs โ we should write descriptions of programs, which we can then introspect, transform, and interpret at will.” How to architect a program that uses separate layers of DSLs to encode business logic in separate domains, and having an interpreter combining those DSLs to generate the actual program. It seems cumbersome to do this, but the composability of this approach looks promising.
- ๐ก Modern Functional Programming: Part 2 John edited his thoughts in part 1 into a more coherent and clear picture in this article and gives a glimpse into the future of programming by combining interpreters for different DSLs.
- ๐บ (45m) Sandy Maguire: Don’t Eff It Up: Free Monads in Action Shows a technique to combine different side effects with free monads using the Eff(ects) monad, which can be used as an alternative to monad transformers with less boilerplate.
- ๐บ (40m) John A De Goes: MTL Versus Free Deathmatch - ฮปC 2016 Fun talk diving deeper into John’s thoughts about the future of programming with abstract functional structures generating and manipulating the program before it’s being executed.
- ๐บ (1h:15m) John DeGoes: Beyond Free Monads - ฮปC Winter Retreat 2017 More thoughts about John’s vision of programming with abstract functional concepts and why we need a better programming language to actually make that future happen.