projects
/
lambda.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7c6b955
)
use arrow for mid
author
jim
<jim@web>
Mon, 23 Mar 2015 14:18:15 +0000
(10:18 -0400)
committer
Linux User
<ikiwiki@localhost.members.linode.com>
Mon, 23 Mar 2015 14:18:15 +0000
(10:18 -0400)
topics/week8_safe_division_with_monads.mdwn
patch
|
blob
|
history
diff --git
a/topics/week8_safe_division_with_monads.mdwn
b/topics/week8_safe_division_with_monads.mdwn
index
cdaa949
..
3e3e14c
100644
(file)
--- a/
topics/week8_safe_division_with_monads.mdwn
+++ b/
topics/week8_safe_division_with_monads.mdwn
@@
-214,13
+214,13
@@
To illustrate some of the polymorphism, here's how we could `map1` the `is_even`
- : int option -> bool option = <fun>
Wherever we have a well-defined monad, we can define the `mapN` operations for them in terms
- : int option -> bool option = <fun>
Wherever we have a well-defined monad, we can define the `mapN` operations for them in terms
-of their `>>=` and `mid`. The general pattern is:
+of their `>>=` and `
⇧`/`
mid`. The general pattern is:
mapN (g : 'a1 -> ... 'an -> 'result) (u1 : 'a1 option) ... (un : 'an option) : 'result option =
mapN (g : 'a1 -> ... 'an -> 'result) (u1 : 'a1 option) ... (un : 'an option) : 'result option =
- u1 >>= (fun x1 -> ... un >>= (fun xn ->
mid
(g x1 ... xn)) ...)
+ u1 >>= (fun x1 -> ... un >>= (fun xn ->
⇧
(g x1 ... xn)) ...)
Our above definitions of `map` and `mapN` were of this form, except we just
Our above definitions of `map` and `mapN` were of this form, except we just
-explicitly supplied the definition of `
mid
` for the Option/Maybe monad (namely, in OCamlese, the constructor `Some`).
+explicitly supplied the definition of `
⇧
` for the Option/Maybe monad (namely, in OCamlese, the constructor `Some`).
If you substitute in the definition of `>>=`, you can see these are equivalent to:
map (g : 'a -> 'b) (u : 'a option) =
If you substitute in the definition of `>>=`, you can see these are equivalent to:
map (g : 'a -> 'b) (u : 'a option) =