[Haskell-cafe] record update

Conrad Parker conrad at metadecks.org
Tue Sep 14 18:28:13 EDT 2010

On 15 September 2010 04:31, Jonathan Geddes <geddes.jonathan at gmail.com> wrote:
> Wow, I had no idea there were so many record packages! This indicates a
> couple things to me: a) Haskell is very flexible. b) I'm not the only one
> who things the built-in record system isn't perfect.
> Digging a bit deeper, it looks like some of the record-related ghc
> extensions might also be useful, such as record punning and field
> disambiguation.
> Since these are already extensions, they're more likely to make it into
> Haskell 20XX. Are these considered to be the solution to current record
> syntax problems?
> With these extensions, couldn't I write the following?
>>someUpdate :: MyRecord -> MyRecord
>>someUpdate myRecord@(MyRecord{..}) = let
>>     { field1 = f field1
>>     , field2 = g field2
>>     , field3 = h filed3
>>     } in myRecord{..}

or just:

someUpdate :: MyRecord -> MyRecord
someUpdate myRecord at MyRecord{..} =
    myRecord{ field1 = f field1
            , field2 = g field2
            , field3 = h field3


More information about the Haskell-Cafe mailing list