{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -Wall #-}
module Control.Exitcode.Exitcode
(
Exitcode,
Exitcode',
ExitcodeBifunctor (..),
ExitcodeBifunctor',
mkExitcode,
mkExitcode',
mkExitSuccess,
mkExitSuccess',
mkExitFailure,
mkExitFailure',
mkExitFailure1,
mkExitFailure1',
mkExitFailure_1,
mkExitFailure_1',
fromExitCode,
fromExitCode',
toExitCode,
toExitCode',
hoistExitcode,
embedExitcode,
bimapExitcode,
runExitcode,
maybeExitcode,
maybeExitcode',
tryExitcode,
liftTryExitcode,
exitCode,
_Exitcode1,
_Exitcode1',
_ExitFailure,
_ExitFailure',
_ExitFailureCode,
_ExitFailureCode',
_ExitFailureValue,
_ExitFailureValue',
_ExitSuccess,
_ExitSuccess',
)
where
import Control.Applicative (Applicative (pure, (<*>)))
import Control.DeepSeq (NFData (rnf), NFData1 (liftRnf))
import Control.Exception (Exception, try)
import Control.Lens (FoldableWithIndex (ifoldMap), FunctorWithIndex (imap), Iso, Lens, Prism, Prism', Traversal, Traversal', TraversableWithIndex (itraverse), iso, preview, prism, prism', review, _Wrapped)
import Control.Monad (Monad ((>>=)), join)
import Control.Monad.Cont.Class (MonadCont (..))
import Control.Monad.Error.Class (MonadError (..))
import Control.Monad.Except (ExceptT (..))
import Control.Monad.Fix (MonadFix (mfix))
import Control.Monad.IO.Class (MonadIO (..))
import Control.Monad.RWS.Class (MonadRWS)
import Control.Monad.Reader (MonadReader (ask, local), asks)
import Control.Monad.State.Lazy (MonadState (get, put))
import Control.Monad.Trans.Class (MonadTrans (lift))
import Control.Monad.Trans.Maybe (MaybeT (MaybeT))
import Control.Monad.Writer.Class (MonadWriter (..))
import Data.Bifoldable (Bifoldable (bifoldMap))
import Data.Bifunctor (Bifunctor (bimap))
import Data.Bitraversable (Bitraversable (bitraverse))
import Data.Either (Either (..), either)
import Data.Eq (Eq ((==)))
import Data.Foldable (Foldable (foldMap, toList))
import Data.Function (const, id, ($), (.))
import Data.Functor (Functor (fmap), (<$>))
import Data.Functor.Alt (Alt ((<!>)))
import Data.Functor.Apply (Apply ((<.>)))
import Data.Functor.Bind (Bind ((>>-)))
import Data.Functor.Bind.Trans (BindTrans (..))
import Data.Functor.Classes
( Eq1 (liftEq),
Ord1 (liftCompare),
Show1 (liftShowList, liftShowsPrec),
)
import Data.Functor.Extend (Extend (duplicated, extended))
import Data.Functor.Identity (Identity (Identity, runIdentity))
import Data.Int (Int)
import Data.Maybe (Maybe (Just, Nothing))
import Data.Monoid (Monoid (mempty))
import Data.Ord (Ord (compare), (>))
import Data.Semigroup (Semigroup ((<>)))
import Data.Traversable (Traversable (traverse), mapAccumL)
import Data.Tuple (fst, snd)
import GHC.Generics (Generic)
import GHC.Show (Show (showsPrec), showParen, showString)
import Natural (NotZero, _NotZero, notZeroOr)
import Prelude (seq)
import System.Exit (ExitCode (ExitFailure, ExitSuccess))
import System.IO (IO)
newtype Exitcode e f a
= Exitcode (f (Either (e, NotZero) a))
deriving stock ((forall x. Exitcode e f a -> Rep (Exitcode e f a) x)
-> (forall x. Rep (Exitcode e f a) x -> Exitcode e f a)
-> Generic (Exitcode e f a)
forall x. Rep (Exitcode e f a) x -> Exitcode e f a
forall x. Exitcode e f a -> Rep (Exitcode e f a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall e (f :: * -> *) a x.
Rep (Exitcode e f a) x -> Exitcode e f a
forall e (f :: * -> *) a x.
Exitcode e f a -> Rep (Exitcode e f a) x
$cfrom :: forall e (f :: * -> *) a x.
Exitcode e f a -> Rep (Exitcode e f a) x
from :: forall x. Exitcode e f a -> Rep (Exitcode e f a) x
$cto :: forall e (f :: * -> *) a x.
Rep (Exitcode e f a) x -> Exitcode e f a
to :: forall x. Rep (Exitcode e f a) x -> Exitcode e f a
Generic)
type Exitcode' e a =
Exitcode e Identity a
{-# INLINE runExitcode #-}
runExitcode ::
Exitcode e f a ->
f (Either (e, NotZero) a)
runExitcode :: forall e (f :: * -> *) a.
Exitcode e f a -> f (Either (e, NotZero) a)
runExitcode (Exitcode f (Either (e, NotZero) a)
x) =
f (Either (e, NotZero) a)
x
{-# INLINE maybeExitcode #-}
maybeExitcode ::
(Functor f) =>
Exitcode e f a ->
f (Maybe NotZero)
maybeExitcode :: forall (f :: * -> *) e a.
Functor f =>
Exitcode e f a -> f (Maybe NotZero)
maybeExitcode (Exitcode f (Either (e, NotZero) a)
x) =
(Either (e, NotZero) a -> Maybe NotZero)
-> f (Either (e, NotZero) a) -> f (Maybe NotZero)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (((e, NotZero) -> Maybe NotZero)
-> (a -> Maybe NotZero) -> Either (e, NotZero) a -> Maybe NotZero
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (NotZero -> Maybe NotZero
forall a. a -> Maybe a
Just (NotZero -> Maybe NotZero)
-> ((e, NotZero) -> NotZero) -> (e, NotZero) -> Maybe NotZero
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (e, NotZero) -> NotZero
forall a b. (a, b) -> b
snd) (Maybe NotZero -> a -> Maybe NotZero
forall a b. a -> b -> a
const Maybe NotZero
forall a. Maybe a
Nothing)) f (Either (e, NotZero) a)
x
{-# INLINE maybeExitcode' #-}
maybeExitcode' ::
Exitcode' e a ->
Maybe NotZero
maybeExitcode' :: forall e a. Exitcode' e a -> Maybe NotZero
maybeExitcode' (Exitcode Identity (Either (e, NotZero) a)
x) =
((e, NotZero) -> Maybe NotZero)
-> (a -> Maybe NotZero) -> Either (e, NotZero) a -> Maybe NotZero
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (NotZero -> Maybe NotZero
forall a. a -> Maybe a
Just (NotZero -> Maybe NotZero)
-> ((e, NotZero) -> NotZero) -> (e, NotZero) -> Maybe NotZero
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (e, NotZero) -> NotZero
forall a b. (a, b) -> b
snd) (Maybe NotZero -> a -> Maybe NotZero
forall a b. a -> b -> a
const Maybe NotZero
forall a. Maybe a
Nothing) (Identity (Either (e, NotZero) a) -> Either (e, NotZero) a
forall a. Identity a -> a
runIdentity Identity (Either (e, NotZero) a)
x)
{-# INLINE exitCode #-}
exitCode ::
(Functor f, Functor g) =>
Iso
(f ExitCode)
(g ExitCode)
(Exitcode () (MaybeT f) ())
(Exitcode () (MaybeT g) ())
exitCode :: forall (f :: * -> *) (g :: * -> *).
(Functor f, Functor g) =>
Iso
(f ExitCode)
(g ExitCode)
(Exitcode () (MaybeT f) ())
(Exitcode () (MaybeT g) ())
exitCode =
(f ExitCode -> Exitcode () (MaybeT f) ())
-> (Exitcode () (MaybeT g) () -> g ExitCode)
-> Iso
(f ExitCode)
(g ExitCode)
(Exitcode () (MaybeT f) ())
(Exitcode () (MaybeT g) ())
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
( MaybeT f (Either ((), NotZero) ()) -> Exitcode () (MaybeT f) ()
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode
(MaybeT f (Either ((), NotZero) ()) -> Exitcode () (MaybeT f) ())
-> (f ExitCode -> MaybeT f (Either ((), NotZero) ()))
-> f ExitCode
-> Exitcode () (MaybeT f) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f (Maybe (Either ((), NotZero) ()))
-> MaybeT f (Either ((), NotZero) ())
forall (m :: * -> *) a. m (Maybe a) -> MaybeT m a
MaybeT
(f (Maybe (Either ((), NotZero) ()))
-> MaybeT f (Either ((), NotZero) ()))
-> (f ExitCode -> f (Maybe (Either ((), NotZero) ())))
-> f ExitCode
-> MaybeT f (Either ((), NotZero) ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ExitCode -> Maybe (Either ((), NotZero) ()))
-> f ExitCode -> f (Maybe (Either ((), NotZero) ()))
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
( \case
ExitCode
ExitSuccess -> Either ((), NotZero) () -> Maybe (Either ((), NotZero) ())
forall a. a -> Maybe a
Just (() -> Either ((), NotZero) ()
forall a b. b -> Either a b
Right ())
ExitFailure Int
n -> (NotZero -> Either ((), NotZero) ())
-> Maybe NotZero -> Maybe (Either ((), NotZero) ())
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (((), NotZero) -> Either ((), NotZero) ()
forall a b. a -> Either a b
Left (((), NotZero) -> Either ((), NotZero) ())
-> (NotZero -> ((), NotZero)) -> NotZero -> Either ((), NotZero) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((),)) (Getting (First NotZero) Int NotZero -> Int -> Maybe NotZero
forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview Getting (First NotZero) Int NotZero
forall a. AsNotZero a => Prism' a NotZero
Prism' Int NotZero
_NotZero Int
n)
)
)
( \(Exitcode (MaybeT g (Maybe (Either ((), NotZero) ()))
x)) ->
(Maybe (Either ((), NotZero) ()) -> ExitCode)
-> g (Maybe (Either ((), NotZero) ())) -> g ExitCode
forall a b. (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
( \case
Just (Right ()) -> ExitCode
ExitSuccess
Maybe (Either ((), NotZero) ())
Nothing -> Int -> ExitCode
ExitFailure Int
0
Just (Left ((), NotZero
nz)) -> Int -> ExitCode
ExitFailure (AReview Int NotZero -> NotZero -> Int
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview Int NotZero
forall a. AsNotZero a => Prism' a NotZero
Prism' Int NotZero
_NotZero NotZero
nz)
)
g (Maybe (Either ((), NotZero) ()))
x
)
{-# INLINE _Exitcode1 #-}
_Exitcode1 ::
Lens
(Exitcode' a a)
(Exitcode' a' a')
a
a'
_Exitcode1 :: forall a a' (f :: * -> *).
Functor f =>
(a -> f a') -> Exitcode' a a -> f (Exitcode' a' a')
_Exitcode1 a -> f a'
g (Exitcode (Identity Either (a, NotZero) a
x)) =
(a' -> Exitcode' a' a') -> f a' -> f (Exitcode' a' a')
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
(\a'
a' -> Identity (Either (a', NotZero) a') -> Exitcode' a' a'
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (Either (a', NotZero) a' -> Identity (Either (a', NotZero) a')
forall a. a -> Identity a
Identity (((a, NotZero) -> Either (a', NotZero) a')
-> (a -> Either (a', NotZero) a')
-> Either (a, NotZero) a
-> Either (a', NotZero) a'
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (\(a
_, NotZero
n) -> (a', NotZero) -> Either (a', NotZero) a'
forall a b. a -> Either a b
Left (a'
a', NotZero
n)) (Either (a', NotZero) a' -> a -> Either (a', NotZero) a'
forall a b. a -> b -> a
const (a' -> Either (a', NotZero) a'
forall a b. b -> Either a b
Right a'
a')) Either (a, NotZero) a
x)))
(a -> f a'
g (((a, NotZero) -> a) -> (a -> a) -> Either (a, NotZero) a -> a
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (a, NotZero) -> a
forall a b. (a, b) -> a
fst a -> a
forall a. a -> a
id Either (a, NotZero) a
x))
{-# INLINE _Exitcode1' #-}
_Exitcode1' ::
(Traversable f) =>
Traversal' (Exitcode a f a) (f a)
_Exitcode1' :: forall (f :: * -> *) a.
Traversable f =>
Traversal' (Exitcode a f a) (f a)
_Exitcode1' f a -> f (f a)
g (Exitcode f (Either (a, NotZero) a)
x) =
(f a -> Exitcode a f a) -> f (f a) -> f (Exitcode a f a)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
( \f a
fa' ->
let ([a]
_, f (Either (a, NotZero) a)
result) =
([a] -> Either (a, NotZero) a -> ([a], Either (a, NotZero) a))
-> [a]
-> f (Either (a, NotZero) a)
-> ([a], f (Either (a, NotZero) a))
forall (t :: * -> *) s a b.
Traversable t =>
(s -> a -> (s, b)) -> s -> t a -> (s, t b)
mapAccumL
( \[a]
as' Either (a, NotZero) a
struct -> case [a]
as' of
(a
a' : [a]
rest) -> ([a]
rest, ((a, NotZero) -> Either (a, NotZero) a)
-> (a -> Either (a, NotZero) a)
-> Either (a, NotZero) a
-> Either (a, NotZero) a
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (\(a
_, NotZero
n) -> (a, NotZero) -> Either (a, NotZero) a
forall a b. a -> Either a b
Left (a
a', NotZero
n)) (Either (a, NotZero) a -> a -> Either (a, NotZero) a
forall a b. a -> b -> a
const (a -> Either (a, NotZero) a
forall a b. b -> Either a b
Right a
a')) Either (a, NotZero) a
struct)
[] -> ([], Either (a, NotZero) a
struct)
)
(f a -> [a]
forall a. f a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList f a
fa')
f (Either (a, NotZero) a)
x
in f (Either (a, NotZero) a) -> Exitcode a f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode f (Either (a, NotZero) a)
result
)
(f a -> f (f a)
g ((Either (a, NotZero) a -> a) -> f (Either (a, NotZero) a) -> f a
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (((a, NotZero) -> a) -> (a -> a) -> Either (a, NotZero) a -> a
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (a, NotZero) -> a
forall a b. (a, b) -> a
fst a -> a
forall a. a -> a
id) f (Either (a, NotZero) a)
x))
{-# INLINE _ExitFailure #-}
_ExitFailure :: (Traversable f) => Prism' (Exitcode e f a) (f (e, NotZero))
_ExitFailure :: forall (f :: * -> *) e a.
Traversable f =>
Prism' (Exitcode e f a) (f (e, NotZero))
_ExitFailure =
(f (e, NotZero) -> Exitcode e f a)
-> (Exitcode e f a -> Maybe (f (e, NotZero)))
-> Prism
(Exitcode e f a) (Exitcode e f a) (f (e, NotZero)) (f (e, NotZero))
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism'
(f (Either (e, NotZero) a) -> Exitcode e f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (f (Either (e, NotZero) a) -> Exitcode e f a)
-> (f (e, NotZero) -> f (Either (e, NotZero) a))
-> f (e, NotZero)
-> Exitcode e f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((e, NotZero) -> Either (e, NotZero) a)
-> f (e, NotZero) -> f (Either (e, NotZero) a)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (e, NotZero) -> Either (e, NotZero) a
forall a b. a -> Either a b
Left)
(\(Exitcode f (Either (e, NotZero) a)
x) -> (Either (e, NotZero) a -> Maybe (e, NotZero))
-> f (Either (e, NotZero) a) -> Maybe (f (e, NotZero))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> f a -> f (f b)
traverse (((e, NotZero) -> Maybe (e, NotZero))
-> (a -> Maybe (e, NotZero))
-> Either (e, NotZero) a
-> Maybe (e, NotZero)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (e, NotZero) -> Maybe (e, NotZero)
forall a. a -> Maybe a
Just (Maybe (e, NotZero) -> a -> Maybe (e, NotZero)
forall a b. a -> b -> a
const Maybe (e, NotZero)
forall a. Maybe a
Nothing)) f (Either (e, NotZero) a)
x)
{-# INLINE _ExitFailure' #-}
_ExitFailure' :: Prism (Exitcode' e a) (Exitcode' e' a) (e, NotZero) (e', NotZero)
_ExitFailure' :: forall e a e' (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p (e, NotZero) (f (e', NotZero))
-> p (Exitcode' e a) (f (Exitcode' e' a))
_ExitFailure' =
((e', NotZero) -> Exitcode' e' a)
-> (Exitcode' e a -> Either (Exitcode' e' a) (e, NotZero))
-> Prism
(Exitcode' e a) (Exitcode' e' a) (e, NotZero) (e', NotZero)
forall b t s a. (b -> t) -> (s -> Either t a) -> Prism s t a b
prism
(\(e'
e', NotZero
nz) -> Identity (Either (e', NotZero) a) -> Exitcode' e' a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (Either (e', NotZero) a -> Identity (Either (e', NotZero) a)
forall a. a -> Identity a
Identity ((e', NotZero) -> Either (e', NotZero) a
forall a b. a -> Either a b
Left (e'
e', NotZero
nz))))
(\(Exitcode (Identity Either (e, NotZero) a
x)) -> case Either (e, NotZero) a
x of
Left (e
e, NotZero
nz) -> (e, NotZero) -> Either (Exitcode' e' a) (e, NotZero)
forall a b. b -> Either a b
Right (e
e, NotZero
nz)
Right a
a -> Exitcode' e' a -> Either (Exitcode' e' a) (e, NotZero)
forall a b. a -> Either a b
Left (Identity (Either (e', NotZero) a) -> Exitcode' e' a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (Either (e', NotZero) a -> Identity (Either (e', NotZero) a)
forall a. a -> Identity a
Identity (a -> Either (e', NotZero) a
forall a b. b -> Either a b
Right a
a))))
{-# INLINE _ExitFailureCode #-}
_ExitFailureCode :: (Traversable f) => Traversal' (Exitcode e f a) (f NotZero)
_ExitFailureCode :: forall (f :: * -> *) e a.
Traversable f =>
Traversal' (Exitcode e f a) (f NotZero)
_ExitFailureCode f NotZero -> f (f NotZero)
g (Exitcode f (Either (e, NotZero) a)
x) =
case (Either (e, NotZero) a -> Maybe (e, NotZero))
-> f (Either (e, NotZero) a) -> Maybe (f (e, NotZero))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> f a -> f (f b)
traverse (((e, NotZero) -> Maybe (e, NotZero))
-> (a -> Maybe (e, NotZero))
-> Either (e, NotZero) a
-> Maybe (e, NotZero)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (e, NotZero) -> Maybe (e, NotZero)
forall a. a -> Maybe a
Just (Maybe (e, NotZero) -> a -> Maybe (e, NotZero)
forall a b. a -> b -> a
const Maybe (e, NotZero)
forall a. Maybe a
Nothing)) f (Either (e, NotZero) a)
x of
Maybe (f (e, NotZero))
Nothing -> Exitcode e f a -> f (Exitcode e f a)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (f (Either (e, NotZero) a) -> Exitcode e f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode f (Either (e, NotZero) a)
x)
Just f (e, NotZero)
pairs ->
let rebuild :: t NotZero -> Exitcode e f a
rebuild t NotZero
newNZs =
let ([NotZero]
_, f (e, NotZero)
result) =
([NotZero] -> (e, NotZero) -> ([NotZero], (e, NotZero)))
-> [NotZero] -> f (e, NotZero) -> ([NotZero], f (e, NotZero))
forall (t :: * -> *) s a b.
Traversable t =>
(s -> a -> (s, b)) -> s -> t a -> (s, t b)
mapAccumL
( \[NotZero]
ns (e
e, NotZero
nz) -> case [NotZero]
ns of
NotZero
n : [NotZero]
rest -> ([NotZero]
rest, (e
e, NotZero
n))
[] -> ([], (e
e, NotZero
nz))
)
(t NotZero -> [NotZero]
forall a. t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t NotZero
newNZs)
f (e, NotZero)
pairs
in f (Either (e, NotZero) a) -> Exitcode e f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (((e, NotZero) -> Either (e, NotZero) a)
-> f (e, NotZero) -> f (Either (e, NotZero) a)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (e, NotZero) -> Either (e, NotZero) a
forall a b. a -> Either a b
Left f (e, NotZero)
result)
in f NotZero -> Exitcode e f a
forall {t :: * -> *} {a}. Foldable t => t NotZero -> Exitcode e f a
rebuild (f NotZero -> Exitcode e f a)
-> f (f NotZero) -> f (Exitcode e f a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f NotZero -> f (f NotZero)
g (((e, NotZero) -> NotZero) -> f (e, NotZero) -> f NotZero
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (e, NotZero) -> NotZero
forall a b. (a, b) -> b
snd f (e, NotZero)
pairs)
{-# INLINE _ExitFailureCode' #-}
_ExitFailureCode' :: Traversal' (Exitcode' e a) NotZero
_ExitFailureCode' :: forall e a (f :: * -> *).
Applicative f =>
(NotZero -> f NotZero) -> Exitcode' e a -> f (Exitcode' e a)
_ExitFailureCode' = (Identity NotZero -> f (Identity NotZero))
-> Exitcode e Identity a -> f (Exitcode e Identity a)
Traversal' (Exitcode e Identity a) (Identity NotZero)
forall (f :: * -> *) e a.
Traversable f =>
Traversal' (Exitcode e f a) (f NotZero)
_ExitFailureCode ((Identity NotZero -> f (Identity NotZero))
-> Exitcode e Identity a -> f (Exitcode e Identity a))
-> ((NotZero -> f NotZero)
-> Identity NotZero -> f (Identity NotZero))
-> (NotZero -> f NotZero)
-> Exitcode e Identity a
-> f (Exitcode e Identity a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Unwrapped (Identity NotZero) -> f (Unwrapped (Identity NotZero)))
-> Identity NotZero -> f (Identity NotZero)
(NotZero -> f NotZero) -> Identity NotZero -> f (Identity NotZero)
forall s t. Rewrapping s t => Iso s t (Unwrapped s) (Unwrapped t)
Iso
(Identity NotZero)
(Identity NotZero)
(Unwrapped (Identity NotZero))
(Unwrapped (Identity NotZero))
_Wrapped
{-# INLINE _ExitFailureValue #-}
_ExitFailureValue :: (Traversable f) => Traversal' (Exitcode e f a) (f e)
_ExitFailureValue :: forall (f :: * -> *) e a.
Traversable f =>
Traversal' (Exitcode e f a) (f e)
_ExitFailureValue f e -> f (f e)
g (Exitcode f (Either (e, NotZero) a)
x) =
case (Either (e, NotZero) a -> Maybe (e, NotZero))
-> f (Either (e, NotZero) a) -> Maybe (f (e, NotZero))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> f a -> f (f b)
traverse (((e, NotZero) -> Maybe (e, NotZero))
-> (a -> Maybe (e, NotZero))
-> Either (e, NotZero) a
-> Maybe (e, NotZero)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (e, NotZero) -> Maybe (e, NotZero)
forall a. a -> Maybe a
Just (Maybe (e, NotZero) -> a -> Maybe (e, NotZero)
forall a b. a -> b -> a
const Maybe (e, NotZero)
forall a. Maybe a
Nothing)) f (Either (e, NotZero) a)
x of
Maybe (f (e, NotZero))
Nothing -> Exitcode e f a -> f (Exitcode e f a)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (f (Either (e, NotZero) a) -> Exitcode e f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode f (Either (e, NotZero) a)
x)
Just f (e, NotZero)
pairs ->
let rebuild :: t e -> Exitcode e f a
rebuild t e
newEs =
let ([e]
_, f (e, NotZero)
result) =
([e] -> (e, NotZero) -> ([e], (e, NotZero)))
-> [e] -> f (e, NotZero) -> ([e], f (e, NotZero))
forall (t :: * -> *) s a b.
Traversable t =>
(s -> a -> (s, b)) -> s -> t a -> (s, t b)
mapAccumL
( \[e]
es (e
e, NotZero
nz) -> case [e]
es of
e
e' : [e]
rest -> ([e]
rest, (e
e', NotZero
nz))
[] -> ([], (e
e, NotZero
nz))
)
(t e -> [e]
forall a. t a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList t e
newEs)
f (e, NotZero)
pairs
in f (Either (e, NotZero) a) -> Exitcode e f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (((e, NotZero) -> Either (e, NotZero) a)
-> f (e, NotZero) -> f (Either (e, NotZero) a)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (e, NotZero) -> Either (e, NotZero) a
forall a b. a -> Either a b
Left f (e, NotZero)
result)
in f e -> Exitcode e f a
forall {t :: * -> *} {a}. Foldable t => t e -> Exitcode e f a
rebuild (f e -> Exitcode e f a) -> f (f e) -> f (Exitcode e f a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f e -> f (f e)
g (((e, NotZero) -> e) -> f (e, NotZero) -> f e
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (e, NotZero) -> e
forall a b. (a, b) -> a
fst f (e, NotZero)
pairs)
{-# INLINE _ExitFailureValue' #-}
_ExitFailureValue' :: Traversal (Exitcode' e a) (Exitcode' e' a) e e'
_ExitFailureValue' :: forall e a e' (f :: * -> *).
Applicative f =>
(e -> f e') -> Exitcode' e a -> f (Exitcode' e' a)
_ExitFailureValue' e -> f e'
g (Exitcode (Identity Either (e, NotZero) a
x)) =
case Either (e, NotZero) a
x of
Left (e
e, NotZero
nz) -> (e' -> Exitcode' e' a) -> f e' -> f (Exitcode' e' a)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\e'
e' -> Identity (Either (e', NotZero) a) -> Exitcode' e' a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (Either (e', NotZero) a -> Identity (Either (e', NotZero) a)
forall a. a -> Identity a
Identity ((e', NotZero) -> Either (e', NotZero) a
forall a b. a -> Either a b
Left (e'
e', NotZero
nz)))) (e -> f e'
g e
e)
Right a
a -> Exitcode' e' a -> f (Exitcode' e' a)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Identity (Either (e', NotZero) a) -> Exitcode' e' a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (Either (e', NotZero) a -> Identity (Either (e', NotZero) a)
forall a. a -> Identity a
Identity (a -> Either (e', NotZero) a
forall a b. b -> Either a b
Right a
a)))
{-# INLINE _ExitSuccess #-}
_ExitSuccess :: (Traversable f) => Prism' (Exitcode e f a) (f a)
_ExitSuccess :: forall (f :: * -> *) e a.
Traversable f =>
Prism' (Exitcode e f a) (f a)
_ExitSuccess =
(f a -> Exitcode e f a)
-> (Exitcode e f a -> Maybe (f a))
-> Prism (Exitcode e f a) (Exitcode e f a) (f a) (f a)
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism'
(f (Either (e, NotZero) a) -> Exitcode e f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (f (Either (e, NotZero) a) -> Exitcode e f a)
-> (f a -> f (Either (e, NotZero) a)) -> f a -> Exitcode e f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Either (e, NotZero) a) -> f a -> f (Either (e, NotZero) a)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> Either (e, NotZero) a
forall a b. b -> Either a b
Right)
(\(Exitcode f (Either (e, NotZero) a)
x) -> (Either (e, NotZero) a -> Maybe a)
-> f (Either (e, NotZero) a) -> Maybe (f a)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> f a -> f (f b)
traverse (((e, NotZero) -> Maybe a)
-> (a -> Maybe a) -> Either (e, NotZero) a -> Maybe a
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Maybe a -> (e, NotZero) -> 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) f (Either (e, NotZero) a)
x)
{-# INLINE _ExitSuccess' #-}
_ExitSuccess' :: Prism (Exitcode' e a) (Exitcode' e a') a a'
_ExitSuccess' :: forall e a a' (p :: * -> * -> *) (f :: * -> *).
(Choice p, Applicative f) =>
p a (f a') -> p (Exitcode' e a) (f (Exitcode' e a'))
_ExitSuccess' =
(a' -> Exitcode' e a')
-> (Exitcode' e a -> Either (Exitcode' e a') a)
-> Prism (Exitcode' e a) (Exitcode' e a') a a'
forall b t s a. (b -> t) -> (s -> Either t a) -> Prism s t a b
prism
(Identity (Either (e, NotZero) a') -> Exitcode' e a'
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (Identity (Either (e, NotZero) a') -> Exitcode' e a')
-> (a' -> Identity (Either (e, NotZero) a'))
-> a'
-> Exitcode' e a'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Either (e, NotZero) a' -> Identity (Either (e, NotZero) a')
forall a. a -> Identity a
Identity (Either (e, NotZero) a' -> Identity (Either (e, NotZero) a'))
-> (a' -> Either (e, NotZero) a')
-> a'
-> Identity (Either (e, NotZero) a')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a' -> Either (e, NotZero) a'
forall a b. b -> Either a b
Right)
( \(Exitcode (Identity Either (e, NotZero) a
x)) -> case Either (e, NotZero) a
x of
Right a
a -> a -> Either (Exitcode' e a') a
forall a b. b -> Either a b
Right a
a
Left (e
e, NotZero
i) -> Exitcode' e a' -> Either (Exitcode' e a') a
forall a b. a -> Either a b
Left (Identity (Either (e, NotZero) a') -> Exitcode' e a'
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (Either (e, NotZero) a' -> Identity (Either (e, NotZero) a')
forall a. a -> Identity a
Identity ((e, NotZero) -> Either (e, NotZero) a'
forall a b. a -> Either a b
Left (e
e, NotZero
i))))
)
{-# INLINE mkExitcode #-}
mkExitcode :: (Applicative f) => f e -> f NotZero -> Exitcode e f a
mkExitcode :: forall (f :: * -> *) e a.
Applicative f =>
f e -> f NotZero -> Exitcode e f a
mkExitcode f e
e f NotZero
nz = f (Either (e, NotZero) a) -> Exitcode e f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode ((\e
e' NotZero
nz' -> (e, NotZero) -> Either (e, NotZero) a
forall a b. a -> Either a b
Left (e
e', NotZero
nz')) (e -> NotZero -> Either (e, NotZero) a)
-> f e -> f (NotZero -> Either (e, NotZero) a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f e
e f (NotZero -> Either (e, NotZero) a)
-> f NotZero -> f (Either (e, NotZero) a)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> f NotZero
nz)
{-# INLINE mkExitcode' #-}
mkExitcode' :: e -> NotZero -> Exitcode' e a
mkExitcode' :: forall e a. e -> NotZero -> Exitcode' e a
mkExitcode' e
e NotZero
nz = Identity e -> Identity NotZero -> Exitcode e Identity a
forall (f :: * -> *) e a.
Applicative f =>
f e -> f NotZero -> Exitcode e f a
mkExitcode (e -> Identity e
forall a. a -> Identity a
Identity e
e) (NotZero -> Identity NotZero
forall a. a -> Identity a
Identity NotZero
nz)
{-# INLINE mkExitSuccess #-}
mkExitSuccess :: (Functor f) => f a -> Exitcode e f a
mkExitSuccess :: forall (f :: * -> *) a e. Functor f => f a -> Exitcode e f a
mkExitSuccess = f (Either (e, NotZero) a) -> Exitcode e f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (f (Either (e, NotZero) a) -> Exitcode e f a)
-> (f a -> f (Either (e, NotZero) a)) -> f a -> Exitcode e f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Either (e, NotZero) a) -> f a -> f (Either (e, NotZero) a)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> Either (e, NotZero) a
forall a b. b -> Either a b
Right
{-# INLINE mkExitSuccess' #-}
mkExitSuccess' :: a -> Exitcode' e a
mkExitSuccess' :: forall a e. a -> Exitcode' e a
mkExitSuccess' = Identity a -> Exitcode e Identity a
forall (f :: * -> *) a e. Functor f => f a -> Exitcode e f a
mkExitSuccess (Identity a -> Exitcode e Identity a)
-> (a -> Identity a) -> a -> Exitcode e Identity a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Identity a
forall a. a -> Identity a
Identity
{-# INLINE mkExitFailure #-}
mkExitFailure :: (Applicative f) => f NotZero -> f e -> Exitcode e f a
mkExitFailure :: forall (f :: * -> *) e a.
Applicative f =>
f NotZero -> f e -> Exitcode e f a
mkExitFailure f NotZero
n f e
e = f (Either (e, NotZero) a) -> Exitcode e f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode ((\NotZero
n' e
e' -> (e, NotZero) -> Either (e, NotZero) a
forall a b. a -> Either a b
Left (e
e', NotZero
n')) (NotZero -> e -> Either (e, NotZero) a)
-> f NotZero -> f (e -> Either (e, NotZero) a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f NotZero
n f (e -> Either (e, NotZero) a) -> f e -> f (Either (e, NotZero) a)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> f e
e)
{-# INLINE mkExitFailure' #-}
mkExitFailure' :: NotZero -> e -> Exitcode' e a
mkExitFailure' :: forall e a. NotZero -> e -> Exitcode' e a
mkExitFailure' NotZero
n e
e = Identity NotZero -> Identity e -> Exitcode e Identity a
forall (f :: * -> *) e a.
Applicative f =>
f NotZero -> f e -> Exitcode e f a
mkExitFailure (NotZero -> Identity NotZero
forall a. a -> Identity a
Identity NotZero
n) (e -> Identity e
forall a. a -> Identity a
Identity e
e)
{-# INLINE mkExitFailure1 #-}
mkExitFailure1 :: (Functor f) => f e -> Exitcode e f a
mkExitFailure1 :: forall (f :: * -> *) e a. Functor f => f e -> Exitcode e f a
mkExitFailure1 = f (Either (e, NotZero) a) -> Exitcode e f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (f (Either (e, NotZero) a) -> Exitcode e f a)
-> (f e -> f (Either (e, NotZero) a)) -> f e -> Exitcode e f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (e -> Either (e, NotZero) a) -> f e -> f (Either (e, NotZero) a)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\e
e' -> (e, NotZero) -> Either (e, NotZero) a
forall a b. a -> Either a b
Left (e
e', Int -> NotZero
forall a. AsNotZero a => a -> NotZero
notZeroOr (Int
1 :: Int)))
{-# INLINE mkExitFailure1' #-}
mkExitFailure1' :: e -> Exitcode' e a
mkExitFailure1' :: forall e a. e -> Exitcode' e a
mkExitFailure1' = Identity e -> Exitcode e Identity a
forall (f :: * -> *) e a. Functor f => f e -> Exitcode e f a
mkExitFailure1 (Identity e -> Exitcode e Identity a)
-> (e -> Identity e) -> e -> Exitcode e Identity a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> Identity e
forall a. a -> Identity a
Identity
{-# INLINE mkExitFailure_1 #-}
mkExitFailure_1 :: (Functor f) => f e -> Exitcode e f a
mkExitFailure_1 :: forall (f :: * -> *) e a. Functor f => f e -> Exitcode e f a
mkExitFailure_1 = f (Either (e, NotZero) a) -> Exitcode e f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (f (Either (e, NotZero) a) -> Exitcode e f a)
-> (f e -> f (Either (e, NotZero) a)) -> f e -> Exitcode e f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (e -> Either (e, NotZero) a) -> f e -> f (Either (e, NotZero) a)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\e
e' -> (e, NotZero) -> Either (e, NotZero) a
forall a b. a -> Either a b
Left (e
e', Int -> NotZero
forall a. AsNotZero a => a -> NotZero
notZeroOr (-Int
1 :: Int)))
{-# INLINE mkExitFailure_1' #-}
mkExitFailure_1' :: e -> Exitcode' e a
mkExitFailure_1' :: forall e a. e -> Exitcode' e a
mkExitFailure_1' = Identity e -> Exitcode e Identity a
forall (f :: * -> *) e a. Functor f => f e -> Exitcode e f a
mkExitFailure_1 (Identity e -> Exitcode e Identity a)
-> (e -> Identity e) -> e -> Exitcode e Identity a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> Identity e
forall a. a -> Identity a
Identity
{-# INLINE fromExitCode #-}
fromExitCode ::
(Functor f) =>
f ExitCode ->
Exitcode () f ()
fromExitCode :: forall (f :: * -> *). Functor f => f ExitCode -> Exitcode () f ()
fromExitCode =
f (Either ((), NotZero) ()) -> Exitcode () f ()
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode
(f (Either ((), NotZero) ()) -> Exitcode () f ())
-> (f ExitCode -> f (Either ((), NotZero) ()))
-> f ExitCode
-> Exitcode () f ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ExitCode -> Either ((), NotZero) ())
-> f ExitCode -> f (Either ((), NotZero) ())
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
( \case
ExitCode
ExitSuccess -> () -> Either ((), NotZero) ()
forall a b. b -> Either a b
Right ()
ExitFailure Int
n -> case Getting (First NotZero) Int NotZero -> Int -> Maybe NotZero
forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview Getting (First NotZero) Int NotZero
forall a. AsNotZero a => Prism' a NotZero
Prism' Int NotZero
_NotZero Int
n of
Just NotZero
nz -> ((), NotZero) -> Either ((), NotZero) ()
forall a b. a -> Either a b
Left ((), NotZero
nz)
Maybe NotZero
Nothing -> () -> Either ((), NotZero) ()
forall a b. b -> Either a b
Right ()
)
{-# INLINE fromExitCode' #-}
fromExitCode' ::
ExitCode ->
Exitcode' () ()
fromExitCode' :: ExitCode -> Exitcode' () ()
fromExitCode' =
Identity ExitCode -> Exitcode' () ()
forall (f :: * -> *). Functor f => f ExitCode -> Exitcode () f ()
fromExitCode (Identity ExitCode -> Exitcode' () ())
-> (ExitCode -> Identity ExitCode) -> ExitCode -> Exitcode' () ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExitCode -> Identity ExitCode
forall a. a -> Identity a
Identity
{-# INLINE toExitCode #-}
toExitCode ::
(Functor f) =>
Exitcode () f () ->
f ExitCode
toExitCode :: forall (f :: * -> *). Functor f => Exitcode () f () -> f ExitCode
toExitCode (Exitcode f (Either ((), NotZero) ())
x) =
(Either ((), NotZero) () -> ExitCode)
-> f (Either ((), NotZero) ()) -> f ExitCode
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((((), NotZero) -> ExitCode)
-> (() -> ExitCode) -> Either ((), NotZero) () -> ExitCode
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (\((), NotZero
nz) -> Int -> ExitCode
ExitFailure (AReview Int NotZero -> NotZero -> Int
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview Int NotZero
forall a. AsNotZero a => Prism' a NotZero
Prism' Int NotZero
_NotZero NotZero
nz)) (ExitCode -> () -> ExitCode
forall a b. a -> b -> a
const ExitCode
ExitSuccess)) f (Either ((), NotZero) ())
x
{-# INLINE toExitCode' #-}
toExitCode' ::
Exitcode' () () ->
ExitCode
toExitCode' :: Exitcode' () () -> ExitCode
toExitCode' =
Identity ExitCode -> ExitCode
forall a. Identity a -> a
runIdentity (Identity ExitCode -> ExitCode)
-> (Exitcode' () () -> Identity ExitCode)
-> Exitcode' () ()
-> ExitCode
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Exitcode' () () -> Identity ExitCode
forall (f :: * -> *). Functor f => Exitcode () f () -> f ExitCode
toExitCode
{-# INLINE hoistExitcode #-}
hoistExitcode ::
(forall x. f x -> g x) ->
Exitcode e f a ->
Exitcode e g a
hoistExitcode :: forall (f :: * -> *) (g :: * -> *) e a.
(forall x. f x -> g x) -> Exitcode e f a -> Exitcode e g a
hoistExitcode forall x. f x -> g x
nat (Exitcode f (Either (e, NotZero) a)
x) =
g (Either (e, NotZero) a) -> Exitcode e g a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (f (Either (e, NotZero) a) -> g (Either (e, NotZero) a)
forall x. f x -> g x
nat f (Either (e, NotZero) a)
x)
{-# INLINE embedExitcode #-}
embedExitcode ::
(Functor g) =>
(forall x. f x -> Exitcode e g x) ->
Exitcode e f a ->
Exitcode e g a
embedExitcode :: forall (g :: * -> *) (f :: * -> *) e a.
Functor g =>
(forall x. f x -> Exitcode e g x)
-> Exitcode e f a -> Exitcode e g a
embedExitcode forall x. f x -> Exitcode e g x
nat (Exitcode f (Either (e, NotZero) a)
x) =
g (Either (e, NotZero) a) -> Exitcode e g a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (Either (e, NotZero) (Either (e, NotZero) a)
-> Either (e, NotZero) a
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (Either (e, NotZero) (Either (e, NotZero) a)
-> Either (e, NotZero) a)
-> g (Either (e, NotZero) (Either (e, NotZero) a))
-> g (Either (e, NotZero) a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Exitcode e g (Either (e, NotZero) a)
-> g (Either (e, NotZero) (Either (e, NotZero) a))
forall e (f :: * -> *) a.
Exitcode e f a -> f (Either (e, NotZero) a)
runExitcode (f (Either (e, NotZero) a) -> Exitcode e g (Either (e, NotZero) a)
forall x. f x -> Exitcode e g x
nat f (Either (e, NotZero) a)
x))
{-# INLINE bimapExitcode #-}
bimapExitcode ::
(Functor f) =>
(e -> e') ->
(a -> a') ->
Exitcode e f a ->
Exitcode e' f a'
bimapExitcode :: forall (f :: * -> *) e e' a a'.
Functor f =>
(e -> e') -> (a -> a') -> Exitcode e f a -> Exitcode e' f a'
bimapExitcode e -> e'
f a -> a'
g (Exitcode f (Either (e, NotZero) a)
x) =
f (Either (e', NotZero) a') -> Exitcode e' f a'
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode ((Either (e, NotZero) a -> Either (e', NotZero) a')
-> f (Either (e, NotZero) a) -> f (Either (e', NotZero) a')
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (((e, NotZero) -> Either (e', NotZero) a')
-> (a -> Either (e', NotZero) a')
-> Either (e, NotZero) a
-> Either (e', NotZero) a'
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (\(e
e, NotZero
n) -> (e', NotZero) -> Either (e', NotZero) a'
forall a b. a -> Either a b
Left (e -> e'
f e
e, NotZero
n)) (a' -> Either (e', NotZero) a'
forall a b. b -> Either a b
Right (a' -> Either (e', NotZero) a')
-> (a -> a') -> a -> Either (e', NotZero) a'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> a'
g)) f (Either (e, NotZero) a)
x)
{-# INLINE tryExitcode #-}
tryExitcode ::
(Exception e') =>
Exitcode e IO a ->
Exitcode e (ExceptT e' IO) a
tryExitcode :: forall e' e a.
Exception e' =>
Exitcode e IO a -> Exitcode e (ExceptT e' IO) a
tryExitcode (Exitcode IO (Either (e, NotZero) a)
x) =
ExceptT e' IO (Either (e, NotZero) a)
-> Exitcode e (ExceptT e' IO) a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (IO (Either e' (Either (e, NotZero) a))
-> ExceptT e' IO (Either (e, NotZero) a)
forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT (IO (Either (e, NotZero) a)
-> IO (Either e' (Either (e, NotZero) a))
forall e a. Exception e => IO a -> IO (Either e a)
try IO (Either (e, NotZero) a)
x))
{-# INLINE liftTryExitcode #-}
liftTryExitcode ::
(Exception e') =>
IO a ->
Exitcode e (ExceptT e' IO) a
liftTryExitcode :: forall e' a e. Exception e' => IO a -> Exitcode e (ExceptT e' IO) a
liftTryExitcode IO a
x =
ExceptT e' IO (Either (e, NotZero) a)
-> Exitcode e (ExceptT e' IO) a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (IO (Either e' (Either (e, NotZero) a))
-> ExceptT e' IO (Either (e, NotZero) a)
forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT ((Either e' a -> Either e' (Either (e, NotZero) a))
-> IO (Either e' a) -> IO (Either e' (Either (e, NotZero) a))
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> Either (e, NotZero) a)
-> Either e' a -> Either e' (Either (e, NotZero) a)
forall a b. (a -> b) -> Either e' a -> Either e' b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> Either (e, NotZero) a
forall a b. b -> Either a b
Right) (IO a -> IO (Either e' a)
forall e a. Exception e => IO a -> IO (Either e a)
try IO a
x)))
{-# INLINE [0] exitcodeMap #-}
exitcodeMap :: (Functor f) => (a -> b) -> Exitcode e f a -> Exitcode e f b
exitcodeMap :: forall (f :: * -> *) a b e.
Functor f =>
(a -> b) -> Exitcode e f a -> Exitcode e f b
exitcodeMap a -> b
f (Exitcode f (Either (e, NotZero) a)
x) = f (Either (e, NotZero) b) -> Exitcode e f b
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode ((Either (e, NotZero) a -> Either (e, NotZero) b)
-> f (Either (e, NotZero) a) -> f (Either (e, NotZero) b)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> b) -> Either (e, NotZero) a -> Either (e, NotZero) b
forall a b.
(a -> b) -> Either (e, NotZero) a -> Either (e, NotZero) b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) f (Either (e, NotZero) a)
x)
{-# INLINE [0] exitcodeFoldMap #-}
exitcodeFoldMap :: (Foldable f, Monoid m) => (a -> m) -> Exitcode e f a -> m
exitcodeFoldMap :: forall (f :: * -> *) m a e.
(Foldable f, Monoid m) =>
(a -> m) -> Exitcode e f a -> m
exitcodeFoldMap a -> m
f (Exitcode f (Either (e, NotZero) a)
x) = (Either (e, NotZero) a -> m) -> f (Either (e, NotZero) a) -> m
forall m a. Monoid m => (a -> m) -> f a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (((e, NotZero) -> m) -> (a -> m) -> Either (e, NotZero) a -> m
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (m -> (e, NotZero) -> m
forall a b. a -> b -> a
const m
forall a. Monoid a => a
mempty) a -> m
f) f (Either (e, NotZero) a)
x
{-# RULES
"exitcodeMap/exitcodeMap" [~0] forall f g xs.
exitcodeMap f (exitcodeMap g xs) =
exitcodeMap (f . g) xs
"exitcodeFoldMap/exitcodeMap" [~0] forall f g xs.
exitcodeFoldMap f (exitcodeMap g xs) =
exitcodeFoldMap (f . g) xs
#-}
instance (Functor f) => Functor (Exitcode e f) where
{-# INLINE fmap #-}
fmap :: forall a b. (a -> b) -> Exitcode e f a -> Exitcode e f b
fmap = (a -> b) -> Exitcode e f a -> Exitcode e f b
forall (f :: * -> *) a b e.
Functor f =>
(a -> b) -> Exitcode e f a -> Exitcode e f b
exitcodeMap
instance (Foldable f) => Foldable (Exitcode e f) where
{-# INLINE foldMap #-}
foldMap :: forall m a. Monoid m => (a -> m) -> Exitcode e f a -> m
foldMap = (a -> m) -> Exitcode e f a -> m
forall (f :: * -> *) m a e.
(Foldable f, Monoid m) =>
(a -> m) -> Exitcode e f a -> m
exitcodeFoldMap
instance (Traversable f) => Traversable (Exitcode e f) where
{-# INLINE traverse #-}
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Exitcode e f a -> f (Exitcode e f b)
traverse a -> f b
f (Exitcode f (Either (e, NotZero) a)
x) =
f (Either (e, NotZero) b) -> Exitcode e f b
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (f (Either (e, NotZero) b) -> Exitcode e f b)
-> f (f (Either (e, NotZero) b)) -> f (Exitcode e f b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Either (e, NotZero) a -> f (Either (e, NotZero) b))
-> f (Either (e, NotZero) a) -> f (f (Either (e, NotZero) b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> f a -> f (f b)
traverse (((e, NotZero) -> f (Either (e, NotZero) b))
-> (a -> f (Either (e, NotZero) b))
-> Either (e, NotZero) a
-> f (Either (e, NotZero) b)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Either (e, NotZero) b -> f (Either (e, NotZero) b)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either (e, NotZero) b -> f (Either (e, NotZero) b))
-> ((e, NotZero) -> Either (e, NotZero) b)
-> (e, NotZero)
-> f (Either (e, NotZero) b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (e, NotZero) -> Either (e, NotZero) b
forall a b. a -> Either a b
Left) ((b -> Either (e, NotZero) b) -> f b -> f (Either (e, NotZero) b)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap b -> Either (e, NotZero) b
forall a b. b -> Either a b
Right (f b -> f (Either (e, NotZero) b))
-> (a -> f b) -> a -> f (Either (e, NotZero) b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> f b
f)) f (Either (e, NotZero) a)
x
instance (FunctorWithIndex i f) => FunctorWithIndex i (Exitcode e f) where
{-# INLINE imap #-}
imap :: forall a b. (i -> a -> b) -> Exitcode e f a -> Exitcode e f b
imap i -> a -> b
f (Exitcode f (Either (e, NotZero) a)
x) = f (Either (e, NotZero) b) -> Exitcode e f b
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode ((i -> Either (e, NotZero) a -> Either (e, NotZero) b)
-> f (Either (e, NotZero) a) -> f (Either (e, NotZero) b)
forall a b. (i -> a -> b) -> f a -> f b
forall i (f :: * -> *) a b.
FunctorWithIndex i f =>
(i -> a -> b) -> f a -> f b
imap (\i
i -> (a -> b) -> Either (e, NotZero) a -> Either (e, NotZero) b
forall a b.
(a -> b) -> Either (e, NotZero) a -> Either (e, NotZero) b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (i -> a -> b
f i
i)) f (Either (e, NotZero) a)
x)
instance (FoldableWithIndex i f) => FoldableWithIndex i (Exitcode e f) where
{-# INLINE ifoldMap #-}
ifoldMap :: forall m a. Monoid m => (i -> a -> m) -> Exitcode e f a -> m
ifoldMap i -> a -> m
f (Exitcode f (Either (e, NotZero) a)
x) = (i -> Either (e, NotZero) a -> m) -> f (Either (e, NotZero) a) -> m
forall m a. Monoid m => (i -> a -> m) -> f a -> m
forall i (f :: * -> *) m a.
(FoldableWithIndex i f, Monoid m) =>
(i -> a -> m) -> f a -> m
ifoldMap (\i
i -> ((e, NotZero) -> m) -> (a -> m) -> Either (e, NotZero) a -> m
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (m -> (e, NotZero) -> m
forall a b. a -> b -> a
const m
forall a. Monoid a => a
mempty) (i -> a -> m
f i
i)) f (Either (e, NotZero) a)
x
instance (TraversableWithIndex i f) => TraversableWithIndex i (Exitcode e f) where
{-# INLINE itraverse #-}
itraverse :: forall (f :: * -> *) a b.
Applicative f =>
(i -> a -> f b) -> Exitcode e f a -> f (Exitcode e f b)
itraverse i -> a -> f b
f (Exitcode f (Either (e, NotZero) a)
x) = f (Either (e, NotZero) b) -> Exitcode e f b
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (f (Either (e, NotZero) b) -> Exitcode e f b)
-> f (f (Either (e, NotZero) b)) -> f (Exitcode e f b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (i -> Either (e, NotZero) a -> f (Either (e, NotZero) b))
-> f (Either (e, NotZero) a) -> f (f (Either (e, NotZero) b))
forall i (t :: * -> *) (f :: * -> *) a b.
(TraversableWithIndex i t, Applicative f) =>
(i -> a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(i -> a -> f b) -> f a -> f (f b)
itraverse (\i
i -> ((e, NotZero) -> f (Either (e, NotZero) b))
-> (a -> f (Either (e, NotZero) b))
-> Either (e, NotZero) a
-> f (Either (e, NotZero) b)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Either (e, NotZero) b -> f (Either (e, NotZero) b)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either (e, NotZero) b -> f (Either (e, NotZero) b))
-> ((e, NotZero) -> Either (e, NotZero) b)
-> (e, NotZero)
-> f (Either (e, NotZero) b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (e, NotZero) -> Either (e, NotZero) b
forall a b. a -> Either a b
Left) ((b -> Either (e, NotZero) b) -> f b -> f (Either (e, NotZero) b)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap b -> Either (e, NotZero) b
forall a b. b -> Either a b
Right (f b -> f (Either (e, NotZero) b))
-> (a -> f b) -> a -> f (Either (e, NotZero) b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. i -> a -> f b
f i
i)) f (Either (e, NotZero) a)
x
instance (Monad f) => Apply (Exitcode e f) where
{-# INLINE (<.>) #-}
Exitcode f (Either (e, NotZero) (a -> b))
f <.> :: forall a b.
Exitcode e f (a -> b) -> Exitcode e f a -> Exitcode e f b
<.> Exitcode f (Either (e, NotZero) a)
a =
f (Either (e, NotZero) b) -> Exitcode e f b
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (f (Either (e, NotZero) (a -> b))
f f (Either (e, NotZero) (a -> b))
-> (Either (e, NotZero) (a -> b) -> f (Either (e, NotZero) b))
-> f (Either (e, NotZero) b)
forall a b. f a -> (a -> f b) -> f b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ((e, NotZero) -> f (Either (e, NotZero) b))
-> ((a -> b) -> f (Either (e, NotZero) b))
-> Either (e, NotZero) (a -> b)
-> f (Either (e, NotZero) b)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Either (e, NotZero) b -> f (Either (e, NotZero) b)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either (e, NotZero) b -> f (Either (e, NotZero) b))
-> ((e, NotZero) -> Either (e, NotZero) b)
-> (e, NotZero)
-> f (Either (e, NotZero) b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (e, NotZero) -> Either (e, NotZero) b
forall a b. a -> Either a b
Left) (\a -> b
f' -> (Either (e, NotZero) a -> Either (e, NotZero) b)
-> f (Either (e, NotZero) a) -> f (Either (e, NotZero) b)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> b) -> Either (e, NotZero) a -> Either (e, NotZero) b
forall a b.
(a -> b) -> Either (e, NotZero) a -> Either (e, NotZero) b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f') f (Either (e, NotZero) a)
a))
instance (Monad f) => Applicative (Exitcode e f) where
{-# INLINE pure #-}
pure :: forall a. a -> Exitcode e f a
pure = f (Either (e, NotZero) a) -> Exitcode e f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (f (Either (e, NotZero) a) -> Exitcode e f a)
-> (a -> f (Either (e, NotZero) a)) -> a -> Exitcode e f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Either (e, NotZero) a -> f (Either (e, NotZero) a)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either (e, NotZero) a -> f (Either (e, NotZero) a))
-> (a -> Either (e, NotZero) a) -> a -> f (Either (e, NotZero) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Either (e, NotZero) a
forall a b. b -> Either a b
Right
{-# INLINE (<*>) #-}
Exitcode f (Either (e, NotZero) (a -> b))
f <*> :: forall a b.
Exitcode e f (a -> b) -> Exitcode e f a -> Exitcode e f b
<*> Exitcode f (Either (e, NotZero) a)
a =
f (Either (e, NotZero) b) -> Exitcode e f b
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (f (Either (e, NotZero) (a -> b))
f f (Either (e, NotZero) (a -> b))
-> (Either (e, NotZero) (a -> b) -> f (Either (e, NotZero) b))
-> f (Either (e, NotZero) b)
forall a b. f a -> (a -> f b) -> f b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ((e, NotZero) -> f (Either (e, NotZero) b))
-> ((a -> b) -> f (Either (e, NotZero) b))
-> Either (e, NotZero) (a -> b)
-> f (Either (e, NotZero) b)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Either (e, NotZero) b -> f (Either (e, NotZero) b)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either (e, NotZero) b -> f (Either (e, NotZero) b))
-> ((e, NotZero) -> Either (e, NotZero) b)
-> (e, NotZero)
-> f (Either (e, NotZero) b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (e, NotZero) -> Either (e, NotZero) b
forall a b. a -> Either a b
Left) (\a -> b
f' -> (Either (e, NotZero) a -> Either (e, NotZero) b)
-> f (Either (e, NotZero) a) -> f (Either (e, NotZero) b)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> b) -> Either (e, NotZero) a -> Either (e, NotZero) b
forall a b.
(a -> b) -> Either (e, NotZero) a -> Either (e, NotZero) b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f') f (Either (e, NotZero) a)
a))
instance (Monad f) => Bind (Exitcode e f) where
{-# INLINE (>>-) #-}
>>- :: forall a b.
Exitcode e f a -> (a -> Exitcode e f b) -> Exitcode e f b
(>>-) = Exitcode e f a -> (a -> Exitcode e f b) -> Exitcode e f b
forall a b.
Exitcode e f a -> (a -> Exitcode e f b) -> Exitcode e f b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
(>>=)
instance (Monad f) => Monad (Exitcode e f) where
{-# INLINE (>>=) #-}
Exitcode f (Either (e, NotZero) a)
x >>= :: forall a b.
Exitcode e f a -> (a -> Exitcode e f b) -> Exitcode e f b
>>= a -> Exitcode e f b
f =
f (Either (e, NotZero) b) -> Exitcode e f b
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (f (Either (e, NotZero) a)
x f (Either (e, NotZero) a)
-> (Either (e, NotZero) a -> f (Either (e, NotZero) b))
-> f (Either (e, NotZero) b)
forall a b. f a -> (a -> f b) -> f b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ((e, NotZero) -> f (Either (e, NotZero) b))
-> (a -> f (Either (e, NotZero) b))
-> Either (e, NotZero) a
-> f (Either (e, NotZero) b)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Either (e, NotZero) b -> f (Either (e, NotZero) b)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either (e, NotZero) b -> f (Either (e, NotZero) b))
-> ((e, NotZero) -> Either (e, NotZero) b)
-> (e, NotZero)
-> f (Either (e, NotZero) b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (e, NotZero) -> Either (e, NotZero) b
forall a b. a -> Either a b
Left) (Exitcode e f b -> f (Either (e, NotZero) b)
forall e (f :: * -> *) a.
Exitcode e f a -> f (Either (e, NotZero) a)
runExitcode (Exitcode e f b -> f (Either (e, NotZero) b))
-> (a -> Exitcode e f b) -> a -> f (Either (e, NotZero) b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Exitcode e f b
f))
instance (MonadFix f) => MonadFix (Exitcode e f) where
{-# INLINE mfix #-}
mfix :: forall a. (a -> Exitcode e f a) -> Exitcode e f a
mfix a -> Exitcode e f a
f = f (Either (e, NotZero) a) -> Exitcode e f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode ((Either (e, NotZero) a -> f (Either (e, NotZero) a))
-> f (Either (e, NotZero) a)
forall a. (a -> f a) -> f a
forall (m :: * -> *) a. MonadFix m => (a -> m a) -> m a
mfix (Exitcode e f a -> f (Either (e, NotZero) a)
forall e (f :: * -> *) a.
Exitcode e f a -> f (Either (e, NotZero) a)
runExitcode (Exitcode e f a -> f (Either (e, NotZero) a))
-> (Either (e, NotZero) a -> Exitcode e f a)
-> Either (e, NotZero) a
-> f (Either (e, NotZero) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Exitcode e f a
f (a -> Exitcode e f a)
-> (Either (e, NotZero) a -> a)
-> Either (e, NotZero) a
-> Exitcode e f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((e, NotZero) -> a) -> (a -> a) -> Either (e, NotZero) a -> a
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (a -> (e, NotZero) -> a
forall a b. a -> b -> a
const (let a :: t
a = t
a in a
forall {t}. t
a)) a -> a
forall a. a -> a
id))
instance (Monad f) => Alt (Exitcode e f) where
{-# INLINE (<!>) #-}
Exitcode f (Either (e, NotZero) a)
a <!> :: forall a. Exitcode e f a -> Exitcode e f a -> Exitcode e f a
<!> Exitcode f (Either (e, NotZero) a)
b =
f (Either (e, NotZero) a) -> Exitcode e f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (f (Either (e, NotZero) a)
a f (Either (e, NotZero) a)
-> (Either (e, NotZero) a -> f (Either (e, NotZero) a))
-> f (Either (e, NotZero) a)
forall a b. f a -> (a -> f b) -> f b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ((e, NotZero) -> f (Either (e, NotZero) a))
-> (a -> f (Either (e, NotZero) a))
-> Either (e, NotZero) a
-> f (Either (e, NotZero) a)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (f (Either (e, NotZero) a)
-> (e, NotZero) -> f (Either (e, NotZero) a)
forall a b. a -> b -> a
const f (Either (e, NotZero) a)
b) (Either (e, NotZero) a -> f (Either (e, NotZero) a)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either (e, NotZero) a -> f (Either (e, NotZero) a))
-> (a -> Either (e, NotZero) a) -> a -> f (Either (e, NotZero) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Either (e, NotZero) a
forall a b. b -> Either a b
Right))
instance (Semigroup a, Monad f) => Semigroup (Exitcode e f a) where
{-# INLINE (<>) #-}
Exitcode f (Either (e, NotZero) a)
a <> :: Exitcode e f a -> Exitcode e f a -> Exitcode e f a
<> Exitcode f (Either (e, NotZero) a)
b =
f (Either (e, NotZero) a) -> Exitcode e f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode
( f (Either (e, NotZero) a)
a
f (Either (e, NotZero) a)
-> (Either (e, NotZero) a -> f (Either (e, NotZero) a))
-> f (Either (e, NotZero) a)
forall a b. f a -> (a -> f b) -> f b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ((e, NotZero) -> f (Either (e, NotZero) a))
-> (a -> f (Either (e, NotZero) a))
-> Either (e, NotZero) a
-> f (Either (e, NotZero) a)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either
(\(e, NotZero)
_ -> f (Either (e, NotZero) a)
b f (Either (e, NotZero) a)
-> (Either (e, NotZero) a -> f (Either (e, NotZero) a))
-> f (Either (e, NotZero) a)
forall a b. f a -> (a -> f b) -> f b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ((e, NotZero) -> f (Either (e, NotZero) a))
-> (a -> f (Either (e, NotZero) a))
-> Either (e, NotZero) a
-> f (Either (e, NotZero) a)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Either (e, NotZero) a -> f (Either (e, NotZero) a)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either (e, NotZero) a -> f (Either (e, NotZero) a))
-> ((e, NotZero) -> Either (e, NotZero) a)
-> (e, NotZero)
-> f (Either (e, NotZero) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (e, NotZero) -> Either (e, NotZero) a
forall a b. a -> Either a b
Left) (Either (e, NotZero) a -> f (Either (e, NotZero) a)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either (e, NotZero) a -> f (Either (e, NotZero) a))
-> (a -> Either (e, NotZero) a) -> a -> f (Either (e, NotZero) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Either (e, NotZero) a
forall a b. b -> Either a b
Right))
(\a
a1 -> f (Either (e, NotZero) a)
b f (Either (e, NotZero) a)
-> (Either (e, NotZero) a -> f (Either (e, NotZero) a))
-> f (Either (e, NotZero) a)
forall a b. f a -> (a -> f b) -> f b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ((e, NotZero) -> f (Either (e, NotZero) a))
-> (a -> f (Either (e, NotZero) a))
-> Either (e, NotZero) a
-> f (Either (e, NotZero) a)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (\(e, NotZero)
_ -> Either (e, NotZero) a -> f (Either (e, NotZero) a)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> Either (e, NotZero) a
forall a b. b -> Either a b
Right a
a1)) (\a
a2 -> Either (e, NotZero) a -> f (Either (e, NotZero) a)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> Either (e, NotZero) a
forall a b. b -> Either a b
Right (a
a1 a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
a2))))
)
instance (Monoid a, Monad f) => Monoid (Exitcode e f a) where
{-# INLINE mempty #-}
mempty :: Exitcode e f a
mempty = f (Either (e, NotZero) a) -> Exitcode e f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (Either (e, NotZero) a -> f (Either (e, NotZero) a)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> Either (e, NotZero) a
forall a b. b -> Either a b
Right a
forall a. Monoid a => a
mempty))
instance (Extend f) => Extend (Exitcode e f) where
{-# INLINE duplicated #-}
duplicated :: forall a. Exitcode e f a -> Exitcode e f (Exitcode e f a)
duplicated (Exitcode f (Either (e, NotZero) a)
x) =
f (Either (e, NotZero) (Exitcode e f a))
-> Exitcode e f (Exitcode e f a)
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode ((f (Either (e, NotZero) a) -> Either (e, NotZero) (Exitcode e f a))
-> f (Either (e, NotZero) a)
-> f (Either (e, NotZero) (Exitcode e f a))
forall a b. (f a -> b) -> f a -> f b
forall (w :: * -> *) a b. Extend w => (w a -> b) -> w a -> w b
extended (Exitcode e f a -> Either (e, NotZero) (Exitcode e f a)
forall a b. b -> Either a b
Right (Exitcode e f a -> Either (e, NotZero) (Exitcode e f a))
-> (f (Either (e, NotZero) a) -> Exitcode e f a)
-> f (Either (e, NotZero) a)
-> Either (e, NotZero) (Exitcode e f a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f (Either (e, NotZero) a) -> Exitcode e f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode) f (Either (e, NotZero) a)
x)
instance (Eq (f (Either (e, NotZero) a))) => Eq (Exitcode e f a) where
{-# INLINE (==) #-}
Exitcode f (Either (e, NotZero) a)
a == :: Exitcode e f a -> Exitcode e f a -> Bool
== Exitcode f (Either (e, NotZero) a)
b = f (Either (e, NotZero) a)
a f (Either (e, NotZero) a) -> f (Either (e, NotZero) a) -> Bool
forall a. Eq a => a -> a -> Bool
== f (Either (e, NotZero) a)
b
instance (Eq1 f, Eq e) => Eq1 (Exitcode e f) where
{-# INLINE liftEq #-}
liftEq :: forall a b.
(a -> b -> Bool) -> Exitcode e f a -> Exitcode e f b -> Bool
liftEq a -> b -> Bool
f (Exitcode f (Either (e, NotZero) a)
a) (Exitcode f (Either (e, NotZero) b)
b) =
(Either (e, NotZero) a -> Either (e, NotZero) b -> Bool)
-> f (Either (e, NotZero) a) -> f (Either (e, NotZero) b) -> Bool
forall a b. (a -> b -> Bool) -> f a -> f b -> Bool
forall (f :: * -> *) a b.
Eq1 f =>
(a -> b -> Bool) -> f a -> f b -> Bool
liftEq ((a -> b -> Bool)
-> Either (e, NotZero) a -> Either (e, NotZero) b -> Bool
forall a b.
(a -> b -> Bool)
-> Either (e, NotZero) a -> Either (e, NotZero) b -> Bool
forall (f :: * -> *) a b.
Eq1 f =>
(a -> b -> Bool) -> f a -> f b -> Bool
liftEq a -> b -> Bool
f) f (Either (e, NotZero) a)
a f (Either (e, NotZero) b)
b
instance (Ord (f (Either (e, NotZero) a))) => Ord (Exitcode e f a) where
{-# INLINE compare #-}
Exitcode f (Either (e, NotZero) a)
a compare :: Exitcode e f a -> Exitcode e f a -> Ordering
`compare` Exitcode f (Either (e, NotZero) a)
b = f (Either (e, NotZero) a) -> f (Either (e, NotZero) a) -> Ordering
forall a. Ord a => a -> a -> Ordering
compare f (Either (e, NotZero) a)
a f (Either (e, NotZero) a)
b
instance (Ord1 f, Ord e) => Ord1 (Exitcode e f) where
{-# INLINE liftCompare #-}
liftCompare :: forall a b.
(a -> b -> Ordering)
-> Exitcode e f a -> Exitcode e f b -> Ordering
liftCompare a -> b -> Ordering
f (Exitcode f (Either (e, NotZero) a)
a) (Exitcode f (Either (e, NotZero) b)
b) =
(Either (e, NotZero) a -> Either (e, NotZero) b -> Ordering)
-> f (Either (e, NotZero) a)
-> f (Either (e, NotZero) b)
-> Ordering
forall a b. (a -> b -> Ordering) -> f a -> f b -> Ordering
forall (f :: * -> *) a b.
Ord1 f =>
(a -> b -> Ordering) -> f a -> f b -> Ordering
liftCompare ((a -> b -> Ordering)
-> Either (e, NotZero) a -> Either (e, NotZero) b -> Ordering
forall a b.
(a -> b -> Ordering)
-> Either (e, NotZero) a -> Either (e, NotZero) b -> Ordering
forall (f :: * -> *) a b.
Ord1 f =>
(a -> b -> Ordering) -> f a -> f b -> Ordering
liftCompare a -> b -> Ordering
f) f (Either (e, NotZero) a)
a f (Either (e, NotZero) b)
b
instance (Show (f (Either (e, NotZero) a))) => Show (Exitcode e f a) where
{-# INLINE showsPrec #-}
showsPrec :: Int -> Exitcode e f a -> ShowS
showsPrec Int
d (Exitcode f (Either (e, NotZero) a)
m) =
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"Exitcode " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> f (Either (e, NotZero) a) -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 f (Either (e, NotZero) a)
m
instance (Show1 f, Show e) => Show1 (Exitcode e f) where
{-# INLINE liftShowsPrec #-}
liftShowsPrec :: forall a.
(Int -> a -> ShowS)
-> ([a] -> ShowS) -> Int -> Exitcode e f a -> ShowS
liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
sl Int
d (Exitcode f (Either (e, NotZero) a)
fa) =
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"Exitcode "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int -> Either (e, NotZero) a -> ShowS)
-> ([Either (e, NotZero) a] -> ShowS)
-> Int
-> f (Either (e, NotZero) a)
-> ShowS
forall a.
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS
forall (f :: * -> *) a.
Show1 f =>
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS
liftShowsPrec ((Int -> a -> ShowS)
-> ([a] -> ShowS) -> Int -> Either (e, NotZero) a -> ShowS
forall a.
(Int -> a -> ShowS)
-> ([a] -> ShowS) -> Int -> Either (e, NotZero) a -> ShowS
forall (f :: * -> *) a.
Show1 f =>
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS
liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
sl) ((Int -> a -> ShowS)
-> ([a] -> ShowS) -> [Either (e, NotZero) a] -> ShowS
forall a.
(Int -> a -> ShowS)
-> ([a] -> ShowS) -> [Either (e, NotZero) a] -> ShowS
forall (f :: * -> *) a.
Show1 f =>
(Int -> a -> ShowS) -> ([a] -> ShowS) -> [f a] -> ShowS
liftShowList Int -> a -> ShowS
sp [a] -> ShowS
sl) Int
11 f (Either (e, NotZero) a)
fa
instance (NFData1 f, NFData e, NFData a) => NFData (Exitcode e f a) where
{-# INLINE rnf #-}
rnf :: Exitcode e f a -> ()
rnf = (a -> ()) -> Exitcode e f a -> ()
forall a. (a -> ()) -> Exitcode e f a -> ()
forall (f :: * -> *) a. NFData1 f => (a -> ()) -> f a -> ()
liftRnf a -> ()
forall a. NFData a => a -> ()
rnf
instance (NFData1 f, NFData e) => NFData1 (Exitcode e f) where
{-# INLINE liftRnf #-}
liftRnf :: forall a. (a -> ()) -> Exitcode e f a -> ()
liftRnf a -> ()
r (Exitcode f (Either (e, NotZero) a)
x) = (Either (e, NotZero) a -> ()) -> f (Either (e, NotZero) a) -> ()
forall a. (a -> ()) -> f a -> ()
forall (f :: * -> *) a. NFData1 f => (a -> ()) -> f a -> ()
liftRnf Either (e, NotZero) a -> ()
forall {a}. NFData a => Either (a, NotZero) a -> ()
rnfEither f (Either (e, NotZero) a)
x
where
rnfEither :: Either (a, NotZero) a -> ()
rnfEither (Right a
a) = a -> ()
r a
a
rnfEither (Left (a
e, NotZero
n)) = a -> ()
forall a. NFData a => a -> ()
rnf a
e () -> () -> ()
forall a b. a -> b -> b
`seq` Int -> ()
forall a. NFData a => a -> ()
rnf (AReview Int NotZero -> NotZero -> Int
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview Int NotZero
forall a. AsNotZero a => Prism' a NotZero
Prism' Int NotZero
_NotZero NotZero
n :: Int)
instance (MonadIO f) => MonadIO (Exitcode e f) where
{-# INLINE liftIO #-}
liftIO :: forall a. IO a -> Exitcode e f a
liftIO IO a
io = f (Either (e, NotZero) a) -> Exitcode e f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (a -> Either (e, NotZero) a
forall a b. b -> Either a b
Right (a -> Either (e, NotZero) a) -> f a -> f (Either (e, NotZero) a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IO a -> f a
forall a. IO a -> f a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO a
io)
instance (MonadReader r f) => MonadReader r (Exitcode e f) where
{-# INLINE ask #-}
ask :: Exitcode e f r
ask = f (Either (e, NotZero) r) -> Exitcode e f r
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode ((r -> Either (e, NotZero) r) -> f (Either (e, NotZero) r)
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks r -> Either (e, NotZero) r
forall a b. b -> Either a b
Right)
{-# INLINE local #-}
local :: forall a. (r -> r) -> Exitcode e f a -> Exitcode e f a
local r -> r
f (Exitcode f (Either (e, NotZero) a)
m) = f (Either (e, NotZero) a) -> Exitcode e f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode ((r -> r) -> f (Either (e, NotZero) a) -> f (Either (e, NotZero) a)
forall a. (r -> r) -> f a -> f a
forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local r -> r
f f (Either (e, NotZero) a)
m)
instance (MonadWriter w f) => MonadWriter w (Exitcode e f) where
{-# INLINE writer #-}
writer :: forall a. (a, w) -> Exitcode e f a
writer (a, w)
t = f (Either (e, NotZero) a) -> Exitcode e f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (f (Either (e, NotZero) a) -> Exitcode e f a)
-> (f a -> f (Either (e, NotZero) a)) -> f a -> Exitcode e f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Either (e, NotZero) a) -> f a -> f (Either (e, NotZero) a)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> Either (e, NotZero) a
forall a. a -> Either (e, NotZero) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (f a -> Exitcode e f a) -> f a -> Exitcode e f a
forall a b. (a -> b) -> a -> b
$ (a, w) -> f a
forall a. (a, w) -> f a
forall w (m :: * -> *) a. MonadWriter w m => (a, w) -> m a
writer (a, w)
t
{-# INLINE listen #-}
listen :: forall a. Exitcode e f a -> Exitcode e f (a, w)
listen (Exitcode f (Either (e, NotZero) a)
m) = f (Either (e, NotZero) (a, w)) -> Exitcode e f (a, w)
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode ((\(Either (e, NotZero) a
e, w
w) -> (,w
w) (a -> (a, w))
-> Either (e, NotZero) a -> Either (e, NotZero) (a, w)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Either (e, NotZero) a
e) ((Either (e, NotZero) a, w) -> Either (e, NotZero) (a, w))
-> f (Either (e, NotZero) a, w) -> f (Either (e, NotZero) (a, w))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f (Either (e, NotZero) a) -> f (Either (e, NotZero) a, w)
forall a. f a -> f (a, w)
forall w (m :: * -> *) a. MonadWriter w m => m a -> m (a, w)
listen f (Either (e, NotZero) a)
m)
{-# INLINE tell #-}
tell :: w -> Exitcode e f ()
tell = f (Either (e, NotZero) ()) -> Exitcode e f ()
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (f (Either (e, NotZero) ()) -> Exitcode e f ())
-> (w -> f (Either (e, NotZero) ())) -> w -> Exitcode e f ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (() -> Either (e, NotZero) ())
-> f () -> f (Either (e, NotZero) ())
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap () -> Either (e, NotZero) ()
forall a b. b -> Either a b
Right (f () -> f (Either (e, NotZero) ()))
-> (w -> f ()) -> w -> f (Either (e, NotZero) ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. w -> f ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell
{-# INLINE pass #-}
pass :: forall a. Exitcode e f (a, w -> w) -> Exitcode e f a
pass Exitcode e f (a, w -> w)
e =
do
((a
a, w -> w
f), w
w) <- Exitcode e f (a, w -> w) -> Exitcode e f ((a, w -> w), w)
forall a. Exitcode e f a -> Exitcode e f (a, w)
forall w (m :: * -> *) a. MonadWriter w m => m a -> m (a, w)
listen Exitcode e f (a, w -> w)
e
w -> Exitcode e f ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (w -> w
f w
w)
a -> Exitcode e f a
forall a. a -> Exitcode e f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
a
instance (MonadState s f) => MonadState s (Exitcode e f) where
{-# INLINE get #-}
get :: Exitcode e f s
get = f (Either (e, NotZero) s) -> Exitcode e f s
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode ((s -> Either (e, NotZero) s) -> f s -> f (Either (e, NotZero) s)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap s -> Either (e, NotZero) s
forall a b. b -> Either a b
Right f s
forall s (m :: * -> *). MonadState s m => m s
get)
{-# INLINE put #-}
put :: s -> Exitcode e f ()
put = f (Either (e, NotZero) ()) -> Exitcode e f ()
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (f (Either (e, NotZero) ()) -> Exitcode e f ())
-> (s -> f (Either (e, NotZero) ())) -> s -> Exitcode e f ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (() -> Either (e, NotZero) ())
-> f () -> f (Either (e, NotZero) ())
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap () -> Either (e, NotZero) ()
forall a b. b -> Either a b
Right (f () -> f (Either (e, NotZero) ()))
-> (s -> f ()) -> s -> f (Either (e, NotZero) ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> f ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put
instance (MonadError e f) => MonadError e (Exitcode e' f) where
{-# INLINE throwError #-}
throwError :: forall a. e -> Exitcode e' f a
throwError = f (Either (e', NotZero) a) -> Exitcode e' f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (f (Either (e', NotZero) a) -> Exitcode e' f a)
-> (e -> f (Either (e', NotZero) a)) -> e -> Exitcode e' f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Either (e', NotZero) a) -> f a -> f (Either (e', NotZero) a)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> Either (e', NotZero) a
forall a b. b -> Either a b
Right (f a -> f (Either (e', NotZero) a))
-> (e -> f a) -> e -> f (Either (e', NotZero) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> f a
forall a. e -> f a
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError
{-# INLINE catchError #-}
catchError :: forall a.
Exitcode e' f a -> (e -> Exitcode e' f a) -> Exitcode e' f a
catchError (Exitcode f (Either (e', NotZero) a)
f) e -> Exitcode e' f a
h = f (Either (e', NotZero) a) -> Exitcode e' f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (f (Either (e', NotZero) a)
-> (e -> f (Either (e', NotZero) a)) -> f (Either (e', NotZero) a)
forall a. f a -> (e -> f a) -> f a
forall e (m :: * -> *) a.
MonadError e m =>
m a -> (e -> m a) -> m a
catchError f (Either (e', NotZero) a)
f (Exitcode e' f a -> f (Either (e', NotZero) a)
forall e (f :: * -> *) a.
Exitcode e f a -> f (Either (e, NotZero) a)
runExitcode (Exitcode e' f a -> f (Either (e', NotZero) a))
-> (e -> Exitcode e' f a) -> e -> f (Either (e', NotZero) a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> Exitcode e' f a
h))
instance (MonadRWS r w s f) => MonadRWS r w s (Exitcode e f)
instance (MonadCont f) => MonadCont (Exitcode e f) where
callCC :: forall a b.
((a -> Exitcode e f b) -> Exitcode e f a) -> Exitcode e f a
callCC (a -> Exitcode e f b) -> Exitcode e f a
f =
f (Either (e, NotZero) a) -> Exitcode e f a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (((Either (e, NotZero) a -> f (Either (e, NotZero) b))
-> f (Either (e, NotZero) a))
-> f (Either (e, NotZero) a)
forall a b. ((a -> f b) -> f a) -> f a
forall (m :: * -> *) a b. MonadCont m => ((a -> m b) -> m a) -> m a
callCC (\Either (e, NotZero) a -> f (Either (e, NotZero) b)
c -> Exitcode e f a -> f (Either (e, NotZero) a)
forall e (f :: * -> *) a.
Exitcode e f a -> f (Either (e, NotZero) a)
runExitcode ((a -> Exitcode e f b) -> Exitcode e f a
f (f (Either (e, NotZero) b) -> Exitcode e f b
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (f (Either (e, NotZero) b) -> Exitcode e f b)
-> (a -> f (Either (e, NotZero) b)) -> a -> Exitcode e f b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Either (e, NotZero) a -> f (Either (e, NotZero) b)
c (Either (e, NotZero) a -> f (Either (e, NotZero) b))
-> (a -> Either (e, NotZero) a) -> a -> f (Either (e, NotZero) b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Either (e, NotZero) a
forall a b. b -> Either a b
Right))))
instance MonadTrans (Exitcode e) where
{-# INLINE lift #-}
lift :: forall (m :: * -> *) a. Monad m => m a -> Exitcode e m a
lift = m (Either (e, NotZero) a) -> Exitcode e m a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (m (Either (e, NotZero) a) -> Exitcode e m a)
-> (m a -> m (Either (e, NotZero) a)) -> m a -> Exitcode e m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Either (e, NotZero) a) -> m a -> m (Either (e, NotZero) a)
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> Either (e, NotZero) a
forall a b. b -> Either a b
Right
instance BindTrans (Exitcode e) where
{-# INLINE liftB #-}
liftB :: forall (b :: * -> *) a. Bind b => b a -> Exitcode e b a
liftB = b (Either (e, NotZero) a) -> Exitcode e b a
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (b (Either (e, NotZero) a) -> Exitcode e b a)
-> (b a -> b (Either (e, NotZero) a)) -> b a -> Exitcode e b a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Either (e, NotZero) a) -> b a -> b (Either (e, NotZero) a)
forall a b. (a -> b) -> b a -> b b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> Either (e, NotZero) a
forall a b. b -> Either a b
Right
newtype ExitcodeBifunctor f e a = ExitcodeBifunctor (Exitcode e f a)
deriving stock ((forall x.
ExitcodeBifunctor f e a -> Rep (ExitcodeBifunctor f e a) x)
-> (forall x.
Rep (ExitcodeBifunctor f e a) x -> ExitcodeBifunctor f e a)
-> Generic (ExitcodeBifunctor f e a)
forall x.
Rep (ExitcodeBifunctor f e a) x -> ExitcodeBifunctor f e a
forall x.
ExitcodeBifunctor f e a -> Rep (ExitcodeBifunctor f e a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (f :: * -> *) e a x.
Rep (ExitcodeBifunctor f e a) x -> ExitcodeBifunctor f e a
forall (f :: * -> *) e a x.
ExitcodeBifunctor f e a -> Rep (ExitcodeBifunctor f e a) x
$cfrom :: forall (f :: * -> *) e a x.
ExitcodeBifunctor f e a -> Rep (ExitcodeBifunctor f e a) x
from :: forall x.
ExitcodeBifunctor f e a -> Rep (ExitcodeBifunctor f e a) x
$cto :: forall (f :: * -> *) e a x.
Rep (ExitcodeBifunctor f e a) x -> ExitcodeBifunctor f e a
to :: forall x.
Rep (ExitcodeBifunctor f e a) x -> ExitcodeBifunctor f e a
Generic)
type ExitcodeBifunctor' e a = ExitcodeBifunctor Identity e a
instance (Functor f) => Bifunctor (ExitcodeBifunctor f) where
{-# INLINE bimap #-}
bimap :: forall a b c d.
(a -> b)
-> (c -> d) -> ExitcodeBifunctor f a c -> ExitcodeBifunctor f b d
bimap a -> b
f c -> d
g (ExitcodeBifunctor Exitcode a f c
x) = Exitcode b f d -> ExitcodeBifunctor f b d
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor ((a -> b) -> (c -> d) -> Exitcode a f c -> Exitcode b f d
forall (f :: * -> *) e e' a a'.
Functor f =>
(e -> e') -> (a -> a') -> Exitcode e f a -> Exitcode e' f a'
bimapExitcode a -> b
f c -> d
g Exitcode a f c
x)
instance (Foldable f) => Bifoldable (ExitcodeBifunctor f) where
{-# INLINE bifoldMap #-}
bifoldMap :: forall m a b.
Monoid m =>
(a -> m) -> (b -> m) -> ExitcodeBifunctor f a b -> m
bifoldMap a -> m
f b -> m
g (ExitcodeBifunctor (Exitcode f (Either (a, NotZero) b)
x)) =
(Either (a, NotZero) b -> m) -> f (Either (a, NotZero) b) -> m
forall m a. Monoid m => (a -> m) -> f a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (((a, NotZero) -> m) -> (b -> m) -> Either (a, NotZero) b -> m
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (\(a
e, NotZero
_) -> a -> m
f a
e) b -> m
g) f (Either (a, NotZero) b)
x
instance (Traversable f) => Bitraversable (ExitcodeBifunctor f) where
{-# INLINE bitraverse #-}
bitraverse :: forall (f :: * -> *) a c b d.
Applicative f =>
(a -> f c)
-> (b -> f d)
-> ExitcodeBifunctor f a b
-> f (ExitcodeBifunctor f c d)
bitraverse a -> f c
f b -> f d
g (ExitcodeBifunctor (Exitcode f (Either (a, NotZero) b)
x)) =
Exitcode c f d -> ExitcodeBifunctor f c d
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor (Exitcode c f d -> ExitcodeBifunctor f c d)
-> (f (Either (c, NotZero) d) -> Exitcode c f d)
-> f (Either (c, NotZero) d)
-> ExitcodeBifunctor f c d
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f (Either (c, NotZero) d) -> Exitcode c f d
forall e (f :: * -> *) a.
f (Either (e, NotZero) a) -> Exitcode e f a
Exitcode (f (Either (c, NotZero) d) -> ExitcodeBifunctor f c d)
-> f (f (Either (c, NotZero) d)) -> f (ExitcodeBifunctor f c d)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Either (a, NotZero) b -> f (Either (c, NotZero) d))
-> f (Either (a, NotZero) b) -> f (f (Either (c, NotZero) d))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> f a -> f (f b)
traverse (((a, NotZero) -> f (Either (c, NotZero) d))
-> (b -> f (Either (c, NotZero) d))
-> Either (a, NotZero) b
-> f (Either (c, NotZero) d)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (\(a
e, NotZero
n) -> (c -> Either (c, NotZero) d) -> f c -> f (Either (c, NotZero) d)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\c
e' -> (c, NotZero) -> Either (c, NotZero) d
forall a b. a -> Either a b
Left (c
e', NotZero
n)) (a -> f c
f a
e)) ((d -> Either (c, NotZero) d) -> f d -> f (Either (c, NotZero) d)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap d -> Either (c, NotZero) d
forall a b. b -> Either a b
Right (f d -> f (Either (c, NotZero) d))
-> (b -> f d) -> b -> f (Either (c, NotZero) d)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> f d
g)) f (Either (a, NotZero) b)
x
instance (Functor f) => Functor (ExitcodeBifunctor f e) where
{-# INLINE fmap #-}
fmap :: forall a b.
(a -> b) -> ExitcodeBifunctor f e a -> ExitcodeBifunctor f e b
fmap a -> b
f (ExitcodeBifunctor Exitcode e f a
x) = Exitcode e f b -> ExitcodeBifunctor f e b
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor ((a -> b) -> Exitcode e f a -> Exitcode e f b
forall a b. (a -> b) -> Exitcode e f a -> Exitcode e f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Exitcode e f a
x)
instance (Foldable f) => Foldable (ExitcodeBifunctor f e) where
{-# INLINE foldMap #-}
foldMap :: forall m a. Monoid m => (a -> m) -> ExitcodeBifunctor f e a -> m
foldMap a -> m
f (ExitcodeBifunctor Exitcode e f a
x) = (a -> m) -> Exitcode e f a -> m
forall m a. Monoid m => (a -> m) -> Exitcode e f a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> m
f Exitcode e f a
x
instance (Traversable f) => Traversable (ExitcodeBifunctor f e) where
{-# INLINE traverse #-}
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b)
-> ExitcodeBifunctor f e a -> f (ExitcodeBifunctor f e b)
traverse a -> f b
f (ExitcodeBifunctor Exitcode e f a
x) = Exitcode e f b -> ExitcodeBifunctor f e b
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor (Exitcode e f b -> ExitcodeBifunctor f e b)
-> f (Exitcode e f b) -> f (ExitcodeBifunctor f e b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> f b) -> Exitcode e f a -> f (Exitcode e f b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Exitcode e f a -> f (Exitcode e f b)
traverse a -> f b
f Exitcode e f a
x
instance (FunctorWithIndex i f) => FunctorWithIndex i (ExitcodeBifunctor f e) where
{-# INLINE imap #-}
imap :: forall a b.
(i -> a -> b) -> ExitcodeBifunctor f e a -> ExitcodeBifunctor f e b
imap i -> a -> b
f (ExitcodeBifunctor Exitcode e f a
x) = Exitcode e f b -> ExitcodeBifunctor f e b
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor ((i -> a -> b) -> Exitcode e f a -> Exitcode e f b
forall a b. (i -> a -> b) -> Exitcode e f a -> Exitcode e f b
forall i (f :: * -> *) a b.
FunctorWithIndex i f =>
(i -> a -> b) -> f a -> f b
imap i -> a -> b
f Exitcode e f a
x)
instance (FoldableWithIndex i f) => FoldableWithIndex i (ExitcodeBifunctor f e) where
{-# INLINE ifoldMap #-}
ifoldMap :: forall m a.
Monoid m =>
(i -> a -> m) -> ExitcodeBifunctor f e a -> m
ifoldMap i -> a -> m
f (ExitcodeBifunctor Exitcode e f a
x) = (i -> a -> m) -> Exitcode e f a -> m
forall m a. Monoid m => (i -> a -> m) -> Exitcode e f a -> m
forall i (f :: * -> *) m a.
(FoldableWithIndex i f, Monoid m) =>
(i -> a -> m) -> f a -> m
ifoldMap i -> a -> m
f Exitcode e f a
x
instance (TraversableWithIndex i f) => TraversableWithIndex i (ExitcodeBifunctor f e) where
{-# INLINE itraverse #-}
itraverse :: forall (f :: * -> *) a b.
Applicative f =>
(i -> a -> f b)
-> ExitcodeBifunctor f e a -> f (ExitcodeBifunctor f e b)
itraverse i -> a -> f b
f (ExitcodeBifunctor Exitcode e f a
x) = Exitcode e f b -> ExitcodeBifunctor f e b
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor (Exitcode e f b -> ExitcodeBifunctor f e b)
-> f (Exitcode e f b) -> f (ExitcodeBifunctor f e b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (i -> a -> f b) -> Exitcode e f a -> f (Exitcode e f b)
forall i (t :: * -> *) (f :: * -> *) a b.
(TraversableWithIndex i t, Applicative f) =>
(i -> a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(i -> a -> f b) -> Exitcode e f a -> f (Exitcode e f b)
itraverse i -> a -> f b
f Exitcode e f a
x
instance (Monad f) => Apply (ExitcodeBifunctor f e) where
{-# INLINE (<.>) #-}
ExitcodeBifunctor Exitcode e f (a -> b)
f <.> :: forall a b.
ExitcodeBifunctor f e (a -> b)
-> ExitcodeBifunctor f e a -> ExitcodeBifunctor f e b
<.> ExitcodeBifunctor Exitcode e f a
a = Exitcode e f b -> ExitcodeBifunctor f e b
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor (Exitcode e f (a -> b)
f Exitcode e f (a -> b) -> Exitcode e f a -> Exitcode e f b
forall a b.
Exitcode e f (a -> b) -> Exitcode e f a -> Exitcode e f b
forall (f :: * -> *) a b. Apply f => f (a -> b) -> f a -> f b
<.> Exitcode e f a
a)
instance (Monad f) => Applicative (ExitcodeBifunctor f e) where
{-# INLINE pure #-}
pure :: forall a. a -> ExitcodeBifunctor f e a
pure = Exitcode e f a -> ExitcodeBifunctor f e a
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor (Exitcode e f a -> ExitcodeBifunctor f e a)
-> (a -> Exitcode e f a) -> a -> ExitcodeBifunctor f e a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Exitcode e f a
forall a. a -> Exitcode e f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
{-# INLINE (<*>) #-}
ExitcodeBifunctor Exitcode e f (a -> b)
f <*> :: forall a b.
ExitcodeBifunctor f e (a -> b)
-> ExitcodeBifunctor f e a -> ExitcodeBifunctor f e b
<*> ExitcodeBifunctor Exitcode e f a
a = Exitcode e f b -> ExitcodeBifunctor f e b
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor (Exitcode e f (a -> b)
f Exitcode e f (a -> b) -> Exitcode e f a -> Exitcode e f b
forall a b.
Exitcode e f (a -> b) -> Exitcode e f a -> Exitcode e f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Exitcode e f a
a)
instance (Monad f) => Bind (ExitcodeBifunctor f e) where
{-# INLINE (>>-) #-}
>>- :: forall a b.
ExitcodeBifunctor f e a
-> (a -> ExitcodeBifunctor f e b) -> ExitcodeBifunctor f e b
(>>-) = ExitcodeBifunctor f e a
-> (a -> ExitcodeBifunctor f e b) -> ExitcodeBifunctor f e b
forall a b.
ExitcodeBifunctor f e a
-> (a -> ExitcodeBifunctor f e b) -> ExitcodeBifunctor f e b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
(>>=)
instance (Monad f) => Monad (ExitcodeBifunctor f e) where
{-# INLINE (>>=) #-}
ExitcodeBifunctor Exitcode e f a
x >>= :: forall a b.
ExitcodeBifunctor f e a
-> (a -> ExitcodeBifunctor f e b) -> ExitcodeBifunctor f e b
>>= a -> ExitcodeBifunctor f e b
f = Exitcode e f b -> ExitcodeBifunctor f e b
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor (Exitcode e f a
x Exitcode e f a -> (a -> Exitcode e f b) -> Exitcode e f b
forall a b.
Exitcode e f a -> (a -> Exitcode e f b) -> Exitcode e f b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (\a
a -> let ExitcodeBifunctor Exitcode e f b
y = a -> ExitcodeBifunctor f e b
f a
a in Exitcode e f b
y))
instance (MonadFix f) => MonadFix (ExitcodeBifunctor f e) where
{-# INLINE mfix #-}
mfix :: forall a. (a -> ExitcodeBifunctor f e a) -> ExitcodeBifunctor f e a
mfix a -> ExitcodeBifunctor f e a
f = Exitcode e f a -> ExitcodeBifunctor f e a
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor ((a -> Exitcode e f a) -> Exitcode e f a
forall a. (a -> Exitcode e f a) -> Exitcode e f a
forall (m :: * -> *) a. MonadFix m => (a -> m a) -> m a
mfix (\a
a -> let ExitcodeBifunctor Exitcode e f a
y = a -> ExitcodeBifunctor f e a
f a
a in Exitcode e f a
y))
instance (Monad f) => Alt (ExitcodeBifunctor f e) where
{-# INLINE (<!>) #-}
ExitcodeBifunctor Exitcode e f a
a <!> :: forall a.
ExitcodeBifunctor f e a
-> ExitcodeBifunctor f e a -> ExitcodeBifunctor f e a
<!> ExitcodeBifunctor Exitcode e f a
b = Exitcode e f a -> ExitcodeBifunctor f e a
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor (Exitcode e f a
a Exitcode e f a -> Exitcode e f a -> Exitcode e f a
forall a. Exitcode e f a -> Exitcode e f a -> Exitcode e f a
forall (f :: * -> *) a. Alt f => f a -> f a -> f a
<!> Exitcode e f a
b)
instance (Semigroup a, Monad f) => Semigroup (ExitcodeBifunctor f e a) where
{-# INLINE (<>) #-}
ExitcodeBifunctor Exitcode e f a
a <> :: ExitcodeBifunctor f e a
-> ExitcodeBifunctor f e a -> ExitcodeBifunctor f e a
<> ExitcodeBifunctor Exitcode e f a
b = Exitcode e f a -> ExitcodeBifunctor f e a
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor (Exitcode e f a
a Exitcode e f a -> Exitcode e f a -> Exitcode e f a
forall a. Semigroup a => a -> a -> a
<> Exitcode e f a
b)
instance (Monoid a, Monad f) => Monoid (ExitcodeBifunctor f e a) where
{-# INLINE mempty #-}
mempty :: ExitcodeBifunctor f e a
mempty = Exitcode e f a -> ExitcodeBifunctor f e a
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor Exitcode e f a
forall a. Monoid a => a
mempty
instance (Extend f) => Extend (ExitcodeBifunctor f e) where
{-# INLINE duplicated #-}
duplicated :: forall a.
ExitcodeBifunctor f e a
-> ExitcodeBifunctor f e (ExitcodeBifunctor f e a)
duplicated (ExitcodeBifunctor Exitcode e f a
x) = Exitcode e f (ExitcodeBifunctor f e a)
-> ExitcodeBifunctor f e (ExitcodeBifunctor f e a)
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor ((Exitcode e f a -> ExitcodeBifunctor f e a)
-> Exitcode e f (Exitcode e f a)
-> Exitcode e f (ExitcodeBifunctor f e a)
forall a b. (a -> b) -> Exitcode e f a -> Exitcode e f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Exitcode e f a -> ExitcodeBifunctor f e a
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor (Exitcode e f a -> Exitcode e f (Exitcode e f a)
forall a. Exitcode e f a -> Exitcode e f (Exitcode e f a)
forall (w :: * -> *) a. Extend w => w a -> w (w a)
duplicated Exitcode e f a
x))
instance (Eq (f (Either (e, NotZero) a))) => Eq (ExitcodeBifunctor f e a) where
{-# INLINE (==) #-}
ExitcodeBifunctor (Exitcode f (Either (e, NotZero) a)
a) == :: ExitcodeBifunctor f e a -> ExitcodeBifunctor f e a -> Bool
== ExitcodeBifunctor (Exitcode f (Either (e, NotZero) a)
b) = f (Either (e, NotZero) a)
a f (Either (e, NotZero) a) -> f (Either (e, NotZero) a) -> Bool
forall a. Eq a => a -> a -> Bool
== f (Either (e, NotZero) a)
b
instance (Eq1 f, Eq e) => Eq1 (ExitcodeBifunctor f e) where
{-# INLINE liftEq #-}
liftEq :: forall a b.
(a -> b -> Bool)
-> ExitcodeBifunctor f e a -> ExitcodeBifunctor f e b -> Bool
liftEq a -> b -> Bool
f (ExitcodeBifunctor (Exitcode f (Either (e, NotZero) a)
a)) (ExitcodeBifunctor (Exitcode f (Either (e, NotZero) b)
b)) =
(Either (e, NotZero) a -> Either (e, NotZero) b -> Bool)
-> f (Either (e, NotZero) a) -> f (Either (e, NotZero) b) -> Bool
forall a b. (a -> b -> Bool) -> f a -> f b -> Bool
forall (f :: * -> *) a b.
Eq1 f =>
(a -> b -> Bool) -> f a -> f b -> Bool
liftEq ((a -> b -> Bool)
-> Either (e, NotZero) a -> Either (e, NotZero) b -> Bool
forall a b.
(a -> b -> Bool)
-> Either (e, NotZero) a -> Either (e, NotZero) b -> Bool
forall (f :: * -> *) a b.
Eq1 f =>
(a -> b -> Bool) -> f a -> f b -> Bool
liftEq a -> b -> Bool
f) f (Either (e, NotZero) a)
a f (Either (e, NotZero) b)
b
instance (Ord (f (Either (e, NotZero) a))) => Ord (ExitcodeBifunctor f e a) where
{-# INLINE compare #-}
ExitcodeBifunctor (Exitcode f (Either (e, NotZero) a)
a) compare :: ExitcodeBifunctor f e a -> ExitcodeBifunctor f e a -> Ordering
`compare` ExitcodeBifunctor (Exitcode f (Either (e, NotZero) a)
b) = f (Either (e, NotZero) a) -> f (Either (e, NotZero) a) -> Ordering
forall a. Ord a => a -> a -> Ordering
compare f (Either (e, NotZero) a)
a f (Either (e, NotZero) a)
b
instance (Ord1 f, Ord e) => Ord1 (ExitcodeBifunctor f e) where
{-# INLINE liftCompare #-}
liftCompare :: forall a b.
(a -> b -> Ordering)
-> ExitcodeBifunctor f e a -> ExitcodeBifunctor f e b -> Ordering
liftCompare a -> b -> Ordering
f (ExitcodeBifunctor (Exitcode f (Either (e, NotZero) a)
a)) (ExitcodeBifunctor (Exitcode f (Either (e, NotZero) b)
b)) =
(Either (e, NotZero) a -> Either (e, NotZero) b -> Ordering)
-> f (Either (e, NotZero) a)
-> f (Either (e, NotZero) b)
-> Ordering
forall a b. (a -> b -> Ordering) -> f a -> f b -> Ordering
forall (f :: * -> *) a b.
Ord1 f =>
(a -> b -> Ordering) -> f a -> f b -> Ordering
liftCompare ((a -> b -> Ordering)
-> Either (e, NotZero) a -> Either (e, NotZero) b -> Ordering
forall a b.
(a -> b -> Ordering)
-> Either (e, NotZero) a -> Either (e, NotZero) b -> Ordering
forall (f :: * -> *) a b.
Ord1 f =>
(a -> b -> Ordering) -> f a -> f b -> Ordering
liftCompare a -> b -> Ordering
f) f (Either (e, NotZero) a)
a f (Either (e, NotZero) b)
b
instance (Show (f (Either (e, NotZero) a))) => Show (ExitcodeBifunctor f e a) where
{-# INLINE showsPrec #-}
showsPrec :: Int -> ExitcodeBifunctor f e a -> ShowS
showsPrec Int
d (ExitcodeBifunctor (Exitcode f (Either (e, NotZero) a)
m)) =
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"ExitcodeBifunctor (Exitcode " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> f (Either (e, NotZero) a) -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 f (Either (e, NotZero) a)
m ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
")"
instance (Show1 f, Show e) => Show1 (ExitcodeBifunctor f e) where
{-# INLINE liftShowsPrec #-}
liftShowsPrec :: forall a.
(Int -> a -> ShowS)
-> ([a] -> ShowS) -> Int -> ExitcodeBifunctor f e a -> ShowS
liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
sl Int
d (ExitcodeBifunctor (Exitcode f (Either (e, NotZero) a)
fa)) =
Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"ExitcodeBifunctor (Exitcode "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int -> Either (e, NotZero) a -> ShowS)
-> ([Either (e, NotZero) a] -> ShowS)
-> Int
-> f (Either (e, NotZero) a)
-> ShowS
forall a.
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS
forall (f :: * -> *) a.
Show1 f =>
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS
liftShowsPrec ((Int -> a -> ShowS)
-> ([a] -> ShowS) -> Int -> Either (e, NotZero) a -> ShowS
forall a.
(Int -> a -> ShowS)
-> ([a] -> ShowS) -> Int -> Either (e, NotZero) a -> ShowS
forall (f :: * -> *) a.
Show1 f =>
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS
liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
sl) ((Int -> a -> ShowS)
-> ([a] -> ShowS) -> [Either (e, NotZero) a] -> ShowS
forall a.
(Int -> a -> ShowS)
-> ([a] -> ShowS) -> [Either (e, NotZero) a] -> ShowS
forall (f :: * -> *) a.
Show1 f =>
(Int -> a -> ShowS) -> ([a] -> ShowS) -> [f a] -> ShowS
liftShowList Int -> a -> ShowS
sp [a] -> ShowS
sl) Int
11 f (Either (e, NotZero) a)
fa
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
")"
instance (NFData1 f, NFData e, NFData a) => NFData (ExitcodeBifunctor f e a) where
{-# INLINE rnf #-}
rnf :: ExitcodeBifunctor f e a -> ()
rnf = (a -> ()) -> ExitcodeBifunctor f e a -> ()
forall a. (a -> ()) -> ExitcodeBifunctor f e a -> ()
forall (f :: * -> *) a. NFData1 f => (a -> ()) -> f a -> ()
liftRnf a -> ()
forall a. NFData a => a -> ()
rnf
instance (NFData1 f, NFData e) => NFData1 (ExitcodeBifunctor f e) where
{-# INLINE liftRnf #-}
liftRnf :: forall a. (a -> ()) -> ExitcodeBifunctor f e a -> ()
liftRnf a -> ()
r (ExitcodeBifunctor (Exitcode f (Either (e, NotZero) a)
x)) = (Either (e, NotZero) a -> ()) -> f (Either (e, NotZero) a) -> ()
forall a. (a -> ()) -> f a -> ()
forall (f :: * -> *) a. NFData1 f => (a -> ()) -> f a -> ()
liftRnf Either (e, NotZero) a -> ()
forall {a}. NFData a => Either (a, NotZero) a -> ()
rnfEither f (Either (e, NotZero) a)
x
where
rnfEither :: Either (a, NotZero) a -> ()
rnfEither (Right a
a) = a -> ()
r a
a
rnfEither (Left (a
e, NotZero
n)) = a -> ()
forall a. NFData a => a -> ()
rnf a
e () -> () -> ()
forall a b. a -> b -> b
`seq` Int -> ()
forall a. NFData a => a -> ()
rnf (AReview Int NotZero -> NotZero -> Int
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview Int NotZero
forall a. AsNotZero a => Prism' a NotZero
Prism' Int NotZero
_NotZero NotZero
n :: Int)
instance (MonadIO f) => MonadIO (ExitcodeBifunctor f e) where
{-# INLINE liftIO #-}
liftIO :: forall a. IO a -> ExitcodeBifunctor f e a
liftIO = Exitcode e f a -> ExitcodeBifunctor f e a
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor (Exitcode e f a -> ExitcodeBifunctor f e a)
-> (IO a -> Exitcode e f a) -> IO a -> ExitcodeBifunctor f e a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IO a -> Exitcode e f a
forall a. IO a -> Exitcode e f a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO
instance (MonadReader r f) => MonadReader r (ExitcodeBifunctor f e) where
{-# INLINE ask #-}
ask :: ExitcodeBifunctor f e r
ask = Exitcode e f r -> ExitcodeBifunctor f e r
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor Exitcode e f r
forall r (m :: * -> *). MonadReader r m => m r
ask
{-# INLINE local #-}
local :: forall a.
(r -> r) -> ExitcodeBifunctor f e a -> ExitcodeBifunctor f e a
local r -> r
f (ExitcodeBifunctor Exitcode e f a
x) = Exitcode e f a -> ExitcodeBifunctor f e a
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor ((r -> r) -> Exitcode e f a -> Exitcode e f a
forall a. (r -> r) -> Exitcode e f a -> Exitcode e f a
forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local r -> r
f Exitcode e f a
x)
instance (MonadWriter w f) => MonadWriter w (ExitcodeBifunctor f e) where
{-# INLINE writer #-}
writer :: forall a. (a, w) -> ExitcodeBifunctor f e a
writer (a, w)
t = Exitcode e f a -> ExitcodeBifunctor f e a
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor ((a, w) -> Exitcode e f a
forall a. (a, w) -> Exitcode e f a
forall w (m :: * -> *) a. MonadWriter w m => (a, w) -> m a
writer (a, w)
t)
{-# INLINE listen #-}
listen :: forall a. ExitcodeBifunctor f e a -> ExitcodeBifunctor f e (a, w)
listen (ExitcodeBifunctor Exitcode e f a
x) = Exitcode e f (a, w) -> ExitcodeBifunctor f e (a, w)
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor (Exitcode e f a -> Exitcode e f (a, w)
forall a. Exitcode e f a -> Exitcode e f (a, w)
forall w (m :: * -> *) a. MonadWriter w m => m a -> m (a, w)
listen Exitcode e f a
x)
{-# INLINE tell #-}
tell :: w -> ExitcodeBifunctor f e ()
tell = Exitcode e f () -> ExitcodeBifunctor f e ()
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor (Exitcode e f () -> ExitcodeBifunctor f e ())
-> (w -> Exitcode e f ()) -> w -> ExitcodeBifunctor f e ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. w -> Exitcode e f ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell
{-# INLINE pass #-}
pass :: forall a.
ExitcodeBifunctor f e (a, w -> w) -> ExitcodeBifunctor f e a
pass (ExitcodeBifunctor Exitcode e f (a, w -> w)
x) = Exitcode e f a -> ExitcodeBifunctor f e a
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor (Exitcode e f (a, w -> w) -> Exitcode e f a
forall a. Exitcode e f (a, w -> w) -> Exitcode e f a
forall w (m :: * -> *) a. MonadWriter w m => m (a, w -> w) -> m a
pass Exitcode e f (a, w -> w)
x)
instance (MonadState s f) => MonadState s (ExitcodeBifunctor f e) where
{-# INLINE get #-}
get :: ExitcodeBifunctor f e s
get = Exitcode e f s -> ExitcodeBifunctor f e s
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor Exitcode e f s
forall s (m :: * -> *). MonadState s m => m s
get
{-# INLINE put #-}
put :: s -> ExitcodeBifunctor f e ()
put = Exitcode e f () -> ExitcodeBifunctor f e ()
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor (Exitcode e f () -> ExitcodeBifunctor f e ())
-> (s -> Exitcode e f ()) -> s -> ExitcodeBifunctor f e ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> Exitcode e f ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put
instance (MonadError e f) => MonadError e (ExitcodeBifunctor f e') where
{-# INLINE throwError #-}
throwError :: forall a. e -> ExitcodeBifunctor f e' a
throwError = Exitcode e' f a -> ExitcodeBifunctor f e' a
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor (Exitcode e' f a -> ExitcodeBifunctor f e' a)
-> (e -> Exitcode e' f a) -> e -> ExitcodeBifunctor f e' a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> Exitcode e' f a
forall a. e -> Exitcode e' f a
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError
{-# INLINE catchError #-}
catchError :: forall a.
ExitcodeBifunctor f e' a
-> (e -> ExitcodeBifunctor f e' a) -> ExitcodeBifunctor f e' a
catchError (ExitcodeBifunctor Exitcode e' f a
x) e -> ExitcodeBifunctor f e' a
h = Exitcode e' f a -> ExitcodeBifunctor f e' a
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor (Exitcode e' f a -> (e -> Exitcode e' f a) -> Exitcode e' f a
forall a.
Exitcode e' f a -> (e -> Exitcode e' f a) -> Exitcode e' f a
forall e (m :: * -> *) a.
MonadError e m =>
m a -> (e -> m a) -> m a
catchError Exitcode e' f a
x (\e
e -> let ExitcodeBifunctor Exitcode e' f a
y = e -> ExitcodeBifunctor f e' a
h e
e in Exitcode e' f a
y))
instance (MonadRWS r w s f) => MonadRWS r w s (ExitcodeBifunctor f e)
instance (MonadCont f) => MonadCont (ExitcodeBifunctor f e) where
callCC :: forall a b.
((a -> ExitcodeBifunctor f e b) -> ExitcodeBifunctor f e a)
-> ExitcodeBifunctor f e a
callCC (a -> ExitcodeBifunctor f e b) -> ExitcodeBifunctor f e a
f = Exitcode e f a -> ExitcodeBifunctor f e a
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor (((a -> Exitcode e f b) -> Exitcode e f a) -> Exitcode e f a
forall a b.
((a -> Exitcode e f b) -> Exitcode e f a) -> Exitcode e f a
forall (m :: * -> *) a b. MonadCont m => ((a -> m b) -> m a) -> m a
callCC (\a -> Exitcode e f b
c -> let ExitcodeBifunctor Exitcode e f a
x = (a -> ExitcodeBifunctor f e b) -> ExitcodeBifunctor f e a
f (Exitcode e f b -> ExitcodeBifunctor f e b
forall (f :: * -> *) e a. Exitcode e f a -> ExitcodeBifunctor f e a
ExitcodeBifunctor (Exitcode e f b -> ExitcodeBifunctor f e b)
-> (a -> Exitcode e f b) -> a -> ExitcodeBifunctor f e b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Exitcode e f b
c) in Exitcode e f a
x))