
We have a test in GHC's test suite called instance-leak, which tests that none of the Haskell 98 libraries exports the Functor instance for (->). I broke this test recently by accident. How did I break it? By using Data.Map internally in System.Process. The Functor instance for (->) is exported from Control.Monad.Instances, makes its way into Data.Map, then into System.Process and thereby into System, which is a Haskell 98 module.
In your opinion, who or what is at fault for this test failure?
You, of course:-p But seriously: I can't see easily how the instance even gets into Data.Map, but since Data.Map doesn't seem to be using either Functor or fmap (other than defining an instance itself), it has no business importing (and thus re-exporting) the instance. If it is actually using any of the other instances (is it?), then perhaps Control.Monad.Instances needs to be split up.
It seems that the ultimate offender is Control.Applicative, which imports Control.Monad.Instances() for no other reason than to infect its importers. That then propagates all over the place. I assume the rationale is "convenience" again? Saving one import in importers at the price of limiting the modules that can afford to import Control.Applicative in the first place? Since libraries@ is the maintainer for Control.Applicative, may I suggest to add Control.Applicative.Alt, differing from the original only in omitting the import of Control.Monad.Instances? Then all importers of Control.Applicative should be checked for whether import of Control.Applicative.Alt is sufficient, and be switched to that if possible. Or am I on the wrong track?-) Claus