stuarray

How to create unboxed mutable array instance

let's say I've got the following type : data MyType = Constructor0 | Constructor1 | Constructor2 deriving (Eq,Show,Enum) Is there a way to create one of such instances : MArray (STUArray s) MyType (ST s) MArray IOUarray MyType IO For the moment I store everything as Word8 and I make conversion with (wrapped) fromEnum/to...

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

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) import...

STUArray with polymorphic type

I want to implement an algorithm using the ST monad and STUArrays, and I want it to be able to work with both Float and Double data. I'll demonstrate on a simpler example problem: calculating a memoized scanl (+) 0 (I know it can be solved without STUArray, just using as example). {-# LANGUAGE FlexibleContexts, ScopedTypeVariables #-} ...