I just wanted to let you know that I have been working on this. The main hold up is that I've been trying to finish up a large blog post over the last few days, but I will drop by IRC soon and work this out with you.
On Sunday, December 8, 2013 2:43:59 PM UTC-8, Merijn Verstraaten wrote: > > I think this IRC discussion was the push I needed. My actual problem is > slightly more complex, since I need to do version dependent > decoding/encoding of frames. I'm curious whether my current design makes > sense and if people can sanity check it or have any comments: > > data Version > data Frame > > readSocket :: MonadIO m => Handle -> Producer ByteString m r > writeSocket :: MonadIO m => Handle -> Consumer ByteString m r > > parseVersion :: Consumer' ByteString m Version > > authenticate :: Pipe Frame Frame m r > > decoder :: Version -> Pipe ByteString Frame m r > encoder :: Version -> Pipe Frame ByteString m r > > handshake :: Monad m => Pipe ByteString ByteString (Producer Frame m) r > handshake = do > version <- parseVersion > decoder version >-> authenticate >-> encoder version > for (cat >-> decoder version) (lift . yield) > > connection :: MonadIO m => Handle -> Producer Frame m r > connection hnd = runEffect (readSocket hnd >-> handshake >-> writeSocket > hnd) > > I'm not sure I'm using the parseVersion Consumer' right, additionally the > "for" usage at the end looks like it should be possible cleaner. Anyway, > thanks for the help so far! > > Cheers, > Merijn > -- You received this message because you are subscribed to the Google Groups "Haskell Pipes" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
