[GHC] #12014: Make it possible to deprecate a method instantiation of a typeclass instance

#12014: Make it possible to deprecate a method instantiation of a typeclass instance -------------------------------------+------------------------------------- Reporter: niteria | Owner: Type: feature | Status: new request | Priority: normal | Milestone: Component: Compiler | Version: Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Consider: {{{ module A where data Foo = Foo instance Eq Foo where -- {-# DEPRECATED (==) "Deprecated for no reason as well" #-} _a == _b = True {-# DEPRECATED (==.) "Deprecated for no reason" #-} (==.) :: Foo -> Foo -> Bool (==.) _a _b = True }}} Deprecating `(==.)` is possible, but it's not possible to deprecate `(==)` of the `Eq Foo` instance. I'd be useful for my use-case of finding out where `Ord Unique` is used, as these would be a potential sources of non-determinism. Currently the best I can do is to remove the instance, get a compile error, suppress it by fixing up the code and repeat for every affected file. I imagine it would also be useful if a method turned out to be a bad idea for a particular type and the library author tried to phase it out. It could be that one method is implementable, but has terrible performance. For my use-case I would be happy with instance level granularity. Related (but not quite the same): * https://ghc.haskell.org/trac/ghc/wiki/Design/DeprecationMechanisms#Classmeth... * https://ghc.haskell.org/trac/ghc/wiki/Design/DeprecationMechanisms/TypeClass... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12014 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12014: Make it possible to deprecate a method instantiation of a typeclass instance -------------------------------------+------------------------------------- Reporter: niteria | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by niteria): * cc: bgamari (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12014#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12014: Make it possible to deprecate a method instantiation of a typeclass instance -------------------------------------+------------------------------------- Reporter: niteria | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Good idea in principle -- but fragile. E.g. {{{ f :: Eq a => a -> a -> Bool f x y = not (x == y) blah = f Foo Foo }}} At the call of `f` GHC can't see that you are ultimately going to use the `(==)` method of the `Eq` dictionary passed to `f`. So would you expect to get a deprecation message here? If you think about what it translates to, it's a bit like {{{ blah = f (eqFoo, neqFoo) Foo Foo }}} where the tuple argument is the dictionary. If you wrote it like that you'd get deprecations for both `eqFoo` and `newFoo` even though only one of them is ultimately actually called. I don't think I see a useful, robust path here, yet. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12014#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12014: Make it possible to deprecate a method instantiation of a typeclass instance -------------------------------------+------------------------------------- Reporter: niteria | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonmar): Deprecating the whole instance should be possible though, right? We could emit the deprecation message whenever the typechecker uses the instance. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12014#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12014: Make it possible to deprecate a method instantiation of a typeclass instance -------------------------------------+------------------------------------- Reporter: niteria | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Replying to [comment:3 simonmar]:
Deprecating the whole instance should be possible though, right? We could emit the deprecation message whenever the typechecker uses the instance.
That would be quite possible, yes, and more robust. The challenge then is the user interface. Possibly {{{ instance Eq Foo where {-# DEPRECATED "Don't use the Eq instance of Foo" #-} }}} This would be fantastic if you want to remove the Eq instance. Not to hard to do if someone wants to try. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12014#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12014: Make it possible to deprecate a method instantiation of a typeclass instance -------------------------------------+------------------------------------- Reporter: niteria | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by DanielDiaz): * cc: DanielDiaz (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12014#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12014: Make it possible to deprecate a method instantiation of a typeclass instance -------------------------------------+------------------------------------- Reporter: niteria | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by niteria): I was able to solve my use case from the description by using `-fdefer- type-errors`. Not having an `Ord` instance is a type error, so I removed the `Ord Unique` instance and compiled with `-fdefer-type-errors`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12014#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC