producer-0.1.0.0: Simple streaming datatype

Copyright(c) Eric Torreborre 2017
Someone Else 2014
LicenseMIT
Maintaineretorreborre@yahoo.com
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell2010

Streaming.Producer

Description

 

Synopsis

Documentation

newtype Producer m a Source #

A Producer generates values of type a with effects of type m

Constructors

Producer 

Fields

Instances

Monad m => Monad (Producer m) Source # 

Methods

(>>=) :: Producer m a -> (a -> Producer m b) -> Producer m b #

(>>) :: Producer m a -> Producer m b -> Producer m b #

return :: a -> Producer m a #

fail :: String -> Producer m a #

Functor m => Functor (Producer m) Source # 

Methods

fmap :: (a -> b) -> Producer m a -> Producer m b #

(<$) :: a -> Producer m b -> Producer m a #

Monad m => Applicative (Producer m) Source # 

Methods

pure :: a -> Producer m a #

(<*>) :: Producer m (a -> b) -> Producer m a -> Producer m b #

(*>) :: Producer m a -> Producer m b -> Producer m b #

(<*) :: Producer m a -> Producer m b -> Producer m a #

Show a => Show (Producer Identity a) Source # 

data Stream m a Source #

ADT for the produced elements. There are either:

  • no element
  • one element
  • several elements (a "chunk") followed by the next producer

Constructors

Done 
One a 
More [a] (Producer m a) 

Instances

Functor m => Functor (Stream m) Source # 

Methods

fmap :: (a -> b) -> Stream m a -> Stream m b #

(<$) :: a -> Stream m b -> Stream m a #

done :: Applicative m => Producer m a Source #

Constructors

A Producer with no elements

one :: Applicative m => a -> Producer m a Source #

A Producer with one element

more :: Applicative m => [a] -> Producer m a -> Producer m a Source #

A Producer with n elements and another Producer

emit :: Applicative m => [a] -> Producer m a Source #

A Producer with n elements

append :: Applicative m => Producer m a -> Producer m a -> Producer m a Source #

Combinators

Append 2 Producers together

filter :: Monad m => (a -> Bool) -> Producer m a -> Producer m a Source #

Filter the values of a Producer

take :: Monad m => Int -> Producer m a -> Producer m a Source #

Take the first n elements If n <= 0 an empty Producer is returned

drop :: Monad m => Int -> Producer m a -> Producer m a Source #

Drop the first n elements If n <= 0 nothing is dropped

chunk :: Monad m => Int -> Producer m a -> Producer m a Source #

Make sure that the underlying chunks have a size n as much as possible

runList :: Monad m => Producer m a -> m [a] Source #

Observations

The following functions can "run" a Producer to get values back

return a list of values

runChunks :: Monad m => Producer m a -> m [[a]] Source #

return a list of chunks