Proposal: FirstClassFieldUpdates

Isaac Dupree ml at isaac.cedarswampstudios.org
Tue Jul 28 21:50:12 EDT 2009


Jon Fairbairn wrote:
> Isaac Dupree
> <ml at isaac.cedarswampstudios.org>
> writes:
> 
>> Jon Fairbairn wrote:
>>> Parenthesis around updates would make them into functions, ie
>>> ({a=1,b=2,...}) would mean the same as (\d -> d{a=1,b=2,...}), but be
>>> more concise.
>> yes it is, however field updates are occasionally slightly
>> annoying, since they can't change something's type at all,
>> IIRC.  Say,
>> data C nx ny = C { x :: nx, y :: ny }
>> x_set :: nx2 -> C nx1 ny -> C nx2 ny
>> --x_set x2 c = c {x = x2}  --type error
> 
> If that were the case, it would be a serious wart that needed to be
> addressed. However, implementation would be fairly straightforward as
> an "extension" is already present in ghc:

oh maybe I got confused.  (My confusion also could have been the result 
of a bug that was recently fixed in GHC that affected the type of some 
cases like that where there are multiple constructors...)

-Isaac


More information about the Haskell-prime mailing list