-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.agda
78 lines (52 loc) · 1.41 KB
/
common.agda
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
77
78
module common where
----------------------------------------
data Bool : Set where
true : Bool
false : Bool
{-# BUILTIN BOOL Bool #-}
{-# BUILTIN TRUE true #-}
{-# BUILTIN FALSE false #-}
_or_ : Bool → Bool → Bool
true or _ = true
false or b = b
_and_ : Bool → Bool → Bool
false and _ = false
true and b = b
not : Bool → Bool
not true = false
not false = true
----------------------------------------
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
{-# BUILTIN NATURAL ℕ #-}
_==_ : ℕ → ℕ → Bool
zero == zero = true
(suc n) == (suc m) = n == m
_ == _ = false
----------------------------------------
data List (A : Set) : Set where
[] : List A
_::_ : A → List A → List A
[_] : {A : Set} → A → List A
[ x ] = x :: []
_++_ : {A : Set} → List A → List A → List A
[] ++ ys = ys
(x :: xs) ++ ys = x :: (xs ++ ys)
infixr 10 _++_
infixr 20 _::_
all : {A : Set} → (A → Bool) → List A → Bool
all _ [] = true
all f (x :: xs) = (f x) and (all f xs)
----------------------------------------
postulate String : Set
{-# BUILTIN STRING String #-}
primitive
primStringAppend : String → String → String
primStringEquality : String → String → Bool
primShowString : String → String
_>>_ : String → String → String
_>>_ = primStringAppend
infixl 1 _>>_
_===_ : String → String → Bool
_===_ = primStringEquality