[Haskell] threading mutable state through callbacks

Glynn Clements glynn.clements at virgin.net
Tue Oct 12 20:09:11 EDT 2004


Vincenzo Ciancia wrote:

> > Unfortunately, in this case the whole point of what people are trying
> > to do with unsafePerformIO is to allow these things to be visible at
> > the top level :-)
> 
> Sometimes I get too much involved in what I think about, and forget the 
> original goal :) A little _too_ naive, it seems, I apologize. So it's 
> like the original idea, that using these toplevel IO bindings one has 
> to impose an order of evaluation over all program bindings, which 
> surely is against the current meaning of haskell programs, e.g. if I 
> say
> 
> conf <- readMyConfFile
> init = fn conf
> 
> people would agree that the correct meaning is to first evaluate all of 
> the IO bindings and then the rest of the program:
> 
> x1 <- a1
> ...
> xn <- an
> 
> v1 = expr1
> ...
> vn = exprn
> 
> main = action
> 
> should be equivalent to
> 
> main = do
>  x1 <- a1
>  ...
>  xn <- an
>  let v1 = expr1
>      ...
>      vn = exprn in
>                action
> 
> This would not change the meaning of a standard haskell program I think 
> (but I am not an expert as you see). Am I wrong?

In the former, the variables have global scope, and may be exported
from the module. Also, what if you do this in a module other than
Main?

-- 
Glynn Clements <glynn.clements at virgin.net>


More information about the Haskell mailing list