Skip to content

yet another toy OCaml interpreter in Haskell

Notifications You must be signed in to change notification settings

momohatt/hscaml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hscaml

toy OCaml interpreter in Haskell

Build & Run

$ stack init
$ stack build
$ stack run hscaml

Example

# let rec fib n = if n <= 1 then 1 else fib (n - 1) + fib (n - 2) in fib 10;;
- : int = 89
# let rec fact n = if n = 0 then 1 else n * fact (n - 1);;
val fact : int -> int = <fun>
# fact 10;;
- : int = 3628800

let polymorphism

# let f x = x;;
val f : t0 -> t0 = <fun>
# (f true, f 0);;
- : (bool * int) = (true, 0)
# (f f) f;;
- : t5 -> t5 = <fun>
# f (f f);;
- : t9 -> t9 = <fun>

pattern match

# match (1, 2) with
  | (x, y) -> x + y;;
- : int = 3
# let hd l = match l with
  | [] -> 0
  | x :: y -> x;;
val hd : int list -> int = <fun>
# hd [1;2;3];;
- : int = 1
# hd [];;
- : int = 0

About

yet another toy OCaml interpreter in Haskell

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published