[Haskell-cafe] Supplying a default implementation for a typeclass based on another class

Johan Jeuring johanj at cs.uu.nl
Sat Feb 28 06:42:31 EST 2009


> Now, that's fine enough, but for simplicity (and for wireshark), I'd
> like to be able to have Binary fall back on an instance based on
> Show/Read for any type that lacks any other Binary instance..
>
> Well, I understand why this would be somewhere between extremely hard
> and impossible in haskell '98, but I'm not entirely up on all the
> extensions, so I thought I'd ask - given every extension implemented
> in ghc 6.10.1, is there any reasonable way to do this?

I'm not sure what you mean by falling back on Show/Read instances,
but this seems like a typical generic programming problem. Recent
releases include the EMGM and SYB libraries for generic programming.

-- Johan Jeuring



More information about the Haskell-Cafe mailing list