[Haskell] Question for the haskell implementors: Arrays, unsafePerformIO, runST

Jan-Willem Maessen jmaessen at alum.mit.edu
Thu Feb 16 12:31:41 EST 2006

On Feb 15, 2006, at 10:53 PM, John Meacham wrote:

> So, I finally decided that jhc needs real arrays, but am running  
> into an
> issue and was wondering how other compilers solve it, or if there is a
> general accepted way to do so.
> ...
> now, the problem occurs in newAT__
>> newAT__ :: Int -> AT a -> Array__ a
>> newAT__ n (AT a1) = a1 (prim_newAT__ n)
>                             ^ this gets floated out as a CAF.

Yes, you need to have some construct in the language which can't be  
floated out.  When you implement runST / unsafePerformIO you quickly  
learn that you can't rely on data dependency alone (though you'll get  
lucky a surprising proportion of the time if you try).

In phc, due to our pH heritage we had a set of compiler primitives  
which were known to be unfloatable.  We were otherwise shockingly  
generous about floating things around (most of the other limitations  
got switched off in Haskell mode and only kicked in when you were  
compiling pH, which let you stick imperative stuff in without monads).

-Jan-Willem Maessen

More information about the Haskell mailing list