[Haskell-cafe] tuple and HList

David Menendez zednenem at psualum.com
Sun Mar 20 23:55:19 EST 2005

Frederik Eaton writes:

> > One way t make tuples into sugar for HLists would be to effectively
> > have a series of declarations like these:
> > 
> >     type (a,b)   = TCons a (TCons b HNil)
> >     type (a,b,c) = TCons a (TCons b (TCons c HNil))
> > 
> > But then we can't use tuples in instance declarations. That is,
> > there isn't any way to desugar 'instance Functor ((,) a)' without
> > using a type lambda.
> I'm not sure I understand this, but the intent was that you'd use e.g.
> TCons instead of the tuple syntax in instance declarations.

Currently, '(,)' is a type constructor of kind * -> * -> * and '(a,b)'
is sugar for '(,) a b'. That means we can partially apply '(,)' in
instance declarations, for example:

    instance Functor ((,) a) where
        fmap f (x,y) = (x, f y)
If we get rid of '(,)' and redefine '(a,b)' as sugar for 'TCons a (TCons
b HNil)' (or whatever), then there is no way to declare the above
instance. I don't think that's a deal-killer, but it is a disadvantage.
David Menendez <zednenem at psualum.com> <http://www.eyrie.org/~zednenem/>

More information about the Haskell-Cafe mailing list