[Haskell-cafe] mapping unfreeze over an IntMap of IOUArrays

Chad Scherrer chad.scherrer at pnl.gov
Tue Nov 11 14:23:09 EST 2008


Hello cafe,

I've hit a bit of a monadic snag here...

I'm scanning a big file, building a table of statistics. I end up with something
like

IO (IntMap (IOUArray Int Double))

Once I've read in the whole file and built my statistics, I don't need any more
updates, so I'd like to do something like

IntMap (IOUArray Int Double) -> IO (IntMap (UArray Int Double)),

using unsafeFreeze. I'm getting stuck here, since the IntMap library is not so
monad-friendly. 

I could rebuild the whole thing using sequence and lists, but the table is
pretty big (4.5 million keys on a first run), so I'd prefer to avoid that. Any
ideas?

BTW, I probably "should" be using ST for this, but I hit the usual "type s
escapes" irritation and gave up. If that would work more easily, that would be
fine with me too.

Thanks!

Chad Scherrer



More information about the Haskell-Cafe mailing list