Re: Lazy IO is useful! [Was: "interact" behaves oddly...]

2003-10-02 Thread Jan-Willem Maessen
Thomas Hallgren <[EMAIL PROTECTED]> replies to Simon M: > Simon Marlow wrote: > > >The real problem is that lazy I/O injects side effects into the pure > >world of expressions. Haskell has a perfectly good system for > >encapsulating side effects - the IO monad. So why put these sneaky side > >e

RE: Lazy IO is useful! [Was: "interact" behaves oddly...]

2003-10-02 Thread Simon Marlow
> main = > do let mylist = [1..1] > writeFile "myfile.txt" (unlines (map show mylist)) This part does run in O(1) space and isn't problematic. > -- ... > mylist' <- (map read . lines) `fmap` readFile "myfile.txt" > let result = sum mylist' > print result Indeed, thi

Lazy IO is useful! [Was: "interact" behaves oddly...]

2003-10-01 Thread Thomas Hallgren
Simon Marlow wrote: The real problem is that lazy I/O injects side effects into the pure world of expressions. Haskell has a perfectly good system for encapsulating side effects - the IO monad. So why put these sneaky side effects into pure values? Although monadic IO is nice in many ways, I