{-# OPTIONS_GHC -Wno-orphans #-}
{-# OPTIONS_GHC -Wno-deprecations #-}
module Control.Monad.Class.MonadST.Trans () where

import Control.Monad.Cont (ContT)
import Control.Monad.Except (ExceptT)
import Control.Monad.RWS.Lazy qualified as Lazy
import Control.Monad.RWS.Strict qualified as Strict
import Control.Monad.State.Lazy qualified as Lazy
import Control.Monad.State.Strict qualified as Strict
import Control.Monad.Trans (lift)
import Control.Monad.Writer.Lazy qualified as Lazy
import Control.Monad.Writer.Strict qualified as Strict

import Control.Monad.Class.MonadST


instance MonadST m => MonadST (ContT r m) where
  stToIO :: forall a. ST (PrimState (ContT r m)) a -> ContT r m a
stToIO = m a -> ContT r m a
forall (m :: * -> *) a. Monad m => m a -> ContT r m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> ContT r m a)
-> (ST (PrimState m) a -> m a) -> ST (PrimState m) a -> ContT r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ST (PrimState m) a -> m a
forall a. ST (PrimState m) a -> m a
forall (m :: * -> *) a. MonadST m => ST (PrimState m) a -> m a
stToIO
  withLiftST :: forall b. (forall s. (forall a. ST s a -> ContT r m a) -> b) -> b
withLiftST forall s. (forall a. ST s a -> ContT r m a) -> b
f = (forall s. (forall a. ST s a -> m a) -> b) -> b
forall b. (forall s. (forall a. ST s a -> m a) -> b) -> b
forall (m :: * -> *) b.
MonadST m =>
(forall s. (forall a. ST s a -> m a) -> b) -> b
withLiftST ((forall s. (forall a. ST s a -> m a) -> b) -> b)
-> (forall s. (forall a. ST s a -> m a) -> b) -> b
forall a b. (a -> b) -> a -> b
$ \forall a. ST s a -> m a
g -> (forall a. ST s a -> ContT r m a) -> b
forall s. (forall a. ST s a -> ContT r m a) -> b
f (m a -> ContT r m a
forall (m :: * -> *) a. Monad m => m a -> ContT r m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> ContT r m a) -> (ST s a -> m a) -> ST s a -> ContT r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ST s a -> m a
forall a. ST s a -> m a
g)

instance MonadST m => MonadST (ExceptT e m) where
  stToIO :: forall a. ST (PrimState (ExceptT e m)) a -> ExceptT e m a
stToIO = m a -> ExceptT e m a
forall (m :: * -> *) a. Monad m => m a -> ExceptT e m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> ExceptT e m a)
-> (ST (PrimState m) a -> m a)
-> ST (PrimState m) a
-> ExceptT e m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ST (PrimState m) a -> m a
forall a. ST (PrimState m) a -> m a
forall (m :: * -> *) a. MonadST m => ST (PrimState m) a -> m a
stToIO
  withLiftST :: forall b. (forall s. (forall a. ST s a -> ExceptT e m a) -> b) -> b
withLiftST forall s. (forall a. ST s a -> ExceptT e m a) -> b
f = (forall s. (forall a. ST s a -> m a) -> b) -> b
forall b. (forall s. (forall a. ST s a -> m a) -> b) -> b
forall (m :: * -> *) b.
MonadST m =>
(forall s. (forall a. ST s a -> m a) -> b) -> b
withLiftST ((forall s. (forall a. ST s a -> m a) -> b) -> b)
-> (forall s. (forall a. ST s a -> m a) -> b) -> b
forall a b. (a -> b) -> a -> b
$ \forall a. ST s a -> m a
g -> (forall a. ST s a -> ExceptT e m a) -> b
forall s. (forall a. ST s a -> ExceptT e m a) -> b
f (m a -> ExceptT e m a
forall (m :: * -> *) a. Monad m => m a -> ExceptT e m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> ExceptT e m a)
-> (ST s a -> m a) -> ST s a -> ExceptT e m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ST s a -> m a
forall a. ST s a -> m a
g)

instance (Monoid w, MonadST m) => MonadST (Lazy.RWST r w s m) where
  stToIO :: forall a. ST (PrimState (RWST r w s m)) a -> RWST r w s m a
stToIO = m a -> RWST r w s m a
forall (m :: * -> *) a. Monad m => m a -> RWST r w s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> RWST r w s m a)
-> (ST (PrimState m) a -> m a)
-> ST (PrimState m) a
-> RWST r w s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ST (PrimState m) a -> m a
forall a. ST (PrimState m) a -> m a
forall (m :: * -> *) a. MonadST m => ST (PrimState m) a -> m a
stToIO
  withLiftST :: forall b.
(forall s. (forall a. ST s a -> RWST r w s m a) -> b) -> b
withLiftST forall s. (forall a. ST s a -> RWST r w s m a) -> b
f = (forall s. (forall a. ST s a -> m a) -> b) -> b
forall b. (forall s. (forall a. ST s a -> m a) -> b) -> b
forall (m :: * -> *) b.
MonadST m =>
(forall s. (forall a. ST s a -> m a) -> b) -> b
withLiftST ((forall s. (forall a. ST s a -> m a) -> b) -> b)
-> (forall s. (forall a. ST s a -> m a) -> b) -> b
forall a b. (a -> b) -> a -> b
$ \forall a. ST s a -> m a
g -> (forall a. ST s a -> RWST r w s m a) -> b
forall s. (forall a. ST s a -> RWST r w s m a) -> b
f (m a -> RWST r w s m a
forall (m :: * -> *) a. Monad m => m a -> RWST r w s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> RWST r w s m a)
-> (ST s a -> m a) -> ST s a -> RWST r w s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ST s a -> m a
forall a. ST s a -> m a
g)

instance (Monoid w, MonadST m) => MonadST (Strict.RWST r w s m) where
  stToIO :: forall a. ST (PrimState (RWST r w s m)) a -> RWST r w s m a
stToIO = m a -> RWST r w s m a
forall (m :: * -> *) a. Monad m => m a -> RWST r w s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> RWST r w s m a)
-> (ST (PrimState m) a -> m a)
-> ST (PrimState m) a
-> RWST r w s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ST (PrimState m) a -> m a
forall a. ST (PrimState m) a -> m a
forall (m :: * -> *) a. MonadST m => ST (PrimState m) a -> m a
stToIO
  withLiftST :: forall b.
(forall s. (forall a. ST s a -> RWST r w s m a) -> b) -> b
withLiftST forall s. (forall a. ST s a -> RWST r w s m a) -> b
f = (forall s. (forall a. ST s a -> m a) -> b) -> b
forall b. (forall s. (forall a. ST s a -> m a) -> b) -> b
forall (m :: * -> *) b.
MonadST m =>
(forall s. (forall a. ST s a -> m a) -> b) -> b
withLiftST ((forall s. (forall a. ST s a -> m a) -> b) -> b)
-> (forall s. (forall a. ST s a -> m a) -> b) -> b
forall a b. (a -> b) -> a -> b
$ \forall a. ST s a -> m a
g -> (forall a. ST s a -> RWST r w s m a) -> b
forall s. (forall a. ST s a -> RWST r w s m a) -> b
f (m a -> RWST r w s m a
forall (m :: * -> *) a. Monad m => m a -> RWST r w s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> RWST r w s m a)
-> (ST s a -> m a) -> ST s a -> RWST r w s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ST s a -> m a
forall a. ST s a -> m a
g)

instance MonadST m => MonadST (Lazy.StateT s m) where
  stToIO :: forall a. ST (PrimState (StateT s m)) a -> StateT s m a
stToIO = m a -> StateT s m a
forall (m :: * -> *) a. Monad m => m a -> StateT s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> StateT s m a)
-> (ST (PrimState m) a -> m a)
-> ST (PrimState m) a
-> StateT s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ST (PrimState m) a -> m a
forall a. ST (PrimState m) a -> m a
forall (m :: * -> *) a. MonadST m => ST (PrimState m) a -> m a
stToIO
  withLiftST :: forall b. (forall s. (forall a. ST s a -> StateT s m a) -> b) -> b
withLiftST forall s. (forall a. ST s a -> StateT s m a) -> b
f = (forall s. (forall a. ST s a -> m a) -> b) -> b
forall b. (forall s. (forall a. ST s a -> m a) -> b) -> b
forall (m :: * -> *) b.
MonadST m =>
(forall s. (forall a. ST s a -> m a) -> b) -> b
withLiftST ((forall s. (forall a. ST s a -> m a) -> b) -> b)
-> (forall s. (forall a. ST s a -> m a) -> b) -> b
forall a b. (a -> b) -> a -> b
$ \forall a. ST s a -> m a
g -> (forall a. ST s a -> StateT s m a) -> b
forall s. (forall a. ST s a -> StateT s m a) -> b
f (m a -> StateT s m a
forall (m :: * -> *) a. Monad m => m a -> StateT s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> StateT s m a) -> (ST s a -> m a) -> ST s a -> StateT s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ST s a -> m a
forall a. ST s a -> m a
g)

instance MonadST m => MonadST (Strict.StateT s m) where
  stToIO :: forall a. ST (PrimState (StateT s m)) a -> StateT s m a
stToIO = m a -> StateT s m a
forall (m :: * -> *) a. Monad m => m a -> StateT s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> StateT s m a)
-> (ST (PrimState m) a -> m a)
-> ST (PrimState m) a
-> StateT s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ST (PrimState m) a -> m a
forall a. ST (PrimState m) a -> m a
forall (m :: * -> *) a. MonadST m => ST (PrimState m) a -> m a
stToIO
  withLiftST :: forall b. (forall s. (forall a. ST s a -> StateT s m a) -> b) -> b
withLiftST forall s. (forall a. ST s a -> StateT s m a) -> b
f = (forall s. (forall a. ST s a -> m a) -> b) -> b
forall b. (forall s. (forall a. ST s a -> m a) -> b) -> b
forall (m :: * -> *) b.
MonadST m =>
(forall s. (forall a. ST s a -> m a) -> b) -> b
withLiftST ((forall s. (forall a. ST s a -> m a) -> b) -> b)
-> (forall s. (forall a. ST s a -> m a) -> b) -> b
forall a b. (a -> b) -> a -> b
$ \forall a. ST s a -> m a
g -> (forall a. ST s a -> StateT s m a) -> b
forall s. (forall a. ST s a -> StateT s m a) -> b
f (m a -> StateT s m a
forall (m :: * -> *) a. Monad m => m a -> StateT s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> StateT s m a) -> (ST s a -> m a) -> ST s a -> StateT s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ST s a -> m a
forall a. ST s a -> m a
g)

instance (Monoid w, MonadST m) => MonadST (Lazy.WriterT w m) where
  stToIO :: forall a. ST (PrimState (WriterT w m)) a -> WriterT w m a
stToIO = m a -> WriterT w m a
forall (m :: * -> *) a. Monad m => m a -> WriterT w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> WriterT w m a)
-> (ST (PrimState m) a -> m a)
-> ST (PrimState m) a
-> WriterT w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ST (PrimState m) a -> m a
forall a. ST (PrimState m) a -> m a
forall (m :: * -> *) a. MonadST m => ST (PrimState m) a -> m a
stToIO
  withLiftST :: forall b. (forall s. (forall a. ST s a -> WriterT w m a) -> b) -> b
withLiftST forall s. (forall a. ST s a -> WriterT w m a) -> b
f = (forall s. (forall a. ST s a -> m a) -> b) -> b
forall b. (forall s. (forall a. ST s a -> m a) -> b) -> b
forall (m :: * -> *) b.
MonadST m =>
(forall s. (forall a. ST s a -> m a) -> b) -> b
withLiftST ((forall s. (forall a. ST s a -> m a) -> b) -> b)
-> (forall s. (forall a. ST s a -> m a) -> b) -> b
forall a b. (a -> b) -> a -> b
$ \forall a. ST s a -> m a
g -> (forall a. ST s a -> WriterT w m a) -> b
forall s. (forall a. ST s a -> WriterT w m a) -> b
f (m a -> WriterT w m a
forall (m :: * -> *) a. Monad m => m a -> WriterT w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> WriterT w m a)
-> (ST s a -> m a) -> ST s a -> WriterT w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ST s a -> m a
forall a. ST s a -> m a
g)

instance (Monoid w, MonadST m) => MonadST (Strict.WriterT w m) where
  stToIO :: forall a. ST (PrimState (WriterT w m)) a -> WriterT w m a
stToIO = m a -> WriterT w m a
forall (m :: * -> *) a. Monad m => m a -> WriterT w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> WriterT w m a)
-> (ST (PrimState m) a -> m a)
-> ST (PrimState m) a
-> WriterT w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ST (PrimState m) a -> m a
forall a. ST (PrimState m) a -> m a
forall (m :: * -> *) a. MonadST m => ST (PrimState m) a -> m a
stToIO
  withLiftST :: forall b. (forall s. (forall a. ST s a -> WriterT w m a) -> b) -> b
withLiftST forall s. (forall a. ST s a -> WriterT w m a) -> b
f = (forall s. (forall a. ST s a -> m a) -> b) -> b
forall b. (forall s. (forall a. ST s a -> m a) -> b) -> b
forall (m :: * -> *) b.
MonadST m =>
(forall s. (forall a. ST s a -> m a) -> b) -> b
withLiftST ((forall s. (forall a. ST s a -> m a) -> b) -> b)
-> (forall s. (forall a. ST s a -> m a) -> b) -> b
forall a b. (a -> b) -> a -> b
$ \forall a. ST s a -> m a
g -> (forall a. ST s a -> WriterT w m a) -> b
forall s. (forall a. ST s a -> WriterT w m a) -> b
f (m a -> WriterT w m a
forall (m :: * -> *) a. Monad m => m a -> WriterT w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> WriterT w m a)
-> (ST s a -> m a) -> ST s a -> WriterT w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ST s a -> m a
forall a. ST s a -> m a
g)