biohazard-2.1: bioinformatics support library
Safe HaskellNone
LanguageHaskell2010

Bio.Streaming.Furrow

Synopsis

Documentation

newtype Furrow a m r Source #

A tiny stream that can be afforded to incrementally.

The streaming abstraction works fine if multiple sources feed into a small constant number of functions, but fails if there is an unpredictable number of such consumers. In that case, evertStream should be used to turn each consumer into a Furrow. It's then possible to incrementally afford stuff to each Furrow in a collection in a simple loop. To get the final value, drain each Furrow.

Constructors

Furrow (Stream ((->) (Maybe a)) m r) 

Instances

Instances details
MMonad (Furrow a) Source # 
Instance details

Defined in Bio.Streaming.Furrow

Methods

embed :: forall (n :: Type -> Type) m b. Monad n => (forall a0. m a0 -> Furrow a n a0) -> Furrow a m b -> Furrow a n b #

MonadTrans (Furrow a) Source # 
Instance details

Defined in Bio.Streaming.Furrow

Methods

lift :: Monad m => m a0 -> Furrow a m a0 #

MFunctor (Furrow a :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Bio.Streaming.Furrow

Methods

hoist :: forall m n (b :: k). Monad m => (forall a0. m a0 -> n a0) -> Furrow a m b -> Furrow a n b #

Monad m => Monad (Furrow a m) Source # 
Instance details

Defined in Bio.Streaming.Furrow

Methods

(>>=) :: Furrow a m a0 -> (a0 -> Furrow a m b) -> Furrow a m b #

(>>) :: Furrow a m a0 -> Furrow a m b -> Furrow a m b #

return :: a0 -> Furrow a m a0 #

Monad m => Functor (Furrow a m) Source # 
Instance details

Defined in Bio.Streaming.Furrow

Methods

fmap :: (a0 -> b) -> Furrow a m a0 -> Furrow a m b #

(<$) :: a0 -> Furrow a m b -> Furrow a m a0 #

Monad m => Applicative (Furrow a m) Source # 
Instance details

Defined in Bio.Streaming.Furrow

Methods

pure :: a0 -> Furrow a m a0 #

(<*>) :: Furrow a m (a0 -> b) -> Furrow a m a0 -> Furrow a m b #

liftA2 :: (a0 -> b -> c) -> Furrow a m a0 -> Furrow a m b -> Furrow a m c #

(*>) :: Furrow a m a0 -> Furrow a m b -> Furrow a m b #

(<*) :: Furrow a m a0 -> Furrow a m b -> Furrow a m a0 #

MonadIO m => MonadIO (Furrow a m) Source # 
Instance details

Defined in Bio.Streaming.Furrow

Methods

liftIO :: IO a0 -> Furrow a m a0 #

MonadThrow m => MonadThrow (Furrow a m) Source # 
Instance details

Defined in Bio.Streaming.Furrow

Methods

throwM :: Exception e => e -> Furrow a m a0 #

evertStream :: Monad m => (Stream (Of a) (Furrow a m) () -> Furrow a m b) -> Furrow a m b Source #

Turns a function that consumes a stream into a furrow. Idea and some code stolen from "streaming-eversion".

afford :: Monad m => Furrow a m b -> a -> m (Furrow a m b) Source #

drain :: Monad m => Furrow a m b -> m b Source #