Skip to content

Instantly share code, notes, and snippets.

Created June 2, 2017 05:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save walkermalling/7565ff97f3c2ec5b1e52d057f09c476d to your computer and use it in GitHub Desktop.
Notes on Intro to Functional Programming

FP Study Group

Overview of Functional Programming

What Makes a Language “Functional”

Higher Order Functions


Immutable Data

Referential Transparency

Lazy Evaluation

Control of Side-Effects



How you think

programming functionally forces you to focus on the abstraction


Lamda Calculus


Professor Frisby’s Guide

Seagull Example

Algebraic Rules

Associative Property (of addition)

X + (Y + Z) === (X + Y) + Z

Commutative Property (of addition)

X + Y === Y + X


X + 0 === X

Distributive Property

X * (Y + Z) === XY + XZ

First Class Functions

This section only covers (1) how in JavaScript function wrapping is often redundant, and (2) that you sometimes need to use =bind= when passing functions around It does not address the fundamental confusion of procedures and functions in JavaScript


Confusion in JavaScript between procedures and funnctions

Example of Aarray.slice vs. Array.splice

slice is pure

splice mutatates

What is a pure function?

a pure function is a mathematical function

What is a mathematical function?

just a relation between two values

“Functions can be described as a set of pairs with the position (input, output)

you can model a function by a table, and the Javascript notation myFunction[input] would be equivalent to myFunction(input), where in the first myFunction is an object of key-value pairs and in the second it is actually a function that implements the mathematical relation between input and output.

Practicalities of Purity

function output can always be cached based on input

portable (everything you need to know is in its argument and its internals)

testable (since you’re forced to inject dependencies, you can mock them easily)

referential transparency

“A spot of code is referentially transparent when it can be substituted for its evaluated value without changing the behavior of the program.”


“we can run any pure function in parallel since it does not need access to shared memory and it cannot, by definition, have a race condition due to some side effect”

Making Pure Functions

sometimes you can conver impure function into pure function by “delaying execution”

this really just means separating the concept of an action from its execution; the action is a value and can be passed around as a function; the execution or procedure is its side effect



Type Signatures

Functors (Containers)


Applicative Functors

Ramda Source Code








Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment