@@ -6,10 +6,12 @@ import Data.Vect
6%default total
6%default total
8using (k : Nat, ts : Vect k Type)
8using (k : Nat, ts : Vect k Type)
9+ ||| Heterogeneous vectors where the type index gives, element-wise, the types of the contents
9 data HVect : Vect k Type -> Type where
10 data HVect : Vect k Type -> Type where
10 Nil : HVect []
11 Nil : HVect []
11 (::) : t -> HVect ts -> HVect (t::ts)
12 (::) : t -> HVect ts -> HVect (t::ts)
14+ ||| Extract an element from an HVect
13 index : (i : Fin k) -> HVect ts -> index i ts
15 index : (i : Fin k) -> HVect ts -> index i ts
14 index fZ (x::xs) = x
16 index fZ (x::xs) = x
15 index (fS j) (x::xs) = index j xs
17 index (fS j) (x::xs) = index j xs
@@ -49,6 +51,8 @@ using (k : Nat, ts : Vect k Type)
49 instance (Shows k ts) => Show (HVect ts) where
51 instance (Shows k ts) => Show (HVect ts) where
50 show xs = show (shows xs)
52 show xs = show (shows xs)
54+ ||| Extract an arbitrary element of the correct type
55+ ||| @ t the goal type
52 get : {default tactics { applyTactic findElem 100; solve; } p : Elem t ts} -> HVect ts -> t
56 get : {default tactics { applyTactic findElem 100; solve; } p : Elem t ts} -> HVect ts -> t
53 get {p = Here} (x::xs) = x
57 get {p = Here} (x::xs) = x
54 get {p = There p'} (x::xs) = get {p = p'} xs
58 get {p = There p'} (x::xs) = get {p = p'} xs