The definition of Representable constraints the implementor to provide an instance for Distributive first.
I wondered why that may be, in the definition of Representable
, there is no mention of any Distributive
functions: source.
In fact, the imports from Distributive
are only ever used for re-exporting and other instance definitions.
Additionally, I wanted to use an instance I defined like this:
instance Representable w => Distributive w where
distribute :: Functor f => f (w a) -> w (f a)
distribute f = tabulate (\ i -> fmap (flip index i) f)
which sadly doesn’t work, or at least I can’t get it to work, because Distributive
is a superclass constraint for Representable
.
GHC and HLS offer me some options about UndecidableInstances
but I’m not experienced enough to successfully use these.
Do you know of a reason for this constraint?
Could I expose the instance I defined maybe using a newtype
?