I run into trouble trying to make Vector.Generic.Vector an instance of other typeclasses (in my case – Functor).
I could settle for adding a Functor instance to Vector.Unboxed.Vector, but I couldn’t figure out the syntax for that either.
My best take was to try something like:
instance (U.Unbox a, U.Unbox b) => Functor U.Vector where
fmap = U.map
But the compiler (justfully) complained that ‘a’ and ‘b’ where nowhere after ‘=>’.
Can I even make this definition for Functor, as it assumes more restrictions on the types fmap is allowed to take?
Most stuff I found in SO was too advanced for me to figure out, so please be gentle 🙂
Think of the type of
fmap:You are trying to add the constraint that
aandbare both instances ofUnbox. This is not doable becausefmapis completely general while a map of an unboxedVectoris specific to instancesUnbox.It cannot be made a
Functor.