
21 Dec
2011
21 Dec
'11
5:24 p.m.
On Wed, 2011-12-21 at 18:34 +0000, Daniel Waterworth wrote:
I made this simple state machine combinator library today. I think it works as a simple example of a good use for GADTs.
Any way to do something along the lines of type StateChange a = SC a a handleChange :: Monad m => StateChange ConnectionState -> m () handleChange (SC Closed Opening) = return () handleChange (SC Opening Closed) = return () handleChange (SC Closed Open) = return () where the last line would yield a type checking error at compile time, and the compiler can warn about handleChange not being exhaustive (for the valid state change steps)? Nicolas