[Haskell-beginners] Possible to update Haskell syntax

Brent Yorgey byorgey at seas.upenn.edu
Mon Nov 24 12:12:53 EST 2008


In general, the point is that there is already a 'whitespace operator'
in Haskell corresponding to function application.  So it would be
ambiguous for whitespace to also indicate separation of list elements.

Also, I rarely need to write explicit lists of any length, so I think
you will find that having to write an explicit comma in between
elements is not that much of an annoyance.

With all that said, you may also find the new 'quasiquoting'
functionality in GHC 6.10.1 to be of interest.  Quasiquoting allows
you to specify arbitrary parsers for specially quoted strings.  In
particular, you could implement a list quasiquoter so that you could
write something like

  [ls| 1 2 3 4 |]

which could parse to the list [1,2,3,4].  I haven't had a chance to
play around with the quasiquoting stuff myself yet, however, so I
don't have a good idea of how difficult this would be.

-Brent

On Sun, Nov 23, 2008 at 06:00:17PM +1300, Steven Ashley wrote:
> Hi cm,
> 
> An ambiguity arises when you have a list containing functions. For
> instance consider:
> 
> fmap ($3) [id id id id]
> 
> Cheers,
> 
> Steven
> 
> 
> 2008/11/23 cm <cm at raytheon.com>:
> > I'm very interested in learning Haskell, but one frustration is that lists
> > always require commas.  As an example [1,2,3,4] is a valid expression, but
> > [1 2 3 4] is not.
> >
> > In this ideal world, another example would be that [(fun1 3 4) 7] would be a
> > valid expression and be a two-element list equivalent to [fun1 3 4, 7].
> >
> > If what I am suggesting is syntactically possible and doesn't break more
> > advanced features of the language that I (as a beginner) am unaware of, I'm
> > interested in patching the open source for my own use (as well as others who
> > might want it).
> > _______________________________________________
> > Beginners mailing list
> > Beginners at haskell.org
> > http://www.haskell.org/mailman/listinfo/beginners
> >
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners


More information about the Beginners mailing list