I defined my own Vect data type as follows
data MyVect : (n : Nat) -> (t : Type) -> Type where
Nil : MyVect Z t
(::) : (x : t) -> (xs : MyVect n t) -> MyVect (S n) t
And then he began to implement the Foldable interface for the data type
Foldable MyVect where
foldr = ?res2
However, when Idris complaint file is reloaded
When checking argument t to type constructor Prelude.Foldable.Foldable:
Type mismatch between
Nat -> Type -> Type (Type of MyVect)
and
Type -> Type (Expected type)
Specifically:
Type mismatch between
Nat
and
TypeUnification failure
Scratching my head a little, I guessed that I could obey Idris' requirements for a type constructor by writing
Foldable (MyVect n) where
foldr = ?res2
Then I started thinking "what if I defined MyVect with parameters of type flipped? ..."
data MyVect : (t : Type) -> (n : Nat) -> Type where
Nil : MyVect t Z
(::) : (x : t) -> (xs : MyVect t n) -> MyVect t (S n)
Is it possible to implement the Foldable interface for this version with a modified parameter MyVect? (And How?)
source
share