[Haskell-beginners] Type inference in ST monad?

Aurimas aurimas.anskaitis at vgtu.lt
Mon Aug 19 16:12:27 CEST 2013


On 08/19/2013 04:59 PM, Brandon Allbery wrote:
> On Mon, Aug 19, 2013 at 1:36 AM, Aurimas <aurimas.anskaitis at vgtu.lt 
> <mailto:aurimas.anskaitis at vgtu.lt>> wrote:
>
>     Thanks, this is clearly the most easy way to fix the problem. But
>     the question remains - why the line
>     "do r1 <- uniformR (-1.0, 1.0 :: Double) gen"  cannot be annotated
>     with ST s Double?
>
>
> Maybe you need ScopedTypeVariables? But I'd be suspicious that, given 
> the forall in the definition of ST, that such a type annotation 
> *always* creates a new `s` and some other way to "force" the type is 
> needed.
>
ScopedTypeVariables does not solve the problem. As you noticed, new s is 
created and runST is not happy about this. It is
strange that this type can be "forced" replacing given line by a 
function returning ST s a.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130819/c4d784c1/attachment.htm>


More information about the Beginners mailing list