Mon, 24 Jan 2000 11:21:24 -0600, Michael Hobbs <[EMAIL PROTECTED]> pisze:

> When this philosophical impediment was pointed out, someone clarified
> the point by saying that an "IO a" function type is *not* equivalent to
> "World -> (World, a)". The result of an IO function is not an action, or
> even a function that performs an action, but instructions on how to
> perform an action. The result of a Haskell program (i.e., Main.main) is
> a sequence of instructions for actions that need to be performed. It is
> then up to the runtime system to execute these instructions.

IMHO "IO a" *is* roughly equivalent to "World -> (World, a)"
(ignoring exceptions and maybe something more). You can't tell the
difference between "an action", "a function that performs an action"
and "instructions on how to perform an action"! Because in all
variants the only useful thing you can do with it is to combine it
using monadic combinators and return it from main. You can't apply the
function to the world yourself (because you don't have a world) and
you can't examine those instructions (because the type is abstract).

> (*) One place where the World -> (World, a) model breaks down is when
> the IO function is a blocking function such as "getChar :: IO Char". If
> this function was equivalent to World -> (World, a) then that would mean
> that the result is completely determined by the input World value.

It is, because...

> Also, if the function was given the same World value on two separate
> occasions then it would have to spit out the same result each time.

...you don't have a way of giving it the same World twice, so you
can't prove it is not.

> Such a view gets entangled with quantum physics, uncertainty
> principles, and other philosophic theories about whether or not
> the universe is deterministic.

If you worry about nondeterminism, we can imagine that the input value
of World is evaluated lazily and as a whole is infinite. Some parts of
it depend on the output of our Haskell program, but it's not unusual
in a lazy world for a value to be expressed in terms of the result of a
function it is passed to as the argument. It happens that when the part
of World that says which character is to be read must be evaluated,
the character has already been read. I think this point of view has
something in common with the old Haskell's model of I/O: lazy streams.

-- 
 __("<    Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
 \__/              GCS/M d- s+:-- a22 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-

Reply via email to