[Haskell-cafe] State Variables

Bulat Ziganshin bulat.ziganshin at gmail.com
Mon May 29 05:25:39 EDT 2006

Hello Matthew,

Monday, May 29, 2006, 1:38:38 AM, you wrote:

> The third and final concern is the point of this post.  How does one
> handle state efficiently in Haskell?
> I've seen the various state monads and gained a superficial enough 
> understanding to be concerned about
> how useful they are, for the following reason:

> I would like to aggregrate a large number of state variables (possibly
> in the hundreds of variables) into a few
> data structures.  These structures would not only contain basic variable
> types, but probably some rather large
> mutable arrays.  So lets say I have such a structure called world and I
> wish to update just 1 entry.  If I do
> w=world{entry=newentry}, the entire enormous world structure is copied to w.

use RealWorld :)  IORef and StorableArray are you best friends. after
all, it's not good idea to work with StorableArray otherwise than
via the IO monad. i think you should create separate thread for each
part of your simulation and send data between them through Channels

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list