module Snap.Snaplet.Auth.Handlers.Errors
( hush
, hushT
, note
, noteT
, hoistMaybe
) where
import Control.Monad
import Control.Monad.Trans.Either
import Control.Monad.Trans.Maybe
hush :: Either a b -> Maybe b
hush = either (const Nothing) Just
hushT :: (Monad m) => EitherT a m b -> MaybeT m b
hushT = MaybeT . liftM hush . runEitherT
note :: a -> Maybe b -> Either a b
note a = maybe (Left a) Right
noteT :: (Monad m) => a -> MaybeT m b -> EitherT a m b
noteT a = EitherT . liftM (note a) . runMaybeT
hoistMaybe :: (Monad m) => Maybe b -> MaybeT m b
hoistMaybe = MaybeT . return