#2182: ghc sessions (--make, --interactive, ghc api) erroneously retain 
instances
---------------------+------------------------------------------------------
 Reporter:  claus    |          Owner:         
     Type:  bug      |         Status:  new    
 Priority:  low      |      Milestone:  _|_    
Component:  GHCi     |        Version:  6.9    
 Severity:  normal   |     Resolution:         
 Keywords:           |     Difficulty:  Unknown
 Testcase:           |   Architecture:  Unknown
       Os:  Unknown  |  
---------------------+------------------------------------------------------
Changes (by claus):

  * summary:  ghci session retains instances after :m -Module => ghc
              sessions (--make, --interactive, ghc api)
              erroneously retain instances

Comment:

 (changed ticket title to reflect broader scope)

 This bug affects all ghc sessions, not just ghci. In particular:

 - Cabal uses `ghc --make`, which can fail because of this bug

 - Haddock 2 uses the ghc api, which can fail because of this bug

 In both cases, the workaround is to repeat the command, so that it
 continues with a fresh ghc session, but that will not at all be obvious to
 users.

 Example:
 {{{
 $ darcs get http://www.cs.kent.ac.uk/~cr3/toolbox/haskell/syb-utils
 Finished getting.

 $ ghc --version
 The Glorious Glasgow Haskell Compilation System, version 6.8.3

 $ cd syb-utils/

 $ runhaskell.exe Setup.hs configure
 Configuring syb-utils-0.0.2008.8.19...
 Warning: No license-file field.

 $ runhaskell.exe Setup.hs build
 Preprocessing library syb-utils-0.0.2008.8.19...
 Building syb-utils-0.0.2008.8.19...
 [1 of 6] Compiling Data.Generics.Instances.Dubious (
 Data/Generics/Instances/Dubious.hs, dist\build/
 Data/Generics/Instances/Dubious.o )
 [2 of 6] Compiling Data.Generics.Utils ( Data/Generics/Utils.hs,
 dist\build/Data/Generics/Utils.o )
 [3 of 6] Compiling Data.Generics.NoInstances (
 Data/Generics/NoInstances.hs, dist\build/Data/Generic
 s/NoInstances.o )
 [4 of 6] Compiling Data.Generics.GPS ( Data/Generics/GPS.hs,
 dist\build/Data/Generics/GPS.o )
 [5 of 6] Compiling Data.Generics.Instances.Standard (
 Data/Generics/Instances/Standard.hs, dist\buil
 d/Data/Generics/Instances/Standard.o )

 Data/Generics/Instances/Standard.hs:61:0:
     Duplicate instance declarations:
       instance Data Bool
         -- Defined at Data/Generics/Instances/Standard.hs:(61,0)-(68,28)
       instance Data Bool -- Defined in Data.Generics.Instances
 ..

 $ runhaskell.exe Setup.hs build
 Preprocessing library syb-utils-0.0.2008.8.19...
 Building syb-utils-0.0.2008.8.19...
 [5 of 6] Compiling Data.Generics.Instances.Standard (
 Data/Generics/Instances/Standard.hs, dist\buil
 d/Data/Generics/Instances/Standard.o )
 [6 of 6] Compiling Data.Generics.Alt ( Data/Generics/Alt.hs,
 dist\build/Data/Generics/Alt.o )
 c:\ghc\ghc-6.8.3\bin\ar.exe: creating dist\build\libHSsyb-
 utils-0.0.2008.8.19.a
 }}}

 Confusingly, the behaviour is compiler-version and tool dependent:
 {{{
 $ runhaskell.exe Setup.hs clean
 cleaning...

 $ /cygdrive/c//fptools/ghc/ghc/stage2-inplace/ghc.exe --version
 The Glorious Glasgow Haskell Compilation System, version 6.9.20080816

 $ runhaskell Setup configure --with-
 compiler=c:/fptools/ghc/ghc/stage2-inplace/ghc.exe --with-hc-pk
 g=c:/fptools/ghc/utils/ghc-pkg/install-inplace/bin/ghc-pkg.exe --with-
 haddock=c:/Program\ Files/Has
 kell/bin/haddock.exe -fGhcApi
 Configuring syb-utils-0.0.2008.8.19...
 Warning: No license-file field.

 [EMAIL PROTECTED] ~/tst/ghc-session-bug/syb-utils
 $ runhaskell.exe Setup.hs build
 Preprocessing library syb-utils-0.0.2008.8.19...
 Building syb-utils-0.0.2008.8.19...
 [1 of 9] Compiling Data.Generics.Instances.Dubious (
 Data\Generics\Instances\Dubious.hs, dist\build\
 Data\Generics\Instances\Dubious.o )
 [2 of 9] Compiling Data.Generics.Instances.Standard (
 Data\Generics\Instances\Standard.hs, dist\buil
 d\Data\Generics\Instances\Standard.o )
 [3 of 9] Compiling Data.Generics.Utils ( Data\Generics\Utils.hs,
 dist\build\Data\Generics\Utils.o )
 [4 of 9] Compiling Data.Generics.NoInstances (
 Data\Generics\NoInstances.hs, dist\build\Data\Generic
 s\NoInstances.o )
 [5 of 9] Compiling Data.Generics.GPS ( Data\Generics\GPS.hs,
 dist\build\Data\Generics\GPS.o )
 [6 of 9] Compiling Data.Generics.Alt ( Data\Generics\Alt.hs,
 dist\build\Data\Generics\Alt.o )
 [7 of 9] Compiling GHC.Syb.Instances0 ( GHC\Syb\Instances0.hs,
 dist\build\GHC\Syb\Instances0.o )
 [8 of 9] Compiling GHC.Syb.Instances ( GHC\Syb\Instances.hs,
 dist\build\GHC\Syb\Instances.o )
 [9 of 9] Compiling GHC.Syb.Utils    ( GHC\Syb\Utils.hs,
 dist\build\GHC\Syb\Utils.o )
 c:\ghc\ghc-6.8.3\bin\ar.exe: creating dist\build\libHSsyb-
 utils-0.0.2008.8.19.a
 }}}
 Note that ghc head and ghc 6.8.3 process the dependencies in a different
 order, which probably explains why the bug isn't triggered in head:
 `Data.Generics.Instances.Dubious` and `Data.Generics.Instances.Standard`
 represent two halves of `base`'s `Data.Generics.Instances`; the latter
 isn't explicitly imported here, but `Data.Generics.GPS` uses
 `Data.IntMap`, which inadvertedly re-exports the instances from
 `Data.Generics.Instances`.

 If `Data.Generics.Instances.*` are compiled first, ghc doesn't complain
 about alternative instances being present, but if either of
 `Data.Generics.Instances.*` is compiled after `Data.Generics.GPS`, the
 erroneously retained instances conflict with the newly defined ones.

 We can confirm the bug is still there by trying to haddock2 the package
 with a fresh darcs haddock, freshly compiled with the same ghc head:
 {{{
 $ runhaskell.exe Setup.hs clean
 cleaning...

 $ /cygdrive/c/Program\ Files/Haskell/bin/haddock.exe --version
 Haddock version 2.2.2, (c) Simon Marlow 2006
 Ported to use the GHC API by David Waern 2006-2008

 $ /cygdrive/c/Program\ Files/Haskell/bin/haddock.exe +RTS --info
  [("GHC RTS", "Yes")
  ,("GHC version", "6.9.20080816")
  ,("RTS way", "rts")
  ,("Host platform", "i386-unknown-mingw32")
  ,("Build platform", "i386-unknown-mingw32")
  ,("Target platform", "i386-unknown-mingw32")
  ,("Compiler unregisterised", "NO")
  ,("Tables next to code", "YES")
  ]

 $ runhaskell Setup configure --with-
 compiler=c:/fptools/ghc/ghc/stage2-inplace/ghc.exe --with-hc-pk
 g=c:/fptools/ghc/utils/ghc-pkg/install-inplace/bin/ghc-pkg.exe --with-
 haddock=c:/Program\ Files/Haskell/bin/haddock.exe -fGhcApi
 Configuring syb-utils-0.0.2008.8.19...
 Warning: No license-file field.

 [EMAIL PROTECTED] ~/tst/ghc-session-bug/syb-utils
 $ runhaskell.exe Setup.hs haddock
 Preprocessing library syb-utils-0.0.2008.8.19...
 Running Haddock for syb-utils-0.0.2008.8.19...
 Preprocessing library syb-utils-0.0.2008.8.19...
 Warning: Cannot read c:\fptools\ghc\compiler\dist-
 stage2\doc\html\ghc\ghc.haddock:
    "Magic number mismatch: couldn't load interface file:
 c:\\fptools\\ghc\\compiler\\dist-stage2\\doc\\html\\ghc\\ghc.haddock"
 Skipping this interface.
 Warning: Cannot read
 c:\fptools\ghc\libraries\base\dist\doc\html\base\base.haddock:
    "Magic number mismatch: couldn't load interface file:
 c:\\fptools\\ghc\\libraries\\base\\dist\\doc\\html\\base\\base.haddock"
 Skipping this interface.
 Warning: Cannot read
 c:\fptools\ghc\libraries\containers\dist\doc\html\containers\containers.haddock
 :
    "Magic number mismatch: couldn't load interface file:
 
c:\\fptools\\ghc\\libraries\\containers\\dist\\doc\\html\\containers\\containers.haddock"
 Skipping this interface.

 Data\Generics\Instances\Dubious.hs:59:9:
     Duplicate instance declarations:
       instance (Data a, Integral a) => Data (Ratio a)
         -- Defined at Data\Generics\Instances\Dubious.hs:59:9-46
       instance (Data a, Integral a) => Data (Ratio a)
         -- Defined in Data.Generics.Instances
 ..

 $ runhaskell.exe Setup.hs haddock
 Preprocessing library syb-utils-0.0.2008.8.19...
 Running Haddock for syb-utils-0.0.2008.8.19...
 Preprocessing library syb-utils-0.0.2008.8.19...
 Warning: Cannot read c:\fptools\ghc\compiler\dist-
 stage2\doc\html\ghc\ghc.haddock:
    "Magic number mismatch: couldn't load interface file:
 c:\\fptools\\ghc\\compiler\\dist-stage2\\doc\\html\\ghc\\ghc.haddock"
 Skipping this interface.
 Warning: Cannot read
 c:\fptools\ghc\libraries\base\dist\doc\html\base\base.haddock:
    "Magic number mismatch: couldn't load interface file:
 c:\\fptools\\ghc\\libraries\\base\\dist\\doc\\html\\base\\base.haddock"
 Skipping this interface.
 Warning: Cannot read
 c:\fptools\ghc\libraries\containers\dist\doc\html\containers\containers.haddock
 :
    "Magic number mismatch: couldn't load interface file:
 
c:\\fptools\\ghc\\libraries\\containers\\dist\\doc\\html\\containers\\containers.haddock"
 Skipping this interface.
 Warning: in export list of "Data.Generics.NoInstances": module not found:
 "Data.Generics.Basics"
 Warning: in export list of "Data.Generics.NoInstances": module not found:
 "Data.Generics.Aliases"
 Warning: in export list of "Data.Generics.NoInstances": module not found:
 "Data.Generics.Schemes"
 Warning: in export list of "Data.Generics.NoInstances": module not found:
 "Data.Generics.Text"
 Warning: in export list of "Data.Generics.NoInstances": module not found:
 "Data.Generics.Twins"
 Warning: in export list of "Data.Generics.Alt": module not found:
 "Data.Generics.Basics"
 Warning: in export list of "Data.Generics.Alt": module not found:
 "Data.Generics.Aliases"
 Warning: in export list of "Data.Generics.Alt": module not found:
 "Data.Generics.Schemes"
 Warning: in export list of "Data.Generics.Alt": module not found:
 "Data.Generics.Text"
 Warning: in export list of "Data.Generics.Alt": module not found:
 "Data.Generics.Twins"
 Warning: syb-utils-0.0.2008.8.19:GHC.Syb.Instances: could not find link
 destinations for:
     Data.Typeable.TyCon
 Warning: syb-utils-0.0.2008.8.19:GHC.Syb.Instances0: could not find link
 destinations for:
     Data.Typeable.TyCon
 Warning: syb-utils-0.0.2008.8.19:GHC.Syb.Utils: could not find link
 destinations for:
     GHC.Classes.Eq GHC.Classes.Ord GHC.Show.Show Data.Generics.Basics.Data
 GHC.Types.Int GHC.Base.St
 ring Data.Generics.Aliases.GenericQ GHC.Bool.Bool
 Warning: syb-utils-0.0.2008.8.19:Data.Generics.GPS: could not find link
 destinations for:
     Data.Generics.Basics.Data Data.Generics.Aliases.GenericQ
 Data.Typeable.Typeable Data.Typeable.Typeable1 Data.Maybe.Maybe
 Data.IntMap.IntMap Data.IntSet.IntSet GHC.Types.Int
 Data.Generics.Aliases.GenericT
 Warning: syb-utils-0.0.2008.8.19:Data.Generics.Utils: could not find link
 destinations for:
     Control.Applicative.Applicative Data.Typeable.Typeable1
 Data.Typeable.Typeable Data.Generics.Basics.Data Data.Generics.Utils.X
 Warning: syb-utils-0.0.2008.8.19:Data.Generics.Instances.Standard: could
 not find link destinations
 for:
     Data.Typeable.TyCon
 Documentation created: dist\doc\html\syb-utils\index.html
 }}}

 What are the chances of getting this fixed?

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2182#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to