[Haskell-cafe] "show" for functional types

Tomasz Zielonka tomasz.zielonka at gmail.com
Sat Apr 1 13:27:24 EST 2006

On Sat, Apr 01, 2006 at 01:50:54PM +0100, Brian Hulley wrote:
> Greg Buchholz wrote:
> >>f x = x + 2
> >>g x = x + 1 + 1
> Interesting! Referential transparency (as I understand it) has indeed 
> been violated. Perhaps the interaction of GADTs and type classes was not 
> sufficiently studied before being introduced to the language.

You cal also tell them apart with some built-in Haskell types,
    (f 1e16 :: Double) == g 1e16

You automatically assume that Num operations have some additional
properties, but it's not always true.

When +, fromIntegral are unknown, you can't be sure that 1 + 1 is the
same as 2.

I think it is still meaningful to talk about referential
transparency if you treat all functions like + and fromIntegral as black
boxes. For example, in many programming languages it's not true that
    let y = f x in (y, y)

is the same as

    (f x, f x)

Best regards

More information about the Haskell-Cafe mailing list