You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> The process of converting a function with multiple arity into the same function with an arity of one. Not to be confused with partial application, which can produce a function with an arity greater than one.
66
66
67
67
```js
68
-
letsum= (a,b) => a+b;
68
+
letsum= (a,b) => a+b;
69
69
70
70
letcurriedSum= (a) => (b) => a + b;
71
71
@@ -133,13 +133,13 @@ let add = (a, b) => a + b;
133
133
// Not points-free - `numbers` is an explicit parameter
// Points-free - The array is an implicit parameter
136
+
// Points-free - The list is an implicit parameter
137
137
let incrementAll2 =map(add(1));
138
138
```
139
139
140
-
`total1` lists and uses the parameter `numbers`, so it is not points-free. `total2` is written just by combining functions and values, making no mention of its arguments. It __is__ points-free.
140
+
`incrementAll` identifies and uses the parameter `numbers`, so it is not points-free. `incrementAll2` is written just by combining functions and values, making no mention of its arguments. It __is__ points-free.
141
141
142
-
It is easy to recognize points-free function definitions; they are the ones that contain no '`function`' keywords and no fat arrows.
142
+
Points-free function definitions look just like normal assignments without `function` or `=>`.
143
143
144
144
---
145
145
@@ -269,12 +269,27 @@ The identity value is empty array `[]`
269
269
270
270
## Monad
271
271
272
-
> A monad is a container type that provides two functions, [chain](#chain) and [ap](#applicative-functor). Monads provide an interface for executing a common sequence of commands on a particular kind of value, often one you want to avoid acting on directly. One of the most common monads is the "maybe" or optional value monad, which wraps a value that could be either nothing or something. By using a monad instead of the raw value, you can protect your code from exposure to null values. Likewise, a "state" monad can be used in a parser to algorithmically consume an input string using a repeatable sequence of steps that preserves the current state of the input from operation to operation. Also, since a monad is, by definition, a special kind of functor that also returns a monad, they can be chained together to describe any sequence of operations. In functional languages with lazy evaluation, monads are used where sequence of evaluation is important, such as in I/O. Due to this sequencing utility, they are sometimes referred to as "programmable semicolons."
272
+
> A monad is a container type that provides two functions, [chain](#chain) and `of`. Monads provide an interface for executing a common sequence of commands on a particular kind of value, often one you want to avoid acting on directly. One of the most common monads is the "maybe" or optional value monad, which wraps a value that could be either nothing or something. By using a monad instead of the raw value, you can protect your code from exposure to null values. Likewise, a "state" monad can be used in a parser to algorithmically consume an input string using a repeatable sequence of steps that preserves the current state of the input from operation to operation. Also, since a monad is, by definition, a special kind of functor that also returns a monad, they can be chained together to describe any sequence of operations. In functional languages with lazy evaluation, monads are used where sequence of evaluation is important, such as in I/O. Due to this sequencing utility, they are sometimes referred to as "programmable semicolons."
273
273
274
274
The simplest monad is the Identity monad. It simply wraps a value.
If a function accepts another function as an argument it is wrapped in parenthesis.
425
+
426
+
```js
427
+
// call :: (a -> b) -> a -> b
428
+
letcall=f=>x=>f(x)
429
+
```
430
+
The letters `a`, `b`, `c`, `d` are used to signify that the argument can be of any type. For this map it takes a function that transforms a value of some type `a` into another type `b`, an array of values of type `a`, and returns an array of values of type `b`.
0 commit comments