instance visibility
Duncan Coutts
duncan.coutts at worc.ox.ac.uk
Fri Sep 26 17:41:27 EDT 2008
On Fri, 2008-09-26 at 21:51 +0100, Simon Marlow wrote:
> You will argue that they have control over what they import, and can
> thereby control whether they export the instance. This is certainly
> true, but it ignores the need for module abstraction: the need to be
> able to change the implementation of a module without changing its API.
> 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.
>
> (hmm, I finally feel like I've explained this clearly. I hope it comes
> across that way.)
Yes, I think that's a clear explanation and one I think is quite
convincing.
> 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.
Right.
No orphan instances in libraries.
Duncan
More information about the Libraries
mailing list