>       I've got a query about exporting classes and instances from a module.
> In the report (1.2beta) it says that a class and all its methods are exported
> if either it is explicitly named in the export list, or implicitly exported
> if the export list is omited. I don't understand what is supposed to happen
> if you split the definition of a class and its instances into different
> modules?

You can't (unless the other module contains the type definition for
the C-T pair).

> For example the class Num and its methods are defined and exported in
> PreludeCore. When the report says that the methods are exported does it also
> mean that the instances for Integer,Int, Float and Double are exported ??

Only if they're in scope in PreludeCore (i.e. Yes for 1.2beta).

> I find this a problem when trying to understand the instance definitions in
> PreludeRatio. Instance definitions for the class Num are defined for
> (Ratio a) in PreludeRatio, but the export list does not mention them.

Export lists never mention instances.  They're exported exactly when
either C or T from the C-T pair is exported.  I think that answers
your next questions.

> Has the closure rule of section 5.1.3 been met ? Or does this mean that
> the export definition in PreludeCore covers this instance as well (which
> seems rather non-intuitive)? If it does (and this is what I assume to be
> correct, otherwise their would be no point in defining instances for Ratio
> in PreludeRatio), then it implies that I cannot multiply define instances,
> and choose which I use in the final program by selective importing/exporting.

Yes, that's the idea!  This avoids the ambiguity that might exist
in your scheme without very careful design.

Kevin


Reply via email to