[Haskell-cafe] Prolog-style list syntax?

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


On Mon, 28 Jun 2021 at 23:20, Johannes Waldmann <
johannes.waldmann at htwk-leipzig.de> wrote:

> > `[ x, y, z | zs ]` is also valid; [...]
> > That structure is particularly ugly in Haskell syntax.
>
> how so?  `x : y : z : zs`
>
>
Because almost always you need to put parens round -- certainly in a
pattern match.

And it's not square brackets, which would say 'here comes a list'.


> Prolog list syntax is ugly here because
> the "cons" operator (|) needs special parentheses.
>

Exactly! Special list-heralding brackets.


>
> Well, a similar thing in Haskell ist the ".."
> (enumFromTo) operator.
>
>
@Jeff But I actually like this the best:
> [x, y, z, zs...] = list
>

Or maybe

>   [x, y, z, zs at ..] = list

Could be an as-pattern binding to the tail. But now it's getting
heavyweight.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20210629/f80c15d4/attachment.html>


More information about the Haskell-Cafe mailing list