When overlapping instances lead to a compile error, show import chains for the instances
Here's an example from work:
• Overlapping instances for ToJSON BackupPhrase
arising from a use of 'aesonRoundtripProp'
Matching instances:
instance ToJSON BackupPhrase
-- Defined in 'Cardano.Wallet.Orphans.Aeson'
instance ToJSON BackupPhrase
-- Defined in 'Pos.Wallet.Aeson.ClientTypes'
Currently resolving such issues requires looking carefully at all imports and trying to guess which ones bring the instance into scope. It'd be quite helpful if the error was explicit about the import chain:
• Overlapping instances for ToJSON BackupPhrase
arising from a use of 'aesonRoundtripProp'
Matching instances:
instance ToJSON BackupPhrase
-- Defined in 'Cardano.Wallet.Orphans.Aeson',
-- imported by 'Cardano.Wallet.Orphans'
instance ToJSON BackupPhrase
-- Defined in 'Pos.Wallet.Aeson.ClientTypes',
-- imported by 'Pos.Wallet.Web.Mode',
-- and then by 'Cardano.Wallet.API.V1.Migration'
Thoughts?
I'm worried about two things here:
- Might these chains get too long?
- Is it sufficiently obvious that “imported by
A
and then byB
” means that you have importedB
andB
importedA
, and not vice-versa?
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.1 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |