This might be a good thread for examples of using Data.Generic.
I’ll begin with a question. I’m at a yak-shaving point where I want to define Eq on this sum type:
data Fill
= Solid Color
| LinearGradient Color Color Percent
| RadialGradient Color Color Point
| NoFill
That means I need Eq for the various component types. Percent is easy:
newtype Percent = Percent Number
derive instance genericPercent :: Generic Percent
instance eqPercent :: Eq Percent where
eq = gEq
But Color (from purescript-colors) presents a problem. It has Eq, but it seems unavailable. This:
derive instance genericFill :: Generic Fill
… produces this:
No type class instance was found for
Data.Generic.Generic Color
while applying a function toSpine
of type Generic t0 => t0 -> GenericSpine
to argument $5
while checking that expression toSpine $5
has type GenericSpine
in value declaration genericFill
I did look at https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md, but I can’t tell if anything there applies.
Various flailing around with newtypes hasn’t helped.