diff --git a/src/Prologue.hs b/src/Prologue.hs index 3b06c8a57..ba5eb64eb 100644 --- a/src/Prologue.hs +++ b/src/Prologue.hs @@ -2,6 +2,7 @@ module Prologue ( module X , eitherA + , eitherM , foldMapA , maybeM , maybeLast @@ -79,6 +80,9 @@ fromMaybeLast b = fromMaybe b . getLast . foldMap (Last . Just) maybeM :: Applicative f => f a -> Maybe a -> f a maybeM f = maybe f pure +eitherM :: Applicative f => (a -> f b) -> Either a b -> f b +eitherM f = either f pure + -- Promote a function to either-applicatives. eitherA :: Applicative f => (b -> f (Either a c)) -> Either a b -> f (Either a c) eitherA = either (pure . Left)