| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
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 :: Conduit String IO Int
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
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 |
| -> Conduit a m x |
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.