Thanks to everyone who replied, indeed it looks like GADTs do what I claimed I wanted. That's neat because I've never been able to think of a use for them. However:
On Sun, Sep 15, 2013 at 2:16 AM, <o...@okmij.org> wrote: > Why not to introduce several type classes, even a type class for each > method if necessary. Grouping methods under one type class is > appropriate when such a grouping makes sense. Otherwise, Haskell won't > lose in expressiveness if a type class could have only one method. That's a very good point too, and one I should have thought of first. It's the simplest and I think most idiomatic. Ok, I guess I'm back to not being able to think of a use for GADTs, it seems like that happens whenever I think I have a use for a fancy feature :) > The main drawback of the intensional type analysis as shown in the > enclosed code is that it breaks parametricity. The constraint Eq a I guess what you're saying is that since I'm implementing a typeswitch, then I lose the nice feature of typeclasses that I know it can't do anything with the value except what the typeclass provides. In a sense, it loses type safety because it's too generic. That's a good point too. No free lunch, I guess, you get one thing and lose another. Typeclasses, though, don't exploit the closed universe part, though I can't think offhand how that hurts me. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe