[Haskell-cafe] Re: Haskell serialisation, was: To yi or not to yi...

apfelmus apfelmus at quantentunnel.de
Thu Jun 21 09:17:07 EDT 2007


Tom Schrijvers wrote:
>> I understand that, depending on what the compiler does the result of :
>>
>> do
>>    let  f = (*) 2
>>    print $ serialise f
>>
>> might differ as, for example, the compiler might have rewritten f as
>> \n ->
>> n+n.
>>
>> But, why would that make equational reasoning on serialise not valid?
>>
>> Isn't that true for all functions in the IO monad that, even when
>> invoked with the same arguments, they can produce different results?
> 
> Not if you take the ``state of the world" to be part of the arguments.
> If two programs behave differently for the same arguments and the same
> state of the world, then they're not equivalent. You do want your
> compiler to preserve equivalence, don't you?

You can put the internal representation of the argument into the "state
of the world".

Regards,
apfelmus



More information about the Haskell-Cafe mailing list