[Hugs-users] Record puns, time for removal?

Seth Kurtzberg seth at cql.com
Tue Oct 31 14:42:58 EST 2006


On Tue, 31 Oct 2006 11:06:01 -0800
"Iavor Diatchki" <iavor.diatchki at gmail.com> wrote:

> Hello,
> I think the "it may be confusing to novices" argument tends to be
> over-used and we should be careful before we make language decisions
> solely based on it.  At the  very least, when there is a suggestion
> that something might be confusing to someone, there should be an
> explanation of what/why/to whom it is confusing.

I don't disagree at all.  I'm not suggesting that the "confusion" issue should have any impact at all on decisions about the language.

I was only talking about whether the pun feature should be accepted by default, or require an -fwhatever.  I don't see this as being different than, say, -fglasgow-exts.

Or, perhaps, it should simply be one of the glasgow extensions.

As to why it might be confusing, I realize this is extremely subjective.  Suppose you have a record type, and add a constructor to it.  As things stand, I can use the compiler to be certain that I've found all areas of the code that require changes because of the addition of the constructor (with the flag that tells gcc to find non-exhaustive pattern matches).  Using the compiler in this manner is (IMO) one of the things that makes refactering in Haskell so much easier than some other languages.

OK, now, if the pun feature is on, it's no longer illegal to provide processing for only one constructor.  (That's not the only thing it does, but that is one thing that it does.)

Seth

> 
> I think record puns are a nice feature, it is easy to explain, and
> without them the Haskell record system is less useful, at least to me.
> 
> By the way, if I recall correctly, in Johan Nordlander's O'Hugs the ..
> notation (called record packing, I think) could also be used to create
> record values.  I think it worked like this:
> > data Point = Point { x,y :: Int }
> > pt = let { x = 3; y = 4 } in Point { .. }
> 
> The ".." is expanded to "{x = x, y = y}" based on the fields for the
> particular constructor.  It seems that if we have the "Point { .. }"
> pattern, we should also have the constructor version.  What do people
> think?
> 
> -Iavor
> 
> 
> 
> 
> On 10/31/06, Seth Kurtzberg <seth at cql.com> wrote:
> > On Tue, 31 Oct 2006 13:59:45 +0300
> > Bulat Ziganshin <bulat.ziganshin at gmail.com> wrote:
> >
> > > Hello Neil,
> > >
> > > Tuesday, October 31, 2006, 4:04:23 AM, you wrote:
> > >
> > > >> > puns like Foo { .. } would be great too.
> > > >>
> > > >> I'd vote for enabling them with a command line switch, rather than by default, as they can be confusing to folks learning the language.
> > >
> > > > How discussions come full circle :) I started this discussion on the
> > > > Hugs users list because I want to _remove_ the command line switch for
> > > > puns from Yhc. I'm not overly fussed whether I remove the entire
> > > > feature, or just remove the command line and make it always on by
> > > > default, but I do want the command line switch gone!
> > >
> > > compiler switch can't be made a part of Haskell' :)
> > >
> > > and anyway, i don't see how cmdline switch may help noivices - when
> > > they use ".." by mistake and program mysteriously not fails? or when
> > > they stare at the other's program and understand that this unknown
> > > ".." work only because this program compiled with some special switch?
> >
> > I wasn't talking about the .., I was talking about the primary issue raised by the email, which has nothing to do with ..
> >
> > Instead of assuming that I was saying something totally useless and worthless, it might not be a bad idea to respond to _my_ email, not an email which contains a quote of one line from my email.
> >
> > >
> > > and yes, record puns seems very ggod candidate for H'. it's widely
> > > used (i used it until switched to GHC), it was already in Haskell, and
> > > now it is impelemnted by every compiler
> > >
> > > wildcard puns is more discussible, but i personally need this feature
> > >
> > >
> > > --
> > > Best regards,
> > >  Bulat                            mailto:Bulat.Ziganshin at gmail.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