on master help sign in
removes bind example which is not a monadic bind
c19b089drbeefsupreme
hoon/reference/rune/mic.md+10−27
@@ -80,11 +80,10 @@ implementation of monadic bind. This rune takes a gate `bind` which takes a mold
80##### Desugaring
80##### Desugaring
81
81
82```hoon
82```hoon
83−%+
84− (bind ^:mold)
83+%+ (bind mold)
85−expr1
84+ expr1
86|= mold
85|= mold
87− expr2
86+expr2
88```
87```
89
88
90##### Discussion
89##### Discussion
@@ -92,13 +91,15 @@ expr1
92`;<` is much like Haskell `do` notation. You have a sequence of events you'd
91`;<` is much like Haskell `do` notation. You have a sequence of events you'd
93like to run such that each past the first depends on the output of the previous
92like to run such that each past the first depends on the output of the previous
94one. The output of the previous one may not be of the correct type to use as an
93one. The output of the previous one may not be of the correct type to use as an
95−input to the next one, and so an adapter such as `+bind` or `+biff` is needed.
94+input to the next one, and so an adapter such as `+biff` is needed.
96
95
97`;<` differs from [`;~`](#micsig) in that it takes a gate which takes a mold
96`;<` differs from [`;~`](#micsig) in that it takes a gate which takes a mold
98that produces an implementation of monadic bind, rather than taking an
97that produces an implementation of monadic bind, rather than taking an
99implementation of monadic bind directly.
98implementation of monadic bind directly.
100
99
101−`;<` can be used to glue a pipeline together to run an asynchronous function or event. This can be helpful when deferring parts of a computation based on external data.
100+`;<` can be used to glue a pipeline together to run an asynchronous function or
101+event. This can be helpful when deferring parts of a computation based on
102+external data.
102
103
103We remark that you can switch binds in the middle of a sequence of `;<`.
104We remark that you can switch binds in the middle of a sequence of `;<`.
104
105
@@ -107,12 +108,9 @@ We remark that you can switch binds in the middle of a sequence of `;<`.
107[`+biff`](@/docs/hoon/reference/stdlib/2a/#biff) is the unit monad's
108[`+biff`](@/docs/hoon/reference/stdlib/2a/#biff) is the unit monad's
108implementation of monadic bind. That is to say, it takes a unit `a` and a gate
109implementation of monadic bind. That is to say, it takes a unit `a` and a gate
109`b` that accepts a noun that produces a unit, and extracts the value from `a` to
110`b` that accepts a noun that produces a unit, and extracts the value from `a` to
110−pass as a sample to `b`. [`+bind`](@/docs/hoon/reference/stdlib/2a/#bind) takes
111+pass as a sample to `b`.
111−a unit `a` and a gate `b` that neither accepts nor produces a unit, and applies
112−`b` to the value of `a` and produces a unit. Note that if you do pass `+bind` a
113−gate that produces a unit, `+bind` will treat it as though it does not.
114
112
115−We illustrate the usage of `;<`, `+biff`, and `+bind` with a `map` of atoms.
113+We illustrate the usage of `;<` with `+biff` with a `map` of atoms:
116```
114```
117~zod:dojo> =m (my ~[[1 3] [2 2] [3 1]])
115~zod:dojo> =m (my ~[[1 3] [2 2] [3 1]])
118 > (~(get by m) 1)
116 > (~(get by m) 1)
@@ -121,31 +119,16 @@ We illustrate the usage of `;<`, `+biff`, and `+bind` with a `map` of atoms.
121A single usage of `;<` only serves to apply the binding function to the output
119A single usage of `;<` only serves to apply the binding function to the output
122of `expr1`:
120of `expr1`:
123```
121```
124−~zod:dojo> ;< a=@ _bind (~(get by m) 1)
125− a
126− [~ 3]
127~zod:dojo> ;< a=@ _biff (~(get by m) 1)
122~zod:dojo> ;< a=@ _biff (~(get by m) 1)
128 a
123 a
129 3
124 3
130```
125```
131−Here we see the results of chaining them together:
126+Here we see the result of chaining them together:
132```
127```
133~zod:dojo> ;< a=@ _biff (~(get by m) 1)
128~zod:dojo> ;< a=@ _biff (~(get by m) 1)
134 ;< b=@ _biff (~(get by m) a)
129 ;< b=@ _biff (~(get by m) a)
135 b
130 b
136 1
131 1
137−~zod:dojo> ;< a=@ _bind (~(get by m) 1)
138− ;< b=@ _biff (~(get by m) a)
139− b
140− [~ 1]
141−~zod:dojo> ;< a=@ _biff (~(get by m) 1)
142− ;< b=@ _bind (~(get by m) a)
143− b
144− [~ 1]
145−~zod:dojo> ;< a=@ _bind (~(get by m) 1)
146− ;< b=@ _bind (~(get by m) a)
147− b
148− [~ [~ 1]]
149```
132```
150
133
151
134