I have a bunch of functions that work on Vectors, i.e. lists with type-enforced lengths.
I'm trying to make my types easier to write, i.e. instead of writing
foo :: (Fold Integer v, Map Integer Integer v v, ...) => ...
I'm declaring a new class NList
so I can just write foo :: NList v Integer => ...
The (simplified) class looks like this:
class ( Fold (v i) i
, Map i i (v i) (v i)
, Map i (Maybe i) (v i) (v (Maybe i))
) => NList v i
As you can see, I have to keep the "vector" type separate from the "item" type (i.e. v
separate from i
) so that I can do things like Map
onto a Maybe
vector.
As such, v
must have kind * -> *
, and i
kind *
.
However, when I try to instantiate it with vectors like so:
instance NList Vec2 Integer
instance NList Vec3 Integer
...
I get the following error:
Type synonym `Vec2' should have 1 argument, but has been given none
In the instance declaration for `NList Vec2 Integer'
Now, I'm very new to type-level programming, and I understand that I'm likely doing this in a very backward fashion. Is it possible to instantiate a type synonym like this? Do any type-wizards have suggestions for better ways to accomplish my goals?