[Haskell-cafe] Inheritance and Wrappers

Daniel Fischer daniel.is.fischer at googlemail.com
Tue Feb 1 13:59:22 CET 2011


On Tuesday 01 February 2011 13:45:34, Ozgur Akgun wrote:
> I want to be able to write the following instance to accomplish that:
>
> instance Data t => Term t where
>     termTag = show . toConstr
>
> And if the user wants to write a more specific instance, they should be
> welcome to do so:
>
> instance Term UserDT where
>     termTag (...) = ...
>
> I am not very much interested in the technical details about how things
> currently are, I am more interested in a discussion about why (if?) this
> would be considered a *design flaw*?

I think the strongest reason to consider it a design flaw is the current 
implementation, that instance selection doesn't take contexts into account.
Things being as they are, an

instance A a => B a where ...

just isn't very useful. If instance selection took contexts into account, 
such an instance might be useful, but it would still prevent users from 
declaring instances for both classes (without an extension which would have 
much the same problems as OverlappingInstances).




More information about the Haskell-Cafe mailing list