typeclass inference depends on whether a module is exposed.
My first bug report for GHC: I've found some strange behavior in GHC 8.2.2 relating to typeclass inference.
Essentially, for two identical modules, GHC infers for one of them that one typeclass instance applies, and for another that a different instance applies. The only language extensions involved are FlexibleInstances, MultiParamTypeClasses, GADTs, and ScopedTypeVariables. There are no INCOHERENT pragmas involved. The only difference between the two modules is that one of them (the one displaying correct typeclass inference) is an exposed module, while the other is not mentioned in the cabal file. The phenomenon affects other packages that import the original package---they display the incorrect behavior, rather than the correct behavior that the exposed module displays.
The original discussion is here: https://github.com/gleachkr/Carnap/issues/4
My best attempt at a minimal example can be found at https://github.com/gleachkr/GHC-Repro. You can run the "test.sh" script included there to see the phenomenon in action.
I don't see this behavior in other GHC versions, but I'm told that bug reports for older GHC versions are welcome, so here I am.
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |