A a small ML-like language interpreted or compiled to x86-64 assembly with a custom runtime
9.3K
silly-ml (aka vacation-ml) is a:
Disclaimer: the silly prefix indicates that this is a hobby project with no other purpose than to learn and explore and it should definently be interpreted as an homage to its big brothers.
Simplest way to try it out is by using Docker:
docker run -it rootmos/silly-ml
and maybe use rlwrap to get a proper REPL feeling with line editing, history etc.
Here's an example session from the REPL:
> 7;;
7: int
> type foo = A | B of int;;
> A;;
A: foo
> B 7;;
B 7: foo
> let f x = match x with A -> 0 | B i -> i;;
> f;;
<fun>: foo -> int
> f A;;
0: int
> f (B 3);;
3: int
> type bar = C of foo;;
> C A;;
C A: bar
> f (C A);;
typed error: unification failed
> ((), 7);;
((), 7): (unit, int)
> 3 * (7 - (1 + 2));;
12: int
> let x = 7;;
> print_int x;; print_newline ();;
7
(): unit
> let f x y = x + y;;
> f;;
<fun>: int -> int -> int
> let g = f 1;;
> g;;
<fun>: int -> int
> let h = f 2;;
> h;;
<fun>: int -> int
> g 2;;
3: int
> h 2;;
4: int
> let sum n = let rec go acc i = match i with 0 -> acc | _ -> go (acc + i) (i - 1) in go 0 n;;
> sum;;
<fun>: int -> int
> sum 6;;
21: int
> let rec fib n = match n with 0 -> 0 | 1 -> 1 | n -> (fib (n - 1)) + (fib (n - 2));;
> fib 5;;
5: int
> fib 6;;
8: int
>
Content type
Image
Digest
sha256:7f886a139…
Size
19.5 MB
Last updated
almost 2 years ago
docker pull rootmos/silly-ml