instance visibility
kahl at cas.mcmaster.ca
kahl at cas.mcmaster.ca
Fri Sep 26 21:25:44 EDT 2008
Simon Marlow <marlowsd at gmail.com> wrote:
> We must have the property that the imports of a module do not affect
> its API - and the only way to have this property is to avoid orphan
> instances in library APIs.
To be more precise, I would say that each orphan instance in a library API
must be the only export of a dedicated visible module,
and only exported by that module.
(The only importers of orphan instances are typically Main modules,
or ``almost-Main'' modules.)
>
> There are basically only two sensible choices for the Functor instance
> for (->):
>
> (a) don't define one at all
> (b) define one in Control.Monad, and give up on Haskell 98 compliance
>
> The current situation, namely
>
> (c) define it as an orphan, and give up on module abstraction
>
> is not a sensible choice.
I would say that there should the a separate
module Data.Function.Functor ()
exporting only that instance.
(And I find it a surprising decision of Haskell98 that something
that is so obviously a functor in so obviously only one way
must not be a Functor instance...)
Wolfram
More information about the Libraries
mailing list