roc
roc copied to clipboard
Pattern matching on qualified constants
It should be possible to do this:
when x == 1 is
Bool.true -> ...
Bool.false -> ...
This would also allow for pattern matching on other constants, e.g. numbers or other opaque tags besides Bool.
I think we may have discussed this before, but I believe this would make it possible to induce breaking changes without changing API surfaces. For example if I have
# Status.roc
Status := [Success, Failure]
success = @Status Success
failure = @Status Failure
# App.roc
when status is
Status.success -> ...
Status.failure -> ...
and now Status gets updated to
Status := [Success, Failure, Pending]
then App.roc is now broken, because the API surface of Status is leaked through the pattern match, even though you would not expect this to be a breaking change.