on master help sign in
Minor docstring additions
commit757adcecb3b95af506a7667240ced4a92899dabf authorDavid Raymond Christiansen <david@davidchristiansen.dk> dateWed 16 Apr 2014, 23:32 (13 years ago) parenta457fdd
2 files changed+10−2
libs/base/Data/BoundedList.idr+4 libs/base/Data/HVect.idr+6−2
libs/base/Data/BoundedList.idr+4
@@ -3,10 +3,12 @@ module Data.BoundedList
33%access public
44%default total
55
6+||| A list with an upper bound on its length.
67data BoundedList : Type -> Nat -> Type where
78 Nil : BoundedList a n
89 (::) : a -> BoundedList a n -> BoundedList a (S n)
910
11+||| Compute the length of a list.
1012length : BoundedList a n -> Fin (S n)
1113length [] = fZ
1214length (x :: xs) = fS (length xs)
@@ -24,6 +26,7 @@ index (fS f) (_ :: xs) = index f xs
2426-- Adjusting bounds
2527--------------------------------------------------------------------------------
2628
29+||| Loosen the bounds on a list's length.
2730weaken : BoundedList a n -> BoundedList a (n + m)
2831weaken [] = []
2932weaken (x :: xs) = x :: weaken xs
@@ -77,6 +80,7 @@ map f (x :: xs) = f x :: map f xs
7780-- Misc
7881--------------------------------------------------------------------------------
7982
83+||| Extend a bounded list to the maximum size by padding on the left.
8084pad : (xs : BoundedList a n) -> (padding : a) -> BoundedList a n
8185pad {n=Z} [] _ = []
8286pad {n=S n'} [] padding = padding :: (pad {n=n'} [] padding)
libs/base/Data/HVect.idr+6−2
@@ -6,7 +6,8 @@ import Data.Vect
66%default total
77
88using (k : Nat, ts : Vect k Type)
9− ||| Heterogeneous vectors where the type index gives, element-wise, the types of the contents
9+ ||| Heterogeneous vectors where the type index gives, element-wise,
10+ ||| the types of the contents.
1011 data HVect : Vect k Type -> Type where
1112 Nil : HVect []
1213 (::) : t -> HVect ts -> HVect (t::ts)
@@ -30,6 +31,7 @@ using (k : Nat, ts : Vect k Type)
3031 updateAt fZ f (x::xs) = f x :: xs
3132 updateAt (fS j) f (x::xs) = x :: updateAt j f xs
3233
34+ ||| Append two `HVect`s.
3335 (++) : {us : Vect l Type} -> HVect ts -> HVect us -> HVect (ts ++ us)
3436 (++) [] ys = ys
3537 (++) (x::xs) ys = x :: (xs ++ ys)
@@ -52,16 +54,18 @@ using (k : Nat, ts : Vect k Type)
5254 instance (Shows k ts) => Show (HVect ts) where
5355 show xs = show (shows xs)
5456
55− ||| Extract an arbitrary element of the correct type
57+ ||| Extract an arbitrary element of the correct type.
5658 ||| @ t the goal type
5759 get : {default tactics { applyTactic findElem 100; solve; } p : Elem t ts} -> HVect ts -> t
5860 get {p = Here} (x::xs) = x
5961 get {p = There p'} (x::xs) = get {p = p'} xs
6062
63+ ||| Replace an element with the correct type.
6164 put : {default tactics { applyTactic findElem 100; solve; } p : Elem t ts} -> t -> HVect ts -> HVect ts
6265 put {p = Here} y (x::xs) = y :: xs
6366 put {p = There p'} y (x::xs) = x :: put {p = p'} y xs
6467
68+ ||| Replace an element with the correct type.
6569 update : {default tactics { applyTactic findElem 100; solve; } p : Elem t ts} -> (t -> u) -> HVect ts -> HVect (replaceByElem ts p u)
6670 update {p = Here} f (x::xs) = f x :: xs
6771 update {p = There p'} f (x::xs) = x :: update {p = p'} f xs