Skip to content

Backpack signature matching doesn't pick up orphan instances

Repro:

unit impl where
    module A where
        data T = T
    module B(module A, module B) where
        import A
        instance Show T where
            show T = "T"

unit sig where
    signature B where
        data T = T
        instance Show T
    module App where
        import B
        app = print T

unit main where
    dependency sig[B=impl:B]
    module Main where
        import App
        main = app

I get:

ezyang@sabre:~$ ghc-head --backpack foo.bkp
[1 of 3] Processing impl
  Instantiating impl
  [1 of 2] Compiling A                (.hs -> .o)
  [2 of 2] Compiling B                (.hs -> .o)
[2 of 3] Processing sig
[3 of 3] Processing main
  Instantiating main
  [1 of 1] Including sig[B=impl:B]
    Instantiating sig[B=impl:B]
    [1 of 2] Compiling B[sig]           (.hsig -> .o)

sig/sig-HVnmSw44WZeBfwnUur4wzl/../B.hi:1:1: error:
    No instance for (GHC.Show.Show impl:A.T)
      arising when attempting to show that
      instance [safe] GHC.Show.Show impl:A.T -- Defined in ‘impl:B’
      is provided by ‘impl:B’
Trac metadata
Trac field Value
Version 8.1
Type Bug
TypeOfFailure OtherFailure
Priority high
Resolution Unresolved
Component Compiler (Type checker)
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