You can use the `(+>>)` operator instead, which has exactly the type you need:

    (+>>) :: Monad m => (Req -> Answerer m r) -> Asker m r -> Effect m r

... so you can just write:

    runEffect (serverLoop +>> asker)

Basically you use `(+>>)` whenever you want the downstream component (i.e. `Asker`) to begin and you use `(>>~)` whenever you want the upstream component (i.e. `Answerer`) to begin. Their types are symmetric:

    (+>>) :: Monad m => (Req -> Answerer m r) -> Asker m r -> Effect m r
    (>>~) :: Monad m => Answerer m r -> (Resp -> Asker m r) -> Effect m r

On 8/19/15 2:51 PM, Erik Rantapaa wrote:
I've been trying to figure out how to use request and response, and after examining the Rakhana package I've manage to come up with the following basic example:

https://gist.github.com/erantapaa/f1075d0d8b1fd0b6be55#file-server-client2-hs

Any comments on how the code is organized?

My main question at this time is how the server loop gets kicked off with an ignored response, e.g. in startServer:


        startServer = do r <- respond undefined

        serverLoop r


Is this the standard way to do things?
--
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 haskell-pipes+unsubscr...@googlegroups.com <mailto:haskell-pipes+unsubscr...@googlegroups.com>. To post to this group, send email to haskell-pipes@googlegroups.com <mailto:haskell-pipes@googlegroups.com>.

--
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 haskell-pipes+unsubscr...@googlegroups.com.
To post to this group, send email to haskell-pipes@googlegroups.com.

Reply via email to