Safe Haskell | Safe |
---|---|
Language | Haskell98 |
Most pull-to-push transformations in this module require functions that are polymorphic over a monad transformer.
Because of this, some of the type signatures look internals, but actually many
(suitably polymorphic) operations on Stream
s will unify with them.
To get "interruptible" operations that can exit early with an error, put a
ExceptT
transformer just below the polymorphic monad transformer. In
practice, that means lifting functions like
throwE
and hoistEither
a
number of times.
Inspired by http://pchiusano.blogspot.com.es/2011/12/programmatic-translation-to-iteratees.html
- evert :: (forall m r. Monad m => Stream (Of a) m r -> m (Of x r)) -> Fold a x
- evertM :: Monad m => (forall t r. (MonadTrans t, Monad (t m)) => Stream (Of a) (t m) r -> t m (Of x r)) -> FoldM m a x
- evertM_ :: Monad m => (forall t r. (MonadTrans t, Monad (t m)) => Stream (Of a) (t m) r -> t m r) -> FoldM m a ()
- evertMIO :: MonadIO m => (forall t r. (MonadTrans t, MonadIO (t m)) => Stream (Of a) (t m) r -> t m (Of x r)) -> FoldM m a x
- evertMIO_ :: MonadIO m => (forall t r. (MonadTrans t, MonadIO (t m)) => Stream (Of a) (t m) r -> t m r) -> FoldM m a ()
- transvert :: (forall m r. Monad m => Stream (Of a) m r -> Stream (Of b) m r) -> Fold b x -> Fold a x
- transvertM :: Monad m => (forall t r. (MonadTrans t, Monad (t m)) => Stream (Of a) (t m) r -> Stream (Of b) (t m) r) -> FoldM m b x -> FoldM m a x
- transvertMIO :: MonadIO m => (forall t r. (MonadTrans t, MonadIO (t m)) => Stream (Of a) (t m) r -> Stream (Of b) (t m) r) -> FoldM m b x -> FoldM m a x
- generalEvertM :: Monad m => (forall r. Stream (Of a) (Stream ((->) (Feed a)) m) r -> Stream ((->) (Feed a)) m (Of b r)) -> FoldM m a b
- generalTransvertM :: Monad m => (forall r. Stream (Of a) (Stream ((->) (Feed a)) m) r -> Stream (Of b) (Stream ((->) (Feed a)) m) r) -> FoldM m b x -> FoldM m a x
Stream folds
:: Monad m | |
=> (forall t r. (MonadTrans t, Monad (t m)) => Stream (Of a) (t m) r -> t m (Of x r)) | |
-> FoldM m a x |
Like evert
, but gives the stream-folding function access to a base monad.
>>>
:{
let consume stream = lift (putStrLn "x") >> S.effects stream in L.foldM (evertM_ consume) ["a","b","c"] :} x
Note however that control operations can't be lifted through the transformer.