However there is nothing in the functions themselves that restricts their
use to just T Double. Thus the functions can be compared for equality by
supplying an argument of type T Double but used elsewhere in the program
with args of type (plain) Double eg:
..
Thus we can determine that f is implemented by different code from g (The
example would be even more convincing if Int's were used instead of
Double's) and so f and g are not interchangeable.
if you have two functions f and g, and an argument applied to which they
deliver different results, then the functions can hardly be equal, can they?
if they are not equal, what makes you think they should be interchangeable?
... nothing prevents us from defining that instance in such a way that we
construct a
representaton instead of doing any additions.
Thus referential transparency of polymorphic functions is foiled.
polymorphic functions (as in: parametrically polymorphic) do not allow
such tricks. overloaded expressions are interpreted as functions from
type information to non-overloaded expressions, so you have to take
that type information into account when comparing or exchanging the
expressions. in particular, an overloaded expression instantiated at a
particular type is not the same as the overloaded expression itself.
btw, you'll notice that I avoid the use of terms like rt - there are too
many non-equivalent interpretations of such terms flying around, so
it is better to define what it is you're talking about (try this for one
study of the many definitions [scanned paper - >3MB]:
http://www.dina.kvl.dk/~sestoft/papers/SondergaardSestoft1990.pdf ).
cheers,
claus
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe