Steve D'Aprano wrote:

And (shamelessly using Python syntax) if I have a function:

def spam(x):
    print(x)
    print(x+1)
>
> spam(time.sleep(60) or 1)

You can't write that in Haskell, because Haskell's
equivalent of print() is not a function (or at least
it's not a function that ever returns), and neither
is sleep().

It's hard to explain without going into a lot of
detail about monads, but if you tried to write that
in Haskell you would find that the type system,
together with the way the I/O "functions" are defined,
makes it impossible to write anything that uses the
return value of an expression that performs an I/O
operation. So "time.sleep(60) or 1" is unwriteable,
because the return value of the sleep() is not
accessible.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to