How to Use Extensible Records in GHCi

Simon Peyton-Jones simonpj at microsoft.com
Tue Mar 30 08:34:23 EST 2004


No, extensible records are not implemented in GHC.  Hugs (or some
variant of it) implements TRex, another extensible record variant.  The
problem is that the record design space is large, and seems to lack
local optima.  And all reasonable variants break backward compatibility.
As a result, nothing much happens.

But for the particular code you write, H98 does the job fine:
	
data C = C { a :: Int, b:: Bool, c::Int, ... i::String}

Then if there's an expression e::C, you can write 
	e { b=True } 
to change the b component to True.  Check the H98 report

SImon

| -----Original Message-----
| From: glasgow-haskell-users-bounces at haskell.org
[mailto:glasgow-haskell-users-
| bounces at haskell.org] On Behalf Of S. Alexander Jacobson
| Sent: 30 March 2004 00:14
| To: GHC users
| Subject: FAQ: How to Use Extensible Records in GHCi
| 
| I feel like I have way too much code of the form:
| 
|    changeGpart (C a b c d e f g h i) g' =
| 	C a b c d e f g' h i
| 
| So, I got excited reading Simon and Mark's
| "Lightweight Extensible Records For Haskell" paper
| as a way to get rid of this cruft.  I immediately
| started GHCi, typed {a="Hello world"}, and got an
| error.
| 
| Is the feature described in the paper just a
| proposal or is there a switch somethere to enable
| it?
| 
| Alternatively, perhaps this code is a common
| beginner mistake due to ignorance of the proper
| idiom...
| 
| -Alex-
| 
| 
| _________________________________________________________________
| S. Alexander Jacobson                  mailto:me at alexjacobson.com
| tel:917-770-6565                       http://alexjacobson.com
| _______________________________________________
| Glasgow-haskell-users mailing list
| Glasgow-haskell-users at haskell.org
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


More information about the Glasgow-haskell-users mailing list