[Haskell-cafe] Supplying a default implementation for a typeclass
based on another class
Svein Ove Aas
svein.ove at aas.no
Sun Mar 1 15:12:34 EST 2009
On Sun, Mar 1, 2009 at 6:42 PM, Martin Huschenbett <huschi at gmx.org> wrote:
> Hi,
>
> you could do something like
>
>> instance (Show a,Read a) => Binary a where
>> put = put . show
>> get = fmap read get
>
> But then you will need the following language extensions: FlexibleInstances,
> OverlappingInstances, UndecidableInstances
>
Well, isn't there a good chance it'll end up picking that instance
even when a more specific one is available, then?
I think the problem here is that I don't know of any way to inform GHC
that any particular instance is "less specific".
More information about the Haskell-Cafe
mailing list