Hello, Group!
-- I implemented a scheme (strN - stream N, a, b - items of stream):
In pseudocode:
I done combining with S.zip from Streaming.Prelude. I suppose it's similar to Pipes and Conduits. And this looks like:
Would somebody help me: how to make this scheme (in simple way)? I can pass a to getStr2 sure and to get from it not simple b but (a, b) but this looks not cool. Is some other way to do it? /Best regards, Paul |
You would just change it like so.
S.mapM (\conn -> liftIO (getStr2 connection) >>= \b -> return (conn,b)) If you want to make it more brief, perhaps {-# LANGUAGE TupleSections #-} S.mapM(\conn = (conn,) <$> liftIO (getStr2 conn)) On Thu, Jun 8, 2017 at 10:57 AM, <[hidden email]> wrote: > Hello, Group! > > I implemented a scheme (strN - stream N, a, b - items of stream): > > a -> b -> (a, b) > a -> b -> (a, b) > a -> b -> (a, b) > . . ... > str1 str2 str3 > > i.e. from each item of str1 I get item of str2 (with network call) and then > combine item from str1 and item from str2 to a pair - to analize combined > item (because I need info from both items: a and b). > > In pseudocode: > > for a in str1Getter: > b = getStr2 a > analize(a, b) > > > I done combining with S.zip from Streaming.Prelude. I suppose it's similar > to Pipes and Conduits. And this looks like: > > (|>) = flip $ > str1Getter |> S.mapM (liftIO . getStr2 connection) |> S.zip str1Getter > > and sure here I got twice execution of str2 retrieving from network (each > request happens twice), due this zip. > > Would somebody help me: how to make this scheme (in simple way)? I can pass > a to getStr2 sure and to get from it not simple b but (a, b) but this looks > not cool. Is some other way to do it? > > > /Best regards, Paul > > -- > > "Haskell Pipes" group. > > email to [hidden email]. > -- |
Thank you David!
-- Have a nice weekand четверг, 8 июня 2017 г., 18:07:47 UTC+3 пользователь David M написал: You would just change it like so. |
Free forum by Nabble | Edit this page |