Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If I recall correctly, `getContent` (and therefore `interact`) uses `unsafeInterleaveIO`, the most unsafe function of the whole Haskell library, while not satisfying all the condition it should satisfy.

More practically, `getContent` is evil because it locks the file it is reading for an unbounded amount of time: as long as it's content (the giant string representing the file), isn't either out of scope (and eventually garbage collected) or fully evaluated.

That can be a problem if you intent to open loads of files (you could hit the OS limit) or if you want to modify the file after reading part of it.

Lazy IO is therefore quite embarrassing. Several people are working at hopefully safer alternatives right now.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: