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=63b3263094081203bebf75fd062564599cff4082;hp=40f518aa37432985c95e088b632730c8bd9cea00;hb=b3fcd749ac69521ca598d3846043bb7aff1ac290;hpb=a9bcd94f06158cf67f3b7bb5f0abaf63050d23eb diff --git a/translating_between_OCaml_Scheme_and_Haskell.mdwn b/translating_between_OCaml_Scheme_and_Haskell.mdwn index 40f518aa..63b32630 100644 --- a/translating_between_OCaml_Scheme_and_Haskell.mdwn +++ b/translating_between_OCaml_Scheme_and_Haskell.mdwn @@ -199,6 +199,12 @@ We will however try to give some general advice about how to translate between O type person = name * address;; type 'a personal_data = PD of 'a;; +* When a type only has a single variant, as with PersonalData, Haskell programmers will often use the same name for both the type and the value constructor, like this: + + data PersonalData a = PersonalData a + + The interpreter can always tell from the context when you're using the type name and when you're using the value constructor. + * The type constructors discussed above took simple types as arguments. In Haskell, types are also allowed to take *type constructors* as arguments: data BarType t = Bint (t Integer) | Bstring (t string) @@ -664,6 +670,11 @@ Haskell has more built-in support for monads, but one can define the monads one which can be translated straightforwardly into OCaml. + For more details, see: + + * [Haskell Wikibook on do-notation](http://en.wikibooks.org/wiki/Haskell/do_Notation) + * [Do-notation considered harmful](http://www.haskell.org/haskellwiki/Do_notation_considered_harmful) + * If you like the Haskell do-notation, there's [a library](http://www.cas.mcmaster.ca/~carette/pa_monad/) you can compile and install to let you use something similar in OCaml. * In order to do any printing, Haskell has to use a special `IO` monad. So programs will look like this: