{-# language GADTSyntax #-} {-# language KindSignatures #-} {-# language MagicHash #-} {-# language TypeInType #-} {-# language UnboxedTuples #-} {-# language UnliftedNewtypes #-} module UnliftedBytes ( Bytes#(..) , lift , unlift ) where import Data.Bytes.Internal (Bytes(Bytes)) import Data.Primitive (ByteArray(ByteArray)) import GHC.Exts (Int(I#),ByteArray#,Int#,RuntimeRep(..),TYPE) newtype Bytes# :: TYPE ('TupleRep '[ 'UnliftedRep,'IntRep,'IntRep]) where Bytes# :: (# ByteArray#, Int#, Int# #) -> Bytes# lift :: Bytes# -> Bytes lift :: Bytes# -> Bytes lift (Bytes# (# ByteArray# arr, Int# off, Int# len #)) = ByteArray -> Int -> Int -> Bytes Bytes (ByteArray# -> ByteArray ByteArray ByteArray# arr) (Int# -> Int I# Int# off) (Int# -> Int I# Int# len) unlift :: Bytes -> Bytes# unlift :: Bytes -> Bytes# unlift (Bytes (ByteArray ByteArray# arr) (I# Int# off) (I# Int# len)) = (# ByteArray#, Int#, Int# #) -> Bytes# Bytes# (# ByteArray# arr, Int# off, Int# len #)