[Haskell-cafe] Confusion with GeneralizedNewtypeDeriving + MultiParamTypeClasses
will.yager at gmail.com
Fri Jul 10 07:01:28 UTC 2015
I have run into a bit of a strange case where I can't get
`GeneralizedNewtypeDeriving` to work as I'd like.
In the `vector` package, under `Data.Vector.Generic`, there is a generic
vector typeclass of the form `Vector v a`, where `v` is the vector type and
`a` is the type of items in the vector.
I have a newtype wrapper of the form `newtype Neuron a = Neuron (Vector
a)`. (Note that "Vector" here is a type "Vector", not the two-parameter
constraint also called "Vector".)
I would like to be able to use everything in `Data.Vector.Generic` on
Using `GeneralizedNewtypeDeriving`, I immediately run up against the issue
that the `Vector` typeclass doesn't have the correct form of `* ->
According to section 22.214.171.124 of
, we should be able to derive instances of multi-parameter type classes,
provided the newtype is the last parameter of the typeclass. The problem
here is that it's the first parameter.
Using `ConstraintKinds` to make a constraint synonym (of the form
`FlippedVectorClass a v`) so that I can do something like `newtype Neuron a
= Neuron (Vector a) deriving (FlippedVectorClass a)` also doesn't seem to
Does anyone have any advice for how to make this work? It's quite tempting
just to make `type Neuron a = Vector a`, but I'd rather do a proper wrapper
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe