On 08/04/2013 02:50 AM, Meta wrote:
On Saturday, 3 August 2013 at 23:04:14 UTC, Timon Gehr wrote:
...

Modification and dereference within a Haskell expression:

import Data.STRef
import Control.Monad.ST

x = runST $ do
  x <- newSTRef 0
  writeSTRef x 1
  v <- readSTRef x
  return v

main = print x

I apologize, as I don't know how familiar you are with Haskell,

With the language, quite intimately.

so forgive me if I'm telling you something you already know. That code is
100% pure and side-effect free;

My point was basically that x is a pure expression of type Integer.

no variables are being modified.

Which I didn't claim. A reference is dereferenced and the contents of the referenced slot are replaced. Then the reference is dereferenced again to read the modified value out.

Haskell only simulates side-effects

What tells you that D does not 'simulate' mutable state?

with monads,

What is done to main behind the scenes in order to execute the program is most definitely side-effecting.

and do-notation

do notation is not central to my point.

(syntwhat you
use in this example) which is syntactic sugar.

(i.e., the academic definition of purity).

I wouldn't go that far.

Perhaps that may go too far, as academics love to obfuscate topics with
a bunch of extraneous cruft,

I take issue with this statement. I meant, I wouldn't assume 'the academic definition of purity' is a thing.

but the fact remains that purity means:

1. No modification of local or global state (side-effects)
2. No dependence on global mutable state.

What does this statement quantify over? Eg, where is the abstraction boundary?

Reply via email to