This is why it's lame that Swift's optionals are a language feature and not an in-language implementation.
In Haskell, optionals are Monads, which means there is a function
join :: m (m a) -> m a
You can also daisy-chain them together using >>=, a la
fail1 :: Maybe a fail2 :: a -> Maybe b result = fail1 >>= fail2
This is why it's lame that Swift's optionals are a language feature and not an in-language implementation.
In Haskell, optionals are Monads, which means there is a function
"Maybe" (Haskell's standard library Optional) is a monad, so you can unwrap/collapse them using Join.You can also daisy-chain them together using >>=, a la
If either fail1 or fail2 fails, the entire "result" function fails (i.e. returns "Nothing").