[Haskell-cafe] pure programs
Jason Dusek
jason.dusek at gmail.com
Wed Nov 5 14:20:49 EST 2008
Jules Bean <jules at jellybean.co.uk> wrote:
> Jason Dusek wrote:
> > Though that seems reasonable, it is not, in general, true.
> > For example, System.Info.os is generally treated as
> > pure, though it is not. It's not clear to me how to
> > disambiguate these "born again" values from really pure
> > values.
>
> System.Info is broken. "os" has the wrong type.
>
> Sorry about that. There is quite a lot of brokenness in the
> standard libs which stops pure functions being pure. It's a
> shame IMO.
I've thought about this a little bit, and it may be okay. What
if our rule for program purity is a program, once compiled,
may be moved from environment to environment, and will either
execute consistently or simply fail to execute. Consider this
program:
import System.Info
main = putStrLn os
If I compile it on Linux and then run the executable on
FreeBSD, it will either fail to run, because FreeBSD Linux
compatibility got worse since I tried it last, or run and
print linux as it would on Linux. Does this seem
reasonable? As long as the programs are statically linked,
through and through, they should be pure. Admittedly, this
approach does not address "source level purity", which is
impossible due to `unsafePerformIO` and, more generally,
conditional compilation.
--
_jsn
More information about the Haskell-Cafe
mailing list