Skip to content

GHC warning shows technical summary of AST instead of the user's code

Have a look at this code and the warning it generates;

-- T10662.hs
main :: IO ()
main = do
  return $ let a = "hello" in a
  return ()

We compile it with ghc --make -Wall T10662.hs

[1 of 1] Compiling Main             ( T10662.hs, T10662.o )

T10662.hs:3:3: Warning:
    A do-notation statement discarded a result of type ‘[Char]’
    Suppress this warning by saying
      ‘_ <- ($)
              return
              let
                AbsBinds [] []
                  {Exports: [a <= a
                               <>]
                   Exported types: a :: [Char]
                                   [LclId, Str=DmdType]
                   Binds: a = "hello"}
              in a’
    or by using the flag -fno-warn-unused-do-bind
Linking T10662 ...
 $

Naturally GHC warns me that I'm throwing away the result, and should write like this;

main :: IO ()
main = do
  _ <- return $ let a = "hello" in a
  return ()

I find it confusing that the warning mentions AbsBinds, exports and types. I'd expect a snippet of my code in the warning.

It doesn't look like this is a (recent) regression. The same happens GHC 7.8.4 and 7.10.1.

Edited by kolmodin@dtek.chalmers.se
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information