I do not think that the definition of for SbTis what you want. This defines functorial composition, and if the parameter mis equal to Functoror Applicative, this should preserve these properties. But such a composition, in general, does not create a new monad from the other two. See this question for more details .
, , ? , . , , . newtype , m , .
, , - , "" - , " " , , , - , , c. , , , . (f . g . h) x h, f "" .
, , , , , ,... ... , SB . , . . ? State - , , , . , - State , ? :
type State s = StateT s Identity
, . , Identity . :
type SB i a = ReaderT ( AlgRO i ) (State ( AlgState i ) ) a
:
type SB i a = ReaderT ( AlgRO i ) ( StateT ( AlgState i ) Identity ) a
:
type SB' i m a = ReaderT ( AlgRO i ) ( StateT ( AlgState i ) m ) a
type SB i a = SB' i Identity a
SB' , , , . newtype :
newtype SbT i m a = SbT { getSB :: ReaderT ( AlgRO i ) ( StateT ( AlgState i ) m ) a }
instance (Functor m) => Functor (SbT i m) where
fmap f (SbT sb) = SbT (fmap f sb)
instance (Monad m) => Monad (SbT i m) where
return x = SbT (return x)
SbT m >>= k = SbT (m >>= (getSB . k))
instance MonadTrans (SbT i) where
lift = SbT . lift . lift
runSbT :: SbT i m a -> AlgRO i -> AlgState i -> m (a, AlgState t)
runSbT (SbT m) e s = runStateT (runReaderT m e) s
, : runSbT , "" , . , lift , newtype. , , .
, MonadReader MonadState, .