[Haskell-cafe] A type level puzzle
Silvio Frischknecht
silvio.frischi at gmail.com
Sat Aug 15 12:35:53 UTC 2015
I'm not going to do the whole thing for you but I can help start you off.
The type level string you think of is called Symbol. Symbol is a kind on
it's own and not (*) it has a type for every string. You can use the
functions in the following link to work with them.
https://hackage.haskell.org/package/base-4.8.1.0/docs/GHC-TypeLits.html
so you might have
newtype (symbol :: Symbol) ::: value = Field value
you can basically use any typelevel combinator you want for Sum e.g.
("foo" ::: Int) `(,)` ("bar" ::: Char) `(,)` ...
or make your own
You will have to use type families which are basically type level
functions to merge two sums.
If you run into trouble you can have a look at the following link which
does some similar things.
https://hackage.haskell.org/package/type-level-sets-0.5/docs/Data-Type-Set.html
P.S. Prepare for a headache
Cheers
Silvio
More information about the Haskell-Cafe
mailing list