implementing Monad for Result type