Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion vector/src/Data/Vector/Primitive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,18 @@ module Data.Vector.Primitive (
) where

import Control.Applicative (Applicative)
import Data.Coerce (Coercible)
import qualified Data.Vector.Generic as G
import Data.Vector.Primitive.Unsafe (Vector,unsafeCoerceVector,unsafeCast)
import Data.Vector.Primitive.Unsafe (Vector)
import qualified Data.Vector.Primitive.Unsafe as U
import Data.Vector.Primitive.Mutable (MVector)
import Data.Vector.Primitive.Pattern

import Data.Primitive ( Prim )

import Control.Monad.ST ( ST )
import Control.Monad.Primitive
import GHC.Stack (HasCallStack)

import Prelude
( Eq, Ord, Num, Enum, Monoid, Traversable, Monad, Bool, Ordering(..), Int, Maybe, Either
Expand Down Expand Up @@ -1904,5 +1907,17 @@ copy :: (Prim a, PrimMonad m) => MVector (PrimState m) a -> Vector a -> m ()
{-# INLINE copy #-}
copy = G.copy

-- | Unsafe functions are defined in "Data.Vector.Primitive.Unsafe"
unsafeCoerceVector :: Coercible a b => Vector a -> Vector b
unsafeCoerceVector = U.unsafeCoerceVector
{-# DEPRECATED unsafeCoerceVector "Use 'Data.Vector.Primitive.Unsafe.unsafeCoerceVector'" #-}

-- | Unsafe functions are defined in "Data.Vector.Primitive.Unsafe"
unsafeCast :: forall a b. (HasCallStack, Prim a, Prim b) => Vector a -> Vector b
unsafeCast = U.unsafeCast
{-# INLINE unsafeCast #-}
{-# DEPRECATED unsafeCast "Use 'Data.Vector.Primitive.Unsafe.unsafeCast'" #-}


-- $setup
-- >>> import Prelude (($), min, even, max, succ, id, Ord(..), Num(..), undefined)
17 changes: 15 additions & 2 deletions vector/src/Data/Vector/Primitive/Mutable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@ module Data.Vector.Primitive.Mutable (
Prim, PrimMonad, PrimState, RealWorld
) where

import Data.Coerce (Coercible)
import qualified Data.Vector.Generic.Mutable as G
import Data.Primitive ( Prim )
import Data.Vector.Primitive.Mutable.Unsafe
(MVector,unsafeCoerceMVector,unsafeCast)
import Data.Vector.Primitive.Mutable.Unsafe (MVector)
import qualified Data.Vector.Primitive.Mutable.Unsafe as U
import Data.Vector.Primitive.Pattern
import Control.Monad.Primitive

import GHC.Stack (HasCallStack)
import Prelude ( Ord, Bool, Int, Maybe, Ordering(..) )

#include "vector.h"
Expand Down Expand Up @@ -666,5 +668,16 @@ ifoldrM' :: (PrimMonad m, Prim a) => (Int -> a -> b -> m b) -> b -> MVector (Pri
{-# INLINE ifoldrM' #-}
ifoldrM' = G.ifoldrM'

-- | Unsafe functions are defined in "Data.Vector.Primitive.Mutable.Unsafe"
unsafeCoerceMVector :: Coercible a b => MVector s a -> MVector s b
unsafeCoerceMVector = U.unsafeCoerceMVector
{-# DEPRECATED unsafeCoerceMVector "Use 'Data.Vector.Primitive.Mutable.Unsafe.unsafeCoerceMVector'" #-}

-- | Unsafe functions are defined in "Data.Vector.Primitive.Mutable.Unsafe"
unsafeCast :: forall a b s. (HasCallStack, Prim a, Prim b) => MVector s a -> MVector s b
unsafeCast = U.unsafeCast
{-# INLINE unsafeCast #-}
{-# DEPRECATED unsafeCast "Use 'Data.Vector.Primitive.Mutable.Unsafe.unsafeCast'" #-}

-- $setup
-- >>> import Prelude (($), Num(..))
Loading