withdependencies-0.2.5: Run computations that depend on one or more elements in a stream.

Safe HaskellNone
LanguageHaskell2010

Data.Conduit.Require

Description

Runs computations depending on some values coming from a conduit. The computations are defined in applicative fashion.

test :: IO [Int]
test = inp =$ cnd $$ CL.consume
    where
        inp = sourceDirectory "/etc"
        cnd :: ConduitT String Int IO ()
        cnd = withRequirement (map Once comps) id (fmap length . readFile)
        comps :: [Require String Int Int]
        comps = [ (+) <$> require "/etc/passwd" <*> require "/etc/passwd"
                , (-) <$> require "/etc/resolv.conf" <*> require "/etc/nonexistent"
                , require "/etc/hosts"
                ]
Synopsis

Documentation

withRequirement Source #

Arguments

:: (Ord identifier, Eq identifier, Monad m, Functor m) 
=> [(RunMode, Require identifier content x)]

The list of dependent computations

-> (a -> identifier)

Extracting the identifier

-> (a -> m content)

Extracting the content, possibly with effects

-> ConduitT a x m () 

Given a stream of values, from which an identifier and a content can be extracted, runs a list of computation that depend on these.

Each computation's output is yielded downstream.

When all computations have been run, the conduit finishes processing.

data RunMode Source #

This allows the user to parameter what happends once a requirement is fulfilled.

Constructors

Reset

The requirement will be reset, and can be run multiple times

Once

The requirement can only run once

Instances
Show RunMode Source # 
Instance details

Defined in Data.Conduit.Require