You can distinguish a monadic action from the distribution of Left values if you really want to:
import Control.Monad import Control.Applicative import Control.Monad.Instances
This gives a simple monadic action:
foo :: Type -> Type -> Either String Type foo t1 t2 | p t1 && p t2 = Right t1 | otherwise = Left somestring
What can you apply to monadic arguments to get the desired function using
fooM :: Either String Type -> Either String Type -> Either String Type fooM t1 t2 = join (foo <$> t1 <*> t2)
or equivalent
fooM t1 t2 = do a <- t1 b <- t2 foo ab
source share