Instances not propagating when using type alias during module mixin
signature A which has a requirement of a type AT with certain type constraints (Show in the case below).
signature A where data AT instance Show AT
Suppose we have a module Derived that satisfies the signature A by making use of another B signature.
signature B where data BT instance Show BT module Derived where import B type AT = BT
Now suppose we have a instance
Concrete of B
module Concrete data BT = BT deriving Show
Concrete mixedin in place of
B signature is unable to satisfy the constraint
Steps to reproduce
Perform cabal install with the following package file
The error message is
Command line argument: -unit-id chained-instances-0.0.1:client[A=Derived]:0:0: error: • No instance for (GHC.Show.Show AT) arising when attempting to show that instance [safe] GHC.Show.Show AT -- Defined in ‘chained-instances-0.0.1:derived[B=<Concrete>]:Derived’ is provided by ‘main:Main’ • while checking that chained-instances-0.0.1:derived[B=<Concrete>]:Derived implements signature A in chained-instances-0.0.1:client[A=chained-instances-0.0.1:derived[B=<Concrete>]:Derived] cabal: Failed to build lib:junction from chained-instances-0.0.1.
The constraint of Show AT should have been satisfied by the AT exposed from Derived as it is the type BT from the Concrete module. This error is therefore unexpected.
Both with ghc-8.4.4 and ghc-8.8.1