re: Explain Pure Functions Like I'm Five VIEW POST

re: Just out of curiosity, how would you implement a pure function of console.log? I have no experience in functional languages.

Answer: You cheat by accepting that there are side-effects in order to run the program.

See wiki.haskell.org/Introduction_to_IO

Eh, IO String in Haskell is just as pure as String. Haskell only has a handful of escape hatches to break out of purity/referential transparency, like unsafePerformIO and unsafeInterleaveIO - but you don't need to (and shouldn't) use them at all. They're there for the runtime system to use and execute your code. See my other reply in this thread.

True. Thats why though Haskell is often considered the "most functional" out of others, but not Purely functional, because the type system allows for any side effects to be encapsulated within the context of a type.

That claim is as meaningful as the claim that no computer is Turing complete because they all have finite memory.

They are if you ignore any resource limitations and thats the point really. A Turing machine is more of a mathematical model than a real world implementation as you cannot possibly express the notion of infinity in computer systems. There has to be an upper limit somewhere.

Code of Conduct Report abuse