translating tweaks
authorJim Pryor <profjim@jimpryor.net>
Sat, 4 Dec 2010 14:27:01 +0000 (09:27 -0500)
committerJim Pryor <profjim@jimpryor.net>
Sat, 4 Dec 2010 14:27:01 +0000 (09:27 -0500)
Signed-off-by: Jim Pryor <profjim@jimpryor.net>
translating_between_OCaml_Scheme_and_Haskell.mdwn

index 171f644..e8b897f 100644 (file)
@@ -508,15 +508,15 @@ Haskell and OCaml both have `records`, which are essentially just tuples with a
 
        you can also write either of:
 
-               (1 >) 2
-               (> 2) 1
+               (2 >) 1
+               (> 1) 2
 
        In OCaml one has to write these out longhand:
 
-               (fun y -> 1 > y) 2;;
-               (fun x -> x > 2) 1;;
+               (fun y -> 2 > y) 1;;
+               (fun x -> x > 1) 2;;
 
-       Also, in Haskell, there's a special syntax for using what are ordinarily prefix functions into infix operators:
+       Also, in Haskell, there's a special syntax for using what are ordinarily prefix functions as infix operators:
 
                Prelude> elem 1 [1, 2]
                True
@@ -568,12 +568,12 @@ Haskell and OCaml both have `records`, which are essentially just tuples with a
 
 *      Some functions are predefined in Haskell but not in OCaml. Here are OCaml definitions for some common ones:
 
-       let id x = x;;
-       let const x _ = x;;
-       let flip f x y = f y x;;
-       let curry (f : ('a, 'b) -> 'c) = fun x y -> f (x, y);;
-       let uncurry (f : 'a -> 'b -> 'c) = fun (x, y) -> f x y;;
-       let null lst = lst = [];;
+               let id x = x;;
+               let const x _ = x;;
+               let flip f x y = f y x;;
+               let curry (f : ('a, 'b) -> 'c) = fun x y -> f (x, y);;
+               let uncurry (f : 'a -> 'b -> 'c) = fun (x, y) -> f x y;;
+               let null lst = lst = [];;
 
        `fst` and `snd` (defined only on pairs) are provided in both languages. Haskell has `head` and `tail` for lists; these will raise an exception if applied to []. In OCaml the corresponding functions are `List.hd` and `List.tl`. Many other Haskell list functions like `length` are available in OCaml as `List.length`, but OCaml's standard libraries are leaner that Haskell's.