How to FP

Bottom-upTop-downCypress

How to FP:
Examples → concepts

Start with the examples and work up to abstract concepts.

How to FP:
Concepts → examples

Start with abstract concepts and work down to the examples.

Resources:
Cypress

Best practices to follow in Cypress.io and anti-patterns to avoid.

How to use this resource

There are two approaches to learning how to FP provided here. You can do either or both. Also included is a list of patterns and anti-patterns for quick reference.

Styles of learning

There are two fundamental and opposing approaches to learning: inductive and deductive. If you've studied science, logic, or philosophy, you've probably heard these terms before.

Inductive learning: from real-world examples to abstract theory

Inductive learning is generally the best way to learn, especially when you're new to a subject. You begin with concrete, real-world examples. After you've seen a few examples and played with them, you begin to notice patterns. From these patterns you derive the abstract rules.

Inductive learning goes from concrete examples to abstract concepts.

For example, to learn functional programming, you jump right in and begin writing functions. You're not worried about abstract concepts such as referential transparency, side-effects, substitution, or the "lambda calculus". You're just writing code.

After we've guided you through a few examples (or given you a Runkit to play with), we extract a principle. We start with the simplest principles and build up from there. We hold off on explaining why until you've seen the what. This works best for most people and especially when you're new to a topic.

Try it the inductive way: learn FP from the bottom up

Deductive learning: from abstract theory to real-world examples

The other method is to start with abstract principles, explain them, and then move on to examples. This works best for people who are already pretty familiar with the material, or at least with similar materials. You need a lot of context, which beginners by definition don't have.

For example, if you're an expert in, say, Java, and you want to learn C#a very similar languagethen you can probably start at the theory level and just learn the differences between the two languages before moving on to examples.

Deductive learning goes from abstract concepts to concrete examples.

But if you're changing paradigmssay from OOP to FPor new to learning programming, then you'll probably do better with the inductive method above.

If you're not sure, then you might try starting with the deductive (top-down) style, and then if you find yourself confused, switch to the inductive (bottom-up) style. There are even links in the deductive version to help you do that.

Let us know what you think.

Try it the deductive way: learn FP from the top down

Resources

Once you've grasped the fundamental differences of the functional, declarative approach and have embraced immutability, pure functions, and functional composition, you can use the resources here to polish up your skills. Or start here, if you prefer, and refer back to the How-to-FP tutorials as needed.

  1. Cypress