[GHC] #16211: Recompiling results in a missing instance

#16211: Recompiling results in a missing instance -------------------------------------+------------------------------------- Reporter: crockeea | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Incorrect Unknown/Multiple | error/warning at compile-time Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- 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 [https://github.com/strake/monad-classes.hs/issues/4 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.] -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16211 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16211: Recompiling results in a missing instance -------------------------------------+------------------------------------- Reporter: crockeea | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by crockeea): * Attachment "bug.zip" added. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16211 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16211: Recompiling results in a missing instance -------------------------------------+------------------------------------- Reporter: crockeea | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): I had a quick go to reproduce, but failed to install `monad-classes`, thus {{{ /c/tmp/T16211$ cabal install monad-classes Warning: The package list for 'hackage.haskell.org' is 292 days old. Run 'cabal update' to get the latest list of available packages. Resolving dependencies... Downloading base-orphans-0.7... Downloading peano-0.1.0.1... Downloading reflection-2.1.3... Configuring base-orphans-0.7... Building base-orphans-0.7... Downloading transformers-compat-0.6.1.6... Configuring peano-0.1.0.1... Configuring reflection-2.1.3... Configuring transformers-compat-0.6.1.6... Installed base-orphans-0.7 Building peano-0.1.0.1... Building reflection-2.1.3... Building transformers-compat-0.6.1.6... Installed peano-0.1.0.1 Installed transformers-compat-0.6.1.6 Downloading transformers-base-0.4.5.2... Downloading mmorph-1.1.2... Configuring mmorph-1.1.2... Installed reflection-2.1.3 Configuring transformers-base-0.4.5.2... Building mmorph-1.1.2... Building transformers-base-0.4.5.2... Installed transformers-base-0.4.5.2 Downloading monad-control-1.0.2.3... Configuring monad-control-1.0.2.3... Installed mmorph-1.1.2 Building monad-control-1.0.2.3... Installed monad-control-1.0.2.3 Downloading monad-classes-0.3.2.0... Configuring monad-classes-0.3.2.0... Building monad-classes-0.3.2.0... Failed to install monad-classes-0.3.2.0 Build log ( C:\Users\simonpj\AppData\Roaming\cabal\logs\ghc-8.4.3\monad- classes-0.3.2.0-8KgSrx1uXAE2nRQBG2VUas.log ): Preprocessing library for monad-classes-0.3.2.0.. Building library for monad-classes-0.3.2.0.. [ 1 of 12] Compiling Control.Monad.Classes.Core ( Control\Monad\Classes\Core.hs, dist\build\Control\Monad\Classes\Core.o ) [ 2 of 12] Compiling Control.Monad.Classes.Effects ( Control\Monad\Classes\Effects.hs, dist\build\Control\Monad\Classes\Effects.o ) [ 3 of 12] Compiling Control.Monad.Classes.Except ( Control\Monad\Classes\Except.hs, dist\build\Control\Monad\Classes\Except.o ) [ 4 of 12] Compiling Control.Monad.Classes.Exec ( Control\Monad\Classes\Exec.hs, dist\build\Control\Monad\Classes\Exec.o ) [ 5 of 12] Compiling Control.Monad.Classes.Proxied ( Control\Monad\Classes\Proxied.hs, dist\build\Control\Monad\Classes\Proxied.o ) [ 6 of 12] Compiling Control.Monad.Classes.Reader ( Control\Monad\Classes\Reader.hs, dist\build\Control\Monad\Classes\Reader.o ) [ 7 of 12] Compiling Control.Monad.Classes.State ( Control\Monad\Classes\State.hs, dist\build\Control\Monad\Classes\State.o ) [ 8 of 12] Compiling Control.Monad.Classes.ReadState ( Control\Monad\Classes\ReadState.hs, dist\build\Control\Monad\Classes\ReadState.o ) Control\Monad\Classes\ReadState.hs:42:8: error: * Type indexes must match class instance head Expected: StT (ReadStateT x) <tv> Actual: StT (ReadStateT s) a where the `<tv>' arguments are type variables, distinct from each other and from the instance variables * In the type instance declaration for `StT' In the instance declaration for `MonadTransControl (ReadStateT x)' | 42 | type StT (ReadStateT s) a = StT IdentityT a | ^^^ cabal: Leaving directory 'C:\Users\simonpj\AppData\Local\Temp\cabal- tmp-19032\monad-classes-0.3.2.0' cabal.exe: Error: some packages failed to install: monad-classes-0.3.2.0-8KgSrx1uXAE2nRQBG2VUas failed during the building phase. The exception was: ExitFailure 1 }}} This is with {{{ /c/tmp$ ghc --version The Glorious Glasgow Haskell Compilation System, version 8.4.3 /c/tmp$ cabal --version cabal-install version 2.2.0.0 compiled using version 2.2.0.1 of the Cabal library }}} I have not investigated further, thus far. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16211#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16211: Recompiling results in a missing instance -------------------------------------+------------------------------------- Reporter: crockeea | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by crockeea): Thanks for looking, Simon. Unfortunately, I was unable to further minimize the example. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16211#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16211: Recompiling results in a missing instance -------------------------------------+------------------------------------- Reporter: crockeea | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): But you are getting further than me. I never got to compile your code even once, because I couldn't install `monad-classes`. (Obviously you were.) Maybe someone can figure out why. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16211#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16211: Recompiling results in a missing instance -------------------------------------+------------------------------------- Reporter: crockeea | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by crockeea): Simon, it looks like you have a pretty outdated Hackage snapshot. Perhaps try a `cabal update`? The latest version of monad-classes is 0.3.2.2, but your failed installation was trying 0.3.2.0. {{{
ghc --version The Glorious Glasgow Haskell Compilation System, version 8.6.3
cabal --version cabal-install version 2.4.1.0 compiled using version 2.4.1.0 of the Cabal library
cd bug
cabal sandbox init
cabal install --only-dependencies Starting peano-0.1.0.1 Starting base-orphans-0.8 Starting reflection-2.1.4 Starting primitive-0.6.4.0 Building base-orphans-0.8 Building reflection-2.1.4 Building primitive-0.6.4.0 Building peano-0.1.0.1 Completed base-orphans-0.8 Starting transformers-compat-0.6.2 Completed peano-0.1.0.1 Building transformers-compat-0.6.2 Completed reflection-2.1.4 Completed transformers-compat-0.6.2 Starting mmorph-1.1.2 Starting transformers-base-0.4.5.2 Building transformers-base-0.4.5.2 Building mmorph-1.1.2 Completed transformers-base-0.4.5.2 Starting monad-control-1.0.2.3 Completed mmorph-1.1.2 Completed primitive-0.6.4.0 Building monad-control-1.0.2.3 Completed monad-control-1.0.2.3 Starting monad-classes-0.3.2.2 Building monad-classes-0.3.2.2 Completed monad-classes-0.3.2.2
cabal build <success> }}}
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16211#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC