20 Feb 2008 15:01
How to define init for vectors?
Serguey Zefirov <sergueyz <at> gmail.com>
2008-02-20 14:01:14 GMT
2008-02-20 14:01:14 GMT
I try to write small familiar programs to understand dependent types
programming better (more precisely, understand it at all). All usual
maps and folds are done and I processed to more dependent ones.
That's what I managed to write:
------------------------------------------------------------------------------
( n : Nat !
data (---------! where (------------! ; !--------------!
! Nat : * ) ! zero : Nat ) ! succ n : Nat )
------------------------------------------------------------------------------
( A : * ! ( a : A !
data !-------------! where (-------------------! ; !------------------!
! Maybe A : * ) ! Nothing : Maybe A ) ! Just a : Maybe A )
------------------------------------------------------------------------------
( A : * ; B : * ! ( a : A ; b : B !
data !----------------! where !----------------------!
! Pair A B : * ) ! Tuple a b : Pair A B )
------------------------------------------------------------------------------
( n : Nat ; X : * ! ( x : X ; xs : Vec n X !
data !------------------! where (--------------! ; !-----------------------!
! Vec n X : * ) ! vnil : ! ! vcons x xs : !
! Vec zero X ) ! Vec (succ n) X )
------------------------------------------------------------------------------
let (-------------!
! width : Nat )
width => succ (succ zero)
------------------------------------------------------------------------------
And here I got stuck:
(Continue reading)
RSS Feed