RFC: Change proposal affecting syntax for Or patterns https://github.com/ghc-proposals/ghc-proposals/pull/585

Hi community,

as syntax is contentious a topic as ever, David (the main proposal author) and I would like to invite you to give your input on Amend #522 by knothed · Pull Request #585 · ghc-proposals/ghc-proposals · GitHub, where we propose to change the syntax of the accepted proposal #522 introducing Or patterns. In particular, we’d like to know

  • Whether you like the syntax ((one of 1,2,3), 4) in the original proposal better than the amended one mirroring case of: (one of {1;2;3},4)
  • Whether you like that it is subject to layout, similar to case of, e.g.,
    f (one of 1
              3) = 4
    Which looks kind of funny here, but perhaps has foreseen use cases.
  • Whether you think it’s good or bad to allow f (one of {}) (with layout just f (one of), even), and whether the semantics should be a strict match (mirroring case x of {}) or lazy (like case x of _ -> ...)
  • If you have experience with writing tools for GHC Haskell, whether mirroring case of syntax poses new problems for you, especially caused by it being subject to layout rules

(Note that we understand that you might not like either syntax. That is fine, but the linked proposal thread is not the place to have that discussion. In all honesty, the syntactic appearance is not why we like Or patterns, rather the opposite.)

Thank you!


There is one place in Haskell syntax that allows both a comma list and/or braces/semicolons (kinda). Language Report section 3.13 ‘Case Expressions’:

case x of
    Bar y z | let w = baz1 y, let { u = baz2 y; v = baz3 z }, let w4 = baz4 z  -> rhs
    --               comma ^,     {           ;            },^

The semantics is the same as putting all four decls inside a single let { ...; ...; ...; ... } or putting four lets, comma-separated let ..., let ..., let ..., let ....

It’s a comma-list because those are <guards> following the |, more typically a list of (Boolean) <infixexp>.

1 Like