Real world use of GADT

后端 未结 5 1320
暗喜
暗喜 2020-12-22 19:50

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.

5条回答
  •  时光说笑
    2020-12-22 20:57

    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.

提交回复
热议问题