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

Christian Klauser ch27k89 at gmail.com
Tue Jul 21 19:16:41 EDT 2009

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.

-----Original Message-----
From: d4ve.menendez at gmail.com [mailto:d4ve.menendez at gmail.com] On Behalf Of
David Menendez
Sent: Mittwoch, 22. Juli 2009 00:53
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 Tue, Jul 21, 2009 at 5:30 PM, Christian Klauser<ch27k89 at gmail.com> wrote:
> Hi, I'm in the process of learning haskell and came across this problem:
> Using `Glasgow Haskell Compiler, Version 6.10.4, for Haskell 98, stage 2
> booted by GHC version 6.10.1`
> Common beginning of the file
> ============================
>    {-# LANGUAGE FlexibleContexts #-}
>    module UPSO where
>    import Control.Monad(forM,forM_)
>    import Control.Monad.ST.Lazy (ST,runST)

This works if I replace Control.Monad.ST.Strict instead of

The problem is that the MArray instances are declared for the strict
ST monad; there appear to be no corresponding instances for the lazy
ST monad.

Dave Menendez <dave at zednenem.com>

More information about the Glasgow-haskell-users mailing list