Narrower (per-method) GND

David Feuer david.feuer at gmail.com
Mon Jan 9 02:16:55 UTC 2017


There are some situations where we may want to use GND to derive some
class methods when it's not applicable to others. For example, some
people would very much like to add a join method to Monad, but doing
so would prevent GND from working for Monad. Similarly, the distribute
method of Data.Distributive.Distributive is incompatible with GND. In
each of these cases, a perfectly valid, and efficient, way to derive
the class would be to use the GND mechanism to derive the methods it
works with and the default method definitions for the rest. To cover
these cases, I think it would be nice to allow a method declaration to
give a default definition intended to be used for GND. This may or may
not be the same as the usual default.

Some classes can support GND for some methods, but using defaults for
the others would give poor implementations. To cover this case, I
think it would be nice to add per-method GND-deriving syntax. This
could look something like

instance C T where
  deriving f
  g = ....


More information about the Glasgow-haskell-users mailing list