Orphan Instance Overlap Error Message
I'm working on moving some code around which unfortunately relies on orphan instances. This is the error I get:
/home/matt/Projects/cardano-sl/wallet-new/src/Cardano/Wallet/API/V1/Types.hs:1794:27: error:
• Overlapping instances for Arbitrary
(NonEmpty PaymentDistribution)
arising from a use of ‘arbitrary’
Matching instances:
instance Arbitrary a => Arbitrary (NonEmpty a)
-- Defined in ‘Pos.Util.Example’
instance [safe] Arbitrary a => Arbitrary (NonEmpty a)
-- Defined in ‘quickcheck-instances-0.3.18:Test.QuickCheck.Instances.Semigroup’
• In the second argument of ‘(<*>)’, namely ‘arbitrary’
In the first argument of ‘(<*>)’, namely
‘Payment <$> arbitrary <*> arbitrary’
In the first argument of ‘(<*>)’, namely
‘Payment <$> arbitrary <*> arbitrary <*> arbitrary’
|
1794 | <*> arbitrary
| ^^^^^^^^^
The first instance is the one that I have defined. The second is defined in library code upstream -- great! I want to use that one instead. However, I don't have a clue which module import is providing that instance.
It would be *fantastic* if there was an additional line that says which module imported the instance, or brought it into scope. Multiple modules might do this; in this case, reporting any of them would be fine. Eg:
/home/matt/Projects/cardano-sl/wallet-new/src/Cardano/Wallet/API/V1/Types.hs:1794:27: error:
• Overlapping instances for Arbitrary
(NonEmpty PaymentDistribution)
arising from a use of ‘arbitrary’
Matching instances:
instance Arbitrary a => Arbitrary (NonEmpty a)
-- Defined in ‘Pos.Util.Example’
-- and imported via
|
186 | import Cardano.Wallet.API.V1.Swagger.Example
|
instance [safe] Arbitrary a => Arbitrary (NonEmpty a)
-- Defined in ‘quickcheck-instances-0.3.18:Test.QuickCheck.Instances.Semigroup’
-- and imported via
|
??? | this information would literally make my day
|
• In the second argument of ‘(<*>)’, namely ‘arbitrary’
In the first argument of ‘(<*>)’, namely
‘Payment <$> arbitrary <*> arbitrary’
In the first argument of ‘(<*>)’, namely
‘Payment <$> arbitrary <*> arbitrary <*> arbitrary’
|
1794 | <*> arbitrary
| ^^^^^^^^^
I'll have to binary search the import list to try and figure out which module is bringing the instance into scope otherwise.
Trac metadata
Trac field | Value |
---|---|
Version | 8.4.3 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |