Re:The struggle with Rust
by dllthomas on Tuesday January 24, 2017 @07:43PM
(#13477332)
First, let me say that I think you're right that expressiveness is reduced. In the best case, all of that reduction is of things we don't want to express because they are incorrect - but in practice (and probably in theory!) the boundary will always be fuzzy.
That said, with regard to your "kill a branch in your AST" example, you can kill a branch with Void:
import Data.Void
frobnicate :: Either a Void -> a
frobnicate (Right x) = absurd x
frobnicate (Left x) = x
Now you can rely on no-one accidentally handing you a Right expecting you to do something reasonable with it.
That said, with regard to your "kill a branch in your AST" example, you can kill a branch with Void:
Now you can rely on no-one accidentally handing you a Right expecting you to do something reasonable with it.