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

Don Stewart dons at galois.com
Tue Nov 11 14:28:23 EST 2008


chad.scherrer:
> 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. 

Hmm. So you'd need to construct a new IntMap, made by fmap'ping
unsafeFreeze over each element of the old map.

-- Don


More information about the Haskell-Cafe mailing list