Tuple-like constructors

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Wed Feb 8 13:19:52 EST 2006


Robert Dockins <robdockins at fastmail.fm> writes:

> instance (Bin a,Bin b,Bin c,Bin d) => Bin (a,b,c,d)
> 
> See the problem?  Sooner or later (probably sooner) I'll get tired of  
> typing.  I have to write down an 'instance' declaration for each  
> value of n.  Clearly this can't generalize to all n.

There has been a suggestion that the 'deriving' mechanism be de-coupled
from the datatype declaration.  Together with a generic default
definition, that means you could write something like

    deriving Bin for (,,,,,,,,,,,,,,,,,,,,)

and hence not need to write the tedious instance header yourself,
since the compiler can easily infer it.

Regards,
    Malcolm


More information about the Haskell-prime mailing list