byteslice 0.2.14.0 → 0.2.15.0
raw patch · 3 files changed
+42/−1 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.Bytes.Internal: [$sel:array:Bytes] :: Bytes -> {-# UNPACK #-} !ByteArray
- Data.Bytes.Internal: [$sel:length:Bytes] :: Bytes -> {-# UNPACK #-} !Int
- Data.Bytes.Internal: [$sel:offset:Bytes] :: Bytes -> {-# UNPACK #-} !Int
- Data.Bytes.Types: [$sel:address:UnmanagedBytes] :: UnmanagedBytes -> {-# UNPACK #-} !Addr
- Data.Bytes.Types: [$sel:array:ByteArrayN] :: ByteArrayN (n :: Nat) -> ByteArray
- Data.Bytes.Types: [$sel:array:BytesN] :: BytesN (n :: Nat) -> {-# UNPACK #-} !ByteArray
- Data.Bytes.Types: [$sel:array:Bytes] :: Bytes -> {-# UNPACK #-} !ByteArray
- Data.Bytes.Types: [$sel:array:MutableBytes] :: MutableBytes s -> {-# UNPACK #-} !MutableByteArray s
- Data.Bytes.Types: [$sel:length:Bytes] :: Bytes -> {-# UNPACK #-} !Int
- Data.Bytes.Types: [$sel:length:MutableBytes] :: MutableBytes s -> {-# UNPACK #-} !Int
- Data.Bytes.Types: [$sel:length:UnmanagedBytes] :: UnmanagedBytes -> {-# UNPACK #-} !Int
- Data.Bytes.Types: [$sel:offset:BytesN] :: BytesN (n :: Nat) -> {-# UNPACK #-} !Int
- Data.Bytes.Types: [$sel:offset:Bytes] :: Bytes -> {-# UNPACK #-} !Int
- Data.Bytes.Types: [$sel:offset:MutableBytes] :: MutableBytes s -> {-# UNPACK #-} !Int
+ Data.Bytes.Indexed: append :: forall (m :: Nat) (n :: Nat). ByteArrayN m -> ByteArrayN n -> ByteArrayN (m + n)
+ Data.Bytes.Indexed: data ByteArrayN (n :: Nat)
+ Data.Bytes.Indexed: length :: forall (n :: Nat). ByteArrayN n -> Nat n
+ Data.Bytes.Indexed: length# :: forall (n :: Nat). ByteArrayN n -> Nat# n
+ Data.Bytes.Internal: [array] :: Bytes -> {-# UNPACK #-} !ByteArray
+ Data.Bytes.Internal: [length] :: Bytes -> {-# UNPACK #-} !Int
+ Data.Bytes.Internal: [offset] :: Bytes -> {-# UNPACK #-} !Int
+ Data.Bytes.Types: [address] :: UnmanagedBytes -> {-# UNPACK #-} !Addr
+ Data.Bytes.Types: [array] :: ByteArrayN (n :: Nat) -> ByteArray
+ Data.Bytes.Types: [length] :: UnmanagedBytes -> {-# UNPACK #-} !Int
+ Data.Bytes.Types: [offset] :: BytesN (n :: Nat) -> {-# UNPACK #-} !Int
- Data.Bytes: splitStream :: forall m. Applicative m => Word8 -> Bytes -> Stream m Bytes
+ Data.Bytes: splitStream :: forall (m :: Type -> Type). Applicative m => Word8 -> Bytes -> Stream m Bytes
- Data.Bytes: withLength :: Bytes -> (forall (n :: Nat). Nat n -> BytesN n -> a) -> a
+ Data.Bytes: withLength :: Bytes -> (forall (n :: Nat). () => Nat n -> BytesN n -> a) -> a
- Data.Bytes: withLengthU :: ByteArray -> (forall (n :: Nat). Nat n -> ByteArrayN n -> a) -> a
+ Data.Bytes: withLengthU :: ByteArray -> (forall (n :: Nat). () => Nat n -> ByteArrayN n -> a) -> a
- Data.Bytes.Types: newtype Bytes# :: TYPE ('TupleRep '[ 'BoxedRep 'Unlifted, 'IntRep, 'IntRep])
+ Data.Bytes.Types: newtype Bytes# :: TYPE 'TupleRep '[UnliftedRep, 'IntRep, 'IntRep]
Files
- CHANGELOG.md +5/−0
- byteslice.cabal +2/−1
- src/Data/Bytes/Indexed.hs +35/−0
CHANGELOG.md view
@@ -1,5 +1,10 @@ # Revision history for byteslice +## 0.2.15.0 -- 2024-06-12++* Add functions for recovering length from `ByteArrayN`+* Add `Data.Bytes.Indexed` for functions on `ByteArrayN`+ ## 0.2.14.0 -- 2024-02-26 * Add functions to `Data.Bytes.Text.AsciiExt`: `split(1|2|3|4)`,
byteslice.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: byteslice-version: 0.2.14.0+version: 0.2.15.0 synopsis: Slicing managed and unmanaged memory description: This library provides types that allow the user to talk about a slice of@@ -35,6 +35,7 @@ exposed-modules: Data.Bytes Data.Bytes.Chunks+ Data.Bytes.Indexed Data.Bytes.Encode.BigEndian Data.Bytes.Encode.LittleEndian Data.Bytes.Internal
+ src/Data/Bytes/Indexed.hs view
@@ -0,0 +1,35 @@+{-# language DataKinds #-}+{-# language MagicHash #-}+{-# language TypeOperators #-}++module Data.Bytes.Indexed+ ( ByteArrayN+ , append+ , length+ , length#+ ) where++import Prelude hiding (length)++import Data.Primitive (ByteArray(ByteArray))+import Data.Bytes.Types (ByteArrayN(ByteArrayN))+import GHC.TypeNats (type (+))+import Arithmetic.Types (Nat, Nat#)++import qualified Data.Primitive as PM+import qualified Arithmetic.Unsafe as Unsafe+import qualified GHC.Exts as Exts++append :: ByteArrayN m -> ByteArrayN n -> ByteArrayN (m + n)+{-# inline append #-}+append (ByteArrayN x) (ByteArrayN y) = ByteArrayN (x <> y)++-- | Recover a witness of the length.+length :: ByteArrayN n -> Nat n+{-# inline length #-}+length (ByteArrayN x) = Unsafe.Nat (PM.sizeofByteArray x)++-- | Recover an unboxed witness of the length.+length# :: ByteArrayN n -> Nat# n+{-# inline length# #-}+length# (ByteArrayN (ByteArray x)) = Unsafe.Nat# (Exts.sizeofByteArray# x)