packages feed

sdp4bytestring (empty) → 0.2

raw patch · 7 files changed

+902/−0 lines, 7 filesdep +QuickCheckdep +basedep +bytestringsetup-changed

Dependencies added: QuickCheck, base, bytestring, quickcheck-instances, sdp, sdp-io, sdp-quickcheck, test-framework, test-framework-quickcheck2

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright Andrey Mulik (c) 2019++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Andrey Mulik nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ sdp4bytestring.cabal view
@@ -0,0 +1,105 @@+name:          sdp4bytestring+version:       0.2+category:      Data Structures++synopsis:      SDP wrapper for ByteString.+description:   This package provides implementations of SDP shared interface for+               simplest data operations with ByteStrings.++author:        Andrey Mulik+maintainer:    work.a.mulik@gmail.com+bug-reports:   https://github.com/andreymulik/sdp4bytestring/issues++copyright:     2019 Andrey Mulik+license-file:  LICENSE+license:       BSD3++build-type:    Simple+cabal-version: >=1.10++source-repository head+  type: git+  location: https://github.com/andreymulik/sdp4bytestring++---            _      _____ ______ ______   ___  ______ __   __              ---+---           | |    |_   _|| ___ \| ___ \ / _ \ | ___ \\ \ / /              ---+---           | |      | |  | |_/ /| |_/ // /_\ \| |_/ / \ V /               ---+---           | |      | |  | ___ \|    / |  _  ||    /   \ /                ---+---           | |____ _| |_ | |_/ /| |\ \ | | | || |\ \   | |                ---+---           \_____/ \___/ \____/ \_| \_|\_| |_/\_| \_|  \_/                ---++Library+  hs-source-dirs:   src+  +  default-language: Haskell2010+  +  build-depends:+    base       >= 4.12 && < 5,+    sdp        >= 0.2  && < 1,+    sdp-io     >= 0.2  && < 1,+    bytestring >= 0.10 && < 0.11+  +  ghc-options: -Wall -Wno-orphans -Wcompat+  +  exposed-modules:+    SDP.ByteString.Lazy+    SDP.ByteString++---            _____  _____  _____  _____  _____  _   _  _____               ---+---           |_   _||  ___|/  ___||_   _||_   _|| \ | ||  __ \              ---+---             | |  | |__  \ `--.   | |    | |  |  \| || |  \/              ---+---             | |  |  __|  `--. \  | |    | |  | . ` || | __               ---+---             | |  | |___ /\__/ /  | |   _| |_ | |\  || |_\ \              ---+---             \_/  \____/ \____/   \_/   \___/ \_| \_/ \____/              ---++test-suite test-bytestring-strict+  default-language: Haskell2010+  hs-source-dirs:   test, src+  +  type:             exitcode-stdio-1.0+  main-is:          test-bytestring-strict.hs+  +  other-modules:+    SDP.ByteString++  build-depends:+    base                       >= 4.12 && < 5,+    sdp                        >= 0.2  && < 1,+    sdp-io                     >= 0.2  && < 1,+    bytestring                 >= 0.10 && < 0.11,+    +    QuickCheck                 >= 2.12 && < 3,+    sdp-quickcheck             >= 0.2  && < 1,+    quickcheck-instances       >= 0.3  && < 0.4,+    +    test-framework             >= 0.8  && < 0.9,+    test-framework-quickcheck2 >= 0.3  && < 0.4++  ghc-options: -Wall -Wno-orphans++test-suite test-bytestring-lazy+  default-language: Haskell2010+  hs-source-dirs:   test, src+  +  type:             exitcode-stdio-1.0+  main-is:          test-bytestring-lazy.hs+  +  other-modules:+    SDP.ByteString.Lazy+    SDP.ByteString++  build-depends:+    base                       >= 4.12 && < 5,+    sdp                        >= 0.2  && < 1,+    sdp-io                     >= 0.2  && < 1,+    bytestring                 >= 0.10 && < 0.11,+    +    QuickCheck                 >= 2.12 && < 3,+    sdp-quickcheck             >= 0.2  && < 1,+    quickcheck-instances       >= 0.3  && < 0.4,+    +    test-framework             >= 0.8  && < 0.9,+    test-framework-quickcheck2 >= 0.3  && < 0.4++  ghc-options: -Wall -Wno-orphans+
+ src/SDP/ByteString.hs view
@@ -0,0 +1,265 @@+{-# LANGUAGE Trustworthy, MagicHash, MultiParamTypeClasses, FlexibleInstances #-}++{- |+    Module      :  SDP.ByteString+    Copyright   :  (c) Andrey Mulik 2019+    License     :  BSD-style+    Maintainer  :  work.a.mulik@gmail.com+    Portability :  non-portable (GHC Extensions)+    +    "SDP.ByteString" provides @sdp@ instances for strict 'ByteString'.+-}+module SDP.ByteString+(+  -- * Exports+  module System.IO.Classes,+  +  module SDP.Indexed,+  module SDP.Sort,+  module SDP.Scan,+  +  -- * ByteString+  ByteString, SByteString+)+where++import Prelude ()+import SDP.SafePrelude+import SDP.SortM.Tim+import SDP.Indexed+import SDP.Sort+import SDP.Scan++import SDP.Prim.SBytes+import SDP.Bytes.ST++import Data.ByteString.Internal ( unsafeCreate )+import Data.ByteString          (  ByteString  )+import qualified Data.ByteString as B++import Data.Coerce+import Data.Maybe++import Foreign.Storable ( Storable ( poke ) )+import Foreign.Ptr      ( plusPtr )++import Control.Exception.SDP++import System.IO.Classes++default ()++--------------------------------------------------------------------------------++-- | Type synomym to avoid ambiguity.+type SByteString = ByteString++--------------------------------------------------------------------------------++{- Nullable and Estimate instances. -}++instance Nullable ByteString+  where+    lzero  = B.empty+    isNull = B.null++instance Estimate ByteString+  where+    (<==>) = on (<=>) sizeOf+    (.<=.) = on (<=)  sizeOf+    (.>=.) = on (>=)  sizeOf+    (.>.)  = on (>)   sizeOf+    (.<.)  = on (<)   sizeOf+    +    (<.=>) = (<=>) . sizeOf+    (.>=)  = (>=)  . sizeOf+    (.<=)  = (<=)  . sizeOf+    (.>)   = (>)   . sizeOf+    (.<)   = (<)   . sizeOf++--------------------------------------------------------------------------------++{- Bordered, Linear and Split instances. -}++instance Bordered ByteString Int+  where+    lower      = const 0+    sizeOf     = B.length+    upper   bs = sizeOf bs - 1+    bounds  bs = (0, sizeOf bs - 1)+    indices bs = [0 .. sizeOf bs - 1]+    indexIn bs = \ i -> i >= 0 && i < sizeOf bs++instance Linear ByteString Word8+  where+    single = B.singleton+    toHead = B.cons+    toLast = B.snoc+    head   = B.head+    tail   = B.tail+    last   = B.last+    init   = B.init+    +    uncons' = B.uncons+    unsnoc' = B.unsnoc+    +    uncons = fromMaybe (pfailEx "uncons") . B.uncons+    unsnoc = fromMaybe (pfailEx "unsnoc") . B.unsnoc+    +    fromFoldable es = unsafeCreate (length es) fromFoldable'+      where+        fromFoldable' ptr = void $ foldr pokeNext (return ptr) es+        pokeNext  e   mp  = do p <- mp; poke p e; return $ p `plusPtr` 1+    +    listR = \ bs -> let n = sizeOf bs in [ bs .! i | i <- [n - 1, n - 2 .. 0] ]+    listL = B.unpack+    (++)  = B.append+    (!^)  = B.index+    force = B.copy+    +    write bs = (bs //) . single ... (,)+    +    concat      = B.concat . toList+    intersperse = B.intersperse+    replicate   = B.replicate+    filter      = B.filter+    fromList    = B.pack+    +    partitions is bs = map fromList . partitions is $ listL bs+    isSubseqOf xs ys = B.all (`B.elem` ys) xs+    +    nub bs = runST $ do+        hs <- filled 256 False+        o_foldr (\ b io -> writeM' hs b True >> io) (return ()) bs+        done' hs+      where+        done' :: STBytes s Word8 Bool -> ST s ByteString+        done' =  fmap fromList . kfoldrM (\ i b is -> return $ b ? (i : is) $ is) []+    +    nubBy f = fromList . o_foldr (\ b es -> any (f b) es ? es $ b : es) [] . nub+    +    ofoldr f = \ base bs ->+      let n = sizeOf bs; go i = n == i ? base $ f i (bs !^ i) (go $ i + 1)+      in  go 0+    +    ofoldl f = \ base bs ->+      let go i = -1 == i ? base $ f i (go $ i + 1) (bs !^ i)+      in  go (upper bs)+    +    o_foldr = B.foldr+    o_foldl = B.foldl++instance Split ByteString Word8+  where+    take  = B.take+    drop  = B.drop+    split = B.splitAt+    +    isPrefixOf = B.isPrefixOf+    isSuffixOf = B.isSuffixOf+    isInfixOf  = B.isInfixOf+    +    takeWhile = B.takeWhile+    dropWhile = B.dropWhile+    +    spanl = B.span+    spanr = B.spanEnd+    +    breakl = B.break+    breakr = B.breakEnd+    +    prefix p = B.foldr (\ e c -> p e ? c + 1 $ 0) 0+    suffix p = B.foldl (\ c e -> p e ? c + 1 $ 0) 0++--------------------------------------------------------------------------------++{- Map and Indexed instances. -}++instance Map ByteString Int Word8+  where+    toMap = toMap' 0+    +    toMap' defvalue ascs = null ascs ? Z $ assoc' (l, u) defvalue ascs+      where+        l = fst $ minimumBy cmpfst ascs+        u = fst $ maximumBy cmpfst ascs+    +    Z  // ascs = toMap ascs+    es // ascs = assoc (bounds es) (assocs es ++ ascs)+    +    (.!) = B.index+    (.$) = B.findIndex+    (*$) = B.findIndices+    +    kfoldr = ofoldr+    kfoldl = ofoldl++instance Indexed ByteString Int Word8+  where+    assoc = flip assoc' 0+    +    assoc' bnds defvalue ascs = unsafeCreate n fromAssocIO+      where+        fromAssocIO ptr = fill >> writeBS+          where+            writeBS = forM_ ies $  \ (i, e) -> poke (ptr `plusPtr` i) e+            fill = forM_ [0 .. n - 1] $ \ i -> poke (ptr `plusPtr` i) defvalue+        +        ies = [ (offset bnds i, e) | (i, e) <- ascs, inRange bnds i ]+        n   = size bnds+    +    fromIndexed es = let n = sizeOf es in unsafeCreate n $+        \ ptr -> forM_ [0 .. n - 1] $ \ i -> poke (ptr `plusPtr` i) (es !^ i)++--------------------------------------------------------------------------------++{- Sort and Scan instances. -}++-- TODO: write counting sort.+instance Sort ByteString Word8+  where+    sortBy f bs = runST $ do es' <- thaw bs; timSortBy f es'; done es'+    +    sortedBy f = sortedBy f . listL++instance Scan ByteString Word8++--------------------------------------------------------------------------------++{- Thaw and Freeze instances. -}++instance Thaw (ST s) ByteString (STBytes# s Word8) where thaw = fromIndexed'++instance Freeze (ST s) (STBytes# s Word8) ByteString where freeze = done++instance (MonadIO io) => Thaw io ByteString (MIOBytes# io Word8) where thaw = fromIndexed'++instance (MonadIO io) => Freeze io (MIOBytes# io Word8) ByteString where freeze = stToMIO . done . coerce++--------------------------------------------------------------------------------++{- IsFile and IsTextFile instances. -}++instance IsFile ByteString+  where+    hGetContents = liftIO  .  B.hGetContents+    hPutContents = liftIO ... B.hPut++instance IsTextFile ByteString+  where+    -- | Print bytestring and CR (0xa) character in Handle encoding.+    hPutStrLn h = liftIO  .  (>> hPutChar h '\n') . hPutStr h+    hGetLine    = liftIO  .  B.hGetLine+    hPutStr     = liftIO ... B.hPut++--------------------------------------------------------------------------------++done :: STBytes# s Word8 -> ST s ByteString+done =  fmap fromList . getLeft++pfailEx :: String -> a+pfailEx =  throw . PatternMatchFail . showString "in SDP.ByteString.Lazy."++++
+ src/SDP/ByteString/Lazy.hs view
@@ -0,0 +1,260 @@+{-# LANGUAGE Trustworthy, MagicHash, MultiParamTypeClasses, FlexibleInstances #-}++{- |+    Module      :  SDP.ByteString.Lazy+    Copyright   :  (c) Andrey Mulik 2019+    License     :  BSD-style+    Maintainer  :  work.a.mulik@gmail.com+    Portability :  non-portable (GHC Extensions)+    +    "SDP.ByteString.Lazy" provides @sdp@ instances for lazy 'ByteString'.+-}+module SDP.ByteString.Lazy+(+  -- * Exports+  module System.IO.Classes,+  +  module SDP.Indexed,+  module SDP.Sort,+  +  -- * ByteString+  ByteString, LByteString, B.fromStrict, B.toStrict, B.fromChunks, B.toChunks+)+where++import Prelude ()+import SDP.SafePrelude+import SDP.Templates.AnyChunks+import SDP.ByteList.IOUblist+import SDP.ByteList.STUblist+import SDP.ByteList.ST+import SDP.SortM.Tim+import SDP.Indexed+import SDP.Sort++import Data.ByteString.Lazy.Internal ( ByteString (..) )+import qualified Data.ByteString.Lazy as B+import qualified SDP.ByteString as S++import Data.Foldable as F ( foldrM )+import Data.Maybe++import Control.Exception.SDP++import System.IO.Classes++default ()++--------------------------------------------------------------------------------++-- | Type synonym to avoid ambiguity.+type LByteString = ByteString++--------------------------------------------------------------------------------++{- Bordered, Linear and Split instances. -}++instance Bordered ByteString Int+  where+    lower      = const 0+    sizeOf     = fromEnum . B.length+    upper   bs = sizeOf bs - 1+    bounds  bs = (0, sizeOf bs - 1)+    indices bs = [0 .. sizeOf bs - 1]+    indexIn bs = \ i -> i >= 0 && i < sizeOf bs++instance Linear ByteString Word8+  where+    replicate   = B.replicate . toEnum+    concat      = B.concat . toList+    fromList    = B.pack+    +    intersperse = B.intersperse+    filter      = B.filter+    +    listR  = \ bs -> let n = sizeOf bs in (bs .!) <$> [n - 1, n - 2 .. 0]+    single = B.singleton+    listL  = B.unpack+    (++)   = B.append+    +    (!^) es = B.index es . toEnum+    +    write bs = (bs //) . single ... (,)+    +    uncons' = B.uncons+    unsnoc' = B.unsnoc+    +    uncons = fromMaybe (pfailEx "uncons") . B.uncons+    unsnoc = fromMaybe (pfailEx "unsnoc") . B.unsnoc+    +    toHead = B.cons+    toLast = B.snoc+    force  = B.copy+    head   = B.head+    tail   = B.tail+    last   = B.last+    init   = B.init+    +    partitions is bs = map fromList . partitions is $ listL bs+    isSubseqOf xs ys = B.all (`B.elem` ys) xs+    +    -- | O(n) nub, requires O(1) memory.+    nub bs = runST $ do+        hs <- filled 256 False+        B.foldr (\ b io -> writeM' hs b True >> io) (return ()) bs+        done' hs+      where+        done' :: STByteList s Word8 Bool -> ST s ByteString+        done' =  fmap fromList . kfoldrM (\ i b is -> pure $ b ? (i : is) $ is) []+    +    nubBy f = fromList . B.foldr (\ b es -> any (f b) es ? es $ (b : es)) [] . nub+    +    ofoldr f = \ base bs ->+      let n = sizeOf bs; go i = n == i ? base $ f i (bs !^ i) (go $ i + 1)+      in  go 0+    +    ofoldl f = \ base bs ->+      let go i = -1 == i ? base $ f i (go $ i + 1) (bs !^ i)+      in  go (upper bs)+    +    o_foldr = B.foldr+    o_foldl = B.foldl++instance Split ByteString Word8+  where+    take  = B.take    . toEnum+    drop  = B.drop    . toEnum+    split = B.splitAt . toEnum+    +    isPrefixOf = B.isPrefixOf+    isSuffixOf = B.isSuffixOf+    isInfixOf  = on isInfixOf listL+    +    takeWhile = B.takeWhile+    dropWhile = B.dropWhile+    +    spanl  = B.span+    breakl = B.break+    +    prefix p = B.foldr (\ e c -> p e ? c + 1 $ 0) 0+    suffix p = B.foldl (\ c e -> p e ? c + 1 $ 0) 0++--------------------------------------------------------------------------------++{- Map, Indexed and Sort instances. -}++instance Map ByteString Int Word8+  where+    toMap = toMap' 0+    +    toMap' defvalue ascs = null ascs ? Z $ assoc' (ascsBounds ascs) defvalue ascs+    +    (.!) es = B.index es . toEnum+    +    Z  // ascs = toMap ascs+    es // ascs = assoc (bounds es) (assocs es ++ ascs)+    +    (.$) = fmap fromEnum ... B.findIndex+    (*$) = fmap fromEnum ... B.findIndices+    +    kfoldr = ofoldr+    kfoldl = ofoldl++instance Indexed ByteString Int Word8+  where+    assoc = flip assoc' 0+    +    assoc' bnds@(l, _) defvalue ascs = B.fromChunks $+        go l [ (offset bnds i, e) | (i, e) <- ascs, inRange bnds i ]+      where+        go :: Int -> [(Int, Word8)] -> [S.ByteString]+        go _   []  = []+        go cl ies' = chunk : go nl rest+          where+            chunk = fromList $ assoc' (cl, nl - 1) defvalue ch+            (ch, rest) = partition (\ (i, _) -> i < nl) ies'+            nl = cl + lim+    +    fromIndexed es = assoc bnds' [ (offset bnds i, e) | (i, e) <- assocs es ]+      where+        bnds' = defaultBounds (sizeOf es)+        bnds  = bounds es++instance Sort ByteString Word8+  where+    sortBy f bs = runST $ do es' <- thaw bs; timSortBy f es'; done es'+    +    sortedBy _ Empty = True+    sortedBy f (Chunk ch   Z) = sortedBy f ch+    sortedBy f (Chunk Z  chs) = sortedBy f chs+    sortedBy f (Chunk ch chs) = sortedBy f ch && last ch `f` head chs && sortedBy f chs++--------------------------------------------------------------------------------++instance Thaw (ST s) ByteString (STUblist s Word8)+  where+    thaw = fromChunksM <=< B.foldrChunks (liftA2 (:) . thaw) (return [])++instance Freeze (ST s) (STUblist s Word8) ByteString+  where+    freeze = F.foldrM (\ e rs -> (`Chunk` rs) <$> freeze e) Empty . toChunks++instance (MonadIO io) => Thaw io ByteString (MIOUblist io Word8)+  where+    thaw = fromChunksM <=< B.foldrChunks (liftA2 (:) . thaw) (return [])++instance (MonadIO io) => Freeze io (MIOUblist io Word8) ByteString+  where+    freeze = F.foldrM (\ e rs -> (`Chunk` rs) <$> freeze e) Empty . toChunks++--------------------------------------------------------------------------------++{- Nullable and Estimate instances. -}++instance Nullable ByteString+  where+    lzero  = B.empty+    isNull = B.null++instance Estimate ByteString+  where+    (<==>) = go 0+      where+        go o Empty Empty = o <=> 0+        go o xs    Empty = xs <.=> (-o)+        go o Empty    ys = o <=.> ys+        go o (Chunk ch1 chs1) (Chunk ch2 chs2) =+          go (o + sizeOf ch1 - sizeOf ch2) chs1 chs2+    +    Empty <.=> n = 0 <=> n+    (Chunk ch chs) <.=> n = ch .> n ? GT $ chs <.=> (n - sizeOf ch)++--------------------------------------------------------------------------------++{- IsFile and IsTextFile instances. -}++instance IsFile ByteString+  where+    hGetContents = liftIO  .  B.hGetContents+    hPutContents = liftIO ... B.hPut++instance IsTextFile ByteString+  where+    hPutStrLn h = liftIO  .  (>> hPutChar h '\n') . hPutStr h+    hGetLine    = liftIO  .  fmap B.fromStrict . S.hGetLine+    hPutStr     = liftIO ... B.hPut++--------------------------------------------------------------------------------++ascsBounds :: (Ord a) => [(a, b)] -> (a, a)+ascsBounds =  \ ((x, _) : xs) -> foldr (\ (e, _) (mn, mx) -> (min mn e, max mx e)) (x, x) xs++done :: STUblist s Word8 -> ST s ByteString+done =  freeze++pfailEx :: String -> a+pfailEx =  throw . PatternMatchFail . showString "in SDP.ByteString.Lazy."++lim :: Int+lim =  1024+
+ test/test-bytestring-lazy.hs view
@@ -0,0 +1,120 @@+module Main where++import Test.Framework.Providers.QuickCheck2+import Test.Framework++import Test.QuickCheck.Instances.ByteString ()++import SDP.ByteString.Lazy++import Test.SDP++default ()++--------------------------------------------------------------------------------++main :: IO ()+main = defaultMain+  [+    -- common tests+    testProperty "lazy-bytestring-eq             " eqProp,+    testProperty "lazy-bytestring-ord            " ordProp,+    testProperty "lazy-bytestring-lexicographic  " lgoProp,+    +    -- linear tests+    testProperty "lazy-bytestring-linear-basic   " basicLinearProp,+    testProperty "lazy-bytestring-linear-decons  " deconstructionLinearProp,+    testProperty "lazy-bytestring-linear-cons    " constructionLinearProp,+    testProperty "lazy-bytestring-linear-reverse " reverseProp,+    testProperty "lazy-bytestring-linear-concat  " concatProp,+    +    -- split test+    testProperty "lazy-bytestring-split          " splitProp,+    +    -- indexed tests+    testProperty "lazy-bytestring-indexed-basic  " basicIndexedProp,+    testProperty "lazy-bytestring-indexed-assoc  " assocIndexedProp,+    testProperty "lazy-bytestring-indexed-read   " readIndexedProp,+    +    -- sort test+    testProperty "lazy-bytestring-sort           " sortProp,+    +    -- set test (planned)+    +    -- estimate test+    testProperty "lazy-bytestring-estimate       " estimateProp+  ]++--------------------------------------------------------------------------------++{- Eq property. -}++eqProp :: TestEq ByteString+eqProp =  eqTest++--------------------------------------------------------------------------------++{- Ord property. -}++ordProp :: TestOrd ByteString+ordProp =  ordTest++lgoProp :: Long ByteString -> Long ByteString -> Bool+lgoProp (Long xs) (Long ys) = lexicographicOrdTest xs ys++--------------------------------------------------------------------------------++{- Linear properties. -}++basicLinearProp          :: Word8 -> ByteString -> Bool+basicLinearProp          =  basicLinearTest++deconstructionLinearProp :: ByteString -> Bool+deconstructionLinearProp =  deconstructionLinearTest++constructionLinearProp   :: Word8 -> ByteString -> Bool+constructionLinearProp   =  constructionLinearTest++reverseProp              :: ByteString -> Bool+reverseProp              =  reverseTest++replicateProp            :: TestLinear ByteString Word8+replicateProp            =  replicateTest++concatProp               :: ByteString -> Bool+concatProp               =  concatTest++--------------------------------------------------------------------------------++{- Split property. -}++splitProp :: Word8 -> TestSplit (Medium ByteString)+splitProp e n (Medium bs) = splitTest (e >) n bs++--------------------------------------------------------------------------------++{- Indexed property. -}++basicIndexedProp :: TestIndexed ByteString Int+basicIndexedProp =  basicIndexedTest++assocIndexedProp :: TestIndexed ByteString Int+assocIndexedProp =  assocIndexedTest++readIndexedProp  :: TestIndexed ByteString Int+readIndexedProp  =  readIndexedTest++--------------------------------------------------------------------------------++{- Sort property. -}++sortProp :: Medium ByteString -> Bool+sortProp =  sortTest++--------------------------------------------------------------------------------++{- Estimate property. -}++estimateProp :: TestEstimate ByteString+estimateProp =  estimateTest+
+ test/test-bytestring-strict.hs view
@@ -0,0 +1,120 @@+module Main where++import Test.Framework.Providers.QuickCheck2+import Test.Framework++import Test.QuickCheck.Instances.ByteString ()++import SDP.ByteString++import Test.SDP++default ()++--------------------------------------------------------------------------------++main :: IO ()+main = defaultMain+  [+    -- common tests+    testProperty "strict-bytestring-eq             " eqProp,+    testProperty "strict-bytestring-ord            " ordProp,+    testProperty "strict-bytestring-lexicographic  " lgoProp,+    +    -- linear tests+    testProperty "strict-bytestring-linear-basic   " basicLinearProp,+    testProperty "strict-bytestring-linear-decons  " deconstructionLinearProp,+    testProperty "strict-bytestring-linear-cons    " constructionLinearProp,+    testProperty "strict-bytestring-linear-reverse " reverseProp,+    testProperty "strict-bytestring-linear-concat  " concatProp,+    +    -- split test+    testProperty "strict-bytestring-split          " splitProp,+    +    -- indexed tests+    testProperty "strict-bytestring-indexed-basic  " basicIndexedProp,+    testProperty "strict-bytestring-indexed-assoc  " assocIndexedProp,+    testProperty "strict-bytestring-indexed-read   " readIndexedProp,+    +    -- sort test+    testProperty "strict-bytestring-sort           " sortProp,+    +    -- set test (planned)+    +    -- estimate test+    testProperty "strict-bytestring-estimate       " estimateProp+  ]++--------------------------------------------------------------------------------++{- Eq property. -}++eqProp :: TestEq ByteString+eqProp =  eqTest++--------------------------------------------------------------------------------++{- Ord property. -}++ordProp :: TestOrd ByteString+ordProp =  ordTest++lgoProp :: Long ByteString -> Long ByteString -> Bool+lgoProp (Long xs) (Long ys) = lexicographicOrdTest xs ys++--------------------------------------------------------------------------------++{- Linear properties. -}++basicLinearProp          :: Word8 -> ByteString -> Bool+basicLinearProp          =  basicLinearTest++deconstructionLinearProp :: ByteString -> Bool+deconstructionLinearProp =  deconstructionLinearTest++constructionLinearProp   :: Word8 -> ByteString -> Bool+constructionLinearProp   =  constructionLinearTest++reverseProp              :: ByteString -> Bool+reverseProp              =  reverseTest++replicateProp            :: TestLinear ByteString Word8+replicateProp            =  replicateTest++concatProp               :: ByteString -> Bool+concatProp               =  concatTest++--------------------------------------------------------------------------------++{- Split property. -}++splitProp :: Word8 -> TestSplit (Medium ByteString)+splitProp e n (Medium bs) = splitTest (e >) n bs++--------------------------------------------------------------------------------++{- Indexed property. -}++basicIndexedProp :: TestIndexed ByteString Int+basicIndexedProp =  basicIndexedTest++assocIndexedProp :: TestIndexed ByteString Int+assocIndexedProp =  assocIndexedTest++readIndexedProp  :: TestIndexed ByteString Int+readIndexedProp  =  readIndexedTest++--------------------------------------------------------------------------------++{- Sort property. -}++sortProp :: Medium ByteString -> Bool+sortProp =  sortTest++--------------------------------------------------------------------------------++{- Estimate property. -}++estimateProp :: TestEstimate ByteString+estimateProp =  estimateTest+