Proposal: Add `Generically` (or `WrappedGeneric`) newtype to GHC.Generics
Alexis King
lexi.lambda at gmail.com
Sat Aug 31 00:25:57 UTC 2019
> On Aug 30, 2019, at 17:26, Alexis King <lexi.lambda at gmail.com> wrote:
>
> If you want to leave that instance out, that’s fine with me; I highly doubt anyone would miss it. As I said before, it’s totally useless.
Actually, I take this back. It’s not totally useless, just unlikely to be useful (and ultimately inessential). It’s theoretically useful if you have some function like
foo :: (Show a, Generic a) => a -> Foo
and want to use the generic version of the `Show` instance, but for some reason don’t want to actually define that instance on your type. You can write `foo (Generically x)`, and it will work out. That wouldn’t work if `Generic (Generically a)` were the derived instance.
On the other hand, you could always get the same behavior in a more flexible way by just defining a separate newtype and deriving the relevant instances as desired, like this:
newtype GenericallyShowable a = GenericallyShowable a
deriving newtype (Generic)
deriving (Show) via Generically a
So the instance isn’t necessary by any means, nor does it seem particularly likely to be useful in practice, but it doesn’t seem impossible that it ever could be. My vote is to keep it; I don’t see the harm.
More information about the Libraries
mailing list