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/toEnum, but it doesn't feel right. I need strictness and unboxing because I'm using a large data structure (>1.2Go) in memory, and I can't load it lazily. If I don't find any solution I'm going to re-implement everything in C++, which I prefer to avoid for my current project.
I've asked the question on #haskell but I didn't get a response, maybe it was not the good time of the day to ask.
The simplest implementation I could think of: just wrap
STUArray
/IOUArray
operations withfromEnum
/toEnum
.Now you can
Likewise,
IArray
instances could be trivially written as well.