@@ -5,28 +5,8 @@ module Prelude.Pairs
6||| Dependent pair where the first field is erased.
6||| Dependent pair where the first field is erased.
7data Exists : {a : Type} -> (P : a -> Type) -> Type where
7data Exists : {a : Type} -> (P : a -> Type) -> Type where
8− witness : .{x : a} -> (pf : P x) -> Exists P
8+ witness : .{P : a -> Type} -> .{x : a} -> (pf : P x) -> Exists P
10||| Dependent pair where the second field is erased.
10||| Dependent pair where the second field is erased.
11data Subset : (a : Type) -> (P : a -> Type) -> Type where
11data Subset : (a : Type) -> (P : a -> Type) -> Type where
12− element : (x : a) -> .(pf : P x) -> Subset a P
12+ element : .{P : a -> Type} -> (x : a) -> .(pf : P x) -> Subset a P
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
19− ||| Project the second field from a dependent pair.
20− getProof : (x : f a P) -> P (getWitness x)
22−instance DependentPair Pair where
23− getWitness (pair x pf) = x
24− getProof (pair x pf) = pf
26−instance DependentPair Exists where
27− getWitness (witness x pf) = x
28− getProof (witness x pf) = pf
30−instance DependentPair Subset where
31− getWitness (element x pf) = x
32− getProof (element x pf) = pf