#2467: orphan instance warnings are badly behaved
---------------------------------+------------------------------------------
Reporter: duncan | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 6.12 branch
Component: Compiler | Version: 6.8.2
Severity: normal | Resolution:
Keywords: | Difficulty: Unknown
Testcase: | Os: Unknown/Multiple
Architecture: Unknown/Multiple |
---------------------------------+------------------------------------------
Comment (by ross):
Replying to [comment:7 Syzygies]:
> It came up in my code that I needed
>
> > instance Foldable ((,) a) where foldr f z (_,y) = f y z
>
> which is completely parallel to the Functor instance, but unlike the
Functor instance is not provided by the standard libraries.
>
> There is no way that this instance can be anything but an orphan in my
code (I shouldn't change Data.Foldable on a whim, it would make my code
non-portable), so in this case I would argue that it is wrong for -Wall
-Werror to abort compilation over this. I added -fno-warn-orphans, but
that is a clunky fix which now deprives me of that warning when it might
be relevant.
The compiler is right: the instance is an orphan, and it's right to warn
about it, because orphan instances are inevitably a pain. The orphan
instances of Monad and Functor for Prelude type constructors (which you
noted) are a case in point; unfortunately they had to be orphans to avoid
breaking compatibility with Haskell 98.
The right fix in this case is to get the above instance (and one for
Either, and Traversable instances for (,) and Either) into Data.Foldable
and Data.Traversable. Unfortunately that won't help you until next
September/October (and will give you a messy changeover then).
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2467#comment:10>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs