Skip to content

Commit

Permalink
Update documentation for unsafeNew
Browse files Browse the repository at this point in the history
Finally fixes haskell#213
  • Loading branch information
Shimuuar committed Feb 2, 2020
1 parent 9b65b8e commit 7a15adc
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
7 changes: 6 additions & 1 deletion Data/Vector/Generic/Mutable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,12 @@ new :: (PrimMonad m, MVector v a) => Int -> m (v (PrimState m) a)
new n = BOUNDS_CHECK(checkLength) "new" n
$ unsafeNew n >>= \v -> basicInitialize v >> return v

-- | Create a mutable vector of the given length. The memory is not initialized.
-- | Create a mutable vector of the given length. The vector content
-- should be presumed uninitialized. However exact semantics depends
-- on vector implementation. For example unboxed and storable
-- vectors will create vector filled with whatever underlying memory
-- buffer happens to contain, while boxed vector initializes every
-- element to @error "..."@.
unsafeNew :: (PrimMonad m, MVector v a) => Int -> m (v (PrimState m) a)
{-# INLINE unsafeNew #-}
unsafeNew n = UNSAFE_CHECK(checkLength) "unsafeNew" n
Expand Down
7 changes: 6 additions & 1 deletion Data/Vector/Mutable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,12 @@ new :: PrimMonad m => Int -> m (MVector (PrimState m) a)
{-# INLINE new #-}
new = G.new

-- | Create a mutable vector of the given length. The memory is not initialized.
-- | Create a mutable vector of the given length. The vector content
-- should be presumed uninitialized. However exact semantics depends
-- on vector implementation. For example unboxed and storable
-- vectors will create vector filled with whatever underlying memory
-- buffer happens to contain, while boxed vector initializes every
-- element to @error "..."@.
unsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) a)
{-# INLINE unsafeNew #-}
unsafeNew = G.unsafeNew
Expand Down
7 changes: 6 additions & 1 deletion Data/Vector/Primitive/Mutable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,12 @@ new :: (PrimMonad m, Prim a) => Int -> m (MVector (PrimState m) a)
{-# INLINE new #-}
new = G.new

-- | Create a mutable vector of the given length. The memory is not initialized.
-- | Create a mutable vector of the given length. The vector content
-- should be presumed uninitialized. However exact semantics depends
-- on vector implementation. For example unboxed and storable
-- vectors will create vector filled with whatever underlying memory
-- buffer happens to contain, while boxed vector initializes every
-- element to @error "..."@.
unsafeNew :: (PrimMonad m, Prim a) => Int -> m (MVector (PrimState m) a)
{-# INLINE unsafeNew #-}
unsafeNew = G.unsafeNew
Expand Down
7 changes: 6 additions & 1 deletion Data/Vector/Storable/Mutable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,12 @@ new :: (PrimMonad m, Storable a) => Int -> m (MVector (PrimState m) a)
{-# INLINE new #-}
new = G.new

-- | Create a mutable vector of the given length. The memory is not initialized.
-- | Create a mutable vector of the given length. The vector content
-- should be presumed uninitialized. However exact semantics depends
-- on vector implementation. For example unboxed and storable
-- vectors will create vector filled with whatever underlying memory
-- buffer happens to contain, while boxed vector initializes every
-- element to @error "..."@.
unsafeNew :: (PrimMonad m, Storable a) => Int -> m (MVector (PrimState m) a)
{-# INLINE unsafeNew #-}
unsafeNew = G.unsafeNew
Expand Down
7 changes: 6 additions & 1 deletion Data/Vector/Unboxed/Mutable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,12 @@ new :: (PrimMonad m, Unbox a) => Int -> m (MVector (PrimState m) a)
{-# INLINE new #-}
new = G.new

-- | Create a mutable vector of the given length. The memory is not initialized.
-- | Create a mutable vector of the given length. The vector content
-- should be presumed uninitialized. However exact semantics depends
-- on vector implementation. For example unboxed and storable
-- vectors will create vector filled with whatever underlying memory
-- buffer happens to contain, while boxed vector initializes every
-- element to @error "..."@.
unsafeNew :: (PrimMonad m, Unbox a) => Int -> m (MVector (PrimState m) a)
{-# INLINE unsafeNew #-}
unsafeNew = G.unsafeNew
Expand Down

0 comments on commit 7a15adc

Please sign in to comment.