
On 08/08/2013 01:19 AM, Jerzy Karczmarczuk wrote:
Bardur Arantsson comments the comment of Joe Quinn:
On 8/7/2013 11:00 AM, David Thomas wrote:
twice :: IO () -> IO () twice x = x >> x
I would call that evaluating x twice (incidentally creating two separate evaluations of one pure action description), but I'd like to better see your perspective here.
x is only evaluated once, but/executed/ twice. For IO, that means magic. For other types, it means different things. For Identity, twice = id!
Your point being? x is the same thing regardless of how many times you run it.
What do you mean by "the same thing"? You cannot compare 'them' in any reasonable sense. ...
http://en.wikipedia.org/wiki/Identity_of_indiscernibles (He is reasoning _about_ the language and not _within_ the language because Haskell does not support very powerful reasoning internally.)
... You make the distinction between "evaluate",
Which essentially means applying reduction rules to an expression until the result is a value.
and "execute" or "run", etc. This is not functional.
How would you know?
Your program doesn't "run" anything, it applies (>>=) (or equivalent) to an IO (...) object. This is the only "practical evaluation" of it, otherwise it can be passed (or duplicated as above). But you cannot apply "bind" twice to the same instance of it (in fact, as I said above, "the same instance" is a bit suspicious concept...). ...
Indeed, but you didn't say that above.
The "running" or "execution" takes place outside of your program. In such a way Richard O'Keefe and I converge... That's why I say that the concept of purity is meaningless in the discussed context.
Not meaningless, but redundant. The point of having a purely functional programming language is to have reasoning based on purity be universally applicable.
It is a kind of counterfeit notion, inherited from "pure functions" to something which belongs to two different worlds. ...
'putStr "c"' is a pure value. On the other hand: 'unsafePerformIO (putStr "c")' is not a pure value. (But this expression does not exist in standard Haskell. unsafePerformIO "unquotes" the action. You may be confusing the "quoted" and "unquoted" versions.)