I suspect it's possible to do something like that with multi parameter type classes, but I tend to find that trying to do pseudo dependently typed things in Haskell tends to bite me sooner or later.
Daniel On 21 December 2011 22:24, Nicolas Trangez <nico...@incubaid.com> wrote: > 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. >> >> https://gist.github.com/1507107 > > 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 > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe