PROPOSAL: Include record puns in Haskell 2011

Iavor Diatchki iavor.diatchki at gmail.com
Fri Feb 26 14:06:02 EST 2010


Hello,

In order to keep the discussion structured I have created two tickets
in the haskell-prime trac system
(http://hackage.haskell.org/trac/haskell-prime):
  * Proposal 1: Add pre-Haskell'98 style punning and record
disambiguation (ticket #136)
  * Proposal 2: Add record-wildcards (ticket #137)

I decided to split the two into separate tickets because, at least in
my mind, there are different things that we might discuss about the
two, and also they make sense independent of each other (although
record wildcards without punning might be a bit weird :-).

I think that both proposals are worth considering for Haskell 2011
because there are situations where they can significantly improve the
readability of code involving record manipulation.  I disagree with
the stylistic issues that were brought up in the discussion because I
do not believe that variable "shadowing" should be avoided at all
costs:  at least for me, avoiding shadowing is a means to an end
rather then an end in itself.  In the case of record puns, I think
that the clarity of the notation far surpasses any confusion that
might be introduced by the shadowing.  Furthermore, as other
participants in the discussion pointed out, the proposed features are
orthogonal to the rest of the language, so their use is entirely
optional.

-Iavor




On Fri, Feb 26, 2010 at 2:59 AM, Heinrich Apfelmus
<apfelmus at quantentunnel.de> wrote:
> 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.
>
>
> Regards,
> Heinrich Apfelmus
>
> --
> http://apfelmus.nfshost.com
>
> _______________________________________________
> Haskell-prime mailing list
> Haskell-prime at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-prime
>


More information about the Haskell-prime mailing list