{-# LANGUAGE CPP #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE UndecidableSuperClasses #-}
{-# LANGUAGE FlexibleContexts #-}

-- | Alternative multi-valued version of mtl's RWS / RWST. In contrast to
-- @'MultiRWS'(T)@ this version only takes a single list of types as
-- parameter, but with additional encoding of the allowed access for each
-- element. This supports the @'MonadMultiGet'@ notion more succinctly, i.e.
-- to pass a "state" element to a function that only requires/expects read/get
-- access. This is not possible with 'MultiRWS'.
module Control.Monad.Trans.MultiGST.Strict
  ( MultiGSTT(..)
  , MultiGSTTNull
  , MultiGST
  -- * MonadMulti classes
  , ContainsReader
  , ContainsState
  , ContainsWriter
  , MonadMultiReader(..)
  , MonadMultiWriter(..)
  , MonadMultiGet(..)
  , CanReadWrite(..)
  -- * run-functions
  , runMultiGSTTNil
  , runMultiGSTTNil_
  -- * with-functions
  , withReader
  , withReader_
  , withWriter
  , withWriterAW
  , withWriterWA
  , withWriterW
  , withState
  , withStateAS
  , withStateSA
  , withStateA
  , withStateS
  , withState_
  -- * without-functions
  , without
  -- * other functions
  , mGetRaw
  , mSetRaw
  , mapMultiGSTT
  )
where



import Control.Monad.State.Strict      ( StateT(..)
                                       , MonadState(..)
                                       , execStateT
                                       , evalStateT
                                       , mapStateT )

import Data.Functor.Identity           ( Identity )

import Control.Monad.Trans.Class       ( MonadTrans
                                       , lift
                                       )
import Control.Monad                   ( MonadPlus(..)
                                       , liftM
                                       , ap
                                       , void )

import Data.Monoid                     ( Monoid
                                       , (<>)
                                       )

import GHC.Exts (Constraint)

import Control.Monad.Trans.MultiReader.Class
import Control.Monad.Trans.MultiWriter.Class
import Control.Monad.Trans.MultiState.Class

import Control.Monad.Trans.MultiGST.Common



newtype MultiGSTT ts m a = MultiGSTT {
  MultiGSTT ts m a -> StateT (HListM ts) m a
runMultiGSTTRaw :: StateT (HListM ts) m a
}
  deriving(a -> MultiGSTT ts m b -> MultiGSTT ts m a
(a -> b) -> MultiGSTT ts m a -> MultiGSTT ts m b
(forall a b. (a -> b) -> MultiGSTT ts m a -> MultiGSTT ts m b)
-> (forall a b. a -> MultiGSTT ts m b -> MultiGSTT ts m a)
-> Functor (MultiGSTT ts m)
forall (ts :: [CanReadWrite *]) (m :: * -> *) a b.
Functor m =>
a -> MultiGSTT ts m b -> MultiGSTT ts m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a b.
Functor m =>
(a -> b) -> MultiGSTT ts m a -> MultiGSTT ts m b
forall a b. a -> MultiGSTT ts m b -> MultiGSTT ts m a
forall a b. (a -> b) -> MultiGSTT ts m a -> MultiGSTT ts m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> MultiGSTT ts m b -> MultiGSTT ts m a
$c<$ :: forall (ts :: [CanReadWrite *]) (m :: * -> *) a b.
Functor m =>
a -> MultiGSTT ts m b -> MultiGSTT ts m a
fmap :: (a -> b) -> MultiGSTT ts m a -> MultiGSTT ts m b
$cfmap :: forall (ts :: [CanReadWrite *]) (m :: * -> *) a b.
Functor m =>
(a -> b) -> MultiGSTT ts m a -> MultiGSTT ts m b
Functor, Functor (MultiGSTT ts m)
a -> MultiGSTT ts m a
Functor (MultiGSTT ts m)
-> (forall a. a -> MultiGSTT ts m a)
-> (forall a b.
    MultiGSTT ts m (a -> b) -> MultiGSTT ts m a -> MultiGSTT ts m b)
-> (forall a b c.
    (a -> b -> c)
    -> MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m c)
-> (forall a b.
    MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m b)
-> (forall a b.
    MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m a)
-> Applicative (MultiGSTT ts m)
MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m b
MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m a
MultiGSTT ts m (a -> b) -> MultiGSTT ts m a -> MultiGSTT ts m b
(a -> b -> c)
-> MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m c
forall (ts :: [CanReadWrite *]) (m :: * -> *).
Monad m =>
Functor (MultiGSTT ts m)
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
Monad m =>
a -> MultiGSTT ts m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a b.
Monad m =>
MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a b.
Monad m =>
MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m b
forall (ts :: [CanReadWrite *]) (m :: * -> *) a b.
Monad m =>
MultiGSTT ts m (a -> b) -> MultiGSTT ts m a -> MultiGSTT ts m b
forall (ts :: [CanReadWrite *]) (m :: * -> *) a b c.
Monad m =>
(a -> b -> c)
-> MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m c
forall a. a -> MultiGSTT ts m a
forall a b.
MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m a
forall a b.
MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m b
forall a b.
MultiGSTT ts m (a -> b) -> MultiGSTT ts m a -> MultiGSTT ts m b
forall a b c.
(a -> b -> c)
-> MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
<* :: MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m a
$c<* :: forall (ts :: [CanReadWrite *]) (m :: * -> *) a b.
Monad m =>
MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m a
*> :: MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m b
$c*> :: forall (ts :: [CanReadWrite *]) (m :: * -> *) a b.
Monad m =>
MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m b
liftA2 :: (a -> b -> c)
-> MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m c
$cliftA2 :: forall (ts :: [CanReadWrite *]) (m :: * -> *) a b c.
Monad m =>
(a -> b -> c)
-> MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m c
<*> :: MultiGSTT ts m (a -> b) -> MultiGSTT ts m a -> MultiGSTT ts m b
$c<*> :: forall (ts :: [CanReadWrite *]) (m :: * -> *) a b.
Monad m =>
MultiGSTT ts m (a -> b) -> MultiGSTT ts m a -> MultiGSTT ts m b
pure :: a -> MultiGSTT ts m a
$cpure :: forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
Monad m =>
a -> MultiGSTT ts m a
$cp1Applicative :: forall (ts :: [CanReadWrite *]) (m :: * -> *).
Monad m =>
Functor (MultiGSTT ts m)
Applicative, Applicative (MultiGSTT ts m)
a -> MultiGSTT ts m a
Applicative (MultiGSTT ts m)
-> (forall a b.
    MultiGSTT ts m a -> (a -> MultiGSTT ts m b) -> MultiGSTT ts m b)
-> (forall a b.
    MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m b)
-> (forall a. a -> MultiGSTT ts m a)
-> Monad (MultiGSTT ts m)
MultiGSTT ts m a -> (a -> MultiGSTT ts m b) -> MultiGSTT ts m b
MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m b
forall (ts :: [CanReadWrite *]) (m :: * -> *).
Monad m =>
Applicative (MultiGSTT ts m)
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
Monad m =>
a -> MultiGSTT ts m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a b.
Monad m =>
MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m b
forall (ts :: [CanReadWrite *]) (m :: * -> *) a b.
Monad m =>
MultiGSTT ts m a -> (a -> MultiGSTT ts m b) -> MultiGSTT ts m b
forall a. a -> MultiGSTT ts m a
forall a b.
MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m b
forall a b.
MultiGSTT ts m a -> (a -> MultiGSTT ts m b) -> MultiGSTT ts m b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> MultiGSTT ts m a
$creturn :: forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
Monad m =>
a -> MultiGSTT ts m a
>> :: MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m b
$c>> :: forall (ts :: [CanReadWrite *]) (m :: * -> *) a b.
Monad m =>
MultiGSTT ts m a -> MultiGSTT ts m b -> MultiGSTT ts m b
>>= :: MultiGSTT ts m a -> (a -> MultiGSTT ts m b) -> MultiGSTT ts m b
$c>>= :: forall (ts :: [CanReadWrite *]) (m :: * -> *) a b.
Monad m =>
MultiGSTT ts m a -> (a -> MultiGSTT ts m b) -> MultiGSTT ts m b
$cp1Monad :: forall (ts :: [CanReadWrite *]) (m :: * -> *).
Monad m =>
Applicative (MultiGSTT ts m)
Monad, m a -> MultiGSTT ts m a
(forall (m :: * -> *) a. Monad m => m a -> MultiGSTT ts m a)
-> MonadTrans (MultiGSTT ts)
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
Monad m =>
m a -> MultiGSTT ts m a
forall (m :: * -> *) a. Monad m => m a -> MultiGSTT ts m a
forall (t :: (* -> *) -> * -> *).
(forall (m :: * -> *) a. Monad m => m a -> t m a) -> MonadTrans t
lift :: m a -> MultiGSTT ts m a
$clift :: forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
Monad m =>
m a -> MultiGSTT ts m a
MonadTrans)

type MultiGSTTNull = MultiGSTT '[]

type MultiGST r = MultiGSTT r Identity


instance
#if MIN_VERSION_base(4,8,0)
  {-# OVERLAPPING #-}
#endif
    (Monad m, HListMContains 'GettableFlag a cts)
      => MonadMultiGet a (MultiGSTT cts m) where
  mGet :: MultiGSTT cts m a
mGet = StateT (HListM cts) m a -> MultiGSTT cts m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
StateT (HListM ts) m a -> MultiGSTT ts m a
MultiGSTT (StateT (HListM cts) m a -> MultiGSTT cts m a)
-> StateT (HListM cts) m a -> MultiGSTT cts m a
forall a b. (a -> b) -> a -> b
$ (HListM cts -> a)
-> StateT (HListM cts) m (HListM cts) -> StateT (HListM cts) m a
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (\HListM cts
ts -> HListM cts -> a
forall (can :: CanReadWriteFlag) t (cts :: [CanReadWrite *]).
HListMContains can t cts =>
HListM cts -> t
readHListMElem @'GettableFlag HListM cts
ts) StateT (HListM cts) m (HListM cts)
forall s (m :: * -> *). MonadState s m => m s
get

instance
#if MIN_VERSION_base(4,8,0)
  {-# OVERLAPPING #-}
#endif
    (Monad m, HListMContains 'SettableFlag a cts)
      => MonadMultiState a (MultiGSTT cts m) where
  mSet :: a -> MultiGSTT cts m ()
mSet a
x = StateT (HListM cts) m () -> MultiGSTT cts m ()
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
StateT (HListM ts) m a -> MultiGSTT ts m a
MultiGSTT (StateT (HListM cts) m () -> MultiGSTT cts m ())
-> StateT (HListM cts) m () -> MultiGSTT cts m ()
forall a b. (a -> b) -> a -> b
$ do
    HListM cts
ts <- StateT (HListM cts) m (HListM cts)
forall s (m :: * -> *). MonadState s m => m s
get
    HListM cts -> StateT (HListM cts) m ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put (HListM cts -> StateT (HListM cts) m ())
-> HListM cts -> StateT (HListM cts) m ()
forall a b. (a -> b) -> a -> b
$ a -> HListM cts -> HListM cts
forall (can :: CanReadWriteFlag) t (cts :: [CanReadWrite *]).
(HListMContains can t cts, CanWriteConstraint can) =>
t -> HListM cts -> HListM cts
writeHListMElem @'SettableFlag a
x HListM cts
ts

instance
#if MIN_VERSION_base(4,8,0)
  {-# OVERLAPPING #-}
#endif
    ( Monad m
    , Monoid a
    , HListMContains 'TellableFlag a cts
    ) => MonadMultiWriter a (MultiGSTT cts m) where
  mTell :: a -> MultiGSTT cts m ()
mTell a
x = StateT (HListM cts) m () -> MultiGSTT cts m ()
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
StateT (HListM ts) m a -> MultiGSTT ts m a
MultiGSTT (StateT (HListM cts) m () -> MultiGSTT cts m ())
-> StateT (HListM cts) m () -> MultiGSTT cts m ()
forall a b. (a -> b) -> a -> b
$ do
    HListM cts
ts <- StateT (HListM cts) m (HListM cts)
forall s (m :: * -> *). MonadState s m => m s
get
    let x' :: a
x' = HListM cts -> a
forall (can :: CanReadWriteFlag) t (cts :: [CanReadWrite *]).
HListMContains can t cts =>
HListM cts -> t
readHListMElem @'TellableFlag HListM cts
ts
    HListM cts -> StateT (HListM cts) m ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put (HListM cts -> StateT (HListM cts) m ())
-> HListM cts -> StateT (HListM cts) m ()
forall a b. (a -> b) -> a -> b
$ a -> HListM cts -> HListM cts
forall (can :: CanReadWriteFlag) t (cts :: [CanReadWrite *]).
(HListMContains can t cts, CanWriteConstraint can) =>
t -> HListM cts -> HListM cts
writeHListMElem @'TellableFlag (a
x' a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
x) HListM cts
ts

runMultiGSTTNil :: Monad m => MultiGSTT '[] m a -> m a
runMultiGSTTNil_ :: Monad m => MultiGSTT '[] m a -> m ()

runMultiGSTTNil :: MultiGSTT '[] m a -> m a
runMultiGSTTNil MultiGSTT '[] m a
k = StateT (HListM '[]) m a -> HListM '[] -> m a
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT (MultiGSTT '[] m a -> StateT (HListM '[]) m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
MultiGSTT ts m a -> StateT (HListM ts) m a
runMultiGSTTRaw MultiGSTT '[] m a
k) (HListM '[]
HNilM)
runMultiGSTTNil_ :: MultiGSTT '[] m a -> m ()
runMultiGSTTNil_ MultiGSTT '[] m a
k = (a -> ()) -> m a -> m ()
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (() -> a -> ()
forall a b. a -> b -> a
const ()) (StateT (HListM '[]) m a -> HListM '[] -> m a
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT (MultiGSTT '[] m a -> StateT (HListM '[]) m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
MultiGSTT ts m a -> StateT (HListM ts) m a
runMultiGSTTRaw MultiGSTT '[] m a
k) (HListM '[]
HNilM))

withReader :: Monad m => t -> MultiGSTT ('Gettable t ': tr) m a -> MultiGSTT tr m a
withReader :: t -> MultiGSTT ('Gettable t : tr) m a -> MultiGSTT tr m a
withReader t
x MultiGSTT ('Gettable t : tr) m a
k = StateT (HListM tr) m a -> MultiGSTT tr m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
StateT (HListM ts) m a -> MultiGSTT ts m a
MultiGSTT (StateT (HListM tr) m a -> MultiGSTT tr m a)
-> StateT (HListM tr) m a -> MultiGSTT tr m a
forall a b. (a -> b) -> a -> b
$ do
  HListM tr
tr <- StateT (HListM tr) m (HListM tr)
forall s (m :: * -> *). MonadState s m => m s
get
  (a
a, HListM ('Gettable t : tr)
ts') <- m (a, HListM ('Gettable t : tr))
-> StateT (HListM tr) m (a, HListM ('Gettable t : tr))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (a, HListM ('Gettable t : tr))
 -> StateT (HListM tr) m (a, HListM ('Gettable t : tr)))
-> m (a, HListM ('Gettable t : tr))
-> StateT (HListM tr) m (a, HListM ('Gettable t : tr))
forall a b. (a -> b) -> a -> b
$ StateT (HListM ('Gettable t : tr)) m a
-> HListM ('Gettable t : tr) -> m (a, HListM ('Gettable t : tr))
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
runStateT (MultiGSTT ('Gettable t : tr) m a
-> StateT (HListM ('Gettable t : tr)) m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
MultiGSTT ts m a -> StateT (HListM ts) m a
runMultiGSTTRaw MultiGSTT ('Gettable t : tr) m a
k) (t
x t -> HListM tr -> HListM ('Gettable t : tr)
forall x (x :: [CanReadWrite *]).
x -> HListM x -> HListM ('Gettable x : x)
:+-: HListM tr
tr)
  HListM tr -> StateT (HListM tr) m ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put (HListM tr -> StateT (HListM tr) m ())
-> HListM tr -> StateT (HListM tr) m ()
forall a b. (a -> b) -> a -> b
$ case HListM ('Gettable t : tr)
ts' of x
_ :+-: HListM xr
tr' -> HListM tr
HListM xr
tr'
  a -> StateT (HListM tr) m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a

withReader_ :: Monad m => t -> MultiGSTT ('Gettable t ': tr) m a -> MultiGSTT tr m ()
withReader_ :: t -> MultiGSTT ('Gettable t : tr) m a -> MultiGSTT tr m ()
withReader_ t
x MultiGSTT ('Gettable t : tr) m a
k = StateT (HListM tr) m () -> MultiGSTT tr m ()
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
StateT (HListM ts) m a -> MultiGSTT ts m a
MultiGSTT (StateT (HListM tr) m () -> MultiGSTT tr m ())
-> StateT (HListM tr) m () -> MultiGSTT tr m ()
forall a b. (a -> b) -> a -> b
$ do
  HListM tr
tr <- StateT (HListM tr) m (HListM tr)
forall s (m :: * -> *). MonadState s m => m s
get
  (a
_, HListM ('Gettable t : tr)
ts') <- m (a, HListM ('Gettable t : tr))
-> StateT (HListM tr) m (a, HListM ('Gettable t : tr))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (a, HListM ('Gettable t : tr))
 -> StateT (HListM tr) m (a, HListM ('Gettable t : tr)))
-> m (a, HListM ('Gettable t : tr))
-> StateT (HListM tr) m (a, HListM ('Gettable t : tr))
forall a b. (a -> b) -> a -> b
$ StateT (HListM ('Gettable t : tr)) m a
-> HListM ('Gettable t : tr) -> m (a, HListM ('Gettable t : tr))
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
runStateT (MultiGSTT ('Gettable t : tr) m a
-> StateT (HListM ('Gettable t : tr)) m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
MultiGSTT ts m a -> StateT (HListM ts) m a
runMultiGSTTRaw MultiGSTT ('Gettable t : tr) m a
k) (t
x t -> HListM tr -> HListM ('Gettable t : tr)
forall x (x :: [CanReadWrite *]).
x -> HListM x -> HListM ('Gettable x : x)
:+-: HListM tr
tr)
  HListM tr -> StateT (HListM tr) m ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put (HListM tr -> StateT (HListM tr) m ())
-> HListM tr -> StateT (HListM tr) m ()
forall a b. (a -> b) -> a -> b
$ case HListM ('Gettable t : tr)
ts' of x
_ :+-: HListM xr
tr' -> HListM tr
HListM xr
tr'

withWriter   :: (Monoid t, Monad m) => MultiGSTT ('Tellable t ': tr) m a -> MultiGSTT tr m (a, t)
withWriterAW :: (Monoid t, Monad m) => MultiGSTT ('Tellable t ': tr) m a -> MultiGSTT tr m (a, t)
withWriterWA :: (Monoid t, Monad m) => MultiGSTT ('Tellable t ': tr) m a -> MultiGSTT tr m (t, a)
withWriterW  :: (Monoid t, Monad m) => MultiGSTT ('Tellable t ': tr) m a -> MultiGSTT tr m t
withWriter :: MultiGSTT ('Tellable t : tr) m a -> MultiGSTT tr m (a, t)
withWriter = MultiGSTT ('Tellable t : tr) m a -> MultiGSTT tr m (a, t)
forall t (m :: * -> *) (tr :: [CanReadWrite *]) a.
(Monoid t, Monad m) =>
MultiGSTT ('Tellable t : tr) m a -> MultiGSTT tr m (a, t)
withWriterAW
withWriterAW :: MultiGSTT ('Tellable t : tr) m a -> MultiGSTT tr m (a, t)
withWriterAW MultiGSTT ('Tellable t : tr) m a
k = StateT (HListM tr) m (a, t) -> MultiGSTT tr m (a, t)
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
StateT (HListM ts) m a -> MultiGSTT ts m a
MultiGSTT (StateT (HListM tr) m (a, t) -> MultiGSTT tr m (a, t))
-> StateT (HListM tr) m (a, t) -> MultiGSTT tr m (a, t)
forall a b. (a -> b) -> a -> b
$ do
  HListM tr
tr <- StateT (HListM tr) m (HListM tr)
forall s (m :: * -> *). MonadState s m => m s
get
  (a
a, HListM ('Tellable t : tr)
ts') <- m (a, HListM ('Tellable t : tr))
-> StateT (HListM tr) m (a, HListM ('Tellable t : tr))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (a, HListM ('Tellable t : tr))
 -> StateT (HListM tr) m (a, HListM ('Tellable t : tr)))
-> m (a, HListM ('Tellable t : tr))
-> StateT (HListM tr) m (a, HListM ('Tellable t : tr))
forall a b. (a -> b) -> a -> b
$ StateT (HListM ('Tellable t : tr)) m a
-> HListM ('Tellable t : tr) -> m (a, HListM ('Tellable t : tr))
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
runStateT (MultiGSTT ('Tellable t : tr) m a
-> StateT (HListM ('Tellable t : tr)) m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
MultiGSTT ts m a -> StateT (HListM ts) m a
runMultiGSTTRaw MultiGSTT ('Tellable t : tr) m a
k) (t
forall a. Monoid a => a
mempty t -> HListM tr -> HListM ('Tellable t : tr)
forall xr (xr :: [CanReadWrite *]).
xr -> HListM xr -> HListM ('Tellable xr : xr)
:-+: HListM tr
tr)
  case HListM ('Tellable t : tr)
ts' of
    x
t :-+: HListM xr
tr' -> do
      HListM xr -> StateT (HListM tr) m ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put HListM xr
tr'
      (a, x) -> StateT (HListM tr) m (a, x)
forall (m :: * -> *) a. Monad m => a -> m a
return (a
a, x
t)
withWriterWA :: MultiGSTT ('Tellable t : tr) m a -> MultiGSTT tr m (t, a)
withWriterWA MultiGSTT ('Tellable t : tr) m a
k = StateT (HListM tr) m (t, a) -> MultiGSTT tr m (t, a)
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
StateT (HListM ts) m a -> MultiGSTT ts m a
MultiGSTT (StateT (HListM tr) m (t, a) -> MultiGSTT tr m (t, a))
-> StateT (HListM tr) m (t, a) -> MultiGSTT tr m (t, a)
forall a b. (a -> b) -> a -> b
$ do
  HListM tr
tr <- StateT (HListM tr) m (HListM tr)
forall s (m :: * -> *). MonadState s m => m s
get
  (a
a, HListM ('Tellable t : tr)
ts') <- m (a, HListM ('Tellable t : tr))
-> StateT (HListM tr) m (a, HListM ('Tellable t : tr))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (a, HListM ('Tellable t : tr))
 -> StateT (HListM tr) m (a, HListM ('Tellable t : tr)))
-> m (a, HListM ('Tellable t : tr))
-> StateT (HListM tr) m (a, HListM ('Tellable t : tr))
forall a b. (a -> b) -> a -> b
$ StateT (HListM ('Tellable t : tr)) m a
-> HListM ('Tellable t : tr) -> m (a, HListM ('Tellable t : tr))
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
runStateT (MultiGSTT ('Tellable t : tr) m a
-> StateT (HListM ('Tellable t : tr)) m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
MultiGSTT ts m a -> StateT (HListM ts) m a
runMultiGSTTRaw MultiGSTT ('Tellable t : tr) m a
k) (t
forall a. Monoid a => a
mempty t -> HListM tr -> HListM ('Tellable t : tr)
forall xr (xr :: [CanReadWrite *]).
xr -> HListM xr -> HListM ('Tellable xr : xr)
:-+: HListM tr
tr)
  case HListM ('Tellable t : tr)
ts' of
    x
t :-+: HListM xr
tr' -> do
      HListM xr -> StateT (HListM tr) m ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put HListM xr
tr'
      (x, a) -> StateT (HListM tr) m (x, a)
forall (m :: * -> *) a. Monad m => a -> m a
return (x
t, a
a)
withWriterW :: MultiGSTT ('Tellable t : tr) m a -> MultiGSTT tr m t
withWriterW MultiGSTT ('Tellable t : tr) m a
k = StateT (HListM tr) m t -> MultiGSTT tr m t
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
StateT (HListM ts) m a -> MultiGSTT ts m a
MultiGSTT (StateT (HListM tr) m t -> MultiGSTT tr m t)
-> StateT (HListM tr) m t -> MultiGSTT tr m t
forall a b. (a -> b) -> a -> b
$ do
  HListM tr
tr <- StateT (HListM tr) m (HListM tr)
forall s (m :: * -> *). MonadState s m => m s
get
  (a
_, HListM ('Tellable t : tr)
ts') <- m (a, HListM ('Tellable t : tr))
-> StateT (HListM tr) m (a, HListM ('Tellable t : tr))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (a, HListM ('Tellable t : tr))
 -> StateT (HListM tr) m (a, HListM ('Tellable t : tr)))
-> m (a, HListM ('Tellable t : tr))
-> StateT (HListM tr) m (a, HListM ('Tellable t : tr))
forall a b. (a -> b) -> a -> b
$ StateT (HListM ('Tellable t : tr)) m a
-> HListM ('Tellable t : tr) -> m (a, HListM ('Tellable t : tr))
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
runStateT (MultiGSTT ('Tellable t : tr) m a
-> StateT (HListM ('Tellable t : tr)) m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
MultiGSTT ts m a -> StateT (HListM ts) m a
runMultiGSTTRaw MultiGSTT ('Tellable t : tr) m a
k) (t
forall a. Monoid a => a
mempty t -> HListM tr -> HListM ('Tellable t : tr)
forall xr (xr :: [CanReadWrite *]).
xr -> HListM xr -> HListM ('Tellable xr : xr)
:-+: HListM tr
tr)
  case HListM ('Tellable t : tr)
ts' of
    x
t :-+: HListM xr
tr' -> do
      HListM xr -> StateT (HListM tr) m ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put HListM xr
tr'
      x -> StateT (HListM tr) m x
forall (m :: * -> *) a. Monad m => a -> m a
return x
t

withState   :: Monad m => t -> MultiGSTT ('Settable t ': tr) m a -> MultiGSTT tr m (a, t)
withStateAS :: Monad m => t -> MultiGSTT ('Settable t ': tr) m a -> MultiGSTT tr m (a, t)
withStateSA :: Monad m => t -> MultiGSTT ('Settable t ': tr) m a -> MultiGSTT tr m (t, a)
withStateA  :: Monad m => t -> MultiGSTT ('Settable t ': tr) m a -> MultiGSTT tr m a
withStateS  :: Monad m => t -> MultiGSTT ('Settable t ': tr) m a -> MultiGSTT tr m t
withState_  :: Monad m => t -> MultiGSTT ('Settable t ': tr) m a -> MultiGSTT tr m ()
withState :: t -> MultiGSTT ('Settable t : tr) m a -> MultiGSTT tr m (a, t)
withState = t -> MultiGSTT ('Settable t : tr) m a -> MultiGSTT tr m (a, t)
forall (m :: * -> *) t (tr :: [CanReadWrite *]) a.
Monad m =>
t -> MultiGSTT ('Settable t : tr) m a -> MultiGSTT tr m (a, t)
withStateAS
withStateAS :: t -> MultiGSTT ('Settable t : tr) m a -> MultiGSTT tr m (a, t)
withStateAS t
t MultiGSTT ('Settable t : tr) m a
k = StateT (HListM tr) m (a, t) -> MultiGSTT tr m (a, t)
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
StateT (HListM ts) m a -> MultiGSTT ts m a
MultiGSTT (StateT (HListM tr) m (a, t) -> MultiGSTT tr m (a, t))
-> StateT (HListM tr) m (a, t) -> MultiGSTT tr m (a, t)
forall a b. (a -> b) -> a -> b
$ do
  HListM tr
tr <- StateT (HListM tr) m (HListM tr)
forall s (m :: * -> *). MonadState s m => m s
get
  (a
a, HListM ('Settable t : tr)
ts') <- m (a, HListM ('Settable t : tr))
-> StateT (HListM tr) m (a, HListM ('Settable t : tr))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (a, HListM ('Settable t : tr))
 -> StateT (HListM tr) m (a, HListM ('Settable t : tr)))
-> m (a, HListM ('Settable t : tr))
-> StateT (HListM tr) m (a, HListM ('Settable t : tr))
forall a b. (a -> b) -> a -> b
$ StateT (HListM ('Settable t : tr)) m a
-> HListM ('Settable t : tr) -> m (a, HListM ('Settable t : tr))
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
runStateT (MultiGSTT ('Settable t : tr) m a
-> StateT (HListM ('Settable t : tr)) m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
MultiGSTT ts m a -> StateT (HListM ts) m a
runMultiGSTTRaw MultiGSTT ('Settable t : tr) m a
k) (t
t t -> HListM tr -> HListM ('Settable t : tr)
forall x (xr :: [CanReadWrite *]).
x -> HListM xr -> HListM ('Settable x : xr)
:++: HListM tr
tr)
  case HListM ('Settable t : tr)
ts' of
    x
t' :++: HListM xr
tr' -> do
      HListM xr -> StateT (HListM tr) m ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put HListM xr
tr'
      (a, x) -> StateT (HListM tr) m (a, x)
forall (m :: * -> *) a. Monad m => a -> m a
return (a
a, x
t')
withStateSA :: t -> MultiGSTT ('Settable t : tr) m a -> MultiGSTT tr m (t, a)
withStateSA t
t MultiGSTT ('Settable t : tr) m a
k = StateT (HListM tr) m (t, a) -> MultiGSTT tr m (t, a)
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
StateT (HListM ts) m a -> MultiGSTT ts m a
MultiGSTT (StateT (HListM tr) m (t, a) -> MultiGSTT tr m (t, a))
-> StateT (HListM tr) m (t, a) -> MultiGSTT tr m (t, a)
forall a b. (a -> b) -> a -> b
$ do
  HListM tr
tr <- StateT (HListM tr) m (HListM tr)
forall s (m :: * -> *). MonadState s m => m s
get
  (a
a, HListM ('Settable t : tr)
ts') <- m (a, HListM ('Settable t : tr))
-> StateT (HListM tr) m (a, HListM ('Settable t : tr))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (a, HListM ('Settable t : tr))
 -> StateT (HListM tr) m (a, HListM ('Settable t : tr)))
-> m (a, HListM ('Settable t : tr))
-> StateT (HListM tr) m (a, HListM ('Settable t : tr))
forall a b. (a -> b) -> a -> b
$ StateT (HListM ('Settable t : tr)) m a
-> HListM ('Settable t : tr) -> m (a, HListM ('Settable t : tr))
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
runStateT (MultiGSTT ('Settable t : tr) m a
-> StateT (HListM ('Settable t : tr)) m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
MultiGSTT ts m a -> StateT (HListM ts) m a
runMultiGSTTRaw MultiGSTT ('Settable t : tr) m a
k) (t
t t -> HListM tr -> HListM ('Settable t : tr)
forall x (xr :: [CanReadWrite *]).
x -> HListM xr -> HListM ('Settable x : xr)
:++: HListM tr
tr)
  case HListM ('Settable t : tr)
ts' of
    x
t' :++: HListM xr
tr' -> do
      HListM xr -> StateT (HListM tr) m ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put HListM xr
tr'
      (x, a) -> StateT (HListM tr) m (x, a)
forall (m :: * -> *) a. Monad m => a -> m a
return (x
t', a
a)
withStateA :: t -> MultiGSTT ('Settable t : tr) m a -> MultiGSTT tr m a
withStateA t
t MultiGSTT ('Settable t : tr) m a
k = StateT (HListM tr) m a -> MultiGSTT tr m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
StateT (HListM ts) m a -> MultiGSTT ts m a
MultiGSTT (StateT (HListM tr) m a -> MultiGSTT tr m a)
-> StateT (HListM tr) m a -> MultiGSTT tr m a
forall a b. (a -> b) -> a -> b
$ do
  HListM tr
tr <- StateT (HListM tr) m (HListM tr)
forall s (m :: * -> *). MonadState s m => m s
get
  (a
a, HListM ('Settable t : tr)
ts') <- m (a, HListM ('Settable t : tr))
-> StateT (HListM tr) m (a, HListM ('Settable t : tr))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (a, HListM ('Settable t : tr))
 -> StateT (HListM tr) m (a, HListM ('Settable t : tr)))
-> m (a, HListM ('Settable t : tr))
-> StateT (HListM tr) m (a, HListM ('Settable t : tr))
forall a b. (a -> b) -> a -> b
$ StateT (HListM ('Settable t : tr)) m a
-> HListM ('Settable t : tr) -> m (a, HListM ('Settable t : tr))
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
runStateT (MultiGSTT ('Settable t : tr) m a
-> StateT (HListM ('Settable t : tr)) m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
MultiGSTT ts m a -> StateT (HListM ts) m a
runMultiGSTTRaw MultiGSTT ('Settable t : tr) m a
k) (t
t t -> HListM tr -> HListM ('Settable t : tr)
forall x (xr :: [CanReadWrite *]).
x -> HListM xr -> HListM ('Settable x : xr)
:++: HListM tr
tr)
  case HListM ('Settable t : tr)
ts' of
    x
_ :++: HListM xr
tr' -> do
      HListM xr -> StateT (HListM tr) m ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put HListM xr
tr'
      a -> StateT (HListM tr) m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a
withStateS :: t -> MultiGSTT ('Settable t : tr) m a -> MultiGSTT tr m t
withStateS t
t MultiGSTT ('Settable t : tr) m a
k = StateT (HListM tr) m t -> MultiGSTT tr m t
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
StateT (HListM ts) m a -> MultiGSTT ts m a
MultiGSTT (StateT (HListM tr) m t -> MultiGSTT tr m t)
-> StateT (HListM tr) m t -> MultiGSTT tr m t
forall a b. (a -> b) -> a -> b
$ do
  HListM tr
tr <- StateT (HListM tr) m (HListM tr)
forall s (m :: * -> *). MonadState s m => m s
get
  (a
_, HListM ('Settable t : tr)
ts') <- m (a, HListM ('Settable t : tr))
-> StateT (HListM tr) m (a, HListM ('Settable t : tr))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (a, HListM ('Settable t : tr))
 -> StateT (HListM tr) m (a, HListM ('Settable t : tr)))
-> m (a, HListM ('Settable t : tr))
-> StateT (HListM tr) m (a, HListM ('Settable t : tr))
forall a b. (a -> b) -> a -> b
$ StateT (HListM ('Settable t : tr)) m a
-> HListM ('Settable t : tr) -> m (a, HListM ('Settable t : tr))
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
runStateT (MultiGSTT ('Settable t : tr) m a
-> StateT (HListM ('Settable t : tr)) m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
MultiGSTT ts m a -> StateT (HListM ts) m a
runMultiGSTTRaw MultiGSTT ('Settable t : tr) m a
k) (t
t t -> HListM tr -> HListM ('Settable t : tr)
forall x (xr :: [CanReadWrite *]).
x -> HListM xr -> HListM ('Settable x : xr)
:++: HListM tr
tr)
  case HListM ('Settable t : tr)
ts' of
    x
t' :++: HListM xr
tr' -> do
      HListM xr -> StateT (HListM tr) m ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put HListM xr
tr'
      x -> StateT (HListM tr) m x
forall (m :: * -> *) a. Monad m => a -> m a
return x
t'
withState_ :: t -> MultiGSTT ('Settable t : tr) m a -> MultiGSTT tr m ()
withState_ t
t MultiGSTT ('Settable t : tr) m a
k = StateT (HListM tr) m () -> MultiGSTT tr m ()
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
StateT (HListM ts) m a -> MultiGSTT ts m a
MultiGSTT (StateT (HListM tr) m () -> MultiGSTT tr m ())
-> StateT (HListM tr) m () -> MultiGSTT tr m ()
forall a b. (a -> b) -> a -> b
$ do
  HListM tr
tr <- StateT (HListM tr) m (HListM tr)
forall s (m :: * -> *). MonadState s m => m s
get
  (a
_, HListM ('Settable t : tr)
ts') <- m (a, HListM ('Settable t : tr))
-> StateT (HListM tr) m (a, HListM ('Settable t : tr))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (a, HListM ('Settable t : tr))
 -> StateT (HListM tr) m (a, HListM ('Settable t : tr)))
-> m (a, HListM ('Settable t : tr))
-> StateT (HListM tr) m (a, HListM ('Settable t : tr))
forall a b. (a -> b) -> a -> b
$ StateT (HListM ('Settable t : tr)) m a
-> HListM ('Settable t : tr) -> m (a, HListM ('Settable t : tr))
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
runStateT (MultiGSTT ('Settable t : tr) m a
-> StateT (HListM ('Settable t : tr)) m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
MultiGSTT ts m a -> StateT (HListM ts) m a
runMultiGSTTRaw MultiGSTT ('Settable t : tr) m a
k) (t
t t -> HListM tr -> HListM ('Settable t : tr)
forall x (xr :: [CanReadWrite *]).
x -> HListM xr -> HListM ('Settable x : xr)
:++: HListM tr
tr)
  case HListM ('Settable t : tr)
ts' of
    x
_ :++: HListM xr
tr' -> do
      HListM xr -> StateT (HListM tr) m ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put HListM xr
tr'

without :: Monad m => MultiGSTT tr m a -> MultiGSTT (ct ': tr) m a
without :: MultiGSTT tr m a -> MultiGSTT (ct : tr) m a
without MultiGSTT tr m a
k = StateT (HListM (ct : tr)) m a -> MultiGSTT (ct : tr) m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
StateT (HListM ts) m a -> MultiGSTT ts m a
MultiGSTT (StateT (HListM (ct : tr)) m a -> MultiGSTT (ct : tr) m a)
-> StateT (HListM (ct : tr)) m a -> MultiGSTT (ct : tr) m a
forall a b. (a -> b) -> a -> b
$ do
  HListM (ct : tr)
ts <- StateT (HListM (ct : tr)) m (HListM (ct : tr))
forall s (m :: * -> *). MonadState s m => m s
get
  case HListM (ct : tr)
ts of
    (x
t :+-: HListM xr
tr) -> do
      (a
a, HListM tr
tr') <- m (a, HListM tr) -> StateT (HListM (ct : tr)) m (a, HListM tr)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (a, HListM tr) -> StateT (HListM (ct : tr)) m (a, HListM tr))
-> m (a, HListM tr) -> StateT (HListM (ct : tr)) m (a, HListM tr)
forall a b. (a -> b) -> a -> b
$ StateT (HListM tr) m a -> HListM tr -> m (a, HListM tr)
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
runStateT (MultiGSTT tr m a -> StateT (HListM tr) m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
MultiGSTT ts m a -> StateT (HListM ts) m a
runMultiGSTTRaw MultiGSTT tr m a
k) HListM tr
HListM xr
tr
      HListM ('Gettable x : tr) -> StateT (HListM (ct : tr)) m ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put (x
t x -> HListM tr -> HListM ('Gettable x : tr)
forall x (x :: [CanReadWrite *]).
x -> HListM x -> HListM ('Gettable x : x)
:+-: HListM tr
tr')
      a -> StateT (HListM (ct : tr)) m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a
    (x
t :-+: HListM xr
tr) -> do
      (a
a, HListM tr
tr') <- m (a, HListM tr) -> StateT (HListM (ct : tr)) m (a, HListM tr)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (a, HListM tr) -> StateT (HListM (ct : tr)) m (a, HListM tr))
-> m (a, HListM tr) -> StateT (HListM (ct : tr)) m (a, HListM tr)
forall a b. (a -> b) -> a -> b
$ StateT (HListM tr) m a -> HListM tr -> m (a, HListM tr)
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
runStateT (MultiGSTT tr m a -> StateT (HListM tr) m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
MultiGSTT ts m a -> StateT (HListM ts) m a
runMultiGSTTRaw MultiGSTT tr m a
k) HListM tr
HListM xr
tr
      HListM ('Tellable x : tr) -> StateT (HListM (ct : tr)) m ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put (x
t x -> HListM tr -> HListM ('Tellable x : tr)
forall xr (xr :: [CanReadWrite *]).
xr -> HListM xr -> HListM ('Tellable xr : xr)
:-+: HListM tr
tr')
      a -> StateT (HListM (ct : tr)) m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a
    (x
t :++: HListM xr
tr) -> do
      (a
a, HListM tr
tr') <- m (a, HListM tr) -> StateT (HListM (ct : tr)) m (a, HListM tr)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (a, HListM tr) -> StateT (HListM (ct : tr)) m (a, HListM tr))
-> m (a, HListM tr) -> StateT (HListM (ct : tr)) m (a, HListM tr)
forall a b. (a -> b) -> a -> b
$ StateT (HListM tr) m a -> HListM tr -> m (a, HListM tr)
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
runStateT (MultiGSTT tr m a -> StateT (HListM tr) m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
MultiGSTT ts m a -> StateT (HListM ts) m a
runMultiGSTTRaw MultiGSTT tr m a
k) HListM tr
HListM xr
tr
      HListM ('Settable x : tr) -> StateT (HListM (ct : tr)) m ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put (x
t x -> HListM tr -> HListM ('Settable x : tr)
forall x (xr :: [CanReadWrite *]).
x -> HListM xr -> HListM ('Settable x : xr)
:++: HListM tr
tr')
      a -> StateT (HListM (ct : tr)) m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a

mGetRaw :: Monad m => MultiGSTT ts m (HListM ts)
mGetRaw :: MultiGSTT ts m (HListM ts)
mGetRaw = StateT (HListM ts) m (HListM ts) -> MultiGSTT ts m (HListM ts)
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
StateT (HListM ts) m a -> MultiGSTT ts m a
MultiGSTT StateT (HListM ts) m (HListM ts)
forall s (m :: * -> *). MonadState s m => m s
get

mSetRaw :: Monad m => HListM ts -> MultiGSTT ts m ()
mSetRaw :: HListM ts -> MultiGSTT ts m ()
mSetRaw = StateT (HListM ts) m () -> MultiGSTT ts m ()
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
StateT (HListM ts) m a -> MultiGSTT ts m a
MultiGSTT (StateT (HListM ts) m () -> MultiGSTT ts m ())
-> (HListM ts -> StateT (HListM ts) m ())
-> HListM ts
-> MultiGSTT ts m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HListM ts -> StateT (HListM ts) m ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put

mapMultiGSTT
  :: (ts ~ HListM cts)
  => (m (a, ts) -> m' (a', ts))
  -> MultiGSTT cts m a
  -> MultiGSTT cts m' a'
mapMultiGSTT :: (m (a, ts) -> m' (a', ts))
-> MultiGSTT cts m a -> MultiGSTT cts m' a'
mapMultiGSTT m (a, ts) -> m' (a', ts)
f = StateT (HListM cts) m' a' -> MultiGSTT cts m' a'
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
StateT (HListM ts) m a -> MultiGSTT ts m a
MultiGSTT (StateT (HListM cts) m' a' -> MultiGSTT cts m' a')
-> (MultiGSTT cts m a -> StateT (HListM cts) m' a')
-> MultiGSTT cts m a
-> MultiGSTT cts m' a'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (m (a, ts) -> m' (a', ts)) -> StateT ts m a -> StateT ts m' a'
forall (m :: * -> *) a s (n :: * -> *) b.
(m (a, s) -> n (b, s)) -> StateT s m a -> StateT s n b
mapStateT m (a, ts) -> m' (a', ts)
f (StateT ts m a -> StateT ts m' a')
-> (MultiGSTT cts m a -> StateT ts m a)
-> MultiGSTT cts m a
-> StateT ts m' a'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MultiGSTT cts m a -> StateT ts m a
forall (ts :: [CanReadWrite *]) (m :: * -> *) a.
MultiGSTT ts m a -> StateT (HListM ts) m a
runMultiGSTTRaw