Skip to content

Turn tuples into syntactic sugar for heterogeneous lists

It would be nice if (x,y,z) were syntactic sugar for a heterogeneous list, i.e. (x :*: y :*: z :*: HNil) where

data a :*: b = a :*: b
data HNil = HNil

(:*: associating to the right). Using functional dependencies and the techniques from the HList paper, we could then process tuples of arbitrary length in a uniform matter: for example, the Data.Monoid.Monoid instances for tuples. At the same time, this would create a slightly more light-weight syntax for heterogeneous lists, making them more acceptable for use cases like functions with optional or keyword arguments.

I'm not sure how much existing code would this would break. Showing and reading heterogeneous lists as tuples doesn't seem hard to implement. I don't know about Typeable and friends.

Trac metadata
Trac field Value
Version 6.6
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Unknown
Architecture Unknown
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information