packages feed

validity-text 0.3.0.1 → 0.3.1.0

raw patch · 2 files changed

+28/−17 lines, 2 files

Files

src/Data/Validity/Text.hs view
@@ -9,18 +9,17 @@  import qualified Data.ByteString.Builder as SBB import qualified Data.ByteString.Lazy as LB-import Data.Text ()+import qualified Data.Text as ST import qualified Data.Text.Array as A import qualified Data.Text.Encoding as E import qualified Data.Text.Encoding.Error as E-import Data.Text.Internal (Text(..))+import qualified Data.Text.Internal as ST+import qualified Data.Text.Internal.Lazy as LT import qualified Data.Text.Unsafe as U-#if !MIN_VERSION_base(4,8,0)-import Data.Monoid (mconcat)-#endif+ -- | A text is valid if the internal structure is consistent.-instance Validity Text where-    validate t@(Text arr off len) =+instance Validity ST.Text where+    validate t@(ST.Text arr off len) =         mconcat             [ check (len >= 0) "The length is positive."             , check (off >= 0) "The offset is positive."@@ -30,7 +29,7 @@                   "The offset character is valid UTF16."                  -- It contains a valid UTF16             , check-                  ((== (Right t :: Either E.UnicodeException Text)) $+                  ((== (Right t :: Either E.UnicodeException ST.Text)) $                    U.unsafeDupablePerformIO .                    try .                    evaluate .@@ -39,4 +38,14 @@                    SBB.toLazyByteString . mconcat . map SBB.word16LE $                    A.toList arr off len)                   "The bytes can correctly be decoded as UTF16."+            ]++-- | A lazy text value is valid if all the internal chunks are valid and nonempty+instance Validity LT.Text where+    validate LT.Empty = valid+    validate (LT.Chunk st lt) =+        mconcat+            [ delve "The strict chunk" st+            , declare "The strict chunk is not empty" $ not $ ST.null st+            , delve "The lazy chunk" lt             ]
validity-text.cabal view
@@ -1,29 +1,35 @@--- This file has been generated from package.yaml by hpack version 0.20.0.+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: be951c2768137ca96d0e6881ffcb5c3aac363e9542d49b4c4c66c04df7eb922a+-- hash: 0831512ec19a28260876715c9d762cca6e353faac66a90bef1a1c0737a694138  name:           validity-text-version:        0.3.0.1+version:        0.3.1.0 synopsis:       Validity instances for text description:    Please see README.md category:       Web homepage:       https://github.com/NorfairKing/validity#readme bug-reports:    https://github.com/NorfairKing/validity/issues author:         Tom Sydney Kerckhove-maintainer:     syd.kerckhove@gmail.com+maintainer:     syd.kerckhove@gmail.com,+                nick.van.den.broeck666@gmail.com copyright:      Copyright: (c) 2016-2018 Tom Sydney Kerckhove 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.Text+  other-modules:+      Paths_validity_text   hs-source-dirs:       src   build-depends:@@ -31,8 +37,4 @@     , bytestring     , text     , validity >=0.5-  exposed-modules:-      Data.Validity.Text-  other-modules:-      Paths_validity_text   default-language: Haskell2010