[Haskell-cafe] Re: philosophy of Haskell
Ertugrul Soeylemez
es at ertes.de
Sun Aug 15 16:29:01 EDT 2010
"Patai Gergely" <patai_gergely at fastmail.fm> wrote:
> > No. As you say the world1 value is immutable, but that's not
> > contradictory. If between 'getLine' and 'print' something was done
> > by a concurrent thread, then that change to the world is captured by
> > 'print'.
>
> Well, that's technically true, but it basically amounts to saying that
> the 'model' of IO is itself. If I see 'print x', I don't really think
> of an action that performs arbitrary side effects and prints x in the
> process (unless some error prevents even that). Some notion of
> compositionality is required, which would allow me to state how 'print
> x' contributes to the changes of the world in a way that doesn't
> depend on any context. Actions in the state monad are composable in
> that sense, while the same doesn't apply to the IO monad when
> explained in terms of state passing.
Why not?
I don't see any problems here. Note that the mental model of IO I
presented is not explicit state passing, but a state /monad/. I'm
proposing the hypothetical existence of a function like this:
advanceEverything :: Universe -> Universe
such that:
print x =
\world0 ->
doTheActualPrinting x (advanceEverything world0)
After all 'print' is not constrained to the effect of printing
something. All sorts of things can happen while printing, including
even network communication, when stdout is not a terminal. In IO
everything can happen everywhere.
The advanceEverything function could just as well be used by (>>=)
instead of the individual IO computations.
Greets,
Ertugrul
--
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/
More information about the Haskell-Cafe
mailing list