[Haskell-beginners] Generalised data constructor matching

Daniel Fischer daniel.is.fischer at web.de
Sat Sep 5 08:45:25 EDT 2009

Am Samstag 05 September 2009 09:53:34 schrieb Chaddaï Fouché:
> On Fri, Sep 4, 2009 at 2:57 PM, Daniel Fischer<daniel.is.fischer at web.de> wrote:
> > In general: not.
> > The problem is that potentially every datatype can be made an instance of
> > the class, so in the default implementations, you can only[*] use
> > functions which work on every datatype. There aren't many interesting
> > functions that do.
> >
> > [*]well, you can also use methods of the class and superclasses.
> And so by using Data and Typeable as superclasses, he could do what he
> is asking for... And Data and Typeable are automatically derivables by
> GHC (extension).

True. But I don't think the code would become any shorter/better/easier to maintain 
(*shudder*), so I'd stick to individual instance declarations.

More information about the Beginners mailing list