[Haskell-cafe] background question about IO monad

Uwe Hollerbach uhollerbach at gmail.com
Wed Feb 6 22:30:12 EST 2008


Hi, all, thanks for the responses. I understand the distinction
between pure functions and impure functions/procedures/IO actions, it
just felt to me in the samples that I quoted that I was in fact
starting from basically the starting point, eventually getting to the
same endpoint (or at least a pair of endpoints that are not easily
distinguished from each other by looking just at code), and inbetween
one path was going through liftIO and the other not. But I guess it
comes down to the fact that, since I'm in a REPL, I'm wallowing in
impurity all the time (or something like that :-) )

regards,
Uwe

On 2/6/08, Bulat Ziganshin <bulat.ziganshin at gmail.com> wrote:
> Hello Uwe,
>
> Wednesday, February 6, 2008, 7:44:27 AM, you wrote:
>
> > But after that, it sure seems to me as if I've taken data out of the
> > IO monad...
>
> this means that you can't use results of IO actions in pure functions.
> your code works in some transformed version of IO monad, so you don't
> escaped it
>
> if we call pure functions as "functions" and non-pure ones as
> "procedures", the rule is "functions can't call procedures", but all
> other activity is possible. in your do_action you calls procedure (to
> format current time) and call a function (to format given time).
> do_action is procedure (because it works in transformed IO monad), so
> you don't break any rules
>
>
> --
> Best regards,
>  Bulat                            mailto:Bulat.Ziganshin at gmail.com
>
>


More information about the Haskell-Cafe mailing list