4 ms·
Most languages with monads have tools for working with them. In Haskell, for example, even without `liftM2` or `sequenceM`, you can simply do case (xm, ym)
by modalduality 9y ago
Most languages with monads have tools for working with them. In Haskell, for example, even without `liftM2` or `sequenceM`, you can simply do
case (xm, ym) of
(Just x, Just y) -> x + y
_ -> 0
- quotemstr 9y agoOh, come on. Is yielding 0 there really the best approach? It's a copout. You want full referential transparency.
- masklinn 9y agoThat's got nothing to do with monads though, you can do that in Swift or Rust which have a monadic option type but don't actually have monads: match (xm, ym) { (Some(x), Some(y)) => x + y, _ => 0 }