6
votes

I was trying to use record update for an existential record when I ran into an error. A quick google led me to feature request #2595, which shows it as implemented for GHC back in version 6.8.3. I'm using 6.10.4, so I'd think it should work, but the example code from the feature request:

{-# LANGUAGE ExistentialQuantification,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 } 

yield the same errors as complained of in the feature request:

test.hs:10: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}

test.hs:13:8:
    Record update for the non-Haskell-98 data type `Foo' is not (yet) supported
    Use pattern-matching instead
    In the expression: rec {bar = 3}
    In the definition of `g': g rec = rec {bar = 3}

Was this a consciously dropped feature at some point, or should I file a bug report?

2

2 Answers

5
votes

Actually, the Trac slip says it was implemented in version 6.12 — the bug was found in version 6.8.3. So you're using a version that's older than the fix.

Also, the changelog entry for the fix seems to indicate that it's not completely fixed; you'd still be getting the first error, just not the second. If there isn't already a bug report for the rest of the problem, I'd say go ahead and file.

4
votes

There is still another way!


If you change the data type definition from

data Foo = forall a . Foo { foo :: a -> a, bar :: Int }

to

data Foo = Foo { foo :: forall a . a -> a, bar :: Int }

, then it compiles without error. -- using ghc-6.12.2.20100531