When type classes are redefined in GHCi bindings that use old instances are still accessible
I found the following behavior surprising:
GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /tmp/ghci7261/ghci-script
Prelude> class Foo a where { foo :: a -> Int }
Prelude> instance Foo () where { foo _ = 1 }
Prelude> f = foo ()
Prelude> class Foo a where { foo :: a -> IO () }
Prelude> f
1
Foo is redefined but f which uses a now illegal instance of Foo is still accessible. I would have expected that any bindings that use the old foo (or have the old foo in their call graph) would be cleared.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.0.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | GHCi |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |