[Haskell-cafe] tuple and HList

Keean Schupke k.schupke at imperial.ac.uk
Sun Mar 20 20:00:56 EST 2005

Frederik Eaton wrote:

>That's a neat technique. Since it's so general it would be nice if
>there were a way to make it more automatic, could one use template
>haskell? It seems one should be able to write
>HListConstraint $(mkConstraint Show) l
>to generate the declarations automatically.
This is planned as part of a template-haskell library  allowing automatic
lifting of data types to classes.

This would most likely be written:

$(ttypelift [d|
    type ShowList = [Show] |])

or for a function

$(ttypelift [d|
    f :: [Show] -> [Show]

(Here Show is assumed to be defined as a type in the environment)

Lifting a list of type [Show] produces an HList where each element is
constrained to be an instance of the class Show.

If we consider type level naturals we can define a list "[HNat]" where
each element is a type level natural number.


More information about the Haskell-Cafe mailing list