potoki-0.11: Simple streaming in IO

Safe HaskellNone
LanguageHaskell2010

Potoki.Transform

Contents

Synopsis

Documentation

data Transform input output :: * -> * -> * #

Potoki integration

consume :: Consume input output -> Transform input output #

produce :: (input -> Produce output) -> Transform input output #

Basics

take :: Int -> Transform input input #

takeWhile :: (input -> Bool) -> Transform input input Source #

drop :: Int -> Transform input input Source #

mapFilter :: (input -> Maybe output) -> Transform input output Source #

filter :: (input -> Bool) -> Transform input input Source #

just :: Transform (Maybe input) input Source #

distinctBy :: (Eq comparable, Hashable comparable) => (element -> comparable) -> Transform element element Source #

distinct :: (Eq element, Hashable element) => Transform element element Source #

executeIO :: Transform (IO a) a #

Execute the IO action.

mapInIO :: (a -> IO b) -> Transform a b Source #

runState :: (a -> State s b) -> s -> Transform a (s, b) Source #

Notice that you can control the emission of output of each step by producing a list of outputs and then composing the transform with the "list" transform.

execState :: (a -> State s b) -> s -> Transform a s Source #

evalState :: (a -> State s b) -> s -> Transform a b Source #

Parsing

parseBytes :: Parser parsed -> Transform ByteString (Either Text parsed) Source #

Lift an Attoparsec ByteString parser.

parseText :: Parser parsed -> Transform Text (Either Text parsed) Source #

Lift an Attoparsec Text parser.

Concurrency

bufferize :: Int -> Transform element element Source #

concurrently :: Int -> Transform input output -> Transform input output Source #

Execute the transform on the specified amount of threads. The order of the outputs produced is indiscriminate.

async :: Int -> Transform input input Source #

A transform, which fetches the inputs asynchronously on the specified number of threads.

File IO

Debugging

traceWithCounter :: (Int -> String) -> Transform a a Source #

Useful for debugging