Questions tagged [stuarray]
4 questions
10
votes
2 answers
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…

Raoul Supercopter
- 5,076
- 1
- 34
- 37
7
votes
2 answers
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…

yairchu
- 23,680
- 7
- 69
- 109
6
votes
1 answer
Revisiting Polymorphic STUArrays with Constraint Kinds
I want to implement a dynamic programming algorithm polymorphic in the score type; here's a simplified 1D version with no boundary conditions:
{-# LANGUAGE ConstraintKinds, FlexibleContexts, RankNTypes, ScopedTypeVariables #-}
import…

Zorn
- 73
- 6
1
vote
1 answer
"Could not deduce (MArray (STUArray s) Int (ST s)) from context ()" when applying runST
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…

Christian Klauser
- 4,416
- 3
- 31
- 42