Closed chshersh closed 3 years ago
I'm starting to think we should just use our own Buildable
, with a fallback to Formatting.Buildable
if there's no instance.
Or even a fallback to Show
.
An alternative solution that wouldn't require having our own Buildable
would be to leverage DerivingVia
, e.g.:
newtype GenericBuildable a = GenericBuildable a
instance (GBuildable (Rep a), Generic a) => Buildable (GenericBuildable a) where
build (GenericBuildable a) = genericF a
Usage:
data D = D
deriving stock Generic
deriving Buildable via GenericBuildable D
@neongreen @cdornan what do you think? I'd be happy to create a PR.
@dcastro I like the DerivingVia
idea : nondisruptive and really gets the job done. Feel free to raise a PR. (Sorry for the delay — other things have been sucking up available bandwidth.)
@cdornan Thanks for getting back to me! No need to apologise, OSS is draining and life is wild, I completely understand :smile: I'll try to raise a PR in the coming weeks then, cheers!
Fixed by #38
Very often you want to write just
It may be better to have default implementation of
build
(which is not possible, because we don't use our ownBuildable
). But still things should be easier...