
26 Jul
2012
26 Jul
'12
1:28 a.m.
Евгений,
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