Reputation: 11830
I am having source crawling some websites and collects items of type Category
from them:
catsSource :: Source IO Category
The next step is to write companies collector (items of type Company
). Companies collector needs categories: for each Category
on input several companies should be produced, one by one. In other word it should "yield" Company
, not [Company]
.
What do I need for this task? Conduit or tricky source? If source, how it should get categories from catsSource
? If conduit how it should pass ("yield") company forward when it is found?
To clear my question here is an attempt (not passing type check):
import qualified Data.Conduit.List as CL
companiesFromCategory cat = [Company "foo", Company "bar"]
companies :: Conduit Category IO Company
companies = CL.fold . (CL.map companiesFromCategory)
Upvotes: 1
Views: 73
Reputation: 11830
The solution is to use concatMap
:
companies = CL.concatMap companiesFromCategory
Upvotes: 3