Closed ulidtko closed 6 months ago
Follow-up: deriving FunctorB
et al actually works, but requires DeriveAnyClass
— while I had only DerivingVia
enabled.
This is good too:
{-# LANGUAGE DeriveAnyClass #-}
newtype EnvFileSource f = EnvFileSource (f Harg.ConfigFile)
deriving stock Generic
deriving anyclass (FunctorB, TraversableB, ApplicativeB)
Hi @jcpetruzza, thanks for publishing & maintaining the library. :pray:
Quick posterity note, just to document a pitfall.
Say I'm defining whatever barbie for use with the Harg library from @alexpeits.
If I follow barbies' docs closely, I write
And all is good with this one :tada:
However, if I follow Harg's docs first, I instead write
— and this elicits a rather exotic complaint out of GHC 9.6.4 (I hadn't seen such before):
I do have a vague idea how eta-reduction can't chew on this newtype's RHS; but just to zoom out to top-level context — as a user of Harg library, it's genuinely puzzling to get this error.
Not sure if it's as expected or not; I will certainly ping Harg to fix the docs there.
TL;DR for the impatient: use standalone
instance FunctorB YourThing
instead ofderiving FunctorB
.