http://t3x.org/mlite/

[mLite]

The mLite Language

mLite [em·ell·ite] —
a lightweight (and slightly odd) inhabitant of the ML universe.

Manual (ps, pdf)  |  Download  |  Apology  |  Changes  |  Guards paper (ps, pdf)

What does it look like?

Much like ML, but with dynamic typing, guards, and a Haskell-style apply operator. Here are some examples:

;; create lists of numbers
fun iota (a, b) where (a = b)
                = [a]
       | (a, b) = a :: iota (a + 1, b)
       | a      = iota (1, a)
 
(* extract elements from lists *)
fun extract
    (f, [])        = []
  | (f, f x :: xs) = x :: extract (f, xs)
  | (f, x :: xs)   = extract (f, xs)

What's going on here?

The iota function uses an explicit guard (where (a=b)) to check its trivial case. It is also polymorpic: when called with just a single number, it generates a range 1..a.   The extract function uses an implicit guard (f x) to check whether or not to include a specific element.

Of course, the full power of ML functions is available. We could define a curried version of extract:

fun filter f a = extract (f, a)

and then do:

val f = filter (fn x = x mod 7 = 0);
f ` iota 100

and get:

[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]

Cool, isn't it?


contact  |  privacy