module Signet.Unstable.Extra.Either where

import qualified Control.Monad.Catch as Exception

hush :: Either x a -> Maybe a
hush :: forall x a. Either x a -> Maybe a
hush = (x -> Maybe a) -> (a -> Maybe a) -> Either x a -> Maybe a
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Maybe a -> x -> Maybe a
forall a b. a -> b -> a
const Maybe a
forall a. Maybe a
Nothing) a -> Maybe a
forall a. a -> Maybe a
Just

throw :: (Exception.Exception e, Exception.MonadThrow m) => Either e a -> m a
throw :: forall e (m :: * -> *) a.
(Exception e, MonadThrow m) =>
Either e a -> m a
throw = (e -> m a) -> (a -> m a) -> Either e a -> m a
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either e -> m a
forall e a. (HasCallStack, Exception e) => e -> m a
forall (m :: * -> *) e a.
(MonadThrow m, HasCallStack, Exception e) =>
e -> m a
Exception.throwM a -> m a
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure