[Haskell] controlling the scope of instances

Ralf Laemmel Ralf.Laemmel at cwi.nl
Thu Dec 2 04:25:43 EST 2004


I refer to Section 5.3 (title see subject line) in
Type classes: exploring the design space
by Simon Peyton Jones, Mark P. Jones and Erik Meijer
HW 1997.

There it is argued very briefly that a type system
with controlled scope of instances risks coherence.

Likewise, in Wadler's and Blotts original paper on ad-hoc polymorphism,
Appendix A.7 sheds light on the related problem of principal typings.
Global scope is suggested while wondering about less restrictive conditions
that retain principal typing. The interaction with the module system is 
not really considered.

I also know of /Functional Pearl: Implicit Configuration -- or, Type 
Classes Reflect the Value of Types/
Oleg Kiselyov, Chung-chieh Shan, Haskell Workshop 2004, which sheds some 
fancy light on the
subject. The paper deals with local instances, but not so much with 
scoping via the module system.

Does anyone know of a published, somewhat deeper analysis regarding
the possibility to scope instances via the normal module system?

For instance, why can't we have as many distinguished "incarnations" of 
a class
in the type system as there are different sets of instances created in 
various scopes.
That is, references to methods are to be *implicitly qualified* by the 
class incarnation (i.e., sets of instances). Methods of different 
incarnations are not to be
confused by the type system. This would solve all coherence issues that 
I can think of.
Or is this just getting too complicated?

Any pointers greatly appreciated.



More information about the Haskell mailing list