[[Hint assignment 5 problem 3]]
-Baby monads
------------
-
-Read the lecture notes for week 6, then write a
-function `lift'` that generalized the correspondence between + and
-`add'`: that is, `lift'` takes any two-place operation on integers
-and returns a version that takes arguments of type `int option`
-instead, returning a result of `int option`. In other words,
-`lift'` will have type
-
- (int -> int -> int) -> (int option) -> (int option) -> (int option)
-
-so that `lift' (+) (Some 3) (Some 4)` will evalute to `Some 7`.
-Don't worry about why you need to put `+` inside of parentheses.
-You should make use of `bind'` in your definition of `lift'`:
-
- let bind' (x: int option) (f: int -> (int option)) =
- match x with None -> None | Some n -> f n;;
-
-
Booleans, Church numbers, and Church lists in OCaml
---------------------------------------------------
(These questions adapted from web materials by Umut Acar. See <http://www.mpi-sws.org/~umut/>.)
-The idea is to get booleans, Church numbers, "Church" lists, and
+The idea is to get booleans, Church numbers, v3 lists, and
binary trees working in OCaml.
Recall from class System F, or the polymorphic λ-calculus.
Write a function `inOrder` : τ tree → τ list that computes the in-order traversal of a binary tree. You
may assume the above encoding of lists; define any auxiliary functions you need.
+Baby monads
+-----------
+
+Read the lecture notes for week 6, then write a
+function `lift'` that generalized the correspondence between + and
+`add'`: that is, `lift'` takes any two-place operation on integers
+and returns a version that takes arguments of type `int option`
+instead, returning a result of `int option`. In other words,
+`lift'` will have type
+
+ (int -> int -> int) -> (int option) -> (int option) -> (int option)
+
+so that `lift' (+) (Some 3) (Some 4)` will evalute to `Some 7`.
+Don't worry about why you need to put `+` inside of parentheses.
+You should make use of `bind'` in your definition of `lift'`:
+
+ let bind' (x: int option) (f: int -> (int option)) =
+ match x with None -> None | Some n -> f n;;
+
+