Compared
λ-calc. | Haskell 98 | SML 97 |
---|---|---|
λx.e | \x->e | fn x=>e |
normal-order evaluation | by need, non-strict | eager, strict |
fixed-point combinator, Y | triggers a type-checker bug in ghc!['05] | y.sml |
ho hum :-) | Haskell 98 | SML 97 |
---|---|---|
: | h:t, list cons(tructor) | e:t, e has type t |
:: | e::t, e has type t | x::xs, list cons(tructor) |
Haskell 98 | SML 97 | |
---|---|---|
e has type t | e :: t | e : t |
reference type | n.a. | t ref |
polymorphic type | data T u v = C u v |... | datatype ('u, 'v) t = C of 'u*'v |... |
product type, U×V×... | (u,v,...) | u*v*... |
function type, -> | |
|
t*, i.e., the type |
[t] | t list |
tuple value | (x1, x2, ...) | (x1, x2, ...) |
list cons | x : xs | x :: xs |
empty list, |
[] | nil or [] |
non-empty list | [1,2,3] | [1,2,3] |
function | sqr x = x*x | fun sqr x = x*x |
function |
len [] = 0 len (_:xs) = 1 + len xs |
fun len [] = 0 | len (_::xs) = 1 + len xs |
anonymous function λx.e | \x-> e | |
composition | (.)::(b->c)->(a->b)->a->c |
e.g., val it = 5 : int |
let | let decs in exp | let decs in exp end |
conditional | if e then et else ef | if e then et else ef |
case | case e of pat->e |... | case e of pat=>e |... |