Skip to content

Cactus-proj/MicroML.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MicroML.jl

Dev Build Status codecov

A tree-walking interpreter for a simple ML-like language.

Rewrite hellerve/microml in julia.

Note that hellerve' implement can compile MicroML' code to C and do compiled execution. I haven't finished this part yet, branch genc contain some progress.

Most test copy from:

You may want to read Eli Bendersky’s blog post to get some idea about:

Usage

You can open a REPL by typing julia mml.jl in the src folder of this repository.

MicroML.jl/src$ julia mml.jl
μML> 

μML> x y z = y + z
x = (lambda y, z -> (y + z)) :: (Int -> Int -> Int)
μML> main = lambda -> print(x(1, 2))
main = (lambda  -> print(x(1, 2))) :: (-> Int)
μML>:i
3
μML>main = lambda -> print(1+1)
[Warning] Redefining main!
main = (lambda  -> print((1 + 1))) :: (-> Int)
μML>:i
2
μML>main = lambda -> print(0)
[Warning] Redefining main!
main = (lambda  -> print(0)) :: (-> Int)
μML>:i
0
μML>

μML> foo f g x = if f(x) then g(x) else 20
foo = (lambda f, g, x -> (if f(x) then g(x) else 20)) :: ((a -> Bool) -> (a -> Int) -> a -> Int)
μML> foo f x = if x then lambda t -> f(t) else lambda j -> f(x)
[Warning] Redefining foo!
foo = (lambda f, x -> (if x then (lambda t -> f(t)) else (lambda j -> f(x)))) :: ((Bool -> a) -> Bool -> (Bool -> a))
μML>:q
Moriturus te saluto!

Read some test code in runtests.jl to get some idea about how to use functions in this package.

About

A minimal ML, type-inferred, interpreted in 1000~ sloc.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors

Languages