forked from dbp/funtal
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexamples.ml
More file actions
31 lines (23 loc) · 768 Bytes
/
examples.ml
File metadata and controls
31 lines (23 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
open Ftal;;
let expr str = Parse.parse_string Parse.expression_eof str
let factorial = expr {|
lam (x2 : int).
let fact : * -> int -> int = lam(fact : *).lam(x : int).
if x = 0 then 1 else x * (fact : * => * -> int -> int) fact (x - 1)
in fact (fact : * -> int -> int => *) x2
|}
let swap_int_bool = expr {|
pi2 ((Lam X. Lam Y. lam (p : <X,Y>). < pi2 p, pi1 p >) [int] [bool] <1, true>)
|}
let swap_bool_int = expr {|
pi1 ((Lam X. Lam Y. lam (p : <X,Y>). < pi2 p, pi1 p >) [bool] [int] <true, 1>)
|}
let bad_swap = expr {|
pi1 (((lam(x:*).x) : *->* => * : * => forall X. forall Y. <X,Y> -> <Y,X>) [int] [int] <1,2>)
|}
let invalid_cast = expr {|
(lam (x : int) . x : int => bool) 5
|}
let no_cast = expr {|
(lam (x : *) . x : * => int) 5
|}