What is the precise promise/guarantee the Haskell language provides with respect to referential transparency? At least the Haskell report does not mention this notion.
C
The problem is overloading, which does indeed sort of violate referential transparency. You have no idea what something like (+)
does in Haskell; it depends on the type.
When a numeric type is unconstrained in a Haskell program the compiler uses type defaulting to pick some suitable type. This is for convenience, and usually doesn't lead to any surprises. But in this case it did lead to a surprise. In ghc you can use -fwarn-type-defaults
to see when the compiler has used defaulting to pick a type for you. You can also add the line default ()
to your module to stop all defaulting.