-- | Wrap the base monad in 'S.StateT'
stateC
  :: (Monad m, Monad (t1 (S.StateT t m)),
      MonadTrans t1,
      MFunctor t1) =>
     (t -> t1 m (b, t)) -> t1 (S.StateT t m) b
stateC k = do
    s <- lift S.get
    (r, s') <- hoist lift (k s)
    lift (S.put s')
    return r

stateC
  :: (Monad m, Monad (t1 (S.StateT t m)),
      MonadTrans t1,
      MFunctor t1) =>
     (t -> t1 m (b, t)) -> t1 (S.StateT t m) b
stateC k = do
    s <- lift S.get
    (r, s') <- hoist lift (k s)
    lift (S.put s')
    return r

stateC k = do
    s <- lift S.get
    (r, s') <- hoist lift (k s)
    lift (S.put s')
    return r
