5 ms·
`?` can do that in Neat, but you'd use a different mechanism where you mark some members of a return value as `fail` fields, which would then be error-propagate
by FeepingCreature 3y ago
`?` can do that in Neat, but you'd use a different mechanism where you mark some members of a return value as `fail` fields, which would then be error-propagated out of the entire function by `?`. Ie. `get_user_id` would return `(UserId | fail HttpError)`, and `get_user_id()?` would get you an expression that either yields `UserId` or returns `HttpError`. Then you could use a nested function to imitate your `try` block, or just map `HttpError` to whatever error you want with `case`.
The thing about `?` being built on basic primitives is that you can always just decide to define your own sumtype error handling.
Anyways, `:else` is more about "expected failures" than "errors". Loop-enders rather than process-enders.