@@ -1,5 +1,7 @@
1module Data.HVect
1module Data.HVect
3using (k : Nat, ts : Vect Type k)
5using (k : Nat, ts : Vect Type k)
4 data HVect : Vect Type k -> Type where
6 data HVect : Vect Type k -> Type where
5 Nil : HVect []
7 Nil : HVect []
@@ -44,3 +46,15 @@ using (k : Nat, ts : Vect Type k)
44 instance (Shows k ts) => Show (HVect ts) where
46 instance (Shows k ts) => Show (HVect ts) where
45 show xs = show (shows xs)
47 show xs = show (shows xs)
49+ get : {default tactics { applyTactic findElem 100; solve; } p : Elem t ts} -> HVect ts -> t
50+ get {p = Here} (x::xs) = x
51+ get {p = There p'} (x::xs) = get {p = p'} xs
53+ put : {default tactics { applyTactic findElem 100; solve; } p : Elem t ts} -> t -> HVect ts -> HVect ts
54+ put {p = Here} y (x::xs) = y :: xs
55+ put {p = There p'} y (x::xs) = x :: put {p = p'} y xs
57+ update : {default tactics { applyTactic findElem 100; solve; } p : Elem t ts} -> (t -> u) -> HVect ts -> HVect (replaceByElem ts p u)
58+ update {p = Here} f (x::xs) = f x :: xs
59+ update {p = There p'} f (x::xs) = x :: update {p = p'} f xs