Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
environment idiom
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-12-13 (18:45)
From: Thomas Fischbacher <Thomas.Fischbacher@P...>
Subject: Re: [Caml-list] environment idiom

> On Mon, 2004-12-13 at 21:20, Thomas Fischbacher wrote:
> > Referential transparency is about the substitution of definitions. 
> > Evidently, x <- ... is _not_ a definition. 
> But this is a bit circular. It is suspect to use the Haskell
> definition of 'definition' and then say Haskell is referentially
> transparent, a property depending on the definition of 'definition',
> because you cannot apply that definition to any other language.

Haskell differs from other languages in the one important point that 
Haskell definitions have all the properties of what a mathematician
would call a definition (maybe mod typeclass subtleties).

And this is what referential transparency is about: is the notion of 
"definition" that a programming language gives you just the same as that 
in mathematics or not?

> C also has 'definitions' but they're not at all the same
> as Haskell ones.

Precisely. And they do not behave like mathematical definitions, so C is 
not reftransparent.

> So when you're looking at monadic Haskell that contains
> 	x <- ...
> you can claim it isn't a definition.. but it surely
> looks like one.. more precisely it looks like an assignment.

Well, the C statement


may also look like an equation to the uninitiated, but everyone would 
perhaps agree with me that this is just a misinterpretation of symbols.

> However clearly the ST monad is sometimes useful.. 
> can you explain when that is?

Good question...

regards,                   (o_
 Thomas Fischbacher -  //\
(lambda (n) ((lambda (p q r) (p p q r)) (lambda (g x y)           V_/_
(if (= x 0) y (g g (- x 1) (* x y)))) n 1))                  (Debian GNU)