{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE MagicHash #-}
module Data.Prim.Memory.Text
( Text(..)
, MText(..)
, Array(..)
, MArray(..)
, fromArrayBytes
, toArrayBytes
, fromMArrayMBytes
, toMArrayMBytes
) where
import Data.Text.Array
import Data.Text.Internal
import Data.Prim.Memory.Bytes.Internal
( Bytes(..)
, MBytes(..)
, Pinned(..)
)
data MText s =
MText
{-# UNPACK #-}!(MArray s)
{-# UNPACK #-}!Int
{-# UNPACK #-}!Int
fromArrayBytes :: Array -> Bytes 'Inc
fromArrayBytes :: Array -> Bytes 'Inc
fromArrayBytes (Array ByteArray#
ba#) = ByteArray# -> Bytes 'Inc
forall (p :: Pinned). ByteArray# -> Bytes p
Bytes ByteArray#
ba#
{-# INLINE fromArrayBytes #-}
toArrayBytes :: Bytes p -> Array
toArrayBytes :: Bytes p -> Array
toArrayBytes (Bytes ByteArray#
ba#) = ByteArray# -> Array
Array ByteArray#
ba#
{-# INLINE toArrayBytes #-}
fromMArrayMBytes :: MArray s -> MBytes 'Inc s
fromMArrayMBytes :: MArray s -> MBytes 'Inc s
fromMArrayMBytes (MArray MutableByteArray# s
mba#) = MutableByteArray# s -> MBytes 'Inc s
forall (p :: Pinned) s. MutableByteArray# s -> MBytes p s
MBytes MutableByteArray# s
mba#
{-# INLINE fromMArrayMBytes #-}
toMArrayMBytes :: MBytes p s -> MArray s
toMArrayMBytes :: MBytes p s -> MArray s
toMArrayMBytes (MBytes MutableByteArray# s
ba#) = MutableByteArray# s -> MArray s
forall s. MutableByteArray# s -> MArray s
MArray MutableByteArray# s
ba#
{-# INLINE toMArrayMBytes #-}