Peter wrote:
> So, How am I supposed to get the value of an IO Monad, such as "IO
> String", without returning an IO Monad?

You read correctly, this is impossible.  You already got some valid
answers, and here's another variant that preserves most of the nice
guarded expressions:


recv_headers' :: Socket.Socket -> String -> IO [[String]]
recv_headers' sock bulk = Socket.recv sock 1 >>= dispatch
  where dispatch ""            = error "Connection died unexpectedly."
        dispatch "\n" | endswith bulk "\r\n\r" = return [["foo", "bar"]]
        dispatch _             = recv_headers' sock (bulk ++ received)

 
Udo.
-- 
"Gadgets are not necessarily an improvement, vide the succession:
Blackboard -> Overhead Projector -> PowerPoint"
        -- E. W. Dijkstra

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to