proposal #2254: have Control.Arrow re-export (>>>) and (<<<)

Niklas Broberg niklas.broberg at gmail.com
Fri May 2 09:46:04 EDT 2008


>  > Perhaps Niklas can say whether #1148 is the bug he is describing, and if not file a new one?
>
>
> Niklas's example:
>
>         module A where
>         foo x = x
>
>         module B(foo) where
>         import A
>
>         module C where
>         import A
>         import B
>         c = foo 'a'
>
>  ghc -W says
>
>  C.hs:2:0:
>     Warning: Module `A' is imported, but nothing from it is used,
>                except perhaps instances visible in `A'
>              To suppress this warning, use: import A()
>
>  It's true that the import can be deleted, but not that "nothing from it
>  is used".

This is actually not what I was hinting at, I'll see if I can
reproduce the bug I experienced. The basic idea behind it was that
module A in package a defines some type class, with member function
foo. Modules B and C in packages b and c separately import A and
create instances of that class, and reexports foo. Then module D in
package D cannot import both B and C and use foo, it will give an
"Ambiguous occurence" error. I tried reproducing this in a simpler
setting, with ABCD all in one package, but the error wouldn't appear.
I hope I wasn't imagining things (or rather, it would be good if I was
:-)). There may have been some qualified imports involved too...

But there are a few other inconvenient behaviors related only to
warnings, for instance

module A where
foo x = x

module B(foo) where
import A

module C (module A, module B) where
import A
import B

%> ghc --make C.hs -W:

C.hs:1:20: Warning: `foo' is exported by `module B' and `module A'

That's certainly true, but it's the same 'foo'. Just a warning of
course, and I'm not so sure I would argue that it shouldn't be there.
It's the same kind of warning as with any other multiple export of a
symbol I guess. But this pattern is not uncommon (in my code at
least), so the warning is inconvenient. Then again, that particular
warning can be turned off.

Another, somewhat stranger, behavior:

module A where
foo x = x

module B(foo) where
import A

module C(foo) where
import A

module D () where
import B
import C
bar x = foo x

%> ghc --make D.hs -W

D.hs:2:0:
    Warning: Module `B' is imported, but nothing from it is used,
               except perhaps instances visible in `B'
             To suppress this warning, use: import B()

D.hs:3:0:
    Warning: Module `C' is imported, but nothing from it is used,
               except perhaps instances visible in `C'
             To suppress this warning, use: import C()

D.hs:4:0: Warning: Defined but not used: `bar'

This might be said to be a bug, although it's a bug that would rarely
bite you, since it requires that 'bar' is not exported (or used in
something that is exported). If you export bar, then the warning talks
only of B - which is a rather arbitrary choice.

I'll see what I can do about that more serious bug.

As regards to this particular discussion though - my main point is
that we shouldn't make decisions on libraries based on what tools make
of them, rather the other way around. Obvious perhaps (I hope), but
bears repeating. :-)

Cheers,

/Niklas


More information about the Libraries mailing list