To carry the philosophy of functional programming to its logical extreme is to deny the existence of time. Some physicists have seriously suggested models that don't include time, but in the milieu of common human existence things happen and stuff has state.<p>State and time are always going to rear their ugly heads for functional programmers (often in the form of "the i/o problem"). There's just no way around it. This isn't to discount functional programming as a tool in the toolbox, but "philosophically pure" functional programming is an ideal as platonic and unreachable as the math it is derived from.
Can anyone explain to me how the io monad gives referential
transparency?
So, say I have a function to read a file:<p>readFile :: String -> IO String<p>readFile filename = ...<p>At time t1, if I invoke it it returns say:<p>IO "Contents at t1"<p>At time t2, if I invoke it it returns say:<p>IO "Contents at t2"<p>Given that we supplied the function with the same
argument (i.e. fname), and it returns two different values,
how can they be said to be equal? I'm probably totally misunderstanding this but anyway....