Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 2
    No, it uses a concept called referential transparency that means that you can not see a difference between an expression that will produce output, and the actual output. This is important since otherwise it could be used as some backdoor mechanism to make functions impure. Commented Mar 30, 2022 at 13:52
  • 1
    Would you provide such a backdoor? Commented Mar 30, 2022 at 14:03
  • 2
    The main thing is it makes evaluation observable. If I have xs = [1, 2, 3] and ys = id xs and then later I ask xs == ys, if == means a pointer comparison then I get different results depending on whether ys has been evaluated or not. And if that's observable then we need to carefully define when evaluation can happen, so that we can make sure the result of evaluating xs == ys is predictable. Which would basically force us to being an imperative language with code as a sequence of steps, rather than a "timeless" expression language. Plus it rules out many compiler optimisations. Commented Mar 30, 2022 at 14:23
  • Somewhat aside, don't time things in GHCi, as the code is not optimized like it would be in the compiled code where you would really care about performance. Commented Mar 31, 2022 at 12:21
  • 1
    You may be interested in reallyUnsafePtrEquality# and these other questions: stackoverflow.com/q/9649500, stackoverflow.com/q/19355772, stackoverflow.com/q/30175974, stackoverflow.com/q/48163259. Commented Apr 4, 2022 at 16:15