I'm writing a network processing program, and having some troubles. I decided to implement my directed graph as a Judy Array of linked lists of arcs. That is
JudyL [Arc]
where,
type Id = Int
type Day = Int
data Arc = Arc { aid :: Id,
time :: Day} deriving (Eq, Show)
However, Judy arrays require that their inputs can be converted to a Word value, or a word-sized pointer. In particular I must implement,
instance JE [a] where
toWord :: [a] -> IO Word
fromWord :: Word -> IO [a]
I however, have no idea whatsoever how to deal with pointers in Haskell. Any wisdom would be greatly appreciated. Perhaps I should just be using an array instead, but I fear that my dataset is very large (a terabyte uncompressed, though a lot of that data is extraneous) and have convinced myself that additional reads/writes on the (admittedly solid state) drive could seriously slow this down. IDK though.
You can just copy and paste the ByteString
instance, which essentially allocates a new StablePtr
and then casts it to Word
. Keep in mind that you will need to do your own deallocation when (if) the time comes for that.