From: jim Date: Mon, 23 Mar 2015 01:41:41 +0000 (-0400) Subject: explain comments X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=commitdiff_plain;h=60cd0904572db1152ff886b08dd6b08fbd5de18b explain comments --- diff --git a/topics/_week8_using_monads.mdwn b/topics/_week8_using_monads.mdwn index 9acd123e..f23ef507 100644 --- a/topics/_week8_using_monads.mdwn +++ b/topics/_week8_using_monads.mdwn @@ -30,7 +30,7 @@ let safe_div (x:int) (y:int) = | 0 -> None | _ -> Some (x / y);; -(* +(* an Ocaml session could continue with OCaml's response: val safe_div : int -> int -> int option = fun # safe_div 12 2;; - : int option = Some 6 @@ -57,7 +57,7 @@ let safe_div2 (u:int option) (v:int option) = | Some 0 -> None | Some y -> Some (x / y));; -(* +(* an Ocaml session could continue with OCaml's response: val safe_div2 : int option -> int option -> int option = # safe_div2 (Some 12) (Some 2);; - : int option = Some 6 @@ -95,7 +95,7 @@ let safe_add (u:int option) (v:int option) = | (_, None) -> None | (Some x, Some y) -> Some (x + y);; -(* +(* an Ocaml session could continue with OCaml's response: val safe_add : int option -> int option -> int option = # safe_add (Some 12) (Some 4);; - : int option = Some 16 @@ -142,7 +142,7 @@ Haskell has an even more user-friendly notation for defining `safe_div3`, namely Let's see our new functions in action:
-(*
+(* an Ocaml session could continue with OCaml's response:
 # safe_div3 (safe_div3 (Some 12) (Some 2)) (Some 3);;
 - : int option = Some 2
 #  safe_div3 (safe_div3 (Some 12) (Some 0)) (Some 3);;