summaryrefslogtreecommitdiff
path: root/transfer/lib/pair.tr
blob: a4956abdddf498dc5248b1e31126247230ad01f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Pair : Type -> Type -> Type
Pair A B = sig { p1 : A; p2 : B }

pair : (A:Type) -> (B:Type) -> A -> B -> Pair A B
pair _ _ x y = rec { p1 = x; p2 = y }

fst : (A:Type) -> (B:Type) -> Pair A B -> A
fst _ _ p = case p of Pair _ _ x _ -> x

snd : (A:Type) -> (B:Type) -> Pair A B -> B
snd _ _ p = case p of Pair _ _ x _ -> x

{-

 syntax:

 (x1,...,xn) => { p1 = e1; ... ; pn = en }

 where n >= 2 and x1,...,xn are expressions or patterns

-}