Re: [Haskell-cafe] Trouble with the ST monad

2008-12-29 Thread Andre Nathan
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.

Re: [Haskell-cafe] Trouble with the ST monad

2008-12-29 Thread Ross Mellgren
On Dec 29, 2008, at 3:43 PM, Andre Nathan wrote: 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

Re[2]: [Haskell-cafe] Trouble with the ST monad

2008-12-22 Thread Bulat Ziganshin
Hello Andre, Monday, December 22, 2008, 4:44:34 AM, you wrote: Is there any difference between using freeze/thaw from Data.Array.MArray versus freezeSTArray/thawSTArray from GHC.Arr? portability, at least -- Best regards, Bulatmailto:bulat.zigans...@gmail.com

[Haskell-cafe] Trouble with the ST monad

2008-12-21 Thread Andre Nathan
Hello, I'm trying to write a function that would take an STArray and and shuffle its elements. I'm having trouble with the ST monad, though, and couldn't find out how fix this issue. The problem happens when I use runST to extract the shuffled array from the ST monad. I'm getting the following

Re: [Haskell-cafe] Trouble with the ST monad

2008-12-21 Thread Ryan Ingram
The problem is that you are trying to return a mutable array out of an ST computation. This lets the mutability of the computation escape. That's what the s type variable is for; without it, runST is just unsafePerformIO. To solve your problem, you need to eliminate any references to the state

Re: [Haskell-cafe] Trouble with the ST monad

2008-12-21 Thread Andre Nathan
On Sun, 2008-12-21 at 16:47 -0800, Ryan Ingram wrote: The problem is that you are trying to return a mutable array out of an ST computation. This lets the mutability of the computation escape. That's what the s type variable is for; without it, runST is just unsafePerformIO. Thanks! If