-
Notifications
You must be signed in to change notification settings - Fork 193
Open
Milestone
Description
Currently handler and match are somewhat similar in that they specify which operator or value constructor they match, and on the right-hand side what to do with them, but the syntax for them are not exactly the same, which looks inconsistent.
Consider:
fun untry_(ex: either<string, a>): <exn_> a
match ex
Right(x) -> x
Left(exn) -> throw_(exn)
val try_ = handler
return(x) -> Right(x)
ctl throw_(exn: string) -> Left(exn)
Here both handler and match use ->.
In handler, I can also indent the right-hand side and omit ->:
// also works
val try_ = handler
return(x)
Right(x)
ctl throw_(exn: string)
Left(exn)
But I can't do the same in match:
// syntax error
fun untry_(ex: either<string, a>): <exn_> a
match ex
Right(x)
x
Left(exn)
throw_(exn)
Since indentation is just braces omitted, I can also use braces in handler if I want to define a handler in one line:
// also works
val try_ = handler
return(x) { Right(x) }
ctl throw_(exn: string) { Left(exn) }
Which also doesn't work for match.
I suggest we get rid of -> in match and use braces. That would make the syntax consistent with handler, and allow for cleaner match expressions when the right-hand sides are indented.
Reactions are currently unavailable