[Haskell-cafe] Trouble with the ST monad

Andre Nathan andre at digirati.com.br
Mon Dec 29 15:43:56 EST 2008

On Mon, 2008-12-29 at 14:19 -0500, Ross Mellgren wrote:
> The problem is that you're trying to take a STMatrix from some other  
> ST computation and freeze it in a new ST computation. The isolation  
> between separate computations is done via the rank-2 type variable "s"  
> in all those ST functions.

I guess I should go and read the rank-n types page on the wiki...

> Try this:
> freezeMatrix :: (forall s . STMatrix s a) -> Matrix a
> freezeMatrix f :: runST (freezeMatrix f)

Do you know why point-free style doesn't work here even with the type

> Also, instead of using an array of arrays, maybe an array with (Int,  
> Int) as the Ix might be a bit smoother?

Thanks for the suggestion. It didn't occur to me that there was an Ix
instance for that.


More information about the Haskell-Cafe mailing list