On line 29, instead of

  liftIO $ do
    mapM_ ...
    runResourceT $ do
      ...
  ...

why not

  liftIO $ mapM_ ...
  ...
  ...

?


Regarding threads, you should use resourceForkIO [1] which has a quite
nicer interface.  So you telnet would end like:

telnet :: String -> Int -> IO ()
telnet host port = runResourceT $ do
    (releaseSock, hsock) <- with (connectTo host $ PortNumber $
fromIntegral port) hClose
    liftIO $ mapM_ (\h -> hSetBuffering h LineBuffering) [ stdin,
stdout, hsock ]
    resourceForkIO $ sourceHandle stdin $$ sinkHandle hsock
    sourceHandle hsock $$ sinkHandle stdout
    release releaseSock

Disclaimer: code not tested =).

Cheers,

[1] 
http://hackage.haskell.org/packages/archive/conduit/0.0.2/doc/html/Control-Monad-Trans-Resource.html#v:resourceForkIO

-- 
Felipe.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to