[GHC] #8026: DatatypeContexts should be fixed, not deprecated

GHC ghc-devs at haskell.org
Mon Jul 1 15:24:24 CEST 2013


#8026: DatatypeContexts should be fixed, not deprecated
-----------------------------+----------------------------------------------
Reporter:  gidyn             |          Owner:                  
    Type:  feature request   |         Status:  new             
Priority:  normal            |      Component:  Compiler        
 Version:  7.6.3             |       Keywords:                  
      Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
 Failure:  None/Unknown      |      Blockedby:                  
Blocking:                    |        Related:                  
-----------------------------+----------------------------------------------
 To borrow an example from the [http://hackage.haskell.org/trac/haskell-
 prime/wiki/NoDatatypeContexts 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.

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



More information about the ghc-tickets mailing list