|
|
|
|
|
by ufo
4290 days ago
|
|
Its harder to reason about resource usage with lazy IO. For example, when is it safe to call hclose to close a file handle? do
f <- open "file.txt"
s <- readContents f
hclose f
print s
Since readcontents is lazy, it only tries to get data from the file when you print s. But by that point the file has already boon closed!If you think about it, its a bit similar to the tradeoffs between garbage collection and reference counting. |
|