summaryrefslogtreecommitdiff
path: root/transfer/examples/array.tr
blob: 7dcf6d44321351d9df6dadb056a107d0d7b7a690 (plain)
1
2
3
4
5
6
7
8
9
10
import nat ;

data Array : Type -> Nat -> Type where {
   Empty : (A:Type) -> Array A Zero ;
   Cell : (A:Type) -> (n:Nat) -> A -> Array A n -> Array A (Succ n) ;
 } ;

mapA : (A:Type) -> (B:Type) -> (n:Nat) -> (A -> B) -> Array A n -> Array B n ;
mapA A B _ f (Empty _) = Empty B ;
mapA A B (Succ n) f (Cell _ _ x xs) = Cell B n (f x) (mapA A B n f xs) ;