The order of type arguments in indexed vectors

Seems common in dependent printing programming to determine

data Vec :: Type -> Nat -> Type where
  Nil :: Vec a 'Z
  Cons :: a -> Vec a n -> Vec a ( n)

In the Haskell, however, classes Functor, Applicative, Foldable, Traversable, Eq1, Ord1, etc., it seems to make a good example for the coup arguments around Vec :: Nat -> Type -> Type.

Is there any important reason for a conventional agreement? Or is it just what people use in languages ​​not based on class classes?

+4
source share
1 answer

, , , . , Agda Coq , .

data Vec (A : Set) : Nat -> Set where ...

Agda, , Set .

data Vec : Nat -> Set -> Set where ...

Set . , , Agda , .

Haskell , , , .

Agda , currying:

data Vec' (A : Set) : Nat -> Set

Vec : Nat -> Set -> Set
Vec n A = Vec' A n

{-# DISPLAY Vec' A n = Vec n A #-}

data Vec' A where
  nil : Vec zero A
  cons : {n : Nat} -> A -> Vec n A -> Vec (succ n) A

, .

+7

Source: https://habr.com/ru/post/1656155/


All Articles