[Haskell-cafe] Attempt to emulate subclasses in Haskell, am I reinventing the wheel?

Bardur Arantsson spam at scientician.net
Mon Apr 20 18:26:01 UTC 2015

On 20-04-2015 20:01, Clinton Mead wrote:
> I've linked to an ugly attempt to emulate subclasses in Haskell, and I'm
> wondering if anyone has done what I have perhaps in a cleaner way.

Well, I would generally advise against trying to emulate a flawed
concept in the first place. "OverlappingInstances" and
"UndecidableInstances" are a red flag unless you know *exactly* what you
are doing.

A much better way (IMO, of course) is to use either

     1) normal aggregation (that's the simpl{e,istic} answer), at
        the cost of some boilerplate. If the boilerplate exceeds
        practicality, I would look at
     2) extensible records/row types as in e.g. "vinyl"


More information about the Haskell-Cafe mailing list