Search code examples
haskellgadt

Real world use of GADT


How do I make use of Generalized Algebraic Data Type?

The example given in the haskell wikibook is too short to give me an insight of the real possibilities of GADT.


Solution

  • I have found the "Prompt" monad (from the "MonadPrompt" package) a very useful tool in several places (along with the equivalent "Program" monad from the "operational" package. Combined with GADTs (which is how it was intended to be used), it allows you to make embedded languages very cheaply and very flexibly. There was a pretty good article in the Monad Reader issue 15 called "Adventures in Three Monads" that had a good introduction to the Prompt monad along with some realistic GADTs.