[Haskell-cafe] ANN: conduit-network-stream, A base layer for network protocols with Conduits

Alexander V Vershilov alexander.vershilov at gmail.com
Mon Feb 25 06:52:03 CET 2013


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



On 24 February 2013 22:23, Nils <mail at nils.cc> wrote:

> Hello everyone,
>
> I just uploaded my "conduit-network-stream" package to hackage. It's a
> base layer for network protocols based on the "Conduit" package by Michael
> Snoyman which makes it possible to send multiple messages over a continuous
> network connection in a convenient way.
>
> I wrote more about it at:
>
> https://github.com/mcmaniac/**conduit-network-stream/blob/**
> master/README.md<https://github.com/mcmaniac/conduit-network-stream/blob/master/README.md>
>
> It is available on hackage and github:
>
> http://hackage.haskell.org/**package/conduit-network-stream<http://hackage.haskell.org/package/conduit-network-stream>
> https://github.com/mcmaniac/**conduit-network-stream<https://github.com/mcmaniac/conduit-network-stream>
>
> Until the documentation on hackage is generated, I also host the haddock
> documentation at:
>
> http://hs.nils.cc/conduit-**network-stream/index.html<http://hs.nils.cc/conduit-network-stream/index.html>
>
> For any questions/problems/requests, please ask!
>
>
> - Nils
>
> ______________________________**_________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/**mailman/listinfo/haskell-cafe<http://www.haskell.org/mailman/listinfo/haskell-cafe>
>



-- 
Alexander
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130225/0f3e8a45/attachment.htm>


More information about the Haskell-Cafe mailing list