[Haskell-beginners] GHC 6.12, -fwarn-unused-do-bind and
nicolas.pouillard at gmail.com
Tue Feb 23 01:37:59 EST 2010
On Mon, 22 Feb 2010 23:02:13 +0100, Iustin Pop <iusty at k1024.org> wrote:
> Hi there,
> I'm trying to upgrade some code to ghc 6.12 but under -Wall, the new
> warning about unused do binds is triggering on Text.Printf.printf usage.
> This code:
> import Text.Printf
> main :: IO ()
> main = do
> printf "Hello, world\n"
> printf "Hello the second time\n"
> When run with runhaskell -Wall gives:
> Warning: A do-notation statement discarded a result of type
> GHC.Prim.Any. Suppress this warning by saying "_ <- printf "Hello,
> world\n"", or by using the flag -fno-warn-unused-do-bind.
> Now, I'm confused why such a simple usage of printf triggers this
> warning; enforcing the first printf to type IO () fixes the warning, but
> it seems strange to no longer be able to simply write printf.
> Anyone knows a workaround, or can enlighten me what I'm doing wrong?
What about providing a printf_ function with "IO ()" as return type?
(like mapM vs mapM_)
More information about the Beginners