X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=translating_between_OCaml_Scheme_and_Haskell.mdwn;h=338a2966824788ddbac301e710cba7039eb27095;hp=69ba76d4ea9635ffcb3eaaa7bcd8419028cf41ba;hb=e4a25b6b413f5e536393226994c171685e50c797;hpb=d0c1b524d79cd88b2979d7825dc297bbbddc4f22 diff --git a/translating_between_OCaml_Scheme_and_Haskell.mdwn b/translating_between_OCaml_Scheme_and_Haskell.mdwn index 69ba76d4..338a2966 100644 --- a/translating_between_OCaml_Scheme_and_Haskell.mdwn +++ b/translating_between_OCaml_Scheme_and_Haskell.mdwn @@ -434,7 +434,7 @@ The syntax for declaring and using these is a little bit different in the two la In OCaml: - let { red = r; green = g } = c + let { red = r; green = g; _ } = c in r In Haskell: @@ -448,7 +448,7 @@ The syntax for declaring and using these is a little bit different in the two la In OCaml it's: - # let makegray ({red = r} as c) = { c with green=r; blue=r };; + # let makegray ({ red = r; _ } as c) = { c with green=r; blue=r };; val makegray : color -> color = # makegray { red = 0; green = 127; blue = 255 };; - : color = {red = 0; green = 0; blue = 0} @@ -466,9 +466,9 @@ The syntax for declaring and using these is a little bit different in the two la and then extract the field you want using pattern-matching: - let Color(r,_,_) = c;; + let Color (r, _, _) = c;; (* or *) - match c with Color(r,_,_) -> ... + match c with Color (r, _, _) -> ... (Or you could just use bare tuples, without the `Color` data constructor.)