|
|
| λ-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 (contents, deref, !x) (assign, :=) |
| 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, -> |
u -> v |
u -> v |
| t*, i.e., the type `list of t', |
[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 by cases |
len [] = 0 len (_:xs) = 1 + len xs |
fun len [] = 0 | len (_::xs) = 1 + len xs |
| anonymous function λx.e |
\x-> e |
fn x=>e |
| composition |
(.)::(b->c)->(a->b)->a->c |
op o:('b->'c)*('a->'b)->'a->'c
e.g., ((fn x=>x+1)o(fn x=>x*x)) 2
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 |... |
|
|