
21 Apr
2009
21 Apr
'09
1:56 p.m.
Luke Palmer ha scritto:
[...] Note that it is not always possible to separate IO from pure code. As an example, consider an HTTP 1.1 server that read a request body containing a number for each line, and return a response body containing the sum of the numbers.
What?
sumRequest :: String -> String -- strips header, sums numbers, returns response
sumServer :: IO () -- reads from socket, writes sumRequest to socket
And many other permutations, with differing degrees of laziness and parametericity.
As long as you stricly read a string from the socket, this is ok. But you can not read a string lazily. Regards Manlio