[Haskell-cafe] Prolog-style list syntax?

Anthony Clayden anthony.d.clayden at gmail.com
Tue Jun 29 11:18:02 UTC 2021

On Tue, 29 Jun 2021 at 04:07, Albert Y. C. Lai <trebla at vex.net> wrote:

> The logical conclusion of "elem : list" is
> e1 : e2 : e3 : e4 : list
> without needing a 2nd notation to make it nicer.
(As I said up-thread you almost always need to add the parens notation --
not to make it "nicer", but to make it parse correctly.)

I appreciate syntax is a matter of personal taste, but my taste prefers the
brackets and commas.

> The logical conclusion of "[elem | list]" is
> [e1 | [e2 | [e3 | [e4 | list]]]]
> That's not nice.

Quite often `e1:e2:e3:e4:list` won't work, because the expressions have
infix operators. So you end up with

>    (e1: (e2: (e3: (e4: list))))

So you still have to squint to make sure the parens balance.

> That explains why someone had to invent a 2nd notation,
> [e1, e2, e3, e4 | list].

Sure. The commas form is a shorthand. Just like

>    (e1, e2, e3, e4)    is shorthand for (,,,) e1 e2 e3 e4
>    e1 + e2 * e3           is shorthand for  (+) e1 ((*) e2 e3)

> Ironically, the need for a 2nd notation proves
> that the original "[elem | list]" design was ill-conceived.
So which form of tuple syntax do you think is ill-conceived?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20210629/fa321beb/attachment.html>

More information about the Haskell-Cafe mailing list