[GHC] #13277: When type classes are redefined in GHCi bindings that use old instances are still accessible

#13277: When type classes are redefined in GHCi bindings that use old instances are still accessible -------------------------------------+------------------------------------- Reporter: deech | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Other Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I found the following behavior surprising: {{{#!hs 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. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13277 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13277: When type classes are redefined in GHCi bindings that use old instances are still accessible -------------------------------------+------------------------------------- Reporter: deech | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * resolution: => invalid Comment: No, this is by design. Consiider {{{ Prelude> let x = 3 Prelude> let y = x+4 Preluce> (\x -> y) 72 8 Prelude> let x = "hello" Prelude> y 8 }}} The value of `y` is `x+4` where `x`'s value comes from the binding site of `y`. The fact that `x` now has a totally different value (72, or "hello" in the two examples) is irrelevant. Same with `f` above. Its value is 1 regardless of what other bindings you bring into scope subsequently. Does that make sense? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13277#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC