Hacker News new | past | comments | ask | show | jobs | submit login

Right, here's my implementation in Haskell:

    f x y =
      case x of
        Left a -> Left a
        Right b ->
          case y of
            Left a -> Left a
            Right c -> Right (b, c)
Each `case` represents a couple of hypothetical contexts, applying case analysis to the Either (the OR). You're going to have to duplicate some work, since the `Left a` branch appears twice and you're getting the `a` from different places.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact