|
|
|
|
|
by rujuladanh
2633 days ago
|
|
Yes, we all know how functional languages work; this is Y Combinator after all. However, that is a pedantic remark and missing OP's point. It is clear OP meant a program as in an entire non-trivial system, not individual functions; even if they are programs themselves. Regardless, when one talks about function purity, it is about the final evaluation, not about partial binding or lazyness. |
|
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.