[GHC] #2595: Implement record update for existential and GADT data types

GHC cvs-ghc at haskell.org
Fri Jan 7 12:12:44 CET 2011


#2595: Implement record update for existential and GADT data types
------------------------------+---------------------------------------------
  Reporter:  simonpj          |          Owner:                  
      Type:  feature request  |         Status:  new             
  Priority:  normal           |      Milestone:  6.12 branch     
 Component:  Compiler         |        Version:  6.8.3           
Resolution:                   |       Keywords:                  
  Testcase:  tc244            |      Blockedby:                  
Difficulty:  Unknown          |             Os:  Unknown/Multiple
  Blocking:                   |   Architecture:  Unknown/Multiple
   Failure:  None/Unknown     |  
------------------------------+---------------------------------------------

Comment(by simonpj):

 The difficulty is this. A simple, consistent position is this. Consider
 {{{
 data T where
   T1 :: { x1 :: <type1>, x2 :: <type2> } -> T
   T2 :: { x1 :: <type1> } -> T
   T3 :: { x3 :: <type2> } -> t
 }}}
 Then we'd like `e { x1=e1 }` to be accepted '''if and only if the
 desugared version would be accepted''':
 {{{
   case e of
     T1 { x2 = x2' } -> T1 { x1=e1, x2=x2' }
     T2 {} -> T2 { x1 = e1 }
     T3 {} -> error "Bad update"
 }}}
 The difficulty is that GHC's typechecker typechecks ''source code'' not
 desugared code.  This is good because it leads to meaningful error
 messages.  But pattern matching (as in the above case) is the hardest bit
 of the typechecker, so figuring out whether the desugared version would
 typecheck is tricky.  If the data type T has existentials, or type
 constraints, or is a GADT, it becomes even more fun.

 Last time I looked at this I decided it was too hard to go the whole hog.
 But I thin the above is the only really consistent position.  Quite when I
 (or anyone else) will get round to doing this I'm not sure!

 Simon

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



More information about the Glasgow-haskell-bugs mailing list