Skip to content

Recompiling results in a missing instance

The attached program compiles without error using cabal.

import Bar

main :: IO ()
main = do
  let x = True   -- line 5
  --x <- True    -- line 6
  foo x bar

foo :: Bool -> IO () -> IO ()
foo _ _ = undefined

However:

  1. cabal build. This succeeds. [This step isn't required to reproduce the bug, but it shows that the program should compile.]
  2. Replace line 5 with line 6 in Main.hs
  3. cabal build. GHC correctly reports a compile error (Couldn't match expected type 'IO Bool' with actual type 'Bool')
  4. Fix the problem by reinstating line 5 and removing line 6.
  5. cabal build. This step *should* compile without errors, but instead I get a GHC error about a missing instance related to the monad-classes library.
  6. cabal build all day. The missing instance error still occurs until you clean temporary files and start from scratch.

I suspect the error in step 5 is itself a (different?) GHC bug, but for now it is reported here. This GHC bug report is specifically about compiling with identical source code (steps 1 and 5) and getting different outcomes (step 1 compiles, step 5 has an error), which shouldn't happen regardless of other bugs.

[Note I can produce the missing instance issue without having to recompile GHC, which is why I think it might be independent of this bug.]

Trac metadata
Trac field Value
Version 8.6.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information