[Haskell-cafe] Lazy IO.
Felipe Lessa
felipe.lessa at gmail.com
Sat Jun 14 12:45:23 EDT 2008
(Sorry, Sebastiaan, I hit send accidentally)
On Sat, Jun 14, 2008 at 1:18 PM, Sebastiaan Visser <sfvisser at cs.uu.nl> wrote:
> readHttpMessage :: IO (Headers, Data.ByteString.Lazy.ByteString)
> readHttpMessage = do
> myStream <- <accept http connection from client>
> request <- hGetContents myStream
> header <- parseHttpHeader request
> bs <- Data.ByteString.Lazy.hGetContents myStream
> return (header, body)
Why not
readHttpMessage = do
myStream <- <accept http connection from client>
data <- Data.ByteString.Lazy.hGetContents myStream
(header, rest) <- parseHttpHeader data
return (header, rest)
i.e. make parseHttpHeader return the rest of the string it didn't parse?
In fact, may I ask why parseHttpHeader is not a pure function?
HTH,
-- Felipe.
More information about the Haskell-Cafe
mailing list