validity-bytestring 0.3.0.2 → 0.4.0.0
raw patch · 2 files changed
+36/−12 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.Validity.ByteString: instance Data.Validity.Validity Data.ByteString.Lazy.Internal.ByteString
Files
src/Data/Validity/ByteString.hs view
@@ -4,8 +4,31 @@ import Data.Validity -import Data.ByteString+import qualified Data.ByteString as SB+import qualified Data.ByteString.Internal as SB+import qualified Data.ByteString.Lazy as LB+import qualified Data.ByteString.Lazy.Internal as LB --- | A 'ByteString' is trivially valid.-instance Validity ByteString where- validate = trivialValidation+-- | A 'ByteString' is NOT trivially valid.+--+-- The offset and the length both need to be positive.+-- Note that the length does not need to be greater than, or equal to, the offset.+--+-- TODO there's nothing we can do about the foreign pointer, I think?+instance Validity SB.ByteString where+ validate (SB.PS _ off len) =+ mconcat+ [ delve "offset" off+ , delve "length" len+ , declare "The offset is positive" $ off >= 0+ , declare "The length is positive" $ len >= 0+ ]++-- | A lazy 'ByteString' is valid according to its chunks.+instance Validity LB.ByteString where+ validate = go 0+ where+ go :: Int -> LB.ByteString -> Validation+ go _ LB.Empty = valid+ go i (LB.Chunk sb lb) =+ mconcat [delve (unwords ["Chunk number", show i]) sb, go (i + 1) lb]
validity-bytestring.cabal view
@@ -1,11 +1,13 @@--- This file has been generated from package.yaml by hpack version 0.28.2.+cabal-version: >= 1.10++-- This file has been generated from package.yaml by hpack version 0.29.6. -- -- see: https://github.com/sol/hpack ----- hash: 87158cbef7a325a4a27cff0303b6fece923e4dada1f3495d335d9717b43766c3+-- hash: 39a9c7df71e39fed88350a4e7577fe2f925f85ee16da092f8d6194ca70b7e561 name: validity-bytestring-version: 0.3.0.2+version: 0.4.0.0 synopsis: Validity instances for bytestring description: Please see README.md category: Validity@@ -18,21 +20,20 @@ license: MIT license-file: LICENSE build-type: Simple-cabal-version: >= 1.10 source-repository head type: git location: https://github.com/NorfairKing/validity library+ exposed-modules:+ Data.Validity.ByteString+ other-modules:+ Paths_validity_bytestring hs-source-dirs: src build-depends: base >=4.7 && <5 , bytestring , validity >=0.5- exposed-modules:- Data.Validity.ByteString- other-modules:- Paths_validity_bytestring default-language: Haskell2010