-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprog.siml
76 lines (56 loc) · 1.55 KB
/
prog.siml
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
let add : Int -> Int -> Int =
\x. \y. primadd;
let tuple : forall a b. a -> b -> (a, b) =
\x. \y. primtuple;
let fst : forall a b. (a, b) -> a =
\x. primfst;
let snd : forall a b. (a, b) -> b =
\x. primsnd;
let swap : forall a b. (a, b) -> (b, a) =
\t. (snd t, fst t);
let self_application : forall b. (forall a. a -> a) -> b -> b =
\f. f f;
let const : forall a b. a -> b -> a =
\a. \b. a;
let wrong_const : forall a b. a -> b -> b =
\a. \b. b;
let twice : forall a. (a -> a) -> a -> a =
\f. \x. f (f x);
let run_st : forall a. (forall h. h -> a) -> a =
\f. f 1;
let nested_let : Int =
let x = 4 in
let x = twice in
let x = add 10 (x (add 1) 1) in x;
let main : Int =
let const10 = (const 10 : forall a. a -> Int) in
let x = twice (add 10) (run_st const10) in
add x (let x = 5 in x);
let tuple_test : Int =
fst (\x. x, true) (snd (snd (true, (true, 2))));
type Day { Monday(), Tuesday(), Wednesday(), Thursday(), Friday() }
type Color { Red(), Green() }
type Location {
Loc(Int, Bool)
}
let red : Color = Color::Red();
let green : Color = Color::Green();
let my_loc : Bool -> Location = \x.
Location::Loc(1, x);
let latitude : Location -> Int =
\loc. match loc {
Location::Loc(lat, long) => lat,
};
let match_test : Int =
let day_of_week =
\day. match day {
Day::Monday() => 1,
Day::Tuesday() => 2,
Day::Wednesday() => 3,
Day::Thursday() => 4,
Day::Friday() => 5,
} in
day_of_week Day::Wednesday();
let ltest : Bool -> Int =
\x. let x = 21 in x;
let main : Int = ltest true;