Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Control.Exitcode
Synopsis
- data ExitcodeT f e a
- type Exitcode e a = ExitcodeT Identity e a
- type ExitcodeT0 f = ExitcodeT f () ()
- type Exitcode0 = Exitcode () ()
- type ExitcodeT1 f a = ExitcodeT f a a
- type Exitcode1 a = ExitcodeT1 Identity a
- exitsuccess :: Applicative f => a -> ExitcodeT f e a
- exitsuccess0 :: Applicative f => ExitcodeT f e ()
- exitfailure :: Applicative f => e -> Int -> ExitcodeT f e ()
- exitfailure0 :: Applicative f => Int -> ExitcodeT0 f
- exitcodeValue :: Applicative f => e -> Int -> a -> ExitcodeT f e a
- exitcodeValue0 :: Applicative f => Int -> ExitcodeT0 f
- fromExitCode :: Functor f => f ExitCode -> ExitcodeT0 f
- fromExitCode' :: ExitCode -> Exitcode0
- liftExitcode :: Functor f => f a -> ExitcodeT f e a
- liftExitcodeError :: Functor f => f (e, Int) -> a -> ExitcodeT f e a
- liftExitcodeError0 :: Functor f => f Int -> ExitcodeT f () ()
- hoistExitcode :: (forall x. f x -> g x) -> ExitcodeT f e a -> ExitcodeT g e a
- embedExitcode :: Functor g => (forall x. f x -> ExitcodeT g e x) -> ExitcodeT f e a -> ExitcodeT g e a
- exitcode1 :: Applicative f => Int -> a -> ExitcodeT1 f a
- runExitcodeT :: ExitcodeT f e a -> f (Either (e, Int) a)
- runExitcodeT0 :: Functor f => ExitcodeT0 f -> f (Maybe Int)
- runExitcode :: Exitcode e a -> Either (e, Int) a
- runExitcode0 :: Exitcode0 -> Maybe Int
- runExitcodeT1 :: ExitcodeT1 f a -> f (Either (a, Int) a)
- runExitcode1 :: Exitcode1 a -> Either (a, Int) a
- tryExitcode :: Exception e' => ExitcodeT IO e a -> ExitcodeT (ExceptT e' IO) e a
- liftTryExitcode :: Exception e' => IO a -> ExitcodeT (ExceptT e' IO) e a
- exitCode :: (Functor f, Functor g) => Iso (f ExitCode) (g ExitCode) (ExitcodeT0 (MaybeT f)) (ExitcodeT0 (MaybeT g))
- _ExitcodeInt :: (Functor f, Functor f') => Iso (ExitcodeT0 f) (ExitcodeT0 f') (f Int) (f' Int)
- _ExitcodeInt' :: Traversable f => Traversal' (ExitcodeT0 f) Int
- _ExitFailure :: Traversable f => Traversal (ExitcodeT f e ()) (ExitcodeT f e' ()) (e, Int) (e', Int)
- _ExitFailureError :: Traversable f => Traversal (ExitcodeT f e a) (ExitcodeT f e' a) e e'
- _ExitSuccess :: Prism (Exitcode e a) (Exitcode e a') a a'
- _Exitcode1 :: Lens (Exitcode1 a) (Exitcode1 a') a a'
Types
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
MonadRWS r w s f => MonadRWS r w s (ExitcodeT f e) Source # | |
Defined in Control.Exitcode | |
MonadError e f => MonadError e (ExitcodeT f e') Source # |
|
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 # | |
MonadReader r f => MonadReader r (ExitcodeT f e) Source # | |
MonadState s f => MonadState s (ExitcodeT f e) Source # | |
MonadWriter w f => MonadWriter w (ExitcodeT f e) Source # |
|
Foldable f => Bifoldable (ExitcodeT f) Source # | |
Functor f => Bifunctor (ExitcodeT f) Source # | |
Traversable f => Bitraversable (ExitcodeT f) Source # | |
Defined in Control.Exitcode Methods bitraverse :: Applicative f0 => (a -> f0 c) -> (b -> f0 d) -> ExitcodeT f a b -> f0 (ExitcodeT f c d) # | |
MonadIO f => MonadIO (ExitcodeT f e) Source # | |
Defined in Control.Exitcode | |
Foldable f => Foldable (ExitcodeT f e) Source # | |
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 # | |
(Eq1 f, Eq e) => Eq1 (ExitcodeT f e) Source # | |
(Ord1 f, Ord e) => Ord1 (ExitcodeT f e) Source # | |
Defined in Control.Exitcode | |
(Show1 f, Show e) => Show1 (ExitcodeT f e) Source # | |
Traversable f => Traversable (ExitcodeT f e) Source # |
|
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) # | |
Monad f => Applicative (ExitcodeT f e) Source # | |
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 # | |
Functor f => Functor (ExitcodeT f e) Source # | |
Monad f => Monad (ExitcodeT f e) Source # | |
MonadCont f => MonadCont (ExitcodeT f e) Source # | |
Monad f => Alt (ExitcodeT f e) Source # |
|
Monad f => Apply (ExitcodeT f e) Source # | |
Defined in Control.Exitcode | |
Monad f => Bind (ExitcodeT f e) Source # |
|
Extend f => Extend (ExitcodeT f e) Source # |
|
(Monoid a, Applicative f) => Monoid (ExitcodeT f e a) Source # |
|
(Semigroup a, Applicative f) => Semigroup (ExitcodeT f e a) Source # |
|
(Show1 f, Show e, Show a) => Show (ExitcodeT f e a) Source # | |
(Eq1 f, Eq e, Eq a) => Eq (ExitcodeT f e a) Source # | |
(Ord1 f, Ord e, Ord a) => Ord (ExitcodeT f e a) Source # | |
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 # |
type ExitcodeT0 f = ExitcodeT f () () Source #
type ExitcodeT1 f a = ExitcodeT f a a Source #
type Exitcode1 a = ExitcodeT1 Identity 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 #
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)
Exceptions
tryExitcode :: Exception e' => ExitcodeT IO e a -> ExitcodeT (ExceptT e' IO) e a Source #
Try the IO action producing the exitcode, possibly throwing an exception.
liftTryExitcode :: Exception e' => IO a -> ExitcodeT (ExceptT e' IO) e a Source #
Try the IO action producing the exitcode, possibly throwing an exception.
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)))