exitcode-0.1.0.6: Monad transformer for exit codes
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Exitcode

Synopsis

Types

data ExitcodeT f e a Source #

An exit code status where failing with a value `0` cannot be represented.

Transformer for either a (non-zero exit code value (Int) with error :: e) or a (value :: a).

Instances

Instances details
MonadRWS r w s f => MonadRWS r w s (ExitcodeT f e) Source # 
Instance details

Defined in Control.Exitcode

MonadReader r f => MonadReader r (ExitcodeT f e) Source # 
Instance details

Defined in Control.Exitcode

Methods

ask :: ExitcodeT f e r #

local :: (r -> r) -> ExitcodeT f e a -> ExitcodeT f e a #

reader :: (r -> a) -> ExitcodeT f e a #

MonadState s f => MonadState s (ExitcodeT f e) Source # 
Instance details

Defined in Control.Exitcode

Methods

get :: ExitcodeT f e s #

put :: s -> ExitcodeT f e () #

state :: (s -> (a, s)) -> ExitcodeT f e a #

MonadError e f => MonadError e (ExitcodeT f e') Source #
>>> throwError 99 :: ExitcodeT (Either Int) () String
ExitcodeT (Left 99)
>>> catchError exitsuccess0 (exitfailure 'x') :: ExitcodeT (Either Int) Char ()
ExitcodeT (Right (Right ()))
>>> catchError (exitfailure 'x' 99) (\_ -> exitsuccess0) :: ExitcodeT (Either Int) Char ()
ExitcodeT (Right (Left ('x',99)))
>>> catchError (exitfailure 'x' 99) (exitfailure 'y') :: ExitcodeT (Either Int) Char ()
ExitcodeT (Right (Left ('x',99)))
>>> catchError exitsuccess0 (\_ -> exitsuccess0) :: ExitcodeT (Either Int) () ()
ExitcodeT (Right (Right ()))
Instance details

Defined in Control.Exitcode

Methods

throwError :: e -> ExitcodeT f e' a #

catchError :: ExitcodeT f e' a -> (e -> ExitcodeT f e' a) -> ExitcodeT f e' a #

MonadWriter w f => MonadWriter w (ExitcodeT f e) Source #
>>> writer ('x', "abc") :: ExitcodeT ((,) String) () Char
ExitcodeT ("abc",Right 'x')
>>> listen (exitfailure 'x' 99 :: ExitcodeT ((,) String) Char ())
ExitcodeT ("",Left ('x',99))
>>> listen (exitsuccess 99 :: ExitcodeT ((,) String) () Int)
ExitcodeT ("",Right (99,""))
>>> tell "abc" :: ExitcodeT ((,) String) () ()
ExitcodeT ("abc",Right ())
>>> pass (exitsuccess ('x', reverse)) :: ExitcodeT ((,) String) () Char
ExitcodeT ("",Right 'x')
>>> pass (('x', reverse) <$ (exitfailure 'x' 99 :: ExitcodeT ((,) String) Char ()))
ExitcodeT ("",Left ('x',99))
Instance details

Defined in Control.Exitcode

Methods

writer :: (a, w) -> ExitcodeT f e a #

tell :: w -> ExitcodeT f e () #

listen :: ExitcodeT f e a -> ExitcodeT f e (a, w) #

pass :: ExitcodeT f e (a, w -> w) -> ExitcodeT f e a #

Functor f => Bifunctor (ExitcodeT f) Source # 
Instance details

Defined in Control.Exitcode

Methods

bimap :: (a -> b) -> (c -> d) -> ExitcodeT f a c -> ExitcodeT f b d #

first :: (a -> b) -> ExitcodeT f a c -> ExitcodeT f b c #

second :: (b -> c) -> ExitcodeT f a b -> ExitcodeT f a c #

Traversable f => Bitraversable (ExitcodeT f) Source # 
Instance details

Defined in Control.Exitcode

Methods

bitraverse :: Applicative f0 => (a -> f0 c) -> (b -> f0 d) -> ExitcodeT f a b -> f0 (ExitcodeT f c d) #

