Generalised algebraic datatype
m (A link back to Libraries and tools/Database interfaces/HaskellDB)
Revision as of 01:45, 18 April 2006
- A short descriptions on generalised algebraic datatypes here as GHC language features
- Another description with links on Haskell' wiki
An example: it seems to me that generalised algebraic datatypes can provide a nice solution to a problem described in the documentation of HaskellDB project: in Daan Leijen and Erik Meijer's paper (see PostScript version) on the original HaskellDB page: making typeful (safe) representation of terms of another language (here: SQL). In this example, the problem has been solved in a funny way with Phantom type
- we make first an untyped language,
- and then a typed one on top of it.
So we we destroy and rebuild -- is it a nice topic for a myth or scifi where a dreamworld is simulated on top of a previously homogenized world to look like the original?
But solving the problem with GADTs seems to be a more direct way (maybe that's why Simple unification-based type inference for GADTs mentions that they are also called as first-class phantom types?)
2 Related concepts
There are other developed tricks with types in Type, and another way to a more general framework in Dependent types. Epigram is a fully dependently typed language, and its Epigram tutorial (section 6.1) mentions that Haskell is closely related to Epigram, and attributes this relatedness e.g. exactly to the presence of GADTs.
The more general problem (representing the terms of a language with the terms of another language) can develop surprising things, e.g. quines (self-replicating or self-representing programs). More details and links on quines can be seen in the section Self-replication, quines, reflective programming of the page Combinatory logic.