PROPOSAL: Include record puns in Haskell 2011

Heinrich Apfelmus apfelmus at
Fri Feb 26 05:59:14 EST 2010

Simon Marlow wrote:
> While I agree with these points, I was converted to record punning
> (actually record wildcards) when I rewrote the GHC IO library.  Handle
> is a record with 12 or so fields, and there are literally dozens of
> functions that start like this:
>   flushWriteBuffer :: Handle -> IO ()
>   flushWriteBuffer Handle{..} = do
> if I had to write out the field names I use each time, and even worse,
> think up names to bind to each of them, it would be hideous.

What about using field names as functions?

    flushWriteBuffer h@(Handle {}) = do
        ... buffer h ...

Of course, you always have to drag  h  around.

Heinrich Apfelmus


More information about the Haskell-prime mailing list