on master help sign in
Instance docs: add some instance docs to libs
commit9d45713cf128e444d07735a6b9be9cdcc9ff9fed authorAdam Sandberg Eriksson <adam@sandbergericsson.se> dateSat 7 Mar 2015, 17:38 (12 years ago) parentdf1a933
2 files changed+8−5
libs/base/Data/VectType.idr+5−4 libs/prelude/Prelude/Nat.idr+3−1
libs/base/Data/VectType.idr+5−4
@@ -1,4 +1,4 @@
1−module Data.VectType
1+module Data.VectType
22
33import Data.Fin
44
@@ -6,7 +6,7 @@ import Data.Fin
66%default total
77
88namespace Vect {
9−
9+
1010infixr 7 ::
1111
1212%elim data Vect : Nat -> Type -> Type where
@@ -531,6 +531,8 @@ instance Applicative (Vect k) where
531531
532532 fs <*> vs = zipWith apply fs vs
533533
534+||| This monad is different from the List monad, (>>=)
535+||| uses the diagonal.
534536instance Monad (Vect n) where
535537 m >>= f = diag (map f m)
536538
@@ -539,7 +541,7 @@ instance Traversable (Vect n) where
539541 traverse f (x::xs) = [| Vect.(::) (f x) (traverse f xs) |]
540542
541543--------------------------------------------------------------------------------
542−-- Show
544+-- Show
543545--------------------------------------------------------------------------------
544546
545547instance Show a => Show (Vect n a) where
@@ -595,4 +597,3 @@ instance DecEq a => DecEq (Vect n a) where
595597
596598-- For the primitives, we have to cheat because we don't have access to their
597599-- internal implementations.
598−
libs/prelude/Prelude/Nat.idr+3−1
@@ -195,6 +195,7 @@ instance Num Nat where
195195instance MinBound Nat where
196196 minBound = Z
197197
198+||| Casts negative `Integers` to 0.
198199instance Cast Integer Nat where
199200 cast = fromInteger
200201
@@ -250,6 +251,7 @@ instance BoundedJoinSemilattice Nat where
250251 bottom = Z
251252
252253
254+||| Casts negative `Ints` to 0.
253255instance Cast Int Nat where
254256 cast i = fromInteger (cast i)
255257
@@ -333,7 +335,7 @@ lcm x y = divNat (x * y) (gcd x y)
333335
334336
335337--------------------------------------------------------------------------------
336−-- An informative comparison view
338+-- An informative comparison view
337339--------------------------------------------------------------------------------
338340data CmpNat : Nat -> Nat -> Type where
339341 CmpLT : (y : _) -> CmpNat x (x + S y)