[EMAIL PROTECTED] (Joachim Schmid) writes:

> I'am using Hugs 1.3 and have the following example:
> 
> import ST
>   
> change :: ST s ()
> change = do
>   error "Hello"
>  
> main = do
>  change
>  return ()
> 
> Starting the example in the interpreter with "runST main" results in "()".
> Why was "change" not executed ??
> Doing the same with the IO-monad (without runST) works correct (The
> expected result is "error ...").

This is not a bug, this is the expected behaviour when using *LAZY* state
threads.

Consider an expression such as:

  runST (do { a <- foo ; b <- bar ; return e })

With *STRICT* state threads (such as GHC's ST monad), you execute foo,
then execute bar then return e.

With *LAZY* state threads (such as those found in Hugs and in most
papers co-authored by John Launchbury), you just return e.  

If the value of e depends on the value of b, then you execute bar (but
not foo) when that part of e is evaluated.  

If the value of e depends on the value of a, then you execute foo then
bar when that part of e is evaluated.


Hope this helps,

Alastair Reid

Reply via email to