@@ -839,39 +839,42 @@ liftInner (Stream step state) = Stream step' state
839 Stop -> Stop
839 Stop -> Stop
841{-# INLINE_NORMAL runReaderT #-}
841{-# INLINE_NORMAL runReaderT #-}
842−runReaderT :: Monad m => s -> Stream (ReaderT s m) a -> Stream m a
842+runReaderT :: Monad m => m s -> Stream (ReaderT s m) a -> Stream m a
843−runReaderT sval (Stream step state) = Stream step' state
843+runReaderT env (Stream step state) = Stream step' (state, env)
845 {-# INLINE_LATE step' #-}
845 {-# INLINE_LATE step' #-}
846− step' gst st = do
846+ step' gst (st, action) = do
847− r <- Reader.runReaderT (step (adaptState gst) st) sval
848+ r <- Reader.runReaderT (step (adaptState gst) st) sv
848 return $ case r of
849 return $ case r of
849− Yield x s -> Yield x s
850+ Yield x s -> Yield x (s, return sv)
850− Skip s -> Skip s
851+ Skip s -> Skip (s, return sv)
851 Stop -> Stop
852 Stop -> Stop
853{-# INLINE_NORMAL evalStateT #-}
854{-# INLINE_NORMAL evalStateT #-}
854−evalStateT :: Monad m => s -> Stream (StateT s m) a -> Stream m a
855+evalStateT :: Monad m => m s -> Stream (StateT s m) a -> Stream m a
855−evalStateT sval (Stream step state) = Stream step' (state, sval)
856+evalStateT initial (Stream step state) = Stream step' (state, initial)
857 {-# INLINE_LATE step' #-}
858 {-# INLINE_LATE step' #-}
858− step' gst (st, sv) = do
859+ step' gst (st, action) = do
859 (r, sv') <- State.runStateT (step (adaptState gst) st) sv
861 (r, sv') <- State.runStateT (step (adaptState gst) st) sv
860 return $ case r of
862 return $ case r of
861− Yield x s -> Yield x (s, sv')
863+ Yield x s -> Yield x (s, return sv')
862− Skip s -> Skip (s, sv')
864+ Skip s -> Skip (s, return sv')
863 Stop -> Stop
865 Stop -> Stop
865{-# INLINE_NORMAL runStateT #-}
867{-# INLINE_NORMAL runStateT #-}
866−runStateT :: Monad m => s -> Stream (StateT s m) a -> Stream m (s, a)
868+runStateT :: Monad m => m s -> Stream (StateT s m) a -> Stream m (s, a)
867−runStateT sval (Stream step state) = Stream step' (state, sval)
869+runStateT initial (Stream step state) = Stream step' (state, initial)
869 {-# INLINE_LATE step' #-}
871 {-# INLINE_LATE step' #-}
870− step' gst (st, sv) = do
872+ step' gst (st, action) = do
871 (r, sv') <- State.runStateT (step (adaptState gst) st) sv
874 (r, sv') <- State.runStateT (step (adaptState gst) st) sv
872 return $ case r of
875 return $ case r of
873− Yield x s -> Yield (sv', x) (s, sv')
876+ Yield x s -> Yield (sv', x) (s, return sv')
874− Skip s -> Skip (s, sv')
877+ Skip s -> Skip (s, return sv')
875 Stop -> Stop
878 Stop -> Stop
877------------------------------------------------------------------------------
880------------------------------------------------------------------------------