Tue, 30 May 2000 00:11:05 -0700 (PDT), Ronald J. Legere <[EMAIL PROTECTED]> pisze:
> Ok, I have a question with regards to IO function that return things
> of type IO [a], but where we are supposed to understand that the
> list is returned in a lazy way. This sounds perfectly ok,
It is not ok. Normally mere evaluation of a value cannot cause any
effect other than nontermination, even reading from a file.
But this is what getContents does. It is magic, not implementable
using other IO primitives. It is there because this effect (reading
from a file) is so "light" effect, and the value obtained is immutable
as every value should, and the thing is so useful, that we live with
that little impurity.
> unsafeInterleaveIO. WHAT the heck is that thing?
When applied to an IO action, it immediately produces a magic value,
which, when later evaluated, will execute the said action and yield
its result.
It is one of ways of producing those impure values. The other is
unsafePerformIO:: IO a -> a, that produces such value in a pure
context.
They are extensions for those who know what they are doing. Good if the
resulting thing has a safe interface, where only its implementation
requires impurity (getContents is not quite of this kind; randomIO is).
--
__("< Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
\__/ GCS/M d- s+:-- a23 C+++$ UL++>++++$ P+++ L++>++++$ E-
^^ W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP+ t
QRCZAK 5? X- R tv-- b+>++ DI D- G+ e>++++ h! r--%>++ y-