▲ | greener_grass 2 days ago | ||||||||||||||||||||||
Then you end up with a pyramid of doom. Fine for small examples but it doesn't scale up easily. Rust has special syntax (`?`) for this AFAICT. | |||||||||||||||||||||||
▲ | solomonb 2 days ago | parent | next [-] | ||||||||||||||||||||||
You still don't need monads for any of this. Monads give you an ad-hoc polymorphic way of doing monadic actions. Short circuiting on `Either` is a specific case of this. You can define your own EitherBind in any language.
Now you can bind over Either to your heart's content without needing an encoding of Monads in your language. | |||||||||||||||||||||||
▲ | kccqzy 2 days ago | parent | prev | next [-] | ||||||||||||||||||||||
That's merely syntax sugar. Haskell doesn't even have this sugar and so in a monad you have to bind explicitly, and it's fine. It's not a pyramid of doom. | |||||||||||||||||||||||
| |||||||||||||||||||||||
▲ | dllthomas 2 days ago | parent | prev [-] | ||||||||||||||||||||||
`?` and `let ... else` both partially address this, yeah. |