File tree Expand file tree Collapse file tree 2 files changed +0
-76
lines changed Expand file tree Collapse file tree 2 files changed +0
-76
lines changed Original file line number Diff line number Diff line change @@ -29,38 +29,6 @@ import Data.Unit (Unit, unit)
29
29
-- | - Composition: `pure (<<<) <*> f <*> g <*> h = f <*> (g <*> h)`
30
30
-- | - Homomorphism: `(pure f) <*> (pure x) = pure (f x)`
31
31
-- | - Interchange: `u <*> (pure y) = (pure (_ $ y)) <*> u`
32
- -- |
33
- -- | ### Ado Notation
34
- -- |
35
- -- | When using a type that has an instance for `Applicative`, one can use
36
- -- | "ado notation." In short, this code...
37
- -- | ```
38
- -- | foo =
39
- -- | functionThatTakes4Args <$> boxedA
40
- -- | <*> boxedB
41
- -- | <*> boxedUnit
42
- -- | <*> boxedC
43
- -- | where
44
- -- | functionThatTakes4Args a b _ c =
45
- -- | let x = a * a + b
46
- -- | in x + c
47
- -- | ```
48
- -- |
49
- -- | ... can be converted into into "ado notation:"
50
- -- | ```
51
- -- | foo = ado
52
- -- | a <- boxedA
53
- -- | b <- boxedB
54
- -- | boxedUnit
55
- -- | c <- boxedC
56
- -- | let x = a * a + b
57
- -- | in x + c
58
- -- | ```
59
- -- |
60
- -- | Note: if one wants to use "ado notation" but redefine what the in-scope
61
- -- | definitions are for `map`, `apply`, and `pure` in a given context, one can
62
- -- | use "qualified ado notation." This is an intermediate/advanced language
63
- -- | feature not explained here.
64
32
class Apply f <= Applicative f where
65
33
pure :: forall a . a -> f a
66
34
Original file line number Diff line number Diff line change @@ -28,50 +28,6 @@ import Data.Unit (Unit)
28
28
-- | - Left Identity: `pure x >>= f = f x`
29
29
-- | - Right Identity: `x >>= pure = x`
30
30
-- | - Applicative Superclass: `apply = ap`
31
- -- |
32
- -- | ### Do Notation
33
- -- |
34
- -- | When using a type that has an instance for `Monad`, one can use
35
- -- | "do notation." In short, this code...
36
- -- | ```
37
- -- | foo =
38
- -- | bind boxedA (\a ->
39
- -- | let b = a + 4
40
- -- | in bind boxedC (\c ->
41
- -- | bind boxedUnit (\_ ->
42
- -- | pure (a * b - c)
43
- -- | )
44
- -- | )
45
- -- | )
46
- -- | ```
47
- -- |
48
- -- | ... can be converted into this code...
49
- -- | ```
50
- -- | foo =
51
- -- | boxedA >>= (\a ->
52
- -- | let b = a + 4
53
- -- | in boxedC >>= (\c ->
54
- -- | boxedUnit >>= (\_ ->
55
- -- | pure (a * b - c)
56
- -- | )
57
- -- | )
58
- -- | )
59
- -- | ```
60
- -- |
61
- -- | ...which can be converted once more into "do notation:"
62
- -- | ```
63
- -- | foo = do
64
- -- | a <- boxedA
65
- -- | let b = a + 4
66
- -- | c <- boxedC
67
- -- | boxedUnit
68
- -- | pure (a * b - c)
69
- -- | ```
70
- -- |
71
- -- | Note: if one wants to use "do notation" but redefine what the in-scope
72
- -- | definitions are for `bind` and `pure` in a given context, one can use
73
- -- | "qualified do notation." This is an intermediate/advanced language feature
74
- -- | not explained here.
75
31
class (Applicative m , Bind m ) <= Monad m
76
32
77
33
instance monadFn :: Monad ((-> ) r )
You can’t perform that action at this time.
0 commit comments