Safe Haskell | None |
---|---|
Language | Haskell2010 |
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" ]
Documentation
:: (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 yield
ed downstream.
When all computations have been run, the conduit finishes processing.
This allows the user to parameter what happends once a requirement is fulfilled.
Reset | The requirement will be reset, and can be run multiple times |
Once | The requirement can only run once, first answer is kept on alts |
OnceCorrect | The requirement can only run once, best answer is kept on alts |