@@ -10,12 +10,12 @@ A functor with application, providing operations to embed pure expressions (``re
1010___
1111Minimal complete definition
1212---------------------------
13- * ``return x``/ ``result x``
13+ * ``return x`` / ``result x``
1414 * ``(<*>) f x``
1515*)
1616(**
17- static member Return (x:'T) : 'Applicative<'T>
18- static member (<*>) (f: 'Applicative<'T-> 'U>, x: 'Applicative<'T>) : 'Applicative<'U>
17+ static member Return (x: 'T) : 'Applicative<'T>
18+ static member (<*>) (f: 'Applicative<'T -> 'U>, x: 'Applicative<'T>) : 'Applicative<'U>
1919*)
2020(**
2121Note: ``return`` can't be used outside computation expressions, use ``result`` instead.
@@ -27,7 +27,7 @@ Other operations
2727* ``lift2``
2828*)
2929(**
30- static member Lift2 (f: 'T1-> 'T2-> 'T, x1: 'Applicative<'T1>, x2: 'Applicative<'T2>) : 'Applicative<'T>
30+ static member Lift2 (f: 'T1 -> 'T2 -> 'T, x1: 'Applicative<'T1>, x2: 'Applicative<'T2>) : 'Applicative<'T>
3131*)
3232(**
3333
@@ -131,13 +131,13 @@ open FSharpPlus
131131open FSharpPlus.Data
132132
133133// Apply +4 to a list
134- let lst5n6 = map ((+) 4 ) [ 1 ; 2 ]
134+ let lst5n6 = map ((+) 4 ) [ 1 ; 2 ]
135135
136136// Apply +4 to an array
137- let arr5n6 = map ((+) 4 ) [| 1 ; 2 |]
137+ let arr5n6 = map ((+) 4 ) [| 1 ; 2 |]
138138
139139// I could have written this
140- let arr5n6 ' = (+) <!> [| 4 |] <*> [| 1 ; 2 |]
140+ let arr5n6 ' = (+) <!> [| 4 |] <*> [| 1 ; 2 |]
141141
142142// Add two options
143143let opt120 = (+) <!> Some 20 <*> tryParse " 100"
@@ -198,7 +198,7 @@ open FSharpPlus.Math.Applicative
198198let opt121 ' = Some 21 .+. tryParse " 100"
199199let optTrue = 30 >. tryParse " 29"
200200let optFalse = tryParse " 30" .< 29
201- let m1m2m3 = -.[ 1 ; 2 ; 3 ]
201+ let m1m2m3 = -.[ 1 ; 2 ; 3 ]
202202
203203
204204// Using applicative computation expression
@@ -245,7 +245,17 @@ let person6 = applicative2 {
245245// A Monad is automatically an Applicative
246246
247247type MyList < 's > = MyList of 's seq with
248- static member Return ( x : 'a ) = MyList ( Seq.singleton x)
248+ static member Return ( x : 'a ) = MyList ( Seq.singleton x)
249249 static member (>>= ) ( MyList x: MyList< 'T>, f) = MyList ( Seq.collect ( f >> ( fun ( MyList x ) -> x)) x)
250250
251- let mappedMyList : MyList < _ > = ( MyList [(+) 1 ;(+) 2 ;(+) 3 ]) <*> ( MyList [ 1 ; 2 ; 3 ])
251+ let mappedMyList : MyList < _ > = ( MyList [(+) 1 ; (+) 2 ; (+) 3 ]) <*> ( MyList [ 1 ; 2 ; 3 ])
252+
253+
254+ (**
255+ Recommended reading
256+ -------------------
257+
258+ - Highly recommended Matt Thornton's blog [Grokking Applicatives](https://dev.to/choc13/grokking-applicatives-44o1).
259+ It contains examples using F#+ and an explanation from scratch.
260+
261+ *)
0 commit comments