"Could not deduce (MArray (STUArray s) Int (ST s)) from context ()" when applying runST

Christian Klauser ch27k89 at gmail.com
Tue Jul 21 19:56:12 EDT 2009


Interesting.

Would be used like this:

    uniquePermutations xs = runST $ strictToLazyST $ (uniquePermutationsST
xs)

After also swapping `runST` to the lazy version, it compiles and runs. Thank
you!

-----Original Message-----
From: Peter Gammie [mailto:peteg42 at gmail.com] 
Sent: Mittwoch, 22. Juli 2009 01:25
To: Christian Klauser
Cc: glasgow-haskell-users at haskell.org
Subject: Re: "Could not deduce (MArray (STUArray s) Int (ST s)) from context
()" when applying runST

On 22/07/2009, at 9:16 AM, Christian Klauser wrote:

> Thank you, works indeed with the strict ST monad. Didn't think of  
> that. But
> makes kind of sense not to define these instances, since unboxed  
> values
> cannot have their computation delayed. It's a bit unfortunate,  
> however, that
> a single use
> of an unboxed array "forces" the whole state thread to become strict.

Hmm. Have you seen the strictToLazyST function?

http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Monad-ST-
Lazy.html#v%3AstrictToLazyST

cheers
peter



More information about the Glasgow-haskell-users mailing list