TestVec.agda 442 B

123456789101112131415161718192021
  1. module TestVec where
  2. open import PreludeNatType
  3. open import PreludeShow
  4. infixr 40 _::_
  5. data Vec (A : Set) : Nat -> Set where
  6. [] : Vec A zero
  7. _::_ : {n : Nat} -> A -> Vec A n -> Vec A (suc n)
  8. head : {A : Set}{n : Nat} -> Vec A (suc n) -> A
  9. head (x :: _) = x -- no need for a [] case
  10. length : {A : Set}{n : Nat} -> Vec A n -> Nat
  11. length {A} {n} v = n
  12. three : Vec Nat 3
  13. three = 1 :: 2 :: 3 :: []
  14. mainS = showNat (length three)