
Brian Smith:
When using AT then we have to decide what part of the abstraction is the class and what part is the associated type. Sometimes this seams arbitrary. If we have:
class A a where type B b f :: a -> B b instance A Int where type B = Bool f = (==0)
Can't we also rewrite it as:
class B b where type A a f :: A a -> b instance B Bool where type A = Int f = (==0)
If it is arbitrary, you should use a two parameter class. The bias in an associated type is on purpose; ie, an associated type should be used if one type depends on the other. Bulat wrote:
Also, has anybody written a paper on the differences between typeclasses + associated types and ML's module system + overloading?
"ML Modules and Haskell Type Classes: A Constructive Comparison" http://www.informatik.uni-freiburg.de/~wehr/diplom/Wehr_ML_modules_and_Haske...
In addition to this comparison, there is now also a proposal for type classes with associated types as a mode of use of ML modules. See our forthcoming POPL paper: http://www.cse.unsw.edu.au/~chak/papers/DHC07.html Ie, this gives you ML modules + overloading. Manuel