[GHC] #14593: Allow deprecation notices for type and data constructors separately

GHC ghc-devs at haskell.org
Sun Dec 17 16:57:40 UTC 2017


#14593: Allow deprecation notices for type and data constructors separately
-------------------------------------+-------------------------------------
           Reporter:  parsonsmatt    |             Owner:  (none)
               Type:  feature        |            Status:  new
  request                            |
           Priority:  low            |         Milestone:
          Component:  Compiler       |           Version:  8.2.1
           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:
-------------------------------------+-------------------------------------
 The
 [https://downloads.haskell.org/~ghc/8.2.2/docs/html/users_guide/glasgow_exts.html
 #warning-and-deprecated-pragmas syntax for deprecations] only allows you
 to provide a single message for deprecations:

 > You can only attach to entities declared at top level in the module
 being compiled, and you can only use unqualified names in the list of
 entities. A capitalised name, such as T refers to either the type
 constructor T or the data constructor T, or both if both are in scope. If
 both are in scope, there is currently no way to specify one without the
 other (c.f. fixities Infix type constructors, classes, and type
 variables).

 It would be nice to provide separate messages in deprecations for type and
 data constructors. As an example, I am making a breaking change to a
 library, and I am providing deprecated shims for backwards-compatibility:

 {{{
 -- Old:
 data SomeField rec where
   SomeField :: EntityField rec field -> SomeField rec

 -- New:
 data UpdateCollision rec where
   CopyField :: EntityField rec field -> UpdateCollision rec
   CopyUnless :: -- etc...

 type SomeField = UpdateCollision
 {-# DEPRECATED SomeField "The SomeField type was renamed to
 UpdateCollision." #-}

 pattern SomeField :: EntityField record typ -> SomeField record
 pattern SomeField x = CopyField x
 {-# DEPRECATED SomeField "The constructor SomeField is deprecated. Use the
 function copyField instead." #-}
 }}}

 The workaround is to provide a longer error message that combines the two.
 This is less pleasant than having separate notices, because it makes it
 less obvious for the client how to migrate.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14593>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list