@@ -0,0 +1,32 @@
1+module Prelude.Pairs
2+
3+%access public
4+%default total
5+
6+||| Dependent pair where the first field is erased.
7+data Exists : {a : Type} -> (P : a -> Type) -> Type where
8+ witness : .{x : a} -> (pf : P x) -> Exists P
9+
10+||| Dependent pair where the second field is erased.
11+data Subset : (a : Type) -> (P : a -> Type) -> Type where
12+ element : (x : a) -> .(pf : P x) -> Subset a P
13+
14+||| Class of dependent pair constructors.
15+class DependentPair f where
16+ ||| Project the first field from a dependent pair.
17+ getWitness : f a P -> a
18+
19+ ||| Project the second field from a dependent pair.
20+ getProof : (x : f a P) -> P (getWitness x)
21+
22+instance DependentPair Pair where
23+ getWitness (pair x pf) = x
24+ getProof (pair x pf) = pf
25+
26+instance DependentPair Exists where
27+ getWitness (witness x pf) = x
28+ getProof (witness x pf) = pf
29+
30+instance DependentPair Subset where
31+ getWitness (element x pf) = x
32+ getProof (element x pf) = pf