On Fri, Dec 30, 2011 at 12:49 AM, Heinrich Apfelmus <apfelmus@quantentunnel.de> wrote:
The functionf x = getAnIntFromTheUser >>= \i -> return (i+x)
f :: Int -> IO Int
is pure according to the common definition of "pure" in the context of purely functional programming. That's because
f 42 = f (43-1) = etc.
Put differently, the function always returns the same IO action, i.e. the same value (of type IO Int) when given the same parameter.time t: f 42 (computational process implementing func application begins…)
t+1: <keystroke> = 1t+2: 43 (… and ends)time t+3: f 42t+4: <keystroke> = 2t+5: 44Conclusion: f 42 != f 42(This seems so extraordinarily obvious that maybe Heinrich has something else in mind.)