[Haskell-cafe] GHC -WAll, -fwarn-unused-do-bind and Cabal

JP Moresmau jpmoresmau at gmail.com
Wed Feb 15 20:43:14 CET 2012


Yes, I would have suspected that the doc was wrong, and indeed the
latest version on GHC 7.4 does not mention that flag as being
excluded, but the fact is that through the GHC API, I don't get that
warning! I can get other warnings so I would say that the way I use
the API is correct.In the GHC 7.0 API are there several ways to get
warnings, or are some warnings only raised at the final generation
stage (which I don't do with the API)? That would be the most sensible
explanation: that warning is only raised during code generation but
not during loading and typechecking of the module. Can somebody privy
with GHC internals confirm? It's just that I've noticed the problem in
my EclipseFP/buildwrapper setup and I want to make sure the issue can
be explained if users run into it.

Thanks anyway for looking into it!

JP

On Wed, Feb 15, 2012 at 8:33 PM, Albert Y. C. Lai <trebla at vex.net> wrote:
> On 12-02-14 03:01 PM, JP Moresmau wrote:
>>
>> I'm confused: I'm using GHC 7.0.2 and Cabal 1.10.1.0 with
>> cabal-install 0.10.2. I use -Wall in my Cabal file. If I build a
>> Haskell file with unused do binds, via the GHC API I get no warning,
>> which is normal, since the doc states: The warnings that are not
>> enabled by -Wall are ..., -fwarn-unused-do-bind .... But if I build my
>> project through cabal it gives me the warning! Why is compiling with
>> Cabal giving that extra warning that GHC on its own with the same
>> flags doesn't give? Using --verbose on cabal build does not give any
>> clue, no suspicious extra flag is passed on.
>
>
> The plot thickens as I perform some experiments.
>
> Experiment #1:
>
> main :: IO ()
> main = do { x <- getLine; putStrLn "thank you" }
>
> ghc -Wall =>
>    Warning: Defined but not used: `x'
>
> ghc -fwarn-unused-do-bind =>
> (no warning)
>
> Apparently, warn-unused-do-bind does not mean that x is unused.
>
> Experiment #2:
>
> main :: IO ()
> main = do { getLine; putStrLn "thank you" }
>
> ghc -fwarn-unused-do-bind =>
>    Warning: A do-notation statement discarded a result of type String.
>             Suppress this warning by saying "_ <- getLine",
>             or by using the flag -fno-warn-unused-do-bind
>
> ghc -Wall =>
>    Warning: A do-notation statement discarded a result of type String.
>             Suppress this warning by saying "_ <- getLine",
>             or by using the flag -fno-warn-unused-do-bind
>
> ghc -Wall -fno-warn-unused-do-bind =>
> (no warning)
>
> Apparently, -Wall turns on -fwarn-unused-do-bind, despite the user guide.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



-- 
JP Moresmau
http://jpmoresmau.blogspot.com/



More information about the Haskell-Cafe mailing list