Евгений,

> The possible extension may look somehow like this:
>
> class Applicative a => Branching a where
>  branch :: a (Either b c) -> (a b -> a d) -> (a c -> a d) -> a d

What about the following alternative that does not require an extension?

  import Control.Applicative

  eitherA :: Applicative f => f (a -> c) -> f (b -> c) -> f (Either a b) -> f c
  eitherA = liftA3 either

Note by the way that the result of this function will execute the
effects of all of its arguments (as you would expect for an
Applicative functor).

Dominique

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to