<div dir="ltr"><br><div class="gmail_quote"><div dir="ltr">One of the annoying (to me) inconsistencies with Haskell syntax is that `[ ]` means 'here comes a list'; but for the most common way to write a list, you can't use `[ ]`:<div><br></div><div>> elem x [] = False</div><div>> elem x ( y: ys ) = ...</div><div><br></div><div>Prolog syntax has lists, signalled by `[ ]`: [], [1], [2, 3], [4, 5, 6], [[7, 8], [9, 10, 11]] are all valid list literals. For cons it also uses `[ ]` syntax</div><div><br></div><div>> elem x [y | ys ] = ...</div><div><br></div><div>`[ x, y, z | zs ]` is also valid; pattern match or build a list with at least 3 elements, where `zs` is the tail -- 4th element onwards (if any). That structure is particularly ugly in Haskell syntax.</div><div><br></div><div>Neither `|` inside `[ ]` in a pattern nor a comma-list with `|` inside `[ ]` is valid H98 syntax, nor valid in GHC extensions AFAICT.</div><div><br></div><div>In an expression, `[ x | xs ]` could be taken as a list comprehension, which is I guess why Haskell didn't follow Prolog. I've come across another theorem-prover that follows Prolog style, except it uses `:` instead of `|` inside `[ ]`. Unfortunately ...</div><div><br></div><div>> elem x [ y: ys ] = ...</div><div><br></div><div>Is valid syntax, where `:` is cons, so this is a nested list. I'm thinking that's relatively uncommon, and means the same as `[ ( y: ys ) ]`. </div><div><br></div><div>Would anyone be violently pro or anti changing the meaning of `:` appearing at top level in `[ ]` to mean cons-tail?</div><div><br></div><div>AntC</div></div>
</div></div>