[vector] #30: There is no safe analog of unsafeFreeze

vector vector at projects.haskell.org
Fri Aug 20 17:51:05 EDT 2010


#30: There is no safe analog of unsafeFreeze
----------------------+-----------------------------------------------------
Reporter:  anonymous  |       Owner:     
    Type:  defect     |      Status:  new
Priority:  major      |   Milestone:     
 Version:             |    Keywords:     
----------------------+-----------------------------------------------------
 Summary is quite exhaustive here. Such function is required when one needs
 snapshot of mutable vector which will be mutated afterwards. Improper
 usage of unsafeFreeze already caused bug in mwc-random.

 Here is safeFreeze I used:

 {{{
 -- Safe version of unsafeFreeze.
 safeFreeze :: (PrimMonad m, Vector v a) => G.Mutable v (PrimState m) a ->
 m (v a)
 safeFreeze v = do
   v' <- GM.unsafeNew (GM.length v)
   GM.unsafeCopy v' v
   unsafeFreeze v'
 }}}

-- 
Ticket URL: <http://trac.haskell.org/vector/ticket/30>
vector <http://trac.haskell.org/vector>
Package vector


More information about the vector mailing list