[Haskell-beginners] GHC 6.12, -fwarn-unused-do-bind and Text.Printf
iusty at k1024.org
Mon Feb 22 17:02:13 EST 2010
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.
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?
A side question would be why we have "instance PrintfType (IO a)"
instead of "instance PrintfType (IO ())"; what use is there for that
generic type? Can printf return anything else than IO () (when used
under IO at all)?
More information about the Beginners