GADTs in the wild

Yitzchak Gale gale at
Wed Aug 15 23:13:39 CEST 2012

Simon Peyton-Jones wrote:
> This message is to invite you to send me your favourite example of using a
> GADT to get the job done.  Ideally I’d like to use examples that are (a)
> realistic, drawn from practice (b) compelling and (c) easy to present
> without a lot of background.

Last year I presented the following simple puzzle to the

That puzzle actually came up in a real-life software project
in Haskell that I was working on.

Several solutions were submitted that used various
Haskell extensions such as rank N types and generics,
as well as a rather cumbersome Haskell 98 solution.

But in my opinion, by far the best solution, using only
GADTs, was submitted by Eric Mertens:

Eric's solution could now be simplified even further
using data kinds.


More information about the Glasgow-haskell-users mailing list