I have 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 started to implement the Foldable interface for the data type
Foldable MyVect where
foldr = ?res2
However when reloading the file, Idris complaints
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
After scratching my head a bit, I guessed that I could obey Idris demands for the type constructor by writing
Foldable (MyVect n) where
foldr = ?res2
Then I started to think "what if I had defined MyVect with the type parameters 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 'parameter-flipped' version of MyVect
? (and how?)