module Data.Either.Extras
( unsafeFromEither
, fromRightM
) where
import Control.Exception
unsafeFromEither :: Exception e => Either e a -> a
unsafeFromEither :: forall e a. Exception e => Either e a -> a
unsafeFromEither = (e -> a) -> (a -> a) -> Either e a -> a
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either e -> a
forall a e. Exception e => e -> a
throw a -> a
forall a. a -> a
id
{-# INLINE unsafeFromEither #-}
fromRightM :: Monad m => (a -> m b) -> Either a b -> m b
fromRightM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Either a b -> m b
fromRightM a -> m b
f = (a -> m b) -> (b -> m b) -> Either a b -> m b
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either a -> m b
f b -> m b
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
{-# INLINE fromRightM #-}