Delint, fix TOC, minor tweaks

This commit is contained in:
jethro larson 2017-06-07 10:45:26 -07:00
parent a30176c55c
commit 1601ecd859

View file

@ -35,8 +35,6 @@ __Table of Contents__
* [Value](#value) * [Value](#value)
* [Constant](#constant) * [Constant](#constant)
* [Functor](#functor) * [Functor](#functor)
* [Preserves identity](#preserves-identity)
* [Composable](#composable)
* [Pointed Functor](#pointed-functor) * [Pointed Functor](#pointed-functor)
* [Lift](#lift) * [Lift](#lift)
* [Referential Transparency](#referential-transparency) * [Referential Transparency](#referential-transparency)
@ -154,9 +152,9 @@ ie. they allow referencing a scope after the block in which the variables were d
```js ```js
const addTo = x => y => x + y; const addTo = x => y => x + y
var addToFive = addTo(5); var addToFive = addTo(5)
addToFive(3); //returns 8 addToFive(3) // returns 8
``` ```
The function ```addTo()``` returns a function(internally called ```add()```), lets store it in a variable called ```addToFive``` with a curried call having parameter 5. The function ```addTo()``` returns a function(internally called ```add()```), lets store it in a variable called ```addToFive``` with a curried call having parameter 5.
@ -173,12 +171,12 @@ A closure is a function that encloses its surrounding state by referencing field
__Further reading/Sources__ __Further reading/Sources__
* [Lambda Vs Closure](http://stackoverflow.com/questions/220658/what-is-the-difference-between-a-closure-and-a-lambda) * [Lambda Vs Closure](http://stackoverflow.com/questions/220658/what-is-the-difference-between-a-closure-and-a-lambda)
* [JavaScript Closures highly voted disucussion](http://stackoverflow.com/questions/111102/how-do-javascript-closures-work) * [How do JavaScript Closures Work?](http://stackoverflow.com/questions/111102/how-do-javascript-closures-work)
## Auto Currying ## Auto Currying
Transforming a function that takes multiple arguments into one that if given less than its correct number of arguments returns a function that takes the rest. When the function gets the correct number of arguments it is then evaluated. Transforming a function that takes multiple arguments into one that if given less than its correct number of arguments returns a function that takes the rest. When the function gets the correct number of arguments it is then evaluated.
lodash & ramda have a `curry` function that works this way. lodash & Ramda have a `curry` function that works this way.
```js ```js
const add = (x, y) => x + y const add = (x, y) => x + y
@ -406,12 +404,12 @@ john.age + five === ({name: 'John', age: 30}).age + (5)
An object that implements a `map` function which, while running over each value in the object to produce a new object, adheres to two rules: An object that implements a `map` function which, while running over each value in the object to produce a new object, adheres to two rules:
### Preserves identity __Preserves identity__
``` ```
object.map(x => x) ≍ object object.map(x => x) ≍ object
``` ```
### Composable __Composable__
``` ```
object.map(compose(f, g)) ≍ object.map(g).map(f) object.map(compose(f, g)) ≍ object.map(g).map(f)
@ -784,8 +782,8 @@ A Sum type is the combination of two types together into another one. It is call
JavaScript doesn't have types like this but we can use `Set`s to pretend: JavaScript doesn't have types like this but we can use `Set`s to pretend:
```js ```js
// imagine that rather than sets here we have types that can only have these values // imagine that rather than sets here we have types that can only have these values
const bools = new Set([true, false]); const bools = new Set([true, false])
const halfTrue = new Set(['half-true']); const halfTrue = new Set(['half-true'])
// The weakLogic type contains the sum of the values from bools and halfTrue // The weakLogic type contains the sum of the values from bools and halfTrue
const weakLogicValues = new Set([...bools, ...halfTrue]) const weakLogicValues = new Set([...bools, ...halfTrue])