Foldable f => Bifoldable (ExitcodeT f) Source # 
Instance details

Defined in Control.Exitcode

Methods

bifold :: Monoid m => ExitcodeT f m m -> m #

bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> ExitcodeT f a b -> m #

bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> ExitcodeT f a b -> c #

bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> ExitcodeT f a b -> c #

Monad f => Monad (ExitcodeT f e) Source # 
Instance details

Defined in Control.Exitcode

Methods

(>>=) :: ExitcodeT f e a -> (a -> ExitcodeT f e b) -> ExitcodeT f e b #

(>>) :: ExitcodeT f e a -> ExitcodeT f e b -> ExitcodeT f e b #

return :: a -> ExitcodeT f e a #

Functor f => Functor (ExitcodeT f e) Source # 
Instance details

Defined in Control.Exitcode

Methods

fmap :: (a -> b) -> ExitcodeT f e a -> ExitcodeT f e b #

(<$) :: a -> ExitcodeT f e b -> ExitcodeT f e a #

Monad f => Applicative (ExitcodeT f e) Source # 
Instance details

Defined in Control.Exitcode

Methods

pure :: a -> ExitcodeT f e a #

(<*>) :: ExitcodeT f e (a -> b) -> ExitcodeT f e a -> ExitcodeT f e b #

liftA2 :: (a -> b -> c) -> ExitcodeT f e a -> ExitcodeT f e b -> ExitcodeT f e c #

(*>) :: ExitcodeT f e a -> ExitcodeT f e b -> ExitcodeT f e b #

(<*) :: ExitcodeT f e a -> ExitcodeT f e b -> ExitcodeT f e a #

Foldable f => Foldable (ExitcodeT f e) Source # 
Instance details

Defined in Control.Exitcode

Methods

fold :: Monoid m => ExitcodeT f e m -> m #

foldMap :: Monoid m => (a -> m) -> ExitcodeT f e a -> m #

foldMap' :: Monoid m => (a -> m) -> ExitcodeT f e a -> m #

foldr :: (a -> b -> b) -> b -> ExitcodeT f e a -> b #

foldr' :: (a -> b -> b) -> b -> ExitcodeT f e a -> b #

foldl :: (b -> a -> b) -> b -> ExitcodeT f e a -> b #

foldl' :: (b -> a -> b) -> b -> ExitcodeT f e a -> b #

foldr1 :: (a -> a -> a) -> ExitcodeT f e a -> a #

foldl1 :: (a -> a -> a) -> ExitcodeT f e a -> a #

toList :: ExitcodeT f e a -> [a] #

null :: ExitcodeT f e a -> Bool #

length :: ExitcodeT f e a -> Int #

elem :: Eq a => a -> ExitcodeT f e a -> Bool #

maximum :: Ord a => ExitcodeT f e a -> a #

minimum :: Ord a => ExitcodeT f e a -> a #

sum :: Num a => ExitcodeT f e a -> a #

product :: Num a => ExitcodeT f e a -> a #

Traversable f => Traversable (ExitcodeT f e) Source #
>>> traverse (\x -> x) [exitfailure 'x' 99] :: ExitcodeT Identity Char [()]
ExitcodeT (Identity (Left ('x',99)))
>>> traverse (\x -> x) [exitfailure 'x' 99, exitsuccess0] :: ExitcodeT Identity Char [()]
ExitcodeT (Identity (Left ('x',99)))
>>> traverse (\x -> x) [exitfailure 'x' 99, exitsuccess0, exitfailure 'y' 88] :: ExitcodeT Identity Char [()]
ExitcodeT (Identity (Left ('x',99)))
>>> traverse (\x -> x) [exitsuccess0, exitfailure 'x' 88] :: ExitcodeT Identity Char [()]
ExitcodeT (Identity (Left ('x',88)))
>>> traverse (\x -> x) [exitsuccess0] :: ExitcodeT Identity () [()]
ExitcodeT (Identity (Right [()]))
Instance details

Defined in Control.Exitcode

Methods

traverse :: Applicative f0 => (a -> f0 b) -> ExitcodeT f e a -> f0 (ExitcodeT f e b) #

