1 Oct
2003
1 Oct
'03
3:16 p.m.
On Wed, 1 Oct 2003, Keith Wansbrough wrote:
Can actually someone supply an implementation of something like interact that does no pipelining for the argument "id"? Simply doing "putStr !$ f !$ s" was not enough!
Yes, of course.
Your code above only forces the evaluation of the first cons-cell of the list, which is not enough. You want to force the entire list. Try
deepSeq :: [a] -> b -> b deepSeq (x:xs) y = deepSeq xs y deepSeq [] y = y
noninteract f = do s <- getContents putStr (f (deepSeq s s))
Here's another way to write the above: import DeepSeq noninteract f = getContents >>= (putStr . f $!!) -- Dean