(Space or Arrow Keys to Navigate)
Functions that have no side effects are said to be pure.
Pure functions are useless, easily tested, and referentially transparent.
and
Take their arguments one at a time.
Use closure to defer computation.
Partial application has many uses e.g. generic functions or fluent computations.
Reduces many functions to one by applying each outer function to the application of the inner function.
In other words, makes one function from two (or more) others.
JavaScript class mixins are a way to share behaviour among classes
Functions which reference their own data are said to be "pointed". Likewise, functions which do not reference their parameters are said to be "pointfree". With curried and point-free functions, always take your data as the last parameter.
A functor is a container for some value, like an envelope.
Functors can map from some value x
in a category to another value y
in that same category.
Array
and Promise
are both functors.
Crocks' curry is very flexible.
A monoid is a type which has an 'empty' value, and an operation to combine values. Combining a value with the 'empty' value always produces the same value.
&&
forms a monoid with true
as empty value||
forms a monoid with false
as empty valueString#concat
forms a monoid with ''
as empty value.Object.assign
forms a monoid with {}
as empty valueArray#concat
forms a monoid with []
as empty valuemreduceMap
Folds an array under a monoid of your choice, first mapping your monoid constructor over it.
Like a functor, Monads can map over their contents.
Monads have the added ability to unwrap their self-similar contents.
This power is called chain
, bind
, or flatMap
The Maybe monad wraps a value which may not exist.
It has two instances: Just a
and Nothing
.
Mapping over a Just
works as expected.
Mapping over a Nothing
skips execution.
Wait!! People code like that?
👉 NOPE 👈
Monads are also applicatives, which means we can lift any function into 'monadic space' with lift
Thanks For
Watching!