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=4a4287a1e776a13524b7db78d2ef9de43fb83b00;hp=e76bab496d6236e706c5e4e5bdb77abcb274c99b;hb=94a588fd25a9a93fd7e8bd5f770f1dfbf5f4e108;hpb=20b4e1e1636218d16ef39a9fbc4da5305f24b40f diff --git a/translating_between_OCaml_Scheme_and_Haskell.mdwn b/translating_between_OCaml_Scheme_and_Haskell.mdwn index e76bab49..4a4287a1 100644 --- a/translating_between_OCaml_Scheme_and_Haskell.mdwn +++ b/translating_between_OCaml_Scheme_and_Haskell.mdwn @@ -131,7 +131,8 @@ Additionally, the syntax of OCaml and SML is superficially much closer to Haskel There is also a library for using *undelimited* continuations in OCaml, but it's shakier than Oleg's delimited continuation library. -We won't say any more about translating to and from Scheme. +There are some more hints about Scheme [here](/assignment8/) and [here](/week1/). We won't say any more here. + #Haskell and OCaml# @@ -198,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)