(Sorry, Sebastiaan, I hit send accidentally)

On Sat, Jun 14, 2008 at 1:18 PM, Sebastiaan Visser <[EMAIL PROTECTED]> 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.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to