A newer interpreter of the ITGL is available at ymyzk/lambda-dti.
lambda-rti is an interpreter of the implicitly typed gradual language (ITGL). This implementation consists of:
$ dune build
$ dune install
$ lrti
Run $ lrti --help for command line options.
$ dune build
$ ./_build/default/bin/main.exe
Run $ ./_build/default/bin/main.exe --help for command line options.
$ docker run -it --rm ymyzk/lambda-rti
$ dune runtest
let x ... = e;;let rec f x ... = e;;e;;etrue, false, and ()+ and -+, -, *, /, mod, =, <>, <, <=, >, >=, &&, and ||fun x -> efun x y z ... -> efun (x: U1) y (z: U3) ... -> ee1 e2let x = e1 in e2let x y z ... = e1 in e2let (x:U1) y (z: U3) ... : U ... = e1 in e2let rec f x = e1 in e2let rec f x y z ... = e1 in e2let rec f (x: U1) y (z: U3) ... : U = e1 in e2if e1 then e2 else e3e1; e2(e : U)U?bool, int, and unitU -> U'a, 'b, ...(* comments *)(* leave comments here (* nested comments are also supported *) *)Some useful functions are available:
# is_bool;;
- : ? -> bool = <fun>
# is_int;;
- : ? -> bool = <fun>
# is_unit;;
- : ? -> bool = <fun>
# is_fun;;
- : ? -> bool = <fun>
# succ;;
- : int -> int = <fun>
# pred;;
- : int -> int = <fun>
# max;;
- : int -> int -> int = <fun>
# min;;
- : int -> int -> int = <fun>
# abs;;
- : int -> int = <fun>
# max_int;;
- : int = 4611686018427387903
# min_int;;
- : int = -4611686018427387904
# not;;
- : bool -> bool = <fun>
# print_bool;;
- : bool -> unit = <fun>
# print_int;;
- : int -> unit = <fun>
# print_newline;;
- : unit -> unit = <fun>
# ignore;;
- : 'a -> unit = <fun>
# exit;;
- : int -> unit = <fun>
# (fun (x:?) -> x + 2) 3;;
- : int = 5
# (fun (x:?) -> x + 2) true;;
Blame on the expression side:
line 2, character 14 -- line 2, character 15
# (fun (x:?) -> x 2) (fun y -> true);;
- : ? = true: bool => ?
# (fun (x:?) -> x) (fun y -> y);;
- : ? = <fun>: ? -> ? => ?
# (fun (x:?) -> x 2) (fun y -> y);;
- : ? = 2: int => ?
# (fun (f:?) -> f true) ((fun x -> x) ((fun (y:?) -> y) (fun z -> z + 1)));;
Blame on the environment side:
line 6, character 55 -- line 6, character 69
# (fun (f:?) -> f 2) ((fun x -> x) ((fun (y:?) -> y) (fun z -> z + 1)));;
- : ? = 3: int => ?
# let id x = x;;
id : 'a -> 'a = <fun>
# let dynid (x:?) = x;;
dynid : ? -> ? = <fun>
# succ;;
- : int -> int = <fun>
# (fun (f:?) -> f 2) (id (dynid succ));;
- : ? = 3: int => ?
# (fun (f:?) -> f true) (id (dynid succ));;
Blame on the environment side:
line 12, character 33 -- line 12, character 37
# let rec sum (n:?) = if n < 1 then 0 else n + sum (n - 1);;
sum : ? -> int = <fun>
# sum 100;;
- : int = 5050
# sum true;;
Blame on the expression side:
line 13, character 23 -- line 13, character 24
# exit 0;;
Content type
Image
Digest
Size
43.9 MB
Last updated
almost 8 years ago
docker pull ymyzk/lambda-rti