|
|
|
|
|
by jcora
2639 days ago
|
|
This is actually not at all pedantic but a very fundamental, if subtle at first glance, point about purity. Once you start doing more advanced monadic programming it stops being subtle at all. Many people, yes "even on HN", are totally fooled by do notation and the imperative nomenclature, but there is nothing similar. You misunderstand it as well: it has nothing to do with evaluation mode. Idris is eagerly evaluated, for example, and _that function is still pure_! `f x = putStrLn x` gets "finally" evaluated and yes there is still no side effect. It is so evaluated that you can bind it to a variable and apply another function on it. Just like 2^100 is a pure expression, so is `putStrLn "hello"`. > It is clear OP meant a program as in an entire non-trivial system, not individual functions; even if they are programs themselves. It is not clear. Does he mean including the OS and hardware? Because no matter how complex, a pure program is still pure. |
|
They are a simple mapping of a tuple (hardware state, queue of world events) onto itself! Truly marvelous!
Vive la pureté!
PS. I am now working on abstracting this further, and I just realized the universe itself is pure too; but somehow I got some strange behaviors when I started to look into particles too closely... will report back soon.