I think that when with full expression support instead of just constants with binding variables could potentially enable super powers, but I am not sure if it would be reasonable. Likely it would enable a large set of confusing code, but I am not really sure cause I haven't messed with it enough. A few examples off the top of my head:
Be used instead of if as mentioned above:
when Bool.true is
num < 10 ->
"less than 10"
num < 100 ->
"less than 100"
num < 1000 ->
"less than 1000"
_ ->
"it's a big number"
try multiple things until the first Ok result and then do something.
Each Ok can be handled different in each branch.
when Ok _ is
List.get someList 3 ->
...
Num.addChecked x y ->
...
somePossiblyFailingFunction a b ->
...
_ ->
crash "everything failed"
Theoretically if the types line up, you could write when Ok val is for the first line of the above example. That would enable still binding the wrapped value and using it in sub branches. I guess this is another way to write a chaining of results with special handling on failure, but it is still intriguing.
I assume something of this nature would actually be very powerful and interesting, but my gut feeling is that it would be too powerful and lead to more confusing code rather than be positive overall.
@Brendan Hansknecht great points, I'm sold.
the second example is "woah very interesting!! I hate it!" haha but you just opened up a box of possibilities in my head :)
A message was moved here from #ideas > Prevent else if by Brendan Hansknecht.
Just throwing this in it's own topic so that it can be explored some. As I said above, I think it is likely too powerful, but it is an interesting idea and may spark some real use cases for people
sorry mate but it just feels so wrong lol
Last updated: Jun 16 2026 at 16:19 UTC