let
... else
syntax in progn let
?
#807
Replies: 2 comments
-
I think extending the type system to support this will be difficult. Rust's never type being first class seems like it has some issues (I just glanced over rust-lang/rust#35121). Coalton doesn't have rank N types, so |
Beta Was this translation helpful? Give feedback.
-
That being said, I think |
Beta Was this translation helpful? Give feedback.
-
I'm unsure of the status of the Rust proposal on this one, but now that we have pattern exhaustiveness checking, it would be nice to have a way to write non-exhaustive destructuring without rightward drift in
progn let
, like:It seems reasonable (although honestly, not my first choice) to disallow the above in favor of requiring a version that explicitly handles the
Nil
case. But usingmatch
in this case (or, really, in more complicated but similar cases) leads to undesirable visual noise and rightward drift. Consider:Or, a similar version that retuns an
None
instead of signaling an error:Instead, I propose copying Rust's
let ... else
construct, to rewrite the above as:Notice how the
let else
version keeps the handler for the failed-match branch close to the match itself, where thematch
version has the handler for the failed-match branch somewhat removed from its source; and how thelet else
version avoids rightward drift.The semantics should be:
progn let
bindings without anelse
clause must be exhaustive.progn let
bindings with anelse
clause need not be exhaustive.else
clause of aprogn let
must not return normally.!
.forall a. a
.In my mind, the main obstacle here is whether we can check that a form doesn't return. Is that feasible?
As always, I am not particularly attached to this specific syntax, so long as whatever we decide on doesn't introduce any nesting of subsequent/body forms.
Beta Was this translation helpful? Give feedback.
All reactions