Allow deprecation notices for type and data constructors separately
The 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.
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.1 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | low |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |