Ticket #2595 (new feature request)
Implement record update for existential and GADT data types
| Reported by: | simonpj | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 6.12 branch |
| Component: | Compiler | Version: | 6.8.3 |
| Keywords: | Cc: | noah.easterly@… | |
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | None/Unknown | Difficulty: | Unknown |
| Test Case: | tc244 | Blocked By: | |
| Blocking: | Related Tickets: |
Description
Ganesh writes: The most important thing for me is supporting record update for existentially quantified data records, as in the error below.
In general I also find working with code that involves existential type variables quite hard work - for example I can't use foo as a record selector either, even if I immediately do something that seals the existential type back up again.
I don't understand this stuff well enough to be sure whether it's an impredicativity issue or not, though.
Foo.hs:11:8:
Record update for the non-Haskell-98 data type `Foo' is not (yet)
supported
Use pattern-matching instead
In the expression: rec {foo = id}
In the definition of `f': f rec = rec {foo = id}
Program is:
{-# LANGUAGE Rank2Types #-}
module Foo where
data Foo = forall a . Foo { foo :: a -> a, bar :: Int }
x :: Foo
x = Foo { foo = id, bar = 3 }
f :: Foo -> Foo
f rec = rec { foo = id }
g :: Foo -> Foo
g rec = rec { bar = 3 }
Simon says: Ah now I see. The relevant comment, TcExpr line 465, says
-- Doing record updates on -- GADTs and/or existentials is more than my tiny -- brain can cope with today
Should be fixable, even with a tiny brain.
Change History
Note: See
TracTickets for help on using
tickets.
