[Haskell-cafe] On the purity of Haskell
Donn Cave
donn at avvanta.com
Thu Dec 29 16:16:52 CET 2011
Quoth Gregg Reynolds <dev at mobileink.com>,
> On Wed, Dec 28, 2011 at 2:44 PM, Heinrich Apfelmus
> <apfelmus at quantentunnel.de> wrote:
>>
>> The beauty of the IO monad is that it doesn't change anything about purity.
>> Applying the function
>>
>> bar :: Int -> IO Int
>>
>> to the value 2 will always give the same result:
>>
>> bar 2 = bar (1+1) = bar (5-3)
>
> Strictly speaking, that doesn't sound right.
Look again at the sentence you trimmed off the end:
>> Of course, the point is that this result is an *IO action* of
>> type IO Int, it's not the Int you would get "when executing this
>> action".
I believe that more or less points to the key to this discussion.
If it didn't make sense to you, or didn't seem relevant to the
question of pure functions, then it would be worth while to think
more about it.
Donn
More information about the Haskell-Cafe
mailing list