[Haskell-cafe] I love purity, but it's killing me.
Henning Thielemann
lemming at henning-thielemann.de
Fri Feb 8 08:16:27 EST 2008
On Fri, 8 Feb 2008, Matthew Naylor wrote:
> Now recall that referential transparency lets you replace equals with
> equals without changing the *value produced* by a program. Note that
> it says nothing about preserving *runtime behaviour*. Sharing, for
> example, may be lost. So if you do equational reasoning on function
> "f" (above), and loose some sharing, then you can only expect that the
> same sharing will also be also lost in the generated program. As long
> as the generated program computes the same result as it did before,
> referential transparency will be, overall, preserved; it would only be
> lost intermediately. This is what I mean by "safe".
I think there are degrees of observability. If a Haskell library
immediately talks to a C library and shares resources generated by the
library, then this sharing can be hardly observed and the method is
somehow safe. If you generate a C program with Haskell and write it to a
disk it can be easily observed and people might rely on a particular
resulting C program. If the C program is piped to a C compiler which is
immediately run, then sharing can be hardly observed. Even within Haskell
sharing is somehow observable, the Haskell program could observe the free
memory of the machine and thus it can see a difference between sharing and
duplicated objects.
More information about the Haskell-Cafe
mailing list