sequenceA :: Applicative f0 => ExitcodeT f e (f0 a) -> f0 (ExitcodeT f e a) #

mapM :: Monad m => (a -> m b) -> ExitcodeT f e a -> m (ExitcodeT f e b) #

sequence :: Monad m => ExitcodeT f e (m a) -> m (ExitcodeT f e a) #

(Eq1 f, Eq e) => Eq1 (ExitcodeT f e) Source # 
Instance details

Defined in Control.Exitcode

Methods

liftEq :: (a -> b -> Bool) -> ExitcodeT f e a -> ExitcodeT f e b -> Bool #

(Ord1 f, Ord e) => Ord1 (ExitcodeT f e) Source # 
Instance details

Defined in Control.Exitcode

Methods

liftCompare :: (a -> b -> Ordering) -> ExitcodeT f e a -> ExitcodeT f e b -> Ordering #

(Show1 f, Show e) => Show1 (ExitcodeT f e) Source # 
Instance details

Defined in Control.Exitcode

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> ExitcodeT f e a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [ExitcodeT f e a] -> ShowS #

MonadIO f => MonadIO (ExitcodeT f e) Source # 
Instance details

Defined in Control.Exitcode

Methods

liftIO :: IO a -> ExitcodeT f e a #

Monad f => Apply (ExitcodeT f e) Source # 
Instance details

Defined in Control.Exitcode

Methods

(<.>) :: ExitcodeT f e (a -> b) -> ExitcodeT f e a -> ExitcodeT f e b #

(.>) :: ExitcodeT f e a -> ExitcodeT f e b -> ExitcodeT f e b #

(<.) :: ExitcodeT f e a -> ExitcodeT f e b -> ExitcodeT f e a #

liftF2 :: (a -> b -> c) -> ExitcodeT f e a -> ExitcodeT f e b -> ExitcodeT f e c #

MonadCont f => MonadCont (ExitcodeT f e) Source # 
Instance details

Defined in Control.Exitcode

Methods

callCC :: ((a -> ExitcodeT f e b) -> ExitcodeT f e a) -> ExitcodeT f e a #

Monad f => Alt (ExitcodeT f e) Source #
>>> exitsuccess "abc" <!> exitsuccess "def" :: ExitcodeT Identity () String
ExitcodeT (Identity (Right "abc"))
>>> exitsuccess "abc" <!> exitcodeValue () 99 "def" :: ExitcodeT Identity () String
ExitcodeT (Identity (Right "abc"))
>>> exitcodeValue 'x' 99 "abc" <!> exitsuccess "def" :: ExitcodeT Identity Char String
ExitcodeT (Identity (Right "def"))
>>> exitcodeValue 'x' 99 "abc" <!> exitcodeValue 'y' 88 "def" :: ExitcodeT Identity Char String
ExitcodeT (Identity (Left ('y',88)))
Instance details

Defined in Control.Exitcode

Methods

(<!>) :: ExitcodeT f e a -> ExitcodeT f e a -> ExitcodeT f e a #

some :: Applicative (ExitcodeT f e) => ExitcodeT f e a -> ExitcodeT f e [a] #

many :: Applicative (ExitcodeT f e) => ExitcodeT f e a -> ExitcodeT f e [a] #

Monad f => Bind (ExitcodeT f e) Source #
>>> exitsuccess "abc" >>- \s -> exitsuccess (reverse s) :: ExitcodeT Identity () String
ExitcodeT (Identity (Right "cba"))
>>> exitsuccess "abc" >>- \_ -> exitfailure () 99 :: ExitcodeT Identity () ()
ExitcodeT (Identity (Left ((),99)))
>>> exitfailure 'x' 99 >>- \_ -> exitsuccess "abc" :: ExitcodeT Identity Char String
ExitcodeT (Identity (Left ('x',99)))
>>> exitfailure 'x' 99 >>- \_ -> exitfailure 'y' 88 :: ExitcodeT Identity Char ()
ExitcodeT (Identity (Left ('x',99)))
>>> let loop = loop in exitfailure () 99 >>- loop :: ExitcodeT Identity () ()
ExitcodeT (Identity (Left ((),99)))
Instance details

