News for hackers. Stuff that matters.
Re:Detecting use cases for GADTs in OCaml by lpw25 on Wednesday January 07, 2015 @08:15AM (#8850297)
> Also, has anyone ever used gadts to implement type safe syntax trees like that?

I believe the main use is for embedded DSLs. I'm afraid I don't have any practical examples on hand to link to.

Re:Detecting use cases for GADTs in OCaml by moomin on Wednesday January 07, 2015 @08:25AM (#8850332)
Consider an HTTP request. A get can't have a body, a post can.

So you could define

    data Request b where
      GET :: Headers -> Request ()
      POST :: Headers -> body -> Request body
As the article says, building up your intuition is the hard bit.

You could go further by typing the headers to recognize the type of body you're dealing with.