Thursday, June 23, 2005

[Haskell-cafe] Re: Using type classes for polymorphism of data constructors

[Haskell-cafe] Re: Using type classes for polymorphism of data constructors

A message on the Haskell-cafe mailing list gives an alternative (better, even) approach to the polymorphism of formulæ using differential types. It works just as well as my solution, and results in much more complex (and therefore complete) types:Main> :t (Impl (Prop "p") (Poss (Prop "p")))
Impl (Prop "p") (Poss (Prop "p")) :: PC2 PC0 (Modal1 PC0)
I'm not yet sure which route I'll take. My approach results in a single data type (PC, Modal, etc) for each language, which is good, but the types don't mean much and it isn't Haskell-98 (or, at least, Hugs won't load it as such). Ralf's approach also works, the types is assigns formulæ contain more information and it is Haskell-98.

I'll probably wind up using a version based on Ralf's example, unless I run into problems.

No comments: