Copyright | (c) Eric Torreborre 2017 Someone Else 2014 |
---|---|

License | MIT |

Maintainer | etorreborre@yahoo.com |

Stability | experimental |

Safe Haskell | Safe |

Language | Haskell2010 |

- newtype Producer m a = Producer {}
- data Stream m a
- done :: Applicative m => Producer m a
- one :: Applicative m => a -> Producer m a
- more :: Applicative m => [a] -> Producer m a -> Producer m a
- emit :: Applicative m => [a] -> Producer m a
- append :: Applicative m => Producer m a -> Producer m a -> Producer m a
- filter :: Monad m => (a -> Bool) -> Producer m a -> Producer m a
- take :: Monad m => Int -> Producer m a -> Producer m a
- drop :: Monad m => Int -> Producer m a -> Producer m a
- chunk :: Monad m => Int -> Producer m a -> Producer m a
- runList :: Monad m => Producer m a -> m [a]
- runChunks :: Monad m => Producer m a -> m [[a]]

# Documentation

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

ADT for the produced elements. There are either:

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

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