Re: [Haskell-cafe] I don't understand how ST works

2012-06-09 Thread Yves Parès
Oh my god, that was it? I looked at your code for half an hour, and I've never thought about that... That is really misleading. So vector forces you to use strict ST? (That's right: http://hackage.haskell.org/packages/archive/primitive/0.4.1/doc/html/Control-Monad-Primitive.html#t:PrimMonadshows th

Re: [Haskell-cafe] I don't understand how ST works

2012-06-09 Thread Nicu Ionita
Ok, the error was: I was using Control.Monad.ST.Lazy. Importing Control.Monad.ST compiles immediately without problem. (Is this because I'm using unboxed mutable vectors?) Now, that's a little bit odd. It's clear that the strict and lazy forms of ST are different types. But unfortunately they

Re: [Haskell-cafe] I don't understand how ST works

2012-06-08 Thread Nicu Ionita
Hi, I created a gist with a minimal (still 111 lines) module: https://gist.github.com/2898128 I still get the errors: WhatsWrong.hs:53:5: Couldn't match type `s' with `PrimState (ST s)' `s' is a rigid type variable bound by a type expected by the context: ST s [Move] at Wh

Re: [Haskell-cafe] I don't understand how ST works

2012-06-07 Thread Silvio Frischknecht
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > Now comes my question: in the impure values there is always that > "s". I was thinking that the whole structure should have s as a > parameter: Yes > >> data MList s = MList { mlVec :: MVector s Move, mlNextPh :: MList >> -> > ST s (Maybe (MList s

[Haskell-cafe] I don't understand how ST works

2012-06-07 Thread Nicu Ionita
Hi, After trying the whole afternoon to make a program work using ST and mutable vectors, I must give up and ask for some help. I have a pure function which generates a list of moves. But the whole thing should live in the ST monad, so: > genMoves ... = runST $ do ... Now, as I understand,