either-result-0.3.0.0: ‘MonadFail’ instance for a wrapper of ‘ExceptT String m a’.

Safe HaskellNone
LanguageHaskell2010
Extensions
  • Cpp
  • ViewPatterns
  • TypeSynonymInstances
  • FlexibleInstances
  • ExplicitNamespaces
  • PatternSynonyms

Control.Monad.Trans.Result

Contents

Description

ResultT interfaces with Result.

Synopsis

The Result monad

type Result = ResultT Identity Source #

A result monad.

pattern Result :: Either String a -> Result a Source #

Wrap Result a.

pattern Error :: String -> Result a Source #

Error means errors and failures etc.

pattern Success :: a -> Result a Source #

Success means successes and OKs etc.

result :: (String -> b) -> (a -> b) -> Result a -> b Source #

Case analysis for the Result type.

Examples

Expand
>>> let s = Success 0
>>> let e = Error "critical"
>>> result ("Bad: " ++) (("OK: " ++) . show) s
"OK: 0"
>>> result ("Bad: " ++) (("OK: " ++) . show) e
"Bad: critical"

fromSuccess :: a -> Result a -> a Source #

Convert Result a to a with a default value.

toMonadFail :: MonadFail m => Result a -> m a Source #

Convert Result a to MonadFail m => m a.

The ResultT monad transformer

data ResultT m a Source #

A monad transformer that is similar to ExceptT except a MonadFail instance.

MonadFail = ResultT . throwE
Instances
MonadTrans ResultT Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

Methods

lift :: Monad m => m a -> ResultT m a #

Monad m => MonadError String (ResultT m) Source # 
Instance details

Defined in Control.Monad.Result

Methods

throwError :: String -> ResultT m a #

catchError :: ResultT m a -> (String -> ResultT m a) -> ResultT m a #

Monad m => Monad (ResultT m) Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

Methods

(>>=) :: ResultT m a -> (a -> ResultT m b) -> ResultT m b #

(>>) :: ResultT m a -> ResultT m b -> ResultT m b #

return :: a -> ResultT m a #

fail :: String -> ResultT m a #

Functor m => Functor (ResultT m) Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

Methods

fmap :: (a -> b) -> ResultT m a -> ResultT m b #

(<$) :: a -> ResultT m b -> ResultT m a #

Read a => Read (Result a) Source # 
Instance details

Defined in Control.Monad.Trans.Result

Show a => Show (Result a) Source # 
Instance details

Defined in Control.Monad.Trans.Result

Methods

showsPrec :: Int -> Result a -> ShowS #

show :: Result a -> String #

showList :: [Result a] -> ShowS #

MonadFix m => MonadFix (ResultT m) Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

Methods

mfix :: (a -> ResultT m a) -> ResultT m a #

Monad m => MonadFail (ResultT m) Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

Methods

fail :: String -> ResultT m a #

Monad m => Applicative (ResultT m) Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

Methods

pure :: a -> ResultT m a #

(<*>) :: ResultT m (a -> b) -> ResultT m a -> ResultT m b #

liftA2 :: (a -> b -> c) -> ResultT m a -> ResultT m b -> ResultT m c #

(*>) :: ResultT m a -> ResultT m b -> ResultT m b #

(<*) :: ResultT m a -> ResultT m b -> ResultT m a #

Foldable m => Foldable (ResultT m) Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

Methods

fold :: Monoid m0 => ResultT m m0 -> m0 #

foldMap :: Monoid m0 => (a -> m0) -> ResultT m a -> m0 #

foldr :: (a -> b -> b) -> b -> ResultT m a -> b #

foldr' :: (a -> b -> b) -> b -> ResultT m a -> b #

foldl :: (b -> a -> b) -> b -> ResultT m a -> b #

foldl' :: (b -> a -> b) -> b -> ResultT m a -> b #

foldr1 :: (a -> a -> a) -> ResultT m a -> a #

foldl1 :: (a -> a -> a) -> ResultT m a -> a #

toList :: ResultT m a -> [a] #

null :: ResultT m a -> Bool #

length :: ResultT m a -> Int #

elem :: Eq a => a -> ResultT m a -> Bool #

maximum :: Ord a => ResultT m a -> a #

minimum :: Ord a => ResultT m a -> a #

sum :: Num a => ResultT m a -> a #

product :: Num a => ResultT m a -> a #

Traversable m => Traversable (ResultT m) Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

Methods

traverse :: Applicative f => (a -> f b) -> ResultT m a -> f (ResultT m b) #

sequenceA :: Applicative f => ResultT m (f a) -> f (ResultT m a) #

mapM :: Monad m0 => (a -> m0 b) -> ResultT m a -> m0 (ResultT m b) #

sequence :: Monad m0 => ResultT m (m0 a) -> m0 (ResultT m a) #

Semigroup (Result a) Source # 
Instance details

Defined in Control.Monad.Trans.Result

Methods

(<>) :: Result a -> Result a -> Result a #

sconcat :: NonEmpty (Result a) -> Result a #

stimes :: Integral b => b -> Result a -> Result a #

Monoid (Result a) Source # 
Instance details

Defined in Control.Monad.Trans.Result

Methods

mempty :: Result a #

mappend :: Result a -> Result a -> Result a #

mconcat :: [Result a] -> Result a #

Contravariant m => Contravariant (ResultT m) Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

Methods

contramap :: (a -> b) -> ResultT m b -> ResultT m a #

(>$) :: b -> ResultT m b -> ResultT m a #

Eq1 m => Eq1 (ResultT m) Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

Methods

liftEq :: (a -> b -> Bool) -> ResultT m a -> ResultT m b -> Bool #

Ord1 m => Ord1 (ResultT m) Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

Methods

liftCompare :: (a -> b -> Ordering) -> ResultT m a -> ResultT m b -> Ordering #

Read1 m => Read1 (ResultT m) Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (ResultT m a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [ResultT m a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (ResultT m a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [ResultT m a] #

Show1 m => Show1 (ResultT m) Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> ResultT m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [ResultT m a] -> ShowS #

MonadZip m => MonadZip (ResultT m) Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

Methods

mzip :: ResultT m a -> ResultT m b -> ResultT m (a, b) #

mzipWith :: (a -> b -> c) -> ResultT m a -> ResultT m b -> ResultT m c #

munzip :: ResultT m (a, b) -> (ResultT m a, ResultT m b) #

MonadIO m => MonadIO (ResultT m) Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

Methods

liftIO :: IO a -> ResultT m a #

Monad m => Alternative (ResultT m) Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

Methods

empty :: ResultT m a #

(<|>) :: ResultT m a -> ResultT m a -> ResultT m a #

some :: ResultT m a -> ResultT m [a] #

many :: ResultT m a -> ResultT m [a] #

Monad m => MonadPlus (ResultT m) Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

Methods

mzero :: ResultT m a #

mplus :: ResultT m a -> ResultT m a -> ResultT m a #

(Eq1 m, Eq a) => Eq (ResultT m a) Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

Methods

(==) :: ResultT m a -> ResultT m a -> Bool #

(/=) :: ResultT m a -> ResultT m a -> Bool #

(Ord1 m, Ord a) => Ord (ResultT m a) Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

Methods

compare :: ResultT m a -> ResultT m a -> Ordering #

(<) :: ResultT m a -> ResultT m a -> Bool #

(<=) :: ResultT m a -> ResultT m a -> Bool #

(>) :: ResultT m a -> ResultT m a -> Bool #

(>=) :: ResultT m a -> ResultT m a -> Bool #

max :: ResultT m a -> ResultT m a -> ResultT m a #

min :: ResultT m a -> ResultT m a -> ResultT m a #

(Read1 m, Read a) => Read (ResultT m a) Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

(Show1 m, Show a) => Show (ResultT m a) Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

Methods

showsPrec :: Int -> ResultT m a -> ShowS #

show :: ResultT m a -> String #

showList :: [ResultT m a] -> ShowS #

Generic (ResultT m a) Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

Associated Types

type Rep (ResultT m a) :: Type -> Type #

Methods

from :: ResultT m a -> Rep (ResultT m a) x #

to :: Rep (ResultT m a) x -> ResultT m a #

type Rep (ResultT m a) Source # 
Instance details

Defined in Control.Monad.Trans.Except.Result

type Rep (ResultT m a) = D1 (MetaData "ResultT" "Control.Monad.Trans.Except.Result" "either-result-0.3.0.0-2MdrAYLaj1r9H6Nl4angWI" True) (C1 (MetaCons "ResultT" PrefixI True) (S1 (MetaSel (Just "runResultT") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (ExceptT String m a))))

pattern ResultT :: Functor m => m (Result a) -> ResultT m a Source #

Construct and destruct Result.

runResultT :: Functor m => ResultT m a -> m (Result a) Source #

Unwrap ResultT.

mapResultT :: (Functor m, Functor n) => (m (Result a) -> n (Result b)) -> ResultT m a -> ResultT n b Source #

Map the unwrapped computation using the given function.

Exception operations

throwE :: Monad m => String -> ResultT m a Source #

Signal an exception.

catchE :: Monad m => ResultT m a -> (String -> ResultT m a) -> ResultT m a Source #

Handle an exception.

Lifting other operations

liftCallCC :: CallCC m (Either String a) (Either String b) -> CallCC (ResultT m) a b Source #

Lift a callCC operation to the new monad.

liftListen :: Monad m => Listen w m (Either String a) -> Listen w (ResultT m) a Source #

Lift a listen operation to the new monad.

liftPass :: Monad m => Pass w m (Either String a) -> Pass w (ResultT m) a Source #

Lift a pass operation to the new monad.

Orphan instances

Read a => Read (Result a) Source # 
Instance details

Show a => Show (Result a) Source # 
Instance details

Methods

showsPrec :: Int -> Result a -> ShowS #

show :: Result a -> String #

showList :: [Result a] -> ShowS #

Semigroup (Result a) Source # 
Instance details

Methods

(<>) :: Result a -> Result a -> Result a #

sconcat :: NonEmpty (Result a) -> Result a #

stimes :: Integral b => b -> Result a -> Result a #

Monoid (Result a) Source # 
Instance details

Methods

mempty :: Result a #

mappend :: Result a -> Result a -> Result a #

mconcat :: [Result a] -> Result a #