Hacker News new | ask | show | jobs
by modalduality 3075 days 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
2 comments

That'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
    }
Oh, come on. Is yielding 0 there really the best approach? It's a copout. You want full referential transparency.