<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello All,<br>
<br>
I am trying to use both the websockets library and the pipes
library. They seem like a natural fit. However, I wanted to use the
websockets library to build a pipes 'Producer' and that does not
seem possible without some heavy lifting.<br>
<br>
The websockets library does not give me a connection I can read from
and write to. Instead, I need to supply an IO action (called a
clientApp). And execute it using something like:<br>
<br>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
--runClient :: String -- ^ Host<br>
-- -> Int -- ^ Port<br>
-- -> String -- ^ Path<br>
-- -> ClientApp a -- ^ Client application --
<meta http-equiv="content-type" content="text/html; charset=utf-8">
type ClientApp a = Connection -> IO a<br>
-- -> IO a<br>
<br>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
main :: IO ()<br>
main = withSocketsDo $ runClient "echo.websocket.org" 80 "/" app<br>
<br>
The problem happens when you couple this restriction with the
requirement that ClientApps have type 'Connection -> IO a'. Pipes
producers are Monad transformer stacks. For example, I would like to
build something like: <br>
messageProducer :: Producer' WebsocketMessage IO ()<br>
<br>
But this does not run in the IO monad and at the same time I cannot
get a 'Connection' object unless I use runClient.<br>
<br>
So, it seems I have a catch22 situation. Or have I overlooked
something? I'd rather not have to do "un-lifting" on the monad
transformer stack.<br>
<br>
Has anyone done this before? Any suggestions on how to go about it?<br>
<br>
<br>
Thanks,<br>
<br>
<br>
Dimitri<br>
<br>
<br>
<br>
</body>
</html>