Stream: ideas

Topic: Would you consider adding equilities in pattern matches?


view this post on Zulip Jamie (Dec 03 2025 at 10:39):

Something like Ok('a' <= l <= 'z') ->

view this post on Zulip Fabian Schmalzried (Dec 03 2025 at 11:05):

I think in the old compiler you could do something like:

  match item {
      Ok(x) if x < 2 => Foo
      Ok(x) if x < 4 => Bar
      _ => Baz
  }

See https://roc-lang.org/tutorial#pattern-matching (old syntax was when item is ...). But I don't think this is implemented in the new compiler yet.

view this post on Zulip Fabian Schmalzried (Dec 03 2025 at 11:07):

If 'a' <= l <= 'z' will be possible or if it has to be 'a' <= l and l <= 'z', I'm not sure. But I personally don't like this shortcut and prefer the long version anyway.

view this post on Zulip Norbert Hajagos (Dec 03 2025 at 12:24):

I've brought something similar up once at #ideas > chained comparison operators for boolean operators. tldr is that it's not going to happen.


Last updated: Jun 16 2026 at 16:19 UTC