[Haskell-cafe] Re: Mutable but boxed arrays?

apfelmus apfelmus at quantentunnel.de
Thu Sep 6 09:12:00 EDT 2007


Henning Thielemann wrote:
> I'll see, if I understand it.
> 
>   do writeArray arr 0 2
>      x <- readArray arr 0
>      writeArray arr 0 (x+x)
> 
> If 'arr' is an STArray, the 'arr' will contain the unevaluated 
> expression "2+2" as zeroth element and with type STUArray it will 
> contain the evaluated "4" ?

Exactly. Put differently,

   writeArray :: STUArray -> ..

is strict in the third argument whereas

   writeArray :: STArray  -> ..

is not.

Regards,
apfelmus



More information about the Haskell-Cafe mailing list