{-# LANGUAGE RankNTypes #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Control.Monad.Class.MonadThrow.Trans () where
import Control.Monad.Except
import qualified Control.Monad.RWS.Lazy as Lazy
import qualified Control.Monad.RWS.Strict as Strict
import qualified Control.Monad.State.Lazy as Lazy
import qualified Control.Monad.State.Strict as Strict
import qualified Control.Monad.Writer.Lazy as Lazy
import qualified Control.Monad.Writer.Strict as Strict
import Control.Monad.Class.MonadThrow
instance MonadCatch m => MonadThrow (ExceptT e m) where
throwIO :: forall e a. Exception e => e -> ExceptT e m a
throwIO = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwIO
instance MonadCatch m => MonadCatch (ExceptT e m) where
catch :: forall e a.
Exception e =>
ExceptT e m a -> (e -> ExceptT e m a) -> ExceptT e m a
catch (ExceptT m (Either e a)
m) e -> ExceptT e m a
f = forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
m a -> (e -> m a) -> m a
catch m (Either e a)
m (forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> ExceptT e m a
f)
generalBracket :: forall a b c.
ExceptT e m a
-> (a -> ExitCase b -> ExceptT e m c)
-> (a -> ExceptT e m b)
-> ExceptT e m (b, c)
generalBracket ExceptT e m a
acquire a -> ExitCase b -> ExceptT e m c
release a -> ExceptT e m b
use = forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT forall a b. (a -> b) -> a -> b
$ do
(Either e b
eb, Either e c
ec) <- forall (m :: * -> *) a b c.
MonadCatch m =>
m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c)
generalBracket
(forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT ExceptT e m a
acquire)
(\Either e a
eresource ExitCase (Either e b)
exitCase -> case Either e a
eresource of
Left e
e -> forall (m :: * -> *) a. Monad m => a -> m a
return (forall a b. a -> Either a b
Left e
e)
Right a
resource -> case ExitCase (Either e b)
exitCase of
ExitCaseSuccess (Right b
b) -> forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (a -> ExitCase b -> ExceptT e m c
release a
resource (forall a. a -> ExitCase a
ExitCaseSuccess b
b))
ExitCaseException SomeException
e -> forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (a -> ExitCase b -> ExceptT e m c
release a
resource (forall a. SomeException -> ExitCase a
ExitCaseException SomeException
e))
ExitCase (Either e b)
_ -> forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (a -> ExitCase b -> ExceptT e m c
release a
resource forall a. ExitCase a
ExitCaseAbort))
(forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. a -> Either a b
Left) (forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> ExceptT e m b
use))
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ do
c
c <- Either e c
ec
b
b <- Either e b
eb
forall (m :: * -> *) a. Monad m => a -> m a
return (b
b, c
c)
instance MonadMask m => MonadMask (ExceptT e m) where
mask :: forall b.
((forall a. ExceptT e m a -> ExceptT e m a) -> ExceptT e m b)
-> ExceptT e m b
mask (forall a. ExceptT e m a -> ExceptT e m a) -> ExceptT e m b
f = forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) b.
MonadMask m =>
((forall a. m a -> m a) -> m b) -> m b
mask forall a b. (a -> b) -> a -> b
$ \forall a. m a -> m a
u -> forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT forall a b. (a -> b) -> a -> b
$ (forall a. ExceptT e m a -> ExceptT e m a) -> ExceptT e m b
f (forall (m :: * -> *) e a.
(m (Either e a) -> m (Either e a))
-> ExceptT e m a -> ExceptT e m a
q forall a. m a -> m a
u)
where
q :: (m (Either e a) -> m (Either e a))
-> ExceptT e m a -> ExceptT e m a
q :: forall (m :: * -> *) e a.
(m (Either e a) -> m (Either e a))
-> ExceptT e m a -> ExceptT e m a
q m (Either e a) -> m (Either e a)
u (ExceptT m (Either e a)
b) = forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT (m (Either e a) -> m (Either e a)
u m (Either e a)
b)
uninterruptibleMask :: forall b.
((forall a. ExceptT e m a -> ExceptT e m a) -> ExceptT e m b)
-> ExceptT e m b
uninterruptibleMask (forall a. ExceptT e m a -> ExceptT e m a) -> ExceptT e m b
f = forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) b.
MonadMask m =>
((forall a. m a -> m a) -> m b) -> m b
uninterruptibleMask forall a b. (a -> b) -> a -> b
$ \forall a. m a -> m a
u -> forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT forall a b. (a -> b) -> a -> b
$ (forall a. ExceptT e m a -> ExceptT e m a) -> ExceptT e m b
f (forall (m :: * -> *) e a.
(m (Either e a) -> m (Either e a))
-> ExceptT e m a -> ExceptT e m a
q forall a. m a -> m a
u)
where
q :: (m (Either e a) -> m (Either e a))
-> ExceptT e m a -> ExceptT e m a
q :: forall (m :: * -> *) e a.
(m (Either e a) -> m (Either e a))
-> ExceptT e m a -> ExceptT e m a
q m (Either e a) -> m (Either e a)
u (ExceptT m (Either e a)
b) = forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT (m (Either e a) -> m (Either e a)
u m (Either e a)
b)
instance (Monoid w, MonadCatch m) => MonadThrow (Lazy.WriterT w m) where
throwIO :: forall e a. Exception e => e -> WriterT w m a
throwIO = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwIO
instance (Monoid w, MonadCatch m) => MonadCatch (Lazy.WriterT w m) where
catch :: forall e a.
Exception e =>
WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a
catch (Lazy.WriterT m (a, w)
m) e -> WriterT w m a
f = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Lazy.WriterT forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
m a -> (e -> m a) -> m a
catch m (a, w)
m (forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
Lazy.runWriterT forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> WriterT w m a
f)
generalBracket :: forall a b c.
WriterT w m a
-> (a -> ExitCase b -> WriterT w m c)
-> (a -> WriterT w m b)
-> WriterT w m (b, c)
generalBracket WriterT w m a
acquire a -> ExitCase b -> WriterT w m c
release a -> WriterT w m b
use = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Lazy.WriterT forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall {a} {b} {b} {b}. ((a, b), (b, b)) -> ((a, b), b)
f forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a b c.
MonadCatch m =>
m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c)
generalBracket
(forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
Lazy.runWriterT WriterT w m a
acquire)
(\(a
resource, w
w) ExitCase (b, w)
e ->
case ExitCase (b, w)
e of
ExitCaseSuccess (b
b, w
w') ->
forall {b} {a}. Semigroup b => b -> (a, b) -> (a, b)
g w
w' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
Lazy.runWriterT (a -> ExitCase b -> WriterT w m c
release a
resource (forall a. a -> ExitCase a
ExitCaseSuccess b
b))
ExitCaseException SomeException
err ->
forall {b} {a}. Semigroup b => b -> (a, b) -> (a, b)
g w
w forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
Lazy.runWriterT (a -> ExitCase b -> WriterT w m c
release a
resource (forall a. SomeException -> ExitCase a
ExitCaseException SomeException
err))
ExitCase (b, w)
ExitCaseAbort ->
forall {b} {a}. Semigroup b => b -> (a, b) -> (a, b)
g w
w forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
Lazy.runWriterT (a -> ExitCase b -> WriterT w m c
release a
resource forall a. ExitCase a
ExitCaseAbort))
(\(a
resource, w
w) -> forall {b} {a}. Semigroup b => b -> (a, b) -> (a, b)
g w
w forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
Lazy.runWriterT (a -> WriterT w m b
use a
resource))
where f :: ((a, b), (b, b)) -> ((a, b), b)
f ((a
x,b
_),(b
y,b
w)) = ((a
x,b
y),b
w)
g :: b -> (a, b) -> (a, b)
g b
w (a
a,b
w') = (a
a,b
wforall a. Semigroup a => a -> a -> a
<>b
w')
instance (Monoid w, MonadMask m) => MonadMask (Lazy.WriterT w m) where
mask :: forall b.
((forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b)
-> WriterT w m b
mask (forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b
f = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Lazy.WriterT forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) b.
MonadMask m =>
((forall a. m a -> m a) -> m b) -> m b
mask forall a b. (a -> b) -> a -> b
$ \forall a. m a -> m a
u -> forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
Lazy.runWriterT forall a b. (a -> b) -> a -> b
$ (forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b
f (forall (m :: * -> *) w a.
(forall x. m x -> m x) -> WriterT w m a -> WriterT w m a
q forall a. m a -> m a
u)
where
q :: (forall x. m x -> m x)
-> Lazy.WriterT w m a -> Lazy.WriterT w m a
q :: forall (m :: * -> *) w a.
(forall x. m x -> m x) -> WriterT w m a -> WriterT w m a
q forall x. m x -> m x
u (Lazy.WriterT m (a, w)
b) = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Lazy.WriterT (forall x. m x -> m x
u m (a, w)
b)
uninterruptibleMask :: forall b.
((forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b)
-> WriterT w m b
uninterruptibleMask (forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b
f = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Lazy.WriterT forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) b.
MonadMask m =>
((forall a. m a -> m a) -> m b) -> m b
uninterruptibleMask forall a b. (a -> b) -> a -> b
$ \forall a. m a -> m a
u -> forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
Lazy.runWriterT forall a b. (a -> b) -> a -> b
$ (forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b
f (forall (m :: * -> *) w a.
(forall x. m x -> m x) -> WriterT w m a -> WriterT w m a
q forall a. m a -> m a
u)
where
q :: (forall x. m x -> m x)
-> Lazy.WriterT w m a -> Lazy.WriterT w m a
q :: forall (m :: * -> *) w a.
(forall x. m x -> m x) -> WriterT w m a -> WriterT w m a
q forall x. m x -> m x
u (Lazy.WriterT m (a, w)
b) = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Lazy.WriterT (forall x. m x -> m x
u m (a, w)
b)
instance (Monoid w, MonadCatch m) => MonadThrow (Strict.WriterT w m) where
throwIO :: forall e a. Exception e => e -> WriterT w m a
throwIO = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwIO
instance (Monoid w, MonadCatch m) => MonadCatch (Strict.WriterT w m) where
catch :: forall e a.
Exception e =>
WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a
catch (Strict.WriterT m (a, w)
m) e -> WriterT w m a
f = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Strict.WriterT forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
m a -> (e -> m a) -> m a
catch m (a, w)
m (forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
Strict.runWriterT forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> WriterT w m a
f)
generalBracket :: forall a b c.
WriterT w m a
-> (a -> ExitCase b -> WriterT w m c)
-> (a -> WriterT w m b)
-> WriterT w m (b, c)
generalBracket WriterT w m a
acquire a -> ExitCase b -> WriterT w m c
release a -> WriterT w m b
use = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Strict.WriterT forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall {a} {b} {b} {b}. ((a, b), (b, b)) -> ((a, b), b)
f forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a b c.
MonadCatch m =>
m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c)
generalBracket
(forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
Strict.runWriterT WriterT w m a
acquire)
(\(a
resource, w
w) ExitCase (b, w)
e ->
case ExitCase (b, w)
e of
ExitCaseSuccess (b
b, w
w') ->
forall {b} {a}. Semigroup b => b -> (a, b) -> (a, b)
g w
w' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
Strict.runWriterT (a -> ExitCase b -> WriterT w m c
release a
resource (forall a. a -> ExitCase a
ExitCaseSuccess b
b))
ExitCaseException SomeException
err ->
forall {b} {a}. Semigroup b => b -> (a, b) -> (a, b)
g w
w forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
Strict.runWriterT (a -> ExitCase b -> WriterT w m c
release a
resource (forall a. SomeException -> ExitCase a
ExitCaseException SomeException
err))
ExitCase (b, w)
ExitCaseAbort ->
forall {b} {a}. Semigroup b => b -> (a, b) -> (a, b)
g w
w forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
Strict.runWriterT (a -> ExitCase b -> WriterT w m c
release a
resource forall a. ExitCase a
ExitCaseAbort))
(\(a
resource, w
w) -> forall {b} {a}. Semigroup b => b -> (a, b) -> (a, b)
g w
w forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
Strict.runWriterT (a -> WriterT w m b
use a
resource))
where f :: ((a, b), (b, b)) -> ((a, b), b)
f ((a
x,b
_),(b
y,b
w)) = ((a
x,b
y),b
w)
g :: b -> (a, b) -> (a, b)
g b
w (a
a,b
w') = (a
a,b
wforall a. Semigroup a => a -> a -> a
<>b
w')
instance (Monoid w, MonadMask m) => MonadMask (Strict.WriterT w m) where
mask :: forall b.
((forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b)
-> WriterT w m b
mask (forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b
f = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Strict.WriterT forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) b.
MonadMask m =>
((forall a. m a -> m a) -> m b) -> m b
mask forall a b. (a -> b) -> a -> b
$ \forall a. m a -> m a
u -> forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
Strict.runWriterT forall a b. (a -> b) -> a -> b
$ (forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b
f (forall (m :: * -> *) w a.
(forall x. m x -> m x) -> WriterT w m a -> WriterT w m a
q forall a. m a -> m a
u)
where
q :: (forall x. m x -> m x)
-> Strict.WriterT w m a -> Strict.WriterT w m a
q :: forall (m :: * -> *) w a.
(forall x. m x -> m x) -> WriterT w m a -> WriterT w m a
q forall x. m x -> m x
u (Strict.WriterT m (a, w)
b) = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Strict.WriterT (forall x. m x -> m x
u m (a, w)
b)
uninterruptibleMask :: forall b.
((forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b)
-> WriterT w m b
uninterruptibleMask (forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b
f = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Strict.WriterT forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) b.
MonadMask m =>
((forall a. m a -> m a) -> m b) -> m b
uninterruptibleMask forall a b. (a -> b) -> a -> b
$ \forall a. m a -> m a
u -> forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
Strict.runWriterT forall a b. (a -> b) -> a -> b
$ (forall a. WriterT w m a -> WriterT w m a) -> WriterT w m b
f (forall (m :: * -> *) w a.
(forall x. m x -> m x) -> WriterT w m a -> WriterT w m a
q forall a. m a -> m a
u)
where
q :: (forall x. m x -> m x)
-> Strict.WriterT w m a -> Strict.WriterT w m a
q :: forall (m :: * -> *) w a.
(forall x. m x -> m x) -> WriterT w m a -> WriterT w m a
q forall x. m x -> m x
u (Strict.WriterT m (a, w)
b) = forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Strict.WriterT (forall x. m x -> m x
u m (a, w)
b)
instance (Monoid w, MonadCatch m) => MonadThrow (Lazy.RWST r w s m) where
throwIO :: forall e a. Exception e => e -> RWST r w s m a
throwIO = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwIO
instance (Monoid w, MonadCatch m) => MonadCatch (Lazy.RWST r w s m) where
catch :: forall e a.
Exception e =>
RWST r w s m a -> (e -> RWST r w s m a) -> RWST r w s m a
catch (Lazy.RWST r -> s -> m (a, s, w)
m) e -> RWST r w s m a
f = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Lazy.RWST forall a b. (a -> b) -> a -> b
$ \r
r s
s -> forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
m a -> (e -> m a) -> m a
catch (r -> s -> m (a, s, w)
m r
r s
s) (\e
e -> forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
Lazy.runRWST (e -> RWST r w s m a
f e
e) r
r s
s)
generalBracket :: forall a b c.
RWST r w s m a
-> (a -> ExitCase b -> RWST r w s m c)
-> (a -> RWST r w s m b)
-> RWST r w s m (b, c)
generalBracket RWST r w s m a
acquire a -> ExitCase b -> RWST r w s m c
release a -> RWST r w s m b
use = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Lazy.RWST forall a b. (a -> b) -> a -> b
$ \r
r s
s ->
forall {a} {b} {c} {b} {b} {c}.
((a, b, c), (b, b, c)) -> ((a, b), b, c)
f forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a b c.
MonadCatch m =>
m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c)
generalBracket
(forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
Lazy.runRWST RWST r w s m a
acquire r
r s
s)
(\(a
resource, s
s', w
w') ExitCase (b, s, w)
e ->
case ExitCase (b, s, w)
e of
ExitCaseSuccess (b
b, s
s'', w
w'') ->
forall {c} {a} {b}. Semigroup c => c -> (a, b, c) -> (a, b, c)
g w
w'' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
Lazy.runRWST (a -> ExitCase b -> RWST r w s m c
release a
resource (forall a. a -> ExitCase a
ExitCaseSuccess b
b)) r
r s
s''
ExitCaseException SomeException
err ->
forall {c} {a} {b}. Semigroup c => c -> (a, b, c) -> (a, b, c)
g w
w' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
Lazy.runRWST (a -> ExitCase b -> RWST r w s m c
release a
resource (forall a. SomeException -> ExitCase a
ExitCaseException SomeException
err)) r
r s
s'
ExitCase (b, s, w)
ExitCaseAbort ->
forall {c} {a} {b}. Semigroup c => c -> (a, b, c) -> (a, b, c)
g w
w' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
Lazy.runRWST (a -> ExitCase b -> RWST r w s m c
release a
resource forall a. ExitCase a
ExitCaseAbort) r
r s
s')
(\(a
a, s
s', w
w') -> forall {c} {a} {b}. Semigroup c => c -> (a, b, c) -> (a, b, c)
g w
w' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
Lazy.runRWST (a -> RWST r w s m b
use a
a) r
r s
s')
where
f :: ((a, b, c), (b, b, c)) -> ((a, b), b, c)
f ((a
x,b
_,c
_),(b
y,b
s,c
w)) = ((a
x,b
y),b
s,c
w)
g :: c -> (a, b, c) -> (a, b, c)
g c
w (a
x,b
s,c
w') = (a
x,b
s,c
wforall a. Semigroup a => a -> a -> a
<>c
w')
instance (Monoid w, MonadMask m) => MonadMask (Lazy.RWST r w s m) where
mask :: forall b.
((forall a. RWST r w s m a -> RWST r w s m a) -> RWST r w s m b)
-> RWST r w s m b
mask (forall a. RWST r w s m a -> RWST r w s m a) -> RWST r w s m b
f = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Lazy.RWST forall a b. (a -> b) -> a -> b
$ \r
r s
s -> forall (m :: * -> *) b.
MonadMask m =>
((forall a. m a -> m a) -> m b) -> m b
mask forall a b. (a -> b) -> a -> b
$ \forall a. m a -> m a
u -> forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
Lazy.runRWST ((forall a. RWST r w s m a -> RWST r w s m a) -> RWST r w s m b
f (forall (m :: * -> *) r w s a.
(forall x. m x -> m x) -> RWST r w s m a -> RWST r w s m a
q forall a. m a -> m a
u)) r
r s
s
where
q :: (forall x. m x -> m x)
-> Lazy.RWST r w s m a -> Lazy.RWST r w s m a
q :: forall (m :: * -> *) r w s a.
(forall x. m x -> m x) -> RWST r w s m a -> RWST r w s m a
q forall x. m x -> m x
u (Lazy.RWST r -> s -> m (a, s, w)
b) = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Lazy.RWST forall a b. (a -> b) -> a -> b
$ \r
r s
s -> forall x. m x -> m x
u (r -> s -> m (a, s, w)
b r
r s
s)
uninterruptibleMask :: forall b.
((forall a. RWST r w s m a -> RWST r w s m a) -> RWST r w s m b)
-> RWST r w s m b
uninterruptibleMask (forall a. RWST r w s m a -> RWST r w s m a) -> RWST r w s m b
f = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Lazy.RWST forall a b. (a -> b) -> a -> b
$ \r
r s
s -> forall (m :: * -> *) b.
MonadMask m =>
((forall a. m a -> m a) -> m b) -> m b
uninterruptibleMask forall a b. (a -> b) -> a -> b
$ \forall a. m a -> m a
u -> forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
Lazy.runRWST ((forall a. RWST r w s m a -> RWST r w s m a) -> RWST r w s m b
f (forall (m :: * -> *) r w s a.
(forall x. m x -> m x) -> RWST r w s m a -> RWST r w s m a
q forall a. m a -> m a
u)) r
r s
s
where
q :: (forall x. m x -> m x)
-> Lazy.RWST r w s m a -> Lazy.RWST r w s m a
q :: forall (m :: * -> *) r w s a.
(forall x. m x -> m x) -> RWST r w s m a -> RWST r w s m a
q forall x. m x -> m x
u (Lazy.RWST r -> s -> m (a, s, w)
b) = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Lazy.RWST forall a b. (a -> b) -> a -> b
$ \r
r s
s -> forall x. m x -> m x
u (r -> s -> m (a, s, w)
b r
r s
s)
instance (Monoid w, MonadCatch m) => MonadThrow (Strict.RWST r w s m) where
throwIO :: forall e a. Exception e => e -> RWST r w s m a
throwIO = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwIO
instance (Monoid w, MonadCatch m) => MonadCatch (Strict.RWST r w s m) where
catch :: forall e a.
Exception e =>
RWST r w s m a -> (e -> RWST r w s m a) -> RWST r w s m a
catch (Strict.RWST r -> s -> m (a, s, w)
m) e -> RWST r w s m a
f = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Strict.RWST forall a b. (a -> b) -> a -> b
$ \r
r s
s -> forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
m a -> (e -> m a) -> m a
catch (r -> s -> m (a, s, w)
m r
r s
s) (\e
e -> forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
Strict.runRWST (e -> RWST r w s m a
f e
e) r
r s
s)
generalBracket :: forall a b c.
RWST r w s m a
-> (a -> ExitCase b -> RWST r w s m c)
-> (a -> RWST r w s m b)
-> RWST r w s m (b, c)
generalBracket RWST r w s m a
acquire a -> ExitCase b -> RWST r w s m c
release a -> RWST r w s m b
use = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Strict.RWST forall a b. (a -> b) -> a -> b
$ \r
r s
s ->
forall {a} {b} {c} {b} {b} {c}.
((a, b, c), (b, b, c)) -> ((a, b), b, c)
f forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a b c.
MonadCatch m =>
m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c)
generalBracket
(forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
Strict.runRWST RWST r w s m a
acquire r
r s
s)
(\(a
resource, s
s', w
w') ExitCase (b, s, w)
e ->
case ExitCase (b, s, w)
e of
ExitCaseSuccess (b
b, s
s'', w
w'') ->
forall {c} {a} {b}. Semigroup c => c -> (a, b, c) -> (a, b, c)
g w
w'' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
Strict.runRWST (a -> ExitCase b -> RWST r w s m c
release a
resource (forall a. a -> ExitCase a
ExitCaseSuccess b
b)) r
r s
s''
ExitCaseException SomeException
err ->
forall {c} {a} {b}. Semigroup c => c -> (a, b, c) -> (a, b, c)
g w
w' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
Strict.runRWST (a -> ExitCase b -> RWST r w s m c
release a
resource (forall a. SomeException -> ExitCase a
ExitCaseException SomeException
err)) r
r s
s'
ExitCase (b, s, w)
ExitCaseAbort ->
forall {c} {a} {b}. Semigroup c => c -> (a, b, c) -> (a, b, c)
g w
w' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
Strict.runRWST (a -> ExitCase b -> RWST r w s m c
release a
resource forall a. ExitCase a
ExitCaseAbort) r
r s
s')
(\(a
a, s
s', w
w') -> forall {c} {a} {b}. Semigroup c => c -> (a, b, c) -> (a, b, c)
g w
w' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
Strict.runRWST (a -> RWST r w s m b
use a
a) r
r s
s')
where
f :: ((a, b, c), (b, b, c)) -> ((a, b), b, c)
f ((a
x,b
_,c
_),(b
y,b
s,c
w)) = ((a
x,b
y),b
s,c
w)
g :: c -> (a, b, c) -> (a, b, c)
g c
w (a
x,b
s,c
w') = (a
x,b
s,c
wforall a. Semigroup a => a -> a -> a
<>c
w')
instance (Monoid w, MonadMask m) => MonadMask (Strict.RWST r w s m) where
mask :: forall b.
((forall a. RWST r w s m a -> RWST r w s m a) -> RWST r w s m b)
-> RWST r w s m b
mask (forall a. RWST r w s m a -> RWST r w s m a) -> RWST r w s m b
f = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Strict.RWST forall a b. (a -> b) -> a -> b
$ \r
r s
s -> forall (m :: * -> *) b.
MonadMask m =>
((forall a. m a -> m a) -> m b) -> m b
mask forall a b. (a -> b) -> a -> b
$ \forall a. m a -> m a
u -> forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
Strict.runRWST ((forall a. RWST r w s m a -> RWST r w s m a) -> RWST r w s m b
f (forall (m :: * -> *) r w s a.
(forall x. m x -> m x) -> RWST r w s m a -> RWST r w s m a
q forall a. m a -> m a
u)) r
r s
s
where
q :: (forall x. m x -> m x)
-> Strict.RWST r w s m a -> Strict.RWST r w s m a
q :: forall (m :: * -> *) r w s a.
(forall x. m x -> m x) -> RWST r w s m a -> RWST r w s m a
q forall x. m x -> m x
u (Strict.RWST r -> s -> m (a, s, w)
b) = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Strict.RWST forall a b. (a -> b) -> a -> b
$ \r
r s
s -> forall x. m x -> m x
u (r -> s -> m (a, s, w)
b r
r s
s)
uninterruptibleMask :: forall b.
((forall a. RWST r w s m a -> RWST r w s m a) -> RWST r w s m b)
-> RWST r w s m b
uninterruptibleMask (forall a. RWST r w s m a -> RWST r w s m a) -> RWST r w s m b
f = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Strict.RWST forall a b. (a -> b) -> a -> b
$ \r
r s
s -> forall (m :: * -> *) b.
MonadMask m =>
((forall a. m a -> m a) -> m b) -> m b
uninterruptibleMask forall a b. (a -> b) -> a -> b
$ \forall a. m a -> m a
u -> forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
Strict.runRWST ((forall a. RWST r w s m a -> RWST r w s m a) -> RWST r w s m b
f (forall (m :: * -> *) r w s a.
(forall x. m x -> m x) -> RWST r w s m a -> RWST r w s m a
q forall a. m a -> m a
u)) r
r s
s
where
q :: (forall x. m x -> m x)
-> Strict.RWST r w s m a -> Strict.RWST r w s m a
q :: forall (m :: * -> *) r w s a.
(forall x. m x -> m x) -> RWST r w s m a -> RWST r w s m a
q forall x. m x -> m x
u (Strict.RWST r -> s -> m (a, s, w)
b) = forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Strict.RWST forall a b. (a -> b) -> a -> b
$ \r
r s
s -> forall x. m x -> m x
u (r -> s -> m (a, s, w)
b r
r s
s)
instance MonadCatch m => MonadThrow (Lazy.StateT s m) where
throwIO :: forall e a. Exception e => e -> StateT s m a
throwIO = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwIO
instance MonadCatch m => MonadCatch (Lazy.StateT s m) where
catch :: forall e a.
Exception e =>
StateT s m a -> (e -> StateT s m a) -> StateT s m a
catch (Lazy.StateT s -> m (a, s)
m) e -> StateT s m a
f = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Lazy.StateT forall a b. (a -> b) -> a -> b
$ \s
s -> forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
m a -> (e -> m a) -> m a
catch (s -> m (a, s)
m s
s) (\e
e -> forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
Lazy.runStateT (e -> StateT s m a
f e
e) s
s)
generalBracket :: forall a b c.
StateT s m a
-> (a -> ExitCase b -> StateT s m c)
-> (a -> StateT s m b)
-> StateT s m (b, c)
generalBracket StateT s m a
acquire a -> ExitCase b -> StateT s m c
release a -> StateT s m b
use = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Lazy.StateT forall a b. (a -> b) -> a -> b
$ \s
s -> forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall {a} {b} {b} {b}. ((a, b), (b, b)) -> ((a, b), b)
f forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a b c.
MonadCatch m =>
m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c)
generalBracket
(forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
Lazy.runStateT StateT s m a
acquire s
s)
(\(a
resource, s
s') ExitCase (b, s)
e ->
case ExitCase (b, s)
e of
ExitCaseSuccess (b
b, s
s'') ->
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
Lazy.runStateT (a -> ExitCase b -> StateT s m c
release a
resource (forall a. a -> ExitCase a
ExitCaseSuccess b
b)) s
s''
ExitCaseException SomeException
err ->
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
Lazy.runStateT (a -> ExitCase b -> StateT s m c
release a
resource (forall a. SomeException -> ExitCase a
ExitCaseException SomeException
err)) s
s'
ExitCase (b, s)
ExitCaseAbort ->
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
Lazy.runStateT (a -> ExitCase b -> StateT s m c
release a
resource forall a. ExitCase a
ExitCaseAbort) s
s')
(\(a
a, s
s') -> forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
Lazy.runStateT (a -> StateT s m b
use a
a) s
s')
where f :: ((a, b), (b, b)) -> ((a, b), b)
f ((a
x,b
_),(b
y,b
s)) = ((a
x,b
y),b
s)
instance MonadMask m => MonadMask (Lazy.StateT s m) where
mask :: forall b.
((forall a. StateT s m a -> StateT s m a) -> StateT s m b)
-> StateT s m b
mask (forall a. StateT s m a -> StateT s m a) -> StateT s m b
f = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Lazy.StateT forall a b. (a -> b) -> a -> b
$ \s
s -> forall (m :: * -> *) b.
MonadMask m =>
((forall a. m a -> m a) -> m b) -> m b
mask forall a b. (a -> b) -> a -> b
$ \forall a. m a -> m a
u -> forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
Lazy.runStateT ((forall a. StateT s m a -> StateT s m a) -> StateT s m b
f (forall (m :: * -> *) s a.
(forall x. m x -> m x) -> StateT s m a -> StateT s m a
q forall a. m a -> m a
u)) s
s
where
q :: (forall x. m x -> m x)
-> Lazy.StateT s m a -> Lazy.StateT s m a
q :: forall (m :: * -> *) s a.
(forall x. m x -> m x) -> StateT s m a -> StateT s m a
q forall x. m x -> m x
u (Lazy.StateT s -> m (a, s)
b) = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Lazy.StateT forall a b. (a -> b) -> a -> b
$ \s
s -> forall x. m x -> m x
u (s -> m (a, s)
b s
s)
uninterruptibleMask :: forall b.
((forall a. StateT s m a -> StateT s m a) -> StateT s m b)
-> StateT s m b
uninterruptibleMask (forall a. StateT s m a -> StateT s m a) -> StateT s m b
f = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Lazy.StateT forall a b. (a -> b) -> a -> b
$ \s
s -> forall (m :: * -> *) b.
MonadMask m =>
((forall a. m a -> m a) -> m b) -> m b
uninterruptibleMask forall a b. (a -> b) -> a -> b
$ \forall a. m a -> m a
u -> forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
Lazy.runStateT ((forall a. StateT s m a -> StateT s m a) -> StateT s m b
f (forall (m :: * -> *) s a.
(forall x. m x -> m x) -> StateT s m a -> StateT s m a
q forall a. m a -> m a
u)) s
s
where
q :: (forall x. m x -> m x)
-> Lazy.StateT s m a -> Lazy.StateT s m a
q :: forall (m :: * -> *) s a.
(forall x. m x -> m x) -> StateT s m a -> StateT s m a
q forall x. m x -> m x
u (Lazy.StateT s -> m (a, s)
b) = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Lazy.StateT forall a b. (a -> b) -> a -> b
$ \s
s -> forall x. m x -> m x
u (s -> m (a, s)
b s
s)
instance MonadCatch m => MonadThrow (Strict.StateT s m) where
throwIO :: forall e a. Exception e => e -> StateT s m a
throwIO = forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwIO
instance MonadCatch m => MonadCatch (Strict.StateT s m) where
catch :: forall e a.
Exception e =>
StateT s m a -> (e -> StateT s m a) -> StateT s m a
catch (Strict.StateT s -> m (a, s)
m) e -> StateT s m a
f = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Strict.StateT forall a b. (a -> b) -> a -> b
$ \s
s -> forall (m :: * -> *) e a.
(MonadCatch m, Exception e) =>
m a -> (e -> m a) -> m a
catch (s -> m (a, s)
m s
s) (\e
e -> forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
Strict.runStateT (e -> StateT s m a
f e
e) s
s)
generalBracket :: forall a b c.
StateT s m a
-> (a -> ExitCase b -> StateT s m c)
-> (a -> StateT s m b)
-> StateT s m (b, c)
generalBracket StateT s m a
acquire a -> ExitCase b -> StateT s m c
release a -> StateT s m b
use = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Strict.StateT forall a b. (a -> b) -> a -> b
$ \s
s -> forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall {a} {b} {b} {b}. ((a, b), (b, b)) -> ((a, b), b)
f forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a b c.
MonadCatch m =>
m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c)
generalBracket
(forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
Strict.runStateT StateT s m a
acquire s
s)
(\(a
resource, s
s') ExitCase (b, s)
e ->
case ExitCase (b, s)
e of
ExitCaseSuccess (b
b, s
s'') ->
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
Strict.runStateT (a -> ExitCase b -> StateT s m c
release a
resource (forall a. a -> ExitCase a
ExitCaseSuccess b
b)) s
s''
ExitCaseException SomeException
err ->
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
Strict.runStateT (a -> ExitCase b -> StateT s m c
release a
resource (forall a. SomeException -> ExitCase a
ExitCaseException SomeException
err)) s
s'
ExitCase (b, s)
ExitCaseAbort ->
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
Strict.runStateT (a -> ExitCase b -> StateT s m c
release a
resource forall a. ExitCase a
ExitCaseAbort) s
s')
(\(a
a, s
s') -> forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
Strict.runStateT (a -> StateT s m b
use a
a) s
s')
where f :: ((a, b), (b, b)) -> ((a, b), b)
f ((a
x,b
_),(b
y,b
s)) = ((a
x,b
y),b
s)
instance MonadMask m => MonadMask (Strict.StateT s m) where
mask :: forall b.
((forall a. StateT s m a -> StateT s m a) -> StateT s m b)
-> StateT s m b
mask (forall a. StateT s m a -> StateT s m a) -> StateT s m b
f = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Strict.StateT forall a b. (a -> b) -> a -> b
$ \s
s -> forall (m :: * -> *) b.
MonadMask m =>
((forall a. m a -> m a) -> m b) -> m b
mask forall a b. (a -> b) -> a -> b
$ \forall a. m a -> m a
u -> forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
Strict.runStateT ((forall a. StateT s m a -> StateT s m a) -> StateT s m b
f (forall (m :: * -> *) s a.
(forall x. m x -> m x) -> StateT s m a -> StateT s m a
q forall a. m a -> m a
u)) s
s
where
q :: (forall x. m x -> m x)
-> Strict.StateT s m a -> Strict.StateT s m a
q :: forall (m :: * -> *) s a.
(forall x. m x -> m x) -> StateT s m a -> StateT s m a
q forall x. m x -> m x
u (Strict.StateT s -> m (a, s)
b) = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Strict.StateT forall a b. (a -> b) -> a -> b
$ \s
s -> forall x. m x -> m x
u (s -> m (a, s)
b s
s)
uninterruptibleMask :: forall b.
((forall a. StateT s m a -> StateT s m a) -> StateT s m b)
-> StateT s m b
uninterruptibleMask (forall a. StateT s m a -> StateT s m a) -> StateT s m b
f = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Strict.StateT forall a b. (a -> b) -> a -> b
$ \s
s -> forall (m :: * -> *) b.
MonadMask m =>
((forall a. m a -> m a) -> m b) -> m b
uninterruptibleMask forall a b. (a -> b) -> a -> b
$ \forall a. m a -> m a
u -> forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
Strict.runStateT ((forall a. StateT s m a -> StateT s m a) -> StateT s m b
f (forall (m :: * -> *) s a.
(forall x. m x -> m x) -> StateT s m a -> StateT s m a
q forall a. m a -> m a
u)) s
s
where
q :: (forall x. m x -> m x)
-> Strict.StateT s m a -> Strict.StateT s m a
q :: forall (m :: * -> *) s a.
(forall x. m x -> m x) -> StateT s m a -> StateT s m a
q forall x. m x -> m x
u (Strict.StateT s -> m (a, s)
b) = forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Strict.StateT forall a b. (a -> b) -> a -> b
$ \s
s -> forall x. m x -> m x
u (s -> m (a, s)
b s
s)