Splitting SYB from the base package in GHC 6.10

David Menendez dave at zednenem.com
Tue Sep 2 13:27:34 EDT 2008


On Tue, Sep 2, 2008 at 11:59 AM, Bart Massey <bart at cs.pdx.edu> wrote:
> Ian Lynagh <igloo <at> earth.li> writes:
>> * You want to use a different instance for the same type.
>>
>>   Instances are global in Haskell, so if one library needs Ratio instance 1,
>>   and another library needs Ratio instance 2, then those libraries cannot be
>>   used in the same program.
>
> For me it's not so much about the libraries.  I've run into cases (not in SYB)
> where I want my program to use a different definition of an instance than the
> one provided by a library, while still using the other stuff provided by that
> library.
>
> The pervasive globality of instances does seem to me to be a Haskell bug; it
> seems to me like they ought to be controlled using the same module export
> control rules as anything else.  But I imagine there's some reason I don't
> understand that makes this hard or impossible...

I think there are some guarantees made by the type system that aren't
valid if class instances aren't global, but I can't remember the
details.

More practically, there is more than one way of implementing classes:
dictionary passing, partial evaluation (see "Dictionary-free
overloading by partial evaluation" by Mark Jones), and explicit type
parameters (used by JHC). The latter two enable optimizations that are
not possible with dictionary passing, but only work if instances are
global.

-- 
Dave Menendez <dave at zednenem.com>
<http://www.eyrie.org/~zednenem/>


More information about the Libraries mailing list