    {-# OPTIONS_GHC -fno-warn-orphans #-}
    module Test.QuickCheck.Instances.Primitive () where

    import Prelude ()
    import Test.QuickCheck.Instances.CustomPrelude

    import Data.Word (Word8)

    import Test.QuickCheck

    import qualified Data.Primitive as P

    -------------------------------------------------------------------------------
    -- ByteArray
    -------------------------------------------------------------------------------

    -- | @since 0.3.28
    instance Arbitrary P.ByteArray where
        arbitrary :: Gen ByteArray
    arbitrary = [Word8] -> ByteArray
    byteArrayFromList ([Word8] -> ByteArray) -> Gen [Word8] -> Gen ByteArray
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen [Word8]
    forall a. Arbitrary a => Gen a
    arbitrary
        shrink :: ByteArray -> [ByteArray]
    shrink ByteArray
    ba = [Word8] -> ByteArray
    byteArrayFromList ([Word8] -> ByteArray) -> [[Word8]] -> [ByteArray]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Word8] -> [[Word8]]
    forall a. Arbitrary a => a -> [a]
    shrink (ByteArray -> [Word8]
    byteArrayToList ByteArray
    ba)

    -- | @since 0.3.28
    instance CoArbitrary P.ByteArray where
        coarbitrary :: forall b. ByteArray -> Gen b -> Gen b
    coarbitrary ByteArray
    ba = [Word8] -> Gen b -> Gen b
    forall b. [Word8] -> Gen b -> Gen b
    forall a b. CoArbitrary a => a -> Gen b -> Gen b
    coarbitrary (ByteArray -> [Word8]
    byteArrayToList ByteArray
    ba)

    -- | @since 0.3.28
    instance Function P.ByteArray where
        function :: forall b. (ByteArray -> b) -> ByteArray :-> b
    function = (ByteArray -> [Word8])
    -> ([Word8] -> ByteArray) -> (ByteArray -> b) -> ByteArray :-> b
    forall b a c.
    Function b =>
    (a -> b) -> (b -> a) -> (a -> c) -> a :-> c
    functionMap ByteArray -> [Word8]
    byteArrayToList [Word8] -> ByteArray
    byteArrayFromList

    byteArrayFromList :: [Word8] -> P.ByteArray
    byteArrayFromList :: [Word8] -> ByteArray
    byteArrayFromList = [Word8] -> ByteArray
    forall a. Prim a => [a] -> ByteArray
    P.byteArrayFromList

    byteArrayToList :: P.ByteArray -> [Word8]
    byteArrayToList :: ByteArray -> [Word8]
    byteArrayToList = (Word8 -> [Word8] -> [Word8]) -> [Word8] -> ByteArray -> [Word8]
    forall a b. Prim a => (a -> b -> b) -> b -> ByteArray -> b
    P.foldrByteArray (:) []