[Haskell-cafe] Re: Silly I/O question
Peter Simons
simons at cryp.to
Tue Sep 28 19:30:49 EDT 2004
John Goerzen writes:
> But the block I/O in Haskell makes no sense to me (how do
> I allocate a Ptr type block thingy)?
With mallocArray. Block I/O is difficult, though.
>> You might want to write a function that copies the file
>> _once_ and then just call that function several times.
> If I load it into memory, yes. Otherwise, it seems not so
> easy.
Looking at your program:
> main = disp 100
> disp 0 = return ()
> disp n =
> let copy x = do
> eof <- isEOF
> if eof
> then return ()
> else do
> line <- getLine
> putStrLn line
> (copy 0)
> in do
> copy 0
> hSeek stdin AbsoluteSeek 0
> disp (n-1)
Just let the function _begin_ with the seek, copy the file,
and return. Then call it 100 times. No recursion.
Peter
More information about the Haskell-Cafe
mailing list