From 460bf1e9cf2b3281a162ade8d790751028c11552 Mon Sep 17 00:00:00 2001
From: Jim Pryor
Date: Sat, 4 Dec 2010 09:27:01 -0500
Subject: [PATCH 1/1] translating tweaks
Signed-off-by: Jim Pryor
---
translating_between_OCaml_Scheme_and_Haskell.mdwn | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/translating_between_OCaml_Scheme_and_Haskell.mdwn b/translating_between_OCaml_Scheme_and_Haskell.mdwn
index 171f644e..e8b897f1 100644
--- a/translating_between_OCaml_Scheme_and_Haskell.mdwn
+++ b/translating_between_OCaml_Scheme_and_Haskell.mdwn
@@ -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.
--
2.11.0