projects
/
lambda.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'pryor'
[lambda.git]
/
reader_monad_for_variable_binding.mdwn
diff --git
a/reader_monad_for_variable_binding.mdwn
b/reader_monad_for_variable_binding.mdwn
index
9ddddc8
..
b9fd816
100644
(file)
--- a/
reader_monad_for_variable_binding.mdwn
+++ b/
reader_monad_for_variable_binding.mdwn
@@
-1,3
+1,5
@@
+[[!toc]]
+
Substitution versus Environment-based Semantics
-----------------------------------------------
Substitution versus Environment-based Semantics
-----------------------------------------------
@@
-155,7
+157,10
@@
Here we'll use a different monad. It's called the **Reader monad**. We define it
(* here's our bind operation; how does it work? *)
let bind (u : 'a reader) (f: 'a -> 'b reader) : 'b reader =
(* here's our bind operation; how does it work? *)
let bind (u : 'a reader) (f: 'a -> 'b reader) : 'b reader =
- fun (e : env) -> f (u e) e
+ (* this can be written more compactly, but having it spelled out
+ like this will be useful down the road *)
+ fun (e : env) -> let a = u e in let u' = f a in u' e
+
(* we also define two special-purpose operations on our reader-monad values *)
(* we also define two special-purpose operations on our reader-monad values *)