[Haskell-cafe] More STUArray questions

Martin Percossi mpercossi at martinpercossi.com
Sun Mar 12 16:00:22 EST 2006


On Sun, Mar 12, 2006 at 08:51:57PM +0000, Chris Kuklewicz wrote:
> There is a small error in the type of runSTMatrix, see below
> runSTMatrix :: (forall s. ST s (MMatrix s)) -> Matrix
> 
> runSTMatrix a = runST ( do (MMatrix i j mblock) <- a
>                            block <- unsafeFreeze mblock
>                            return (Matrix i j block)
>                       )

Hmm... now I get 

matrix.hs:138:27:
    Couldn't match the rigid variable `.' against `ST'
      `.' is bound by the type signature for `runSTMatrix'
      Expected type: ST s
      Inferred type: . (forall s1)
    In a 'do' expression: (MMatrix i j mblock) <- a
    In the first argument of `runST', namely
        `(do
            (MMatrix i j mblock) <- a
            block <- unsafeFreeze mblock
            return (Matrix i j block))'

matrix.hs:150:32:
    Couldn't match `ST s (MMatrix s)' against `MMatrix (forall s)'
      Expected type: ST (forall s) (ST s (MMatrix s))
      Inferred type: ST (forall s) (MMatrix (forall s))
    In the first argument of `runSTMatrix', namely `runMatrix'
    In the second argument of `($)', namely `runSTMatrix runMatrix'
Failed, modules loaded: none.

Martin


More information about the Haskell-Cafe mailing list