It has exceptions
You can divide by zero
It has unsafe IO primitives
Exceptions aren't impure anyway.
In some pure functional languages, the pure fragment doesn't have exceptions, and you add exceptions as an effect (or as a monad)
(If you reify the effect with a type like Either or Result, then the code becomes pure: but that's just a monad like said above)
Sure they do, at least in Haskell. Bottom inhabits all types.
Haskell has impure constructs but sets you up to define referentially transparent abstractions with them, and this is actually valued by the Haskell community
let x = <definition of x>
in ... x ... x ...
(i.e. defining a variable x and then using it some number of times) is equivalent to ... <definition of x> ... <definition of x> ...
Seen in the opposite direction (transforming the bottom code to the top code) this means that extracting repeated code is always a valid thing to do. It's not valid in most other languages, and certainly no mainstream ones.Also, even if Haskell were perfectly pure, the fact that it uses lazy evaluation is far more important to actually being able to make use of referential transparency. In a strict language you will still see a massive performance differences if replacing the first version with the second, in the most common cases.
Ah, well, regardless of whether it holds in Haskell, referential transparency is a well-defined concept. Purity is not a well-defined concept (at least as far as I know. Please share a formal definition if you have one!). That's primarily what I'm trying to say.
But I also disagree with your point about unsafePerformIO. In practice, nothing in Haskell violates referential transparency in a significant way. Who knows why? It's an emergent phenomenon that in principle need not have occurred, but in practice it did. Debug.Trace and similar are about the only things that technically violate referential transparency (and they are extremely tame).
> the fact that it uses lazy evaluation is far more important to actually being able to make use of referential transparency
Yes, I agree with that.
In hindsight I think few would now regret not having added them in the first place.
I strongly believe that there is a point in the PL design space that makes optionals everywhere usable. Maybe Haskell can still be the language that delivers this.
https://hackage.haskell.org/package/bluefin-0.0.3.0/docs/Blu...
To be tongue in cheek then it also has the side effect of heating the CPU.