blob: 476c96b947e54737e388821d6e00e74d54b4ff11 (
plain)
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
|
; Probably not going to implement this,
; just writing down ideas
; lowercase types: polymorphic
; everything else: monomorphic
(type compose (\[
(\[b] c) ; f
(\[a] b)] ; g
(\[a] c)))
(let
compose (\[f g] (\[x] (f (g x)))))
((compose (+ 1) (+ 2)) 3)
(type id (\[a] a))
(let id (\[a] a))
(type mod (\[Int Int] Int))
(let mod (\[n k]
(- n (* k (/ n k)))))
(type not (\[Bool] Bool))
(let not (\[b]
(match b
true false
false true)))
(type is-even (\[Int] Bool))
(let is-even (\[n]
(match (mod n 2)
0 true
1 false)))
; match cannot be type annotated because its variadic
; but the match above is inferred as this:
(type match (\[a a b a b] b))
|