Skip to content

DatatypeContexts should be fixed, not deprecated

To borrow an example from the prime wiki page, the following code fails to compile:

data Eq a => Foo a = Foo a

isEq :: Foo a -> Foo a -> Bool
isEq (Foo x) (Foo y) = x == y

We have to tell the compiler that Eq a => Foo a in isEq, even though this is part of the data type's definition. Furthermore,

getVal :: Foo a -> a
getVal (Foo x) = x

will also fail because of the missing constraint, even though it isn't used in the function's definition.

Rather than just deprecating the DatatypeContexts extension, it should be "fixed" to remember the context wherever the data type is used.

Trac metadata
Trac field Value
Version 7.6.3
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information