potoki-core-2.1: Low-level components of "potoki"

Safe HaskellNone
LanguageHaskell2010

Potoki.Core.Transform

Contents

Synopsis

Documentation

newtype Transform input output Source #

Constructors

Transform (Fetch input -> Acquire (Fetch output)) 

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

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

mapFetch :: (Fetch a -> Fetch b) -> Transform a b Source #

Basics

take :: Int -> Transform input input Source #

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 Source #

Execute the IO action.

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

ByteString

extractLines :: Transform ByteString ByteString Source #

Convert freeform bytestring chunks into chunks, which are strictly separated by newline no matter how long they may be.

State

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