Hello, Nils.
Can you describe if there any difference with latest conduit API (yield, await) that can be
used to write functions in a very similar style, but without using exeternal packages:
> runTCPServer settings app = appSource ap $$ go =$= CL.mapM_ encode =$ appSink app
> where
> go = forever $ do
> bp <- decode <$> await {- decode is inlined here assuming it can return different types -}
> {- logic here-}
> yield $ result
> mapM (yeild) [result1,result2...]
more over you don't need to write appSource $$ ... appSink on the top.
Here is an example of a client that authorizes and then reads commands
from TBMChan and requests server using json format.
> runTCPClient settings ad go
> where
> go = do
> source $$ await
> is <- authorize
> when is loop'
> authorize = do
> yield u >> yield (S8.pack "\n") $$ sink -- send authorization token
> mx <- source $$ sinkParser json -- get responce
> ...
> loop' = do
> minfo <- atomically $ readTBMChan ch
> case minfo of
> Nothing -> return ()
> Just (message, respBox) -> do
> yield message $$ C.concatMap (SL.toChunks . encode) =$ sink
> resp <- source $$ sinkParser json
> atomically $ putTMVar respBox resp
> loop'
> source = ppSource ad
> sink = appSink ad