X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=assignment5.mdwn;h=5a2a488c4d01befe7a47f023710eea2117bfa641;hp=02c0ac4dd8bcd45d6e5d470eaa64dcdcb24a54f6;hb=6ea619babdb3656bf940636bd6823c6a2b8697c1;hpb=0d85c76d0d37b32bf99483b86828a7d2829db44e diff --git a/assignment5.mdwn b/assignment5.mdwn index 02c0ac4d..5a2a488c 100644 --- a/assignment5.mdwn +++ b/assignment5.mdwn @@ -127,19 +127,19 @@ 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 +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 +`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`. +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`: +You should make use of `bind'` in your definition of `lift'`: - let bind (x: int option) (f: int -> (int option)) = + let bind' (x: int option) (f: int -> (int option)) = match x with None -> None | Some n -> f n;;