{-# LANGUAGE CPP #-}
{-# OPTIONS_HADDOCK not-home #-}
module Control.Effect.Type.Regional where
import Control.Effect.Internal.Union
import Control.Monad.Trans.Reader (ReaderT(..), mapReaderT)
import Control.Monad.Trans.Except (ExceptT(..), mapExceptT)
import qualified Control.Monad.Trans.State.Strict as SSt
import qualified Control.Monad.Trans.State.Lazy as LSt
import qualified Control.Monad.Trans.Writer.Lazy as LWr
import qualified Control.Monad.Trans.Writer.Strict as SWr
import qualified Control.Monad.Trans.Writer.CPS as CPSWr
data Regional s :: Effect where
Regionally :: s -> m a -> Regional s m a
instance ThreadsEff (ExceptT e) (Regional s) where
threadEff :: (forall x. Regional s m x -> m x)
-> Regional s (ExceptT e m) a -> ExceptT e m a
threadEff forall x. Regional s m x -> m x
alg (Regionally s
s ExceptT e m a
m) = (m (Either e a) -> m (Either e a))
-> ExceptT e m a -> ExceptT e m a
forall (m :: * -> *) e a (n :: * -> *) e' b.
(m (Either e a) -> n (Either e' b))
-> ExceptT e m a -> ExceptT e' n b
mapExceptT (Regional s m (Either e a) -> m (Either e a)
forall x. Regional s m x -> m x
alg (Regional s m (Either e a) -> m (Either e a))
-> (m (Either e a) -> Regional s m (Either e a))
-> m (Either e a)
-> m (Either e a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> m (Either e a) -> Regional s m (Either e a)
forall s (m :: * -> *) a. s -> m a -> Regional s m a
Regionally s
s) ExceptT e m a
m
{-# INLINE threadEff #-}
instance ThreadsEff (ReaderT i) (Regional s) where
threadEff :: (forall x. Regional s m x -> m x)
-> Regional s (ReaderT i m) a -> ReaderT i m a
threadEff forall x. Regional s m x -> m x
alg (Regionally s
s ReaderT i m a
m) = (m a -> m a) -> ReaderT i m a -> ReaderT i m a
forall (m :: * -> *) a (n :: * -> *) b r.
(m a -> n b) -> ReaderT r m a -> ReaderT r n b
mapReaderT (Regional s m a -> m a
forall x. Regional s m x -> m x
alg (Regional s m a -> m a) -> (m a -> Regional s m a) -> m a -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> m a -> Regional s m a
forall s (m :: * -> *) a. s -> m a -> Regional s m a
Regionally s
s) ReaderT i m a
m
{-# INLINE threadEff #-}
instance ThreadsEff (SSt.StateT i) (Regional s) where
threadEff :: (forall x. Regional s m x -> m x)
-> Regional s (StateT i m) a -> StateT i m a
threadEff forall x. Regional s m x -> m x
alg (Regionally s
s StateT i m a
m) = (m (a, i) -> m (a, i)) -> StateT i m a -> StateT i m a
forall (m :: * -> *) a s (n :: * -> *) b.
(m (a, s) -> n (b, s)) -> StateT s m a -> StateT s n b
SSt.mapStateT (Regional s m (a, i) -> m (a, i)
forall x. Regional s m x -> m x
alg (Regional s m (a, i) -> m (a, i))
-> (m (a, i) -> Regional s m (a, i)) -> m (a, i) -> m (a, i)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> m (a, i) -> Regional s m (a, i)
forall s (m :: * -> *) a. s -> m a -> Regional s m a
Regionally s
s) StateT i m a
m
{-# INLINE threadEff #-}
instance ThreadsEff (LSt.StateT i) (Regional s) where
threadEff :: (forall x. Regional s m x -> m x)
-> Regional s (StateT i m) a -> StateT i m a
threadEff forall x. Regional s m x -> m x
alg (Regionally s
s StateT i m a
m) = (m (a, i) -> m (a, i)) -> StateT i m a -> StateT i m a
forall (m :: * -> *) a s (n :: * -> *) b.
(m (a, s) -> n (b, s)) -> StateT s m a -> StateT s n b
LSt.mapStateT (Regional s m (a, i) -> m (a, i)
forall x. Regional s m x -> m x
alg (Regional s m (a, i) -> m (a, i))
-> (m (a, i) -> Regional s m (a, i)) -> m (a, i) -> m (a, i)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> m (a, i) -> Regional s m (a, i)
forall s (m :: * -> *) a. s -> m a -> Regional s m a
Regionally s
s) StateT i m a
m
{-# INLINE threadEff #-}
instance ThreadsEff (LWr.WriterT w) (Regional s) where
threadEff :: (forall x. Regional s m x -> m x)
-> Regional s (WriterT w m) a -> WriterT w m a
threadEff forall x. Regional s m x -> m x
alg (Regionally s
s WriterT w m a
m) = (m (a, w) -> m (a, w)) -> WriterT w m a -> WriterT w m a
forall (m :: * -> *) a w (n :: * -> *) b w'.
(m (a, w) -> n (b, w')) -> WriterT w m a -> WriterT w' n b
LWr.mapWriterT (Regional s m (a, w) -> m (a, w)
forall x. Regional s m x -> m x
alg (Regional s m (a, w) -> m (a, w))
-> (m (a, w) -> Regional s m (a, w)) -> m (a, w) -> m (a, w)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> m (a, w) -> Regional s m (a, w)
forall s (m :: * -> *) a. s -> m a -> Regional s m a
Regionally s
s) WriterT w m a
m
{-# INLINE threadEff #-}
instance ThreadsEff (SWr.WriterT w) (Regional s) where
threadEff :: (forall x. Regional s m x -> m x)
-> Regional s (WriterT w m) a -> WriterT w m a
threadEff forall x. Regional s m x -> m x
alg (Regionally s
s WriterT w m a
m) = (m (a, w) -> m (a, w)) -> WriterT w m a -> WriterT w m a
forall (m :: * -> *) a w (n :: * -> *) b w'.
(m (a, w) -> n (b, w')) -> WriterT w m a -> WriterT w' n b
SWr.mapWriterT (Regional s m (a, w) -> m (a, w)
forall x. Regional s m x -> m x
alg (Regional s m (a, w) -> m (a, w))
-> (m (a, w) -> Regional s m (a, w)) -> m (a, w) -> m (a, w)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> m (a, w) -> Regional s m (a, w)
forall s (m :: * -> *) a. s -> m a -> Regional s m a
Regionally s
s) WriterT w m a
m
{-# INLINE threadEff #-}
instance Monoid w => ThreadsEff (CPSWr.WriterT w) (Regional s) where
threadEff :: (forall x. Regional s m x -> m x)
-> Regional s (WriterT w m) a -> WriterT w m a
threadEff forall x. Regional s m x -> m x
alg (Regionally s
s WriterT w m a
m) = (m (a, w) -> m (a, w)) -> WriterT w m a -> WriterT w m a
forall (n :: * -> *) w w' (m :: * -> *) a b.
(Monad n, Monoid w, Monoid w') =>
(m (a, w) -> n (b, w')) -> WriterT w m a -> WriterT w' n b
CPSWr.mapWriterT (Regional s m (a, w) -> m (a, w)
forall x. Regional s m x -> m x
alg (Regional s m (a, w) -> m (a, w))
-> (m (a, w) -> Regional s m (a, w)) -> m (a, w) -> m (a, w)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> m (a, w) -> Regional s m (a, w)
forall s (m :: * -> *) a. s -> m a -> Regional s m a
Regionally s
s) WriterT w m a
m
{-# INLINE threadEff #-}