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=45bb412ca548c5cd02967d2b6c4d7ce2b0a88f0b;hpb=d9e25980d9b3e62e89ab731ed5fbc33126df57e6 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.)