Hi!

Yes, I know, the following code snippets are wrong, because instances are
always imported. The compiler yields an error message, like it should:

====
Foo1.lhs:2:
    Duplicate or overlapping instance declarations
        for `Read FooData'
Name.lhs:382: Non-exhaustive patterns in function provSrcLoc
====

But the "Non-exhaustive patterns" error shouldn't be there, should it?
BTW: is it possible to show the names of the overlapping modules?


Cheers,
Michael

\begin{code}
module Data where
data FooData = FooData
\end{code}

\begin{code}
module Foo2 where
import Data
instance Read FooData where
   readsPrec _ _ = [(FooData,"")]
\end{code}

\begin{code}
module Foo3 where
import Data
instance Read FooData where
   readsPrec _ _ = [(FooData,"")]
\end{code}

\begin{code}
module Foo1 where
import Data
import Foo2
import Foo3

data Baz = Baz deriving Read -- if this line is commented out -> no error
trigger  = FooData           -- else, if this line is commented out -> no error
                             -- instances only imported if used?
\end{code}
-- 
XXXVII:
        Ninety percent of the time things will turn out worse than you expect.
        The other 10 percent of the time you had no right to expect so much.

Reply via email to