3
Types Summer School 2007
16
module Datatypes where
33
_+_ : Nat -> Nat -> Nat
35
suc n + m = suc (n + m)
44
if_then_else_ : {A : Set} -> Bool -> A -> A -> A
45
if true then x else y = x
46
if_then_else_ false x y = y
50
Parameterised datatypes
54
data List (A : Set) : Set where
56
_::_ : A -> List A -> List A
58
nil : (A : Set) -> List A
61
map : {A B : Set} -> (A -> B) -> List A -> List B
63
map f (x :: xs) = f x :: map f xs
71
data False : Set where
74
elim-False : {A : Set} -> False -> A
75
elim-False () -- Look Ma, no right hand side!