Defined in Control.Exitcode

Methods

(>>-) :: ExitcodeT f e a -> (a -> ExitcodeT f e b) -> ExitcodeT f e b #

join :: ExitcodeT f e (ExitcodeT f e a) -> ExitcodeT f e a #

Extend f => Extend (ExitcodeT f e) Source #
>>> duplicated (exitfailure () 0) :: ExitcodeT Identity () (ExitcodeT Identity () ())
ExitcodeT (Identity (Right (ExitcodeT (Identity (Right ())))))
>>> duplicated (exitfailure () 99) :: ExitcodeT Identity () (ExitcodeT Identity () ())
ExitcodeT (Identity (Right (ExitcodeT (Identity (Left ((),99))))))
>>> duplicated (exitsuccess "abc") :: ExitcodeT Identity () (ExitcodeT Identity () String)
ExitcodeT (Identity (Right (ExitcodeT (Identity (Right "abc")))))
Instance details

Defined in Control.Exitcode

Methods

duplicated :: ExitcodeT f e a -> ExitcodeT f e (ExitcodeT f e a) #

extended :: (ExitcodeT f e a -> b) -> ExitcodeT f e a -> ExitcodeT f e b #

(Eq1 f, Eq e, Eq a) => Eq (ExitcodeT f e a) Source # 
Instance details

Defined in Control.Exitcode

Methods

(==) :: ExitcodeT f e a -> ExitcodeT f e a -> Bool #

(/=) :: ExitcodeT f e a -> ExitcodeT f e a -> Bool #

(Ord1 f, Ord e, Ord a) => Ord (ExitcodeT f e a) Source # 
Instance details

Defined in Control.Exitcode

Methods

compare :: ExitcodeT f e a -> ExitcodeT f e a -> Ordering #

(<) :: ExitcodeT f e a -> ExitcodeT f e a -> Bool #

(<=) :: ExitcodeT f e a -> ExitcodeT f e a -> Bool #

(>) :: ExitcodeT f e a -> ExitcodeT f e a -> Bool #

(>=) :: ExitcodeT f e a -> ExitcodeT f e a -> Bool #

max :: ExitcodeT f e a -> ExitcodeT f e a -> ExitcodeT f e a #

min :: ExitcodeT f e a -> ExitcodeT f e a -> ExitcodeT f e a #

(Show1 f, Show e, Show a) => Show (ExitcodeT f e a) Source # 
Instance details

Defined in Control.Exitcode

Methods

showsPrec :: Int -> ExitcodeT f e a -> ShowS #

show :: ExitcodeT f e a -> String #

showList :: [ExitcodeT f e a] -> ShowS #

(Semigroup a, Applicative f) => Semigroup (ExitcodeT f e a) Source #
>>> exitsuccess "abc" <> exitsuccess "def" :: ExitcodeT Identity () String
ExitcodeT (Identity (Right "abcdef"))
>>> exitsuccess "abc" <> exitcodeValue () 99 "def" :: ExitcodeT Identity () String
ExitcodeT (Identity (Right "abc"))
>>> exitcodeValue 'x' 99 "abc" <> exitsuccess "def" :: ExitcodeT Identity Char String
ExitcodeT (Identity (Right "def"))
>>> exitcodeValue 'x' 99 "abc" <> exitcodeValue 'y' 88 "def" :: ExitcodeT Identity Char String
ExitcodeT (Identity (Left ('y',88)))
Instance details

Defined in Control.Exitcode

Methods

(<>) :: ExitcodeT f e a -> ExitcodeT f e a -> ExitcodeT f e a #

sconcat :: NonEmpty (ExitcodeT f e a) -> ExitcodeT f e a #

stimes :: Integral b => b -> ExitcodeT f e a -> ExitcodeT f e a #

(Monoid a, Applicative f) => Monoid (ExitcodeT f e a) Source #
>>> mempty :: ExitcodeT Identity () String
ExitcodeT (Identity (Right ""))
Instance details

Defined in Control.Exitcode

Methods

mempty :: ExitcodeT f e a #

mappend :: ExitcodeT f e a -> ExitcodeT f e a -> ExitcodeT f e a #

mconcat :: [ExitcodeT f e a] -> ExitcodeT f e a #

type ExitcodeT0 f = ExitcodeT f () () Source #

type Exitcode0 = Exitcode () () Source #

type ExitcodeT1 f a = ExitcodeT f a a Source #

Construction

exitsuccess :: Applicative f => a -> ExitcodeT f e a Source #

Construct a succeeding exit code with the given value.

>>> exitsuccess "abc" :: ExitcodeT Identity () String
ExitcodeT (Identity (Right "abc"))

exitsuccess0 :: Applicative f => ExitcodeT f e () Source #

Construct a succeeding exit code with unit.

>>> exitsuccess0 :: ExitcodeT0 Identity
ExitcodeT (Identity (Right ()))

exitfailure :: Applicative f => e -> Int -> ExitcodeT f e () Source #

Construct a failing exit code with the given status.

If the given status is `0` then the exit code will succeed with unit.

>>> exitfailure 'x' 99 :: ExitcodeT Identity Char ()
ExitcodeT (Identity (Left ('x',99)))

exitfailure0 :: Applicative f => Int -> ExitcodeT0 f Source #

Construct a failing exit code with the given status.

If the given status is `0` then the exit code will succeed with unit.

exitcodeValue :: Applicative f => e -> Int -> a -> ExitcodeT f e a Source #

Construct an exit code with the given status. Associate a value of type e with a failing exit code and a value of the type a with a success exit code.

If the given status is `0` then the exit code will succeed with unit. >>> exitcodeValue x 99 "abc" :: ExitcodeT Identity Char String ExitcodeT (Identity (Left (x,99))) >>> exitcodeValue x 0 "abc" :: ExitcodeT Identity Char String ExitcodeT (Identity (Right "abc"))

exitcodeValue0 :: Applicative f => Int -> ExitcodeT0 f Source #

Construct an exit code with the given status.

If the given status is `0` then the exit code will succeed with unit.

>>> exitcodeValue0 99 :: ExitcodeT0 Identity
ExitcodeT (Identity (Left ((),99)))
>>> exitcodeValue0 0 :: ExitcodeT0 Identity
ExitcodeT (Identity (Right ()))

fromExitCode :: Functor f => f ExitCode -> ExitcodeT0 f Source #

From base exitcode.

>>> fromExitCode (Identity ExitSuccess)
ExitcodeT (Identity (Right ()))
>>> fromExitCode (Identity (ExitFailure 99))
ExitcodeT (Identity (Left ((),99)))

fromExitCode' :: ExitCode -> Exitcode0 Source #

From base exitcode.

>>> fromExitCode' ExitSuccess
ExitcodeT (Identity (Right ()))
>>> fromExitCode' (ExitFailure 99)
ExitcodeT (Identity (Left ((),99)))
>>> fromExitCode' (ExitFailure 0)
ExitcodeT (Identity (Right ()))

liftExitcode :: Functor f => f a -> ExitcodeT f e a Source #

liftExitcodeError :: Functor f => f (e, Int) -> a -> ExitcodeT f e a Source #

hoistExitcode :: (forall x. f x -> g x) -> ExitcodeT f e a -> ExitcodeT g e a Source #

embedExitcode :: Functor g => (forall x. f x -> ExitcodeT g e x) -> ExitcodeT f e a -> ExitcodeT g e a Source #

exitcode1 :: Applicative f => Int -> a -> ExitcodeT1 f a Source #

Construct an exitcode with an associated value.

>>> exitcode1 99 "abc" :: ExitcodeT1 Identity String
ExitcodeT (Identity (Left ("abc",99)))
>>> exitcode1 0 "abc" :: ExitcodeT1 Identity String
ExitcodeT (Identity (Right "abc"))

Extraction

runExitcodeT :: ExitcodeT f e a -> f (Either (e, Int) a) Source #

Extract either the non-zero value or the success value.

>>> runExitcodeT exitsuccess0 :: Identity (Either ((), Int) ())
Identity (Right ())
>>> runExitcodeT (exitfailure () 99) :: Identity (Either ((), Int) ())
Identity (Left ((),99))

runExitcodeT0 :: Functor f => ExitcodeT0 f -> f (Maybe Int) Source #

Extract either the non-zero value or Nothing.

>>> runExitcodeT0 exitsuccess0 :: Identity (Maybe Int)
Identity Nothing
>>> runExitcodeT0 (exitfailure () 99) :: Identity (Maybe Int)
Identity (Just 99)

runExitcode :: Exitcode e a -> Either (e, Int) a Source #

Extract either the non-zero value or the success value.

>>> runExitcode exitsuccess0 :: Either ((), Int) ()
Right ()
>>> runExitcode (exitfailure () 99) :: Either ((), Int) ()
Left ((),99)

runExitcode0 :: Exitcode0 -> Maybe Int Source #

Extract either the non-zero value or Nothing.

>>> runExitcode0 exitsuccess0 :: Maybe Int
Nothing
>>> runExitcode0 (exitfailure () 99) :: Maybe Int
Just 99

runExitcodeT1 :: ExitcodeT1 f a -> f (Either (a, Int) a) Source #

Extract either the non-zero value or the success value.

>>> runExitcodeT1 exitsuccess0
Right ()
>>> runExitcodeT1 (exitfailure () 99) :: Identity (Either ((), Int) ())
Identity (Left ((),99))
>>> runExitcodeT1 (exitcode1 0 "abc") :: Identity (Either (String, Int) String)
Identity (Right "abc")
>>> runExitcodeT1 (exitcode1 99 "abc") :: Identity (Either (String, Int) String)
Identity (Left ("abc",99))

runExitcode1 :: Exitcode1 a -> Either (a, Int) a Source #

Extract either the non-zero value or the success value.

>>> runExitcode1 exitsuccess0
Right ()
>>> runExitcode1 (exitfailure () 99)
Left ((),99)
>>> runExitcode1 (exitcode1 0 "abc")
Right "abc"
>>> runExitcode1 (exitcode1 99 "abc")
Left ("abc",99)

Optics

exitCode :: (Functor f, Functor g) => Iso (f ExitCode) (g ExitCode) (ExitcodeT0 (MaybeT f)) (ExitcodeT0 (MaybeT g)) Source #

Isomorphism from base exitcode to underlying `Maybe (Either Int ())` where Int is non-zero.

>>> view exitCode (Identity (ExitFailure 99))
ExitcodeT (MaybeT (Identity (Just (Left ((),99)))))
>>> view exitCode (Identity ExitSuccess)
ExitcodeT (MaybeT (Identity (Just (Right ()))))
>>> Control.Lens.review exitCode (exitfailure () 99) :: Identity ExitCode
Identity (ExitFailure 99)
>>> Control.Lens.review exitCode exitsuccess0 :: Identity ExitCode
Identity ExitSuccess

_ExitcodeInt :: (Functor f, Functor f') => Iso (ExitcodeT0 f) (ExitcodeT0 f') (f Int) (f' Int) Source #

Isomorphism to integer.

>>> view _ExitcodeInt exitsuccess0 :: [Int]
[0]
>>> view _ExitcodeInt (exitfailure0 99) :: [Int]
[99]
>>> review _ExitcodeInt [0]
ExitcodeT [Right ()]
>>> review _ExitcodeInt [99]
ExitcodeT [Left ((),99)]

_ExitcodeInt' :: Traversable f => Traversal' (ExitcodeT0 f) Int Source #

Setter to integer.

>>> > preview _ExitcodeInt' (exitsuccess0 :: ExitcodeT [] () ())
Just 0
>>> preview _ExitcodeInt' (exitfailure0 99 :: ExitcodeT [] () ())
Just 99
>>> preview _ExitcodeInt' (exitfailure0 0 :: ExitcodeT [] () ())
Just 0
>>> over _ExitcodeInt' (subtract 1) exitsuccess0 :: ExitcodeT0 Identity
ExitcodeT (Identity (Left ((),-1)))
>>> over _ExitcodeInt' (subtract 1) (exitfailure0 99) :: ExitcodeT0 Identity
ExitcodeT (Identity (Left ((),98)))
>>> over _ExitcodeInt' (subtract 1) (exitfailure0 1) :: ExitcodeT0 Identity
ExitcodeT (Identity (Right ()))

_ExitFailure :: Traversable f => Traversal (ExitcodeT f e ()) (ExitcodeT f e' ()) (e, Int) (e', Int) Source #

A traversal to exit failure.

>>> preview _ExitFailure (exitfailure () 99 :: ExitcodeT0 Identity)
Just ((),99)
>>> preview _ExitFailure (exitsuccess0 :: ExitcodeT0 Identity)
Nothing
>>> over _ExitFailure (\(e, n) -> (e + 1, n + 1)) (exitsuccess0 :: ExitcodeT Identity Int ())
ExitcodeT (Identity (Right ()))
>>> over _ExitFailure (\(e, n) -> (reverse e, n + 1)) (exitfailure "abc" 1 :: ExitcodeT Identity String ())
ExitcodeT (Identity (Left ("cba",2)))
>>> over _ExitFailure (\(e, n) -> (reverse e, n - 1)) (exitfailure "abc" 1 :: ExitcodeT Identity String ())
ExitcodeT (Identity (Right ()))

_ExitFailureError :: Traversable f => Traversal (ExitcodeT f e a) (ExitcodeT f e' a) e e' Source #

A traversal over the associated failing value.

>>> over _ExitFailureError reverse exitsuccess0 :: ExitcodeT Identity [Int] ()
ExitcodeT (Identity (Right ()))
>>> over _ExitFailureError reverse (exitfailure "abc" 99) :: ExitcodeT Identity String ()
ExitcodeT (Identity (Left ("cba",99)))
>>> over _ExitFailureError reverse (exitfailure "abc" 0) :: ExitcodeT Identity String ()
ExitcodeT (Identity (Right ()))
>>> preview _ExitFailureError (exitfailure () 99 :: ExitcodeT0 Identity)
Just ()
>>> preview _ExitFailureError (exitsuccess0 :: ExitcodeT0 Identity)
Nothing

_ExitSuccess :: Prism (Exitcode e a) (Exitcode e a') a a' Source #

A prism to exit success.

>>> over _ExitSuccess (\x -> x) (exitfailure0 99)
ExitcodeT (Identity (Left ((),99)))
>>> over _ExitSuccess (\x -> x) (exitfailure0 0)
ExitcodeT (Identity (Right ()))
>>> over _ExitSuccess (\x -> x) (exitfailure0 0)
ExitcodeT (Identity (Right ()))
>>> preview _ExitSuccess (exitfailure () 99)
Nothing
>>> preview _ExitSuccess exitsuccess0
Just ()
>>> Control.Lens.review _ExitSuccess "abc" :: ExitcodeT Identity () String
ExitcodeT (Identity (Right "abc"))

_Exitcode1 :: Lens (Exitcode1 a) (Exitcode1 a') a a' Source #

A lens to the value associated with an exitcode.

>>> view _Exitcode1 (exitcode1 0 "abc")
"abc"
>>> view _Exitcode1 (exitcode1 99 "abc")
"abc"
>>> view _Exitcode1 (exitcodeValue "abc" 0 "def")
"def"
>>> view _Exitcode1 (exitcodeValue "abc" 99 "def")
"abc"
>>> over _Exitcode1 reverse (exitcode1 0 "abc")
ExitcodeT (Identity (Right "cba"))
>>> over _Exitcode1 reverse (exitcode1 99 "abc")
ExitcodeT (Identity (Left ("cba",99)))
>>> over _Exitcode1 reverse (exitcodeValue "abc" 0 "def")
ExitcodeT (Identity (Right "fed"))
>>> over _Exitcode1 reverse (exitcodeValue "abc" 99 "def")
ExitcodeT (Identity (Left ("cba",99)))