GHCi gives misleading error message when looking up info of ambiguous type
When GHCi imports multiple functions with the same name, using :i
results in an ambiguous occurrence error:
> import Data.Text
> import Data.Text.Lazy
> :i length
Top level:
Ambiguous occurrence ‘length’
It could refer to either ‘Data.Text.Lazy.length’,
imported from ‘Data.Text.Lazy’
or ‘Prelude.length’,
imported from ‘Prelude’ (and originally defined in ‘GHC.List’)
or ‘Data.Text.length’, imported from ‘Data.Text’
However, if you use :i
on a type name that has imported multiple times in GHCi, a misleading error is given:
> import Data.Text
> import Data.Text.Lazy
> :i Text
Top level: Not in scope: data constructor ‘Text’
The real problem is that the type name Text
was imported twice with two different definitions, so the error should probably look something like this:
Top level:
Ambiguous occurrence ‘Text’
It could refer to either ‘Data.Text.Lazy.Text’,
imported from ‘Data.Text.Lazy’ (and originally defined in ‘Data.Text.Internal.Lazy’)
or ‘Data.Text.Text’,
imported from ‘Data.Text’ (and originally defined in ‘Data.Text.Internal‘)
Trac metadata
Trac field | Value |
---|---|
Version | 7.8.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | GHCi |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | hvr |
Operating system | |
Architecture |