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

import           Control.Monad.Cont
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.MonadST


instance MonadST m => MonadST (ContT r m) where
  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 (m :: * -> *) b.
MonadST m =>
(forall s. (forall a. ST s a -> m a) -> b) -> b
withLiftST forall a b. (a -> b) -> a -> b
$ \forall a. ST s a -> m a
g -> forall s. (forall a. ST s a -> ContT r m a) -> b
f (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 a. ST s a -> m a
g)

instance MonadST m => MonadST (ExceptT e m) where
  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 (m :: * -> *) b.
MonadST m =>
(forall s. (forall a. ST s a -> m a) -> b) -> b
withLiftST forall a b. (a -> b) -> a -> b
$ \forall a. ST s a -> m a
g -> forall s. (forall a. ST s a -> ExceptT e m a) -> b
f (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 a. ST s a -> m a
g)

instance (Monoid w, MonadST m) => MonadST (Lazy.RWST r w s m) where
  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 (m :: * -> *) b.
MonadST m =>
(forall s. (forall a. ST s a -> m a) -> b) -> b
withLiftST forall a b. (a -> b) -> a -> b
$ \forall a. ST s a -> m a
g -> forall s. (forall a. ST s a -> RWST r w s m a) -> b
f (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 a. ST s a -> m a
g)

instance (Monoid w, MonadST m) => MonadST (Strict.RWST r w s m) where
  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 (m :: * -> *) b.
MonadST m =>
(forall s. (forall a. ST s a -> m a) -> b) -> b
withLiftST forall a b. (a -> b) -> a -> b
$ \forall a. ST s a -> m a
g -> forall s. (forall a. ST s a -> RWST r w s m a) -> b
f (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 a. ST s a -> m a
g)

instance MonadST m => MonadST (Lazy.StateT s m) where
  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 (m :: * -> *) b.
MonadST m =>
(forall s. (forall a. ST s a -> m a) -> b) -> b
withLiftST forall a b. (a -> b) -> a -> b
$ \forall a. ST s a -> m a
g -> forall s. (forall a. ST s a -> StateT s m a) -> b
f (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 a. ST s a -> m a
g)

instance MonadST m => MonadST (Strict.StateT s m) where
  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 (m :: * -> *) b.
MonadST m =>
(forall s. (forall a. ST s a -> m a) -> b) -> b
withLiftST forall a b. (a -> b) -> a -> b
$ \forall a. ST s a -> m a
g -> forall s. (forall a. ST s a -> StateT s m a) -> b
f (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 a. ST s a -> m a
g)

instance (Monoid w, MonadST m) => MonadST (Lazy.WriterT w m) where
   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 (m :: * -> *) b.
MonadST m =>
(forall s. (forall a. ST s a -> m a) -> b) -> b
withLiftST forall a b. (a -> b) -> a -> b
$ \forall a. ST s a -> m a
g -> forall s. (forall a. ST s a -> WriterT w m a) -> b
f (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 a. ST s a -> m a
g) 

instance (Monoid w, MonadST m) => MonadST (Strict.WriterT w m) where
  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 (m :: * -> *) b.
MonadST m =>
(forall s. (forall a. ST s a -> m a) -> b) -> b
withLiftST forall a b. (a -> b) -> a -> b
$ \forall a. ST s a -> m a
g -> forall s. (forall a. ST s a -> WriterT w m a) -> b
f (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 a. ST s a -> m a
g)