Re: [Haskell] Help in understanding a type error involving forall and class constraints

2004-06-30 Thread MR K P SCHUPKE
Then we get the problem when we use difST in distString. I no such problem. The Glorious Glasgow Haskell Compilation System, version 6.3 ghc -H32m -Wall -O2 -fvia-C -optc-O2 -optc-march=pentium3 -optc-mfpmath=sse -fexcess-precision -fliberate-case-threshold100 -funbox-strict-fields -threaded

[Haskell-cafe] Re: [Haskell] Help in understanding a type error involving forall and class constraints

2004-06-30 Thread Duncan Coutts
On Wed, 2004-06-30 at 12:00, MR K P SCHUPKE wrote: Ahh.. I see whats happening: MArray (STUArray s) a (ST s) = String - String - ST s (UArray (Int,Int) a) IArray UArray a = String - String - a nothing here is specifying a... you cannot leave a polymorphic in this case. You need to

[Haskell] Help in understanding a type error involving forall and class constraints

2004-06-29 Thread Duncan Coutts
Here's a small bit of code that involves some fairly hairy class overloadings (ghc's mutable unboxed array classes) The code builds an array in the ST monad by creating a mutable array then assigning to each element and finally freezing the array and returning an immutable array. Firstly the bit

Re: [Haskell] Help in understanding a type error involving forall and class constraints

2004-06-29 Thread MR K P SCHUPKE
Erm, something I remember about needing MArrays... Here's something which does the same thing (cooks and MArray then freezes it - also using STUArray... The neat thing is MArray is a class, so you can swap between STUArray and STArray implementations without changing code. This is the classic

Re: [Haskell] Help in understanding a type error involving forall and class constraints

2004-06-29 Thread Duncan Coutts
On Tue, 2004-06-29 at 18:42, MR K P SCHUPKE wrote: Erm, something I remember about needing MArrays... Here's something which does the same thing (cooks and MArray then freezes it - also using STUArray... The neat thing is MArray is a class, so you can swap between STUArray and STArray

Re: [Haskell] Help in understanding a type error involving forall and class constraints

2004-06-29 Thread MR K P SCHUPKE
Try this: distString :: String - String - Int distString s0 s1 = let a = runST (difST s0 s1) in a!(1,1) difST :: MArray (STUArray s) Int (ST s) = String - String - ST s (UArray (Int,Int) Int) difST s0 s1 = do b@(_,br) - return $ (\x1 y1 - ((0,0),(x1,y1))) (length s0) (length s1) d -