-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.txt
60 lines (45 loc) · 1.05 KB
/
types.txt
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
(declare [X :type Bool])
(declare [x :type Char])
(declare [x :type Int])
(declare [y :type Word])
(declare [x :type Rational])
(declare [y :type String])
(declare [x :type [Int]])
(declare [x :type (Int Int) -> (Int)])
-----------ploymorphic function------------
-----------ploymorphic
(define fst
(fun ([a b] [-> a.type])))
-----------subtype-----------------
(define fst
(fun ([:a (Int (a < 2))])))
------------constrained
(typename (:T Floadable))
(define length
(fun ([:a T] [-> T])))
(define head
(fun ([array] [-> array.type])))
(typename (:T Num))
(define add
(fun ([:x T] [-> T])
(+ x 1)))
(add :x 1.0)
(add :x 1.2)
(add :x 1.3)
(add :y 1.0)
----------type synonym-----------------
(type RGB [Int Int Int])
(type ID Int)
(type BookName String)
(typename (:a Eq))
(define add
(fun ([:b Int] [-> Int])))
---what is the a?--------------
(Class Eq a
[== :type [(a a) -> Bool]]
[/= :type [(a a) -> Bool]])
---curry function----------------
(define add
(fun ([:a Int] [:b Int] [-> (Int -> Int)])
(fun (c)
(+ a (+ b c)))))