Ticket #30 (closed defect: worksforme)
There is no safe analog of unsafeFreeze
|Reported by:||anonymous||Owned by:|
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'