Z-Data 0.6.1.0 → 0.7.0.0
raw patch · 13 files changed
+597/−403 lines, 13 filesdep ~QuickCheckdep ~case-insensitivedep ~containersPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: QuickCheck, case-insensitive, containers, deepseq, ghc-prim, hashable, integer-gmp, scientific, tagged, unordered-containers
API changes (from Hackage documentation)
- Z.Data.JSON.Builder: scientific :: Scientific -> Builder ()
+ Z.Data.ASCII: pattern ACK :: Word8
+ Z.Data.ASCII: pattern BEL :: Word8
+ Z.Data.ASCII: pattern BS :: Word8
+ Z.Data.ASCII: pattern CAN :: Word8
+ Z.Data.ASCII: pattern DC1 :: Word8
+ Z.Data.ASCII: pattern DC2 :: Word8
+ Z.Data.ASCII: pattern DC3 :: Word8
+ Z.Data.ASCII: pattern DC4 :: Word8
+ Z.Data.ASCII: pattern DLE :: Word8
+ Z.Data.ASCII: pattern EM :: Word8
+ Z.Data.ASCII: pattern ENQ :: Word8
+ Z.Data.ASCII: pattern EOT :: Word8
+ Z.Data.ASCII: pattern ESC :: Word8
+ Z.Data.ASCII: pattern ETB :: Word8
+ Z.Data.ASCII: pattern ETX :: Word8
+ Z.Data.ASCII: pattern FS :: Word8
+ Z.Data.ASCII: pattern GS :: Word8
+ Z.Data.ASCII: pattern NAK :: Word8
+ Z.Data.ASCII: pattern RS :: Word8
+ Z.Data.ASCII: pattern SI :: Word8
+ Z.Data.ASCII: pattern SO :: Word8
+ Z.Data.ASCII: pattern SOH :: Word8
+ Z.Data.ASCII: pattern STX :: Word8
+ Z.Data.ASCII: pattern SUB :: Word8
+ Z.Data.ASCII: pattern SYN :: Word8
+ Z.Data.ASCII: pattern US :: Word8
+ Z.Data.Builder: scientific' :: Scientific -> Builder ()
+ Z.Data.Builder.Numeric: scientific' :: Scientific -> Builder ()
+ Z.Data.Text.Print: instance Z.Data.Text.Print.Print Data.Time.Calendar.CalendarDiffDays.CalendarDiffDays
+ Z.Data.Text.Print: instance Z.Data.Text.Print.Print Data.Time.Calendar.Days.Day
+ Z.Data.Text.Print: instance Z.Data.Text.Print.Print Data.Time.Calendar.Week.DayOfWeek
+ Z.Data.Text.Print: instance Z.Data.Text.Print.Print Data.Time.Clock.Internal.DiffTime.DiffTime
+ Z.Data.Text.Print: instance Z.Data.Text.Print.Print Data.Time.Clock.Internal.NominalDiffTime.NominalDiffTime
+ Z.Data.Text.Print: instance Z.Data.Text.Print.Print Data.Time.Clock.Internal.SystemTime.SystemTime
+ Z.Data.Text.Print: instance Z.Data.Text.Print.Print Data.Time.Clock.Internal.UTCTime.UTCTime
+ Z.Data.Text.Print: instance Z.Data.Text.Print.Print Data.Time.LocalTime.Internal.CalendarDiffTime.CalendarDiffTime
+ Z.Data.Text.Print: instance Z.Data.Text.Print.Print Data.Time.LocalTime.Internal.LocalTime.LocalTime
+ Z.Data.Text.Print: instance Z.Data.Text.Print.Print Data.Time.LocalTime.Internal.TimeOfDay.TimeOfDay
+ Z.Data.Text.Print: instance Z.Data.Text.Print.Print Data.Time.LocalTime.Internal.ZonedTime.ZonedTime
+ Z.Data.Text.Print: instance Z.Data.Text.Print.Print GHC.Exception.Type.SomeException
+ Z.Data.Text.Print: scientific' :: Scientific -> Builder ()
Files
- ChangeLog.md +8/−0
- Z-Data.cabal +340/−349
- Z/Data/ASCII.hs +78/−1
- Z/Data/Builder.hs +1/−0
- Z/Data/Builder/Numeric.hs +15/−0
- Z/Data/JSON.hs +2/−3
- Z/Data/JSON/Base.hs +12/−11
- Z/Data/JSON/Builder.hs +2/−18
- Z/Data/Text/Print.hs +87/−3
- Z/Data/Vector/Base.hs +13/−3
- Z/Data/Vector/Search.hs +6/−6
- Z/Data/Vector/Sort.hs +28/−9
- test/Z/Data/Vector/SortSpec.hs +5/−0
ChangeLog.md view
@@ -1,5 +1,13 @@ # Revision history for Z-Data +## 0.7.0.0 -- 2020-03-03++* Add more patterns to `Z.Data.ASCII`.+* Fix a bug in `Z.Data.Vector.Search` where needle is a singleton.+* Optimize `mergeDupAdjacent` family funtions in `Z.Data.Vector.Sort` to not copy vector in case of no duplication.+* Add `scientific'` to `Z.Data.Builder`, Add more `Print` instances.+* Bump deps to support GHC 9.0.+ ## 0.6.1.0 -- 2020-02-04 * Add `key` and `nth` lens to `Z.Data.JSON.Value` for manipulating nested value more easily.
Z-Data.cabal view
@@ -1,376 +1,367 @@-cabal-version: 2.4-name: Z-Data-version: 0.6.1.0-synopsis: Array, vector and text-description: This package provides array, slice and text operations-license: BSD-3-Clause-license-file: LICENSE-author: Z.Haskell Contributors-maintainer: winterland1989@gmail.com-copyright: (c) Z.Haskell Contributors-category: Data-build-type: Custom-homepage: https://github.com/haskell-Z/z-data-bug-reports: https://github.com/haskell-Z/z-data/issues--extra-source-files: ChangeLog.md- README.md- LICENSE- AUTHORS-- include/bytes.h- include/dtoa.h- include/text.h- cbits/bytes.c- cbits/dtoa.c- cbits/text.c- cbits/text_width.c-- -- utf8rewind C sources- third_party/utf8rewind/include/utf8rewind/utf8rewind.h- third_party/utf8rewind/source/unicodedatabase.c- third_party/utf8rewind/source/unicodedatabase.h- third_party/utf8rewind/source/internal/base.h- third_party/utf8rewind/source/internal/casemapping.c- third_party/utf8rewind/source/internal/casemapping.h- third_party/utf8rewind/source/internal/codepoint.c- third_party/utf8rewind/source/internal/codepoint.h- third_party/utf8rewind/source/internal/composition.c- third_party/utf8rewind/source/internal/composition.h- third_party/utf8rewind/source/internal/database.c- third_party/utf8rewind/source/internal/database.h- third_party/utf8rewind/source/internal/decomposition.c- third_party/utf8rewind/source/internal/decomposition.h- third_party/utf8rewind/source/internal/seeking.c- third_party/utf8rewind/source/internal/seeking.h- third_party/utf8rewind/source/internal/streaming.c- third_party/utf8rewind/source/internal/streaming.h- third_party/utf8rewind/source/utf8rewind.c-- -- simd utf8 code- third_party/fastvalidate-utf-8/include/simdasciicheck.h- third_party/fastvalidate-utf-8/include/simdutf8check.h-- -- Turbo-Base64- third_party/Turbo-Base64/conf.h- third_party/Turbo-Base64/turbob64.h- third_party/Turbo-Base64/turbob64_.h- third_party/Turbo-Base64/turbob64avx2.c- third_party/Turbo-Base64/turbob64c.c- third_party/Turbo-Base64/turbob64d.c- third_party/Turbo-Base64/turbob64sse.c-- -- re2-- third_party/re2/util/flags.h- third_party/re2/util/logging.h- third_party/re2/util/malloc_counter.h- third_party/re2/util/mix.h- third_party/re2/util/mutex.h- third_party/re2/util/strutil.h- third_party/re2/util/utf.h- third_party/re2/util/util.h- third_party/re2/re2/bitmap256.h- third_party/re2/re2/filtered_re2.h- third_party/re2/re2/pod_array.h- third_party/re2/re2/prefilter.h- third_party/re2/re2/prefilter_tree.h- third_party/re2/re2/prog.h- third_party/re2/re2/re2.h- third_party/re2/re2/regexp.h- third_party/re2/re2/set.h- third_party/re2/re2/sparse_array.h- third_party/re2/re2/sparse_set.h- third_party/re2/re2/stringpiece.h- third_party/re2/re2/unicode_casefold.h- third_party/re2/re2/unicode_groups.h- third_party/re2/re2/walker-inl.h-- third_party/re2/util/rune.cc- third_party/re2/util/strutil.cc- third_party/re2/re2/bitstate.cc- third_party/re2/re2/compile.cc- third_party/re2/re2/dfa.cc- third_party/re2/re2/filtered_re2.cc- third_party/re2/re2/mimics_pcre.cc- third_party/re2/re2/nfa.cc- third_party/re2/re2/onepass.cc- third_party/re2/re2/parse.cc- third_party/re2/re2/perl_groups.cc- third_party/re2/re2/prefilter.cc- third_party/re2/re2/prefilter_tree.cc- third_party/re2/re2/prog.cc- third_party/re2/re2/re2.cc- third_party/re2/re2/regexp.cc- third_party/re2/re2/set.cc- third_party/re2/re2/simplify.cc- third_party/re2/re2/stringpiece.cc- third_party/re2/re2/tostring.cc- third_party/re2/re2/unicode_casefold.cc- third_party/re2/re2/unicode_groups.cc+cabal-version: 2.4+name: Z-Data+version: 0.7.0.0+synopsis: Array, vector and text+description: This package provides array, slice and text operations+license: BSD-3-Clause+license-file: LICENSE+author: Z.Haskell Contributors+maintainer: winterland1989@gmail.com+copyright: (c) Z.Haskell Contributors+category: Data+build-type: Custom+homepage: https://github.com/haskell-Z/z-data+bug-reports: https://github.com/haskell-Z/z-data/issues+extra-source-files:+ AUTHORS+ cbits/bytes.c+ cbits/dtoa.c+ cbits/text.c+ cbits/text_width.c+ ChangeLog.md+ include/bytes.h+ include/dtoa.h+ include/text.h+ LICENSE+ README.md+ third_party/fastvalidate-utf-8/include/simdasciicheck.h+ third_party/fastvalidate-utf-8/include/simdutf8check.h+ third_party/re2/re2/bitmap256.h+ third_party/re2/re2/bitstate.cc+ third_party/re2/re2/compile.cc+ third_party/re2/re2/dfa.cc+ third_party/re2/re2/filtered_re2.cc+ third_party/re2/re2/filtered_re2.h+ third_party/re2/re2/mimics_pcre.cc+ third_party/re2/re2/nfa.cc+ third_party/re2/re2/onepass.cc+ third_party/re2/re2/parse.cc+ third_party/re2/re2/perl_groups.cc+ third_party/re2/re2/pod_array.h+ third_party/re2/re2/prefilter.cc+ third_party/re2/re2/prefilter.h+ third_party/re2/re2/prefilter_tree.cc+ third_party/re2/re2/prefilter_tree.h+ third_party/re2/re2/prog.cc+ third_party/re2/re2/prog.h+ third_party/re2/re2/re2.cc+ third_party/re2/re2/re2.h+ third_party/re2/re2/regexp.cc+ third_party/re2/re2/regexp.h+ third_party/re2/re2/set.cc+ third_party/re2/re2/set.h+ third_party/re2/re2/simplify.cc+ third_party/re2/re2/sparse_array.h+ third_party/re2/re2/sparse_set.h+ third_party/re2/re2/stringpiece.cc+ third_party/re2/re2/stringpiece.h+ third_party/re2/re2/tostring.cc+ third_party/re2/re2/unicode_casefold.cc+ third_party/re2/re2/unicode_casefold.h+ third_party/re2/re2/unicode_groups.cc+ third_party/re2/re2/unicode_groups.h+ third_party/re2/re2/walker-inl.h+ third_party/re2/util/flags.h+ third_party/re2/util/logging.h+ third_party/re2/util/malloc_counter.h+ third_party/re2/util/mix.h+ third_party/re2/util/mutex.h+ third_party/re2/util/rune.cc+ third_party/re2/util/strutil.cc+ third_party/re2/util/strutil.h+ third_party/re2/util/utf.h+ third_party/re2/util/util.h+ third_party/Turbo-Base64/conf.h+ third_party/Turbo-Base64/turbob64.h+ third_party/Turbo-Base64/turbob64_.h+ third_party/Turbo-Base64/turbob64avx2.c+ third_party/Turbo-Base64/turbob64c.c+ third_party/Turbo-Base64/turbob64d.c+ third_party/Turbo-Base64/turbob64sse.c+ third_party/utf8rewind/include/utf8rewind/utf8rewind.h+ third_party/utf8rewind/source/internal/base.h+ third_party/utf8rewind/source/internal/casemapping.c+ third_party/utf8rewind/source/internal/casemapping.h+ third_party/utf8rewind/source/internal/codepoint.c+ third_party/utf8rewind/source/internal/codepoint.h+ third_party/utf8rewind/source/internal/composition.c+ third_party/utf8rewind/source/internal/composition.h+ third_party/utf8rewind/source/internal/database.c+ third_party/utf8rewind/source/internal/database.h+ third_party/utf8rewind/source/internal/decomposition.c+ third_party/utf8rewind/source/internal/decomposition.h+ third_party/utf8rewind/source/internal/seeking.c+ third_party/utf8rewind/source/internal/seeking.h+ third_party/utf8rewind/source/internal/streaming.c+ third_party/utf8rewind/source/internal/streaming.h+ third_party/utf8rewind/source/unicodedatabase.c+ third_party/utf8rewind/source/unicodedatabase.h+ third_party/utf8rewind/source/utf8rewind.c custom-setup- setup-depends: base >= 4.5 && < 5, Cabal >= 2.4 && < 4+ setup-depends:+ , base >=4.5 && <5+ , Cabal >=2.4 && <4 source-repository head- type: git- location: git://github.com/haskell-Z/z-data.git+ type: git+ location: git://github.com/haskell-Z/z-data.git flag integer-simple- description:- Use the [simple integer library](http://hackage.haskell.org/package/integer-simple)- instead of [integer-gmp](http://hackage.haskell.org/package/integer-gmp)- default: False- manual: False--library- exposed-modules: Z.Data.Array- Z.Data.Array.Cast- Z.Data.Array.Checked- Z.Data.Array.QQ- Z.Data.Array.Unaligned- Z.Data.Array.UnliftedArray- Z.Data.ASCII- Z.Data.CBytes- Z.Data.Vector- Z.Data.Vector.Base- Z.Data.Vector.Extra- Z.Data.Vector.Search- Z.Data.Vector.Sort- Z.Data.Vector.QQ- Z.Data.Vector.FlatIntMap- Z.Data.Vector.FlatIntSet- Z.Data.Vector.FlatMap- Z.Data.Vector.FlatSet- Z.Data.Vector.Hex- Z.Data.Vector.Base64-- Z.Data.Text- Z.Data.Text.Base- Z.Data.Text.Extra- Z.Data.Text.Regex- Z.Data.Text.Search- Z.Data.Text.Print- Z.Data.Text.UTF8Codec- Z.Data.Text.UTF8Rewind-- Z.Data.Builder- Z.Data.Builder.Base- Z.Data.Builder.Numeric- Z.Data.Builder.Numeric.DigitTable- Z.Data.Builder.Time-- Z.Data.Generics.Utils-- Z.Data.Parser- Z.Data.Parser.Base- Z.Data.Parser.Numeric- Z.Data.Parser.Time-- Z.Data.PrimRef- Z.Data.PrimRef.PrimSTRef- Z.Data.PrimRef.PrimIORef-- Z.Data.JSON- Z.Data.JSON.Base- Z.Data.JSON.Builder- Z.Data.JSON.Converter- Z.Data.JSON.Value+ description:+ Use the [simple integer library](http://hackage.haskell.org/package/integer-simple)+ instead of [integer-gmp](http://hackage.haskell.org/package/integer-gmp) - Z.Foreign+ default: False+ manual: True +library+ exposed-modules:+ Z.Data.Array+ Z.Data.Array.Cast+ Z.Data.Array.Checked+ Z.Data.Array.QQ+ Z.Data.Array.Unaligned+ Z.Data.Array.UnliftedArray+ Z.Data.ASCII+ Z.Data.Builder+ Z.Data.Builder.Base+ Z.Data.Builder.Numeric+ Z.Data.Builder.Numeric.DigitTable+ Z.Data.Builder.Time+ Z.Data.CBytes+ Z.Data.Generics.Utils+ Z.Data.JSON+ Z.Data.JSON.Base+ Z.Data.JSON.Builder+ Z.Data.JSON.Converter+ Z.Data.JSON.Value+ Z.Data.Parser+ Z.Data.Parser.Base+ Z.Data.Parser.Numeric+ Z.Data.Parser.Time+ Z.Data.PrimRef+ Z.Data.PrimRef.PrimIORef+ Z.Data.PrimRef.PrimSTRef+ Z.Data.Text+ Z.Data.Text.Base+ Z.Data.Text.Extra+ Z.Data.Text.Print+ Z.Data.Text.Regex+ Z.Data.Text.Search+ Z.Data.Text.UTF8Codec+ Z.Data.Text.UTF8Rewind+ Z.Data.Vector+ Z.Data.Vector.Base+ Z.Data.Vector.Base64+ Z.Data.Vector.Extra+ Z.Data.Vector.FlatIntMap+ Z.Data.Vector.FlatIntSet+ Z.Data.Vector.FlatMap+ Z.Data.Vector.FlatSet+ Z.Data.Vector.Hex+ Z.Data.Vector.QQ+ Z.Data.Vector.Search+ Z.Data.Vector.Sort+ Z.Foreign - build-depends: base >= 4.12 && < 5.0- , bytestring >= 0.10.4 && < 0.12- , ghc-prim >= 0.5.3 && < 0.6.2- , primitive >= 0.7.1 && < 0.7.2- , scientific == 0.3.*- , hashable == 1.3.*- , case-insensitive == 1.2.*- , deepseq >= 1.4 && < 1.5- , QuickCheck >= 2.10- , tagged == 0.8.*- , template-haskell >= 2.14.0- , time >= 1.9 && < 2.0- , unordered-containers == 0.2.*- , containers == 0.6.*+ build-depends:+ , base >=4.12 && <5.0+ , bytestring >=0.10.4 && <0.12+ , case-insensitive ^>=1.2+ , containers ^>=0.6+ , deepseq ^>=1.4+ , ghc-prim >=0.5.3 && <0.8+ , hashable ^>=1.3+ , primitive >=0.7.1 && <0.7.2+ , QuickCheck >=2.10+ , scientific ^>=0.3+ , tagged ^>=0.8+ , template-haskell >=2.14.0+ , time >=1.9 && <2.0+ , unordered-containers ^>=0.2 - if os(windows)- extra-libraries: stdc++- cc-options: -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600- else- extra-libraries: stdc++ pthread+ if os(windows)+ extra-libraries: stdc+++ cc-options: -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600 - if flag(integer-simple)- cpp-options: -DINTEGER_SIMPLE- build-depends: integer-simple >= 0.1 && < 0.5- else- cpp-options: -DINTEGER_GMP- build-depends: integer-gmp >= 0.2 && < 1.1+ else+ extra-libraries:+ stdc+++ pthread + if flag(integer-simple)+ cpp-options: -DINTEGER_SIMPLE+ build-depends: integer-simple >=0.1 && <0.5 - include-dirs: include- third_party/utf8rewind/include/utf8rewind- third_party/utf8rewind/source/internal- third_party/utf8rewind/source- third_party/fastvalidate-utf-8/include- third_party/Turbo-Base64- third_party/re2+ else+ cpp-options: -DINTEGER_GMP+ build-depends: integer-gmp >=0.2 && <1.2 - includes: bytes.h- dtoa.h- text.h- utf8rewind.h- simdasciicheck.h- simdutf8check.h- turbob64.h+ include-dirs:+ include third_party/utf8rewind/include/utf8rewind+ third_party/utf8rewind/source/internal+ third_party/utf8rewind/source+ third_party/fastvalidate-utf-8/include third_party/Turbo-Base64+ third_party/re2 - install-includes: bytes.h- dtoa.h- text.h+ includes:+ bytes.h+ dtoa.h+ simdasciicheck.h+ simdutf8check.h+ text.h+ turbob64.h+ utf8rewind.h - c-sources: cbits/bytes.c- cbits/dtoa.c- cbits/text.c- cbits/text_width.c+ install-includes:+ bytes.h+ dtoa.h+ text.h - third_party/utf8rewind/source/unicodedatabase.c- third_party/utf8rewind/source/internal/casemapping.c- third_party/utf8rewind/source/internal/codepoint.c- third_party/utf8rewind/source/internal/composition.c- third_party/utf8rewind/source/internal/database.c- third_party/utf8rewind/source/internal/decomposition.c- third_party/utf8rewind/source/internal/seeking.c- third_party/utf8rewind/source/internal/streaming.c- third_party/utf8rewind/source/utf8rewind.c+ c-sources:+ cbits/bytes.c+ cbits/dtoa.c+ cbits/text.c+ cbits/text_width.c+ third_party/Turbo-Base64/turbob64c.c+ third_party/Turbo-Base64/turbob64d.c+ third_party/Turbo-Base64/turbob64sse.c+ third_party/utf8rewind/source/internal/casemapping.c+ third_party/utf8rewind/source/internal/codepoint.c+ third_party/utf8rewind/source/internal/composition.c+ third_party/utf8rewind/source/internal/database.c+ third_party/utf8rewind/source/internal/decomposition.c+ third_party/utf8rewind/source/internal/seeking.c+ third_party/utf8rewind/source/internal/streaming.c+ third_party/utf8rewind/source/unicodedatabase.c+ third_party/utf8rewind/source/utf8rewind.c - third_party/Turbo-Base64/turbob64c.c- third_party/Turbo-Base64/turbob64d.c- third_party/Turbo-Base64/turbob64sse.c+ cxx-sources:+ cbits/regex.cc+ third_party/re2/re2/bitstate.cc+ third_party/re2/re2/compile.cc+ third_party/re2/re2/dfa.cc+ third_party/re2/re2/filtered_re2.cc+ third_party/re2/re2/mimics_pcre.cc+ third_party/re2/re2/nfa.cc+ third_party/re2/re2/onepass.cc+ third_party/re2/re2/parse.cc+ third_party/re2/re2/perl_groups.cc+ third_party/re2/re2/prefilter.cc+ third_party/re2/re2/prefilter_tree.cc+ third_party/re2/re2/prog.cc+ third_party/re2/re2/re2.cc+ third_party/re2/re2/regexp.cc+ third_party/re2/re2/set.cc+ third_party/re2/re2/simplify.cc+ third_party/re2/re2/stringpiece.cc+ third_party/re2/re2/tostring.cc+ third_party/re2/re2/unicode_casefold.cc+ third_party/re2/re2/unicode_groups.cc+ third_party/re2/util/rune.cc+ third_party/re2/util/strutil.cc - cxx-sources: cbits/regex.cc+ default-language: Haskell2010+ build-tool-depends: hsc2hs:hsc2hs -any+ cc-options: -march=native -Wno-sign-compare - third_party/re2/util/rune.cc- third_party/re2/util/strutil.cc- third_party/re2/re2/bitstate.cc- third_party/re2/re2/compile.cc- third_party/re2/re2/dfa.cc- third_party/re2/re2/filtered_re2.cc- third_party/re2/re2/mimics_pcre.cc- third_party/re2/re2/nfa.cc- third_party/re2/re2/onepass.cc- third_party/re2/re2/parse.cc- third_party/re2/re2/perl_groups.cc- third_party/re2/re2/prefilter.cc- third_party/re2/re2/prefilter_tree.cc- third_party/re2/re2/prog.cc- third_party/re2/re2/re2.cc- third_party/re2/re2/regexp.cc- third_party/re2/re2/set.cc- third_party/re2/re2/simplify.cc- third_party/re2/re2/stringpiece.cc- third_party/re2/re2/tostring.cc- third_party/re2/re2/unicode_casefold.cc- third_party/re2/re2/unicode_groups.cc+ -- currently it's ignored, see https://github.com/haskell/cabal/pull/6226+ -- we work around this issue using Setup.hs+ cxx-options: -std=c++11+ ghc-options:+ -Wall -Wno-unticked-promoted-constructors -Wno-incomplete-patterns - default-language: Haskell2010- build-tool-depends: hsc2hs:hsc2hs- cc-options: -march=native -Wno-sign-compare - cxx-options: -std=c++11- -- currently it's ignored, see https://github.com/haskell/cabal/pull/6226- -- we work around this issue using Setup.hs- ghc-options: -Wall - -Wno-unticked-promoted-constructors- -Wno-incomplete-patterns- -- ploymorphic pattern synonym messed exhaustiveness checker- default-extensions: BangPatterns- BinaryLiterals- CApiFFI- ConstraintKinds- CPP - DerivingStrategies- DeriveGeneric- DeriveAnyClass- DefaultSignatures- DataKinds- ExistentialQuantification- FlexibleContexts- FlexibleInstances- GeneralizedNewtypeDeriving - KindSignatures- MagicHash- MultiParamTypeClasses- MultiWayIf- PartialTypeSignatures- PatternSynonyms - PolyKinds- QuantifiedConstraints- QuasiQuotes- OverloadedStrings- RankNTypes- RecordWildCards- ScopedTypeVariables - StandaloneDeriving- TemplateHaskell- TypeApplications- TypeFamilyDependencies- TypeFamilies- TypeOperators- TupleSections- UnboxedTuples - UnliftedFFITypes - ViewPatterns+ default-extensions:+ BangPatterns+ BinaryLiterals+ CApiFFI+ CPP+ ConstraintKinds+ DataKinds+ DefaultSignatures+ DeriveAnyClass+ DeriveGeneric+ DerivingStrategies+ ExistentialQuantification+ FlexibleContexts+ FlexibleInstances+ GeneralizedNewtypeDeriving+ KindSignatures+ MagicHash+ MultiParamTypeClasses+ MultiWayIf+ OverloadedStrings+ PartialTypeSignatures+ PatternSynonyms+ PolyKinds+ QuantifiedConstraints+ QuasiQuotes+ RankNTypes+ RecordWildCards+ ScopedTypeVariables+ StandaloneDeriving+ TemplateHaskell+ TupleSections+ TypeApplications+ TypeFamilies+ TypeFamilyDependencies+ TypeOperators+ UnboxedTuples+ UnliftedFFITypes+ ViewPatterns test-suite Z-Data-Test- type: exitcode-stdio-1.0- hs-source-dirs: test/- main-is: Spec.hs-- ghc-options: -threaded- default-language: Haskell2010- build-tool-depends: hsc2hs:hsc2hs, hspec-discover:hspec-discover- other-modules: Z.Data.CBytesSpec- Z.Data.Builder.NumericSpec- Z.Data.Builder.TimeSpec- Z.Data.JSON.BaseSpec- Z.Data.JSON.ValueSpec- Z.Data.Parser.BaseSpec- Z.Data.Parser.NumericSpec- Z.Data.Parser.TimeSpec- Z.Data.Array.UnalignedSpec- Z.Data.Text.BaseSpec- Z.Data.Text.ExtraSpec- Z.Data.Text.SearchSpec- Z.Data.Text.PrintSpec- Z.Data.Vector.BaseSpec- Z.Data.Vector.ExtraSpec- Z.Data.Vector.SearchSpec- Z.Data.Vector.SortSpec- Z.Data.Vector.FlatMapSpec- Z.Data.Vector.FlatSetSpec- Z.Data.Vector.HexSpec- Z.Data.Vector.Base64Spec- Z.ForeignSpec+ type: exitcode-stdio-1.0+ hs-source-dirs: test/+ main-is: Spec.hs+ ghc-options: -threaded+ default-language: Haskell2010+ build-tool-depends: hsc2hs:hsc2hs -any, hspec-discover:hspec-discover -any+ other-modules:+ Z.Data.Array.UnalignedSpec+ Z.Data.Builder.NumericSpec+ Z.Data.Builder.TimeSpec+ Z.Data.CBytesSpec+ Z.Data.JSON.BaseSpec+ Z.Data.JSON.ValueSpec+ Z.Data.Parser.BaseSpec+ Z.Data.Parser.NumericSpec+ Z.Data.Parser.TimeSpec+ Z.Data.Text.BaseSpec+ Z.Data.Text.ExtraSpec+ Z.Data.Text.PrintSpec+ Z.Data.Text.SearchSpec+ Z.Data.Vector.Base64Spec+ Z.Data.Vector.BaseSpec+ Z.Data.Vector.ExtraSpec+ Z.Data.Vector.FlatMapSpec+ Z.Data.Vector.FlatSetSpec+ Z.Data.Vector.HexSpec+ Z.Data.Vector.SearchSpec+ Z.Data.Vector.SortSpec+ Z.ForeignSpec - build-depends: Z-Data- , base- , hspec >= 2.5.4- , hashable- , HUnit- , QuickCheck >= 2.10- , quickcheck-instances- , scientific- , primitive- , containers - , unordered-containers - , time+ build-depends:+ , base+ , containers+ , hashable+ , hspec >=2.5.4+ , HUnit+ , primitive+ , QuickCheck >=2.10+ , quickcheck-instances+ , scientific+ , time+ , unordered-containers+ , Z-Data - c-sources: test/cbits/ffi.c+ c-sources: test/cbits/ffi.c - if flag(integer-simple)- cpp-options: -DINTEGER_SIMPLE- build-depends: integer-simple >= 0.1 && < 0.5- else- cpp-options: -DINTEGER_GMP- build-depends: integer-gmp >= 0.2 && < 1.1+ if flag(integer-simple)+ cpp-options: -DINTEGER_SIMPLE+ build-depends: integer-simple >=0.1 && <0.5 + else+ cpp-options: -DINTEGER_GMP+ build-depends: integer-gmp >=0.2 && <1.1
Z/Data/ASCII.hs view
@@ -73,6 +73,30 @@ -- | @\\NUL@ pattern NUL :: Word8 pattern NUL = 0x00+-- | Start of Heading+pattern SOH :: Word8+pattern SOH = 0x01+-- | Start of Text+pattern STX :: Word8+pattern STX = 0x02+-- | End of Text+pattern ETX :: Word8+pattern ETX = 0x03+-- | End of Transmission+pattern EOT :: Word8+pattern EOT = 0x04+-- | Enquiry+pattern ENQ :: Word8+pattern ENQ = 0x05+-- | Acknowledgment+pattern ACK :: Word8+pattern ACK = 0x06+-- | Bell+pattern BEL :: Word8+pattern BEL = 0x07+-- | Back Space+pattern BS :: Word8+pattern BS = 0x08 -- | @\\t@ pattern TAB :: Word8 pattern TAB = 0x09@@ -88,7 +112,60 @@ -- | @\\r@ pattern CARRIAGE_RETURN :: Word8 pattern CARRIAGE_RETURN = 0x0d-+-- | Shift Out / X-On+pattern SO :: Word8+pattern SO = 0x0e+-- | Shift In / X-Off+pattern SI :: Word8+pattern SI = 0x0f+-- | Data Line Escape+pattern DLE :: Word8+pattern DLE = 0x10+-- | Device Control 1 (oft. XON)+pattern DC1 :: Word8+pattern DC1 = 0x11+-- | Device Control 2+pattern DC2 :: Word8+pattern DC2 = 0x12+-- | Device Control 3 (oft. XOFF)+pattern DC3 :: Word8+pattern DC3 = 0x13+-- | Device Control 4+pattern DC4 :: Word8+pattern DC4 = 0x14+-- | Negative Acknowledgement+pattern NAK :: Word8+pattern NAK = 0x15+-- | Synchronous Idle+pattern SYN :: Word8+pattern SYN = 0x16+-- | End of Transmit Block+pattern ETB :: Word8+pattern ETB = 0x17+-- | Cancel+pattern CAN :: Word8+pattern CAN = 0x18+-- | End of Medium+pattern EM :: Word8+pattern EM = 0x19+-- | Substitute+pattern SUB :: Word8+pattern SUB = 0x1a+-- | Escape+pattern ESC :: Word8+pattern ESC = 0x1b+-- | File Separator+pattern FS :: Word8+pattern FS = 0x1c+-- | Group Separator+pattern GS :: Word8+pattern GS = 0x1d+-- | Record Separator+pattern RS :: Word8+pattern RS = 0x1e+-- | Unit Separator+pattern US :: Word8+pattern US = 0x1f -- | @\' \'@ pattern SPACE :: Word8 pattern SPACE = 0x20
Z/Data/Builder.hs view
@@ -53,6 +53,7 @@ , float , floatWith , scientific+ , scientific' , scientificWith -- * Builder helpers , paren, curly, square, angle, quotes, squotes, colon, comma, intercalateVec, intercalateList
Z/Data/Builder/Numeric.hs view
@@ -29,6 +29,7 @@ , float , floatWith , scientific+ , scientific' , scientificWith -- * Misc , grisu3@@ -768,6 +769,20 @@ scientific :: Sci.Scientific -> Builder () {-# INLINE scientific #-} scientific = scientificWith Generic Nothing++-- | This builder try to avoid scientific notation when 0 <= exponent < 16.+--+scientific' :: Sci.Scientific -> Builder ()+{-# INLINE scientific' #-}+scientific' s+ | e < 0 || e >= 16 = scientific s+ | e == 0 = integer c+ | otherwise = do+ integer c+ when (c /= 0) (replicateM_ e (encodePrim DIGIT_0))+ where+ e = Sci.base10Exponent s+ c = Sci.coefficient s -- | Like 'scientific' but provides rendering options. scientificWith :: FFormat
Z/Data/JSON.hs view
@@ -70,7 +70,6 @@ import System.Exit (ExitCode(..)) import qualified Z.Data.Builder as B import Z.Data.JSON.Base-import qualified Z.Data.JSON.Builder as JB import qualified Z.Data.Parser as P import qualified Z.Data.Text as T @@ -321,7 +320,7 @@ {-# INLINE toValue #-} toValue = Number . realToFrac {-# INLINE encodeJSON #-}- encodeJSON = JB.scientific . realToFrac+ encodeJSON = B.scientific' . realToFrac -- | This instance includes a bounds check to prevent maliciously -- large inputs to fill up the memory of the target system. You can@@ -333,7 +332,7 @@ {-# INLINE toValue #-} toValue = Number . realToFrac {-# INLINE encodeJSON #-}- encodeJSON = JB.scientific . realToFrac+ encodeJSON = B.scientific' . realToFrac -- | @{"seconds": SSS, "nanoseconds": NNN}@. instance JSON SystemTime where
Z/Data/JSON/Base.hs view
@@ -57,6 +57,7 @@ import qualified Data.Set as Set import qualified Data.Tree as Tree import Data.Int+import Data.Kind (Type) import Data.List.NonEmpty (NonEmpty (..)) import qualified Data.List.NonEmpty as NonEmpty import qualified Data.Primitive.ByteArray as A@@ -577,7 +578,7 @@ {-# INLINE gEncodeJSON #-} gEncodeJSON _ (K1 x) = encodeJSON x -class GAddPunctuation (f :: * -> *) where+class GAddPunctuation (f :: Type -> Type) where gAddPunctuation :: Proxy# f -> B.Builder () -> B.Builder () instance GAddPunctuation a => GAddPunctuation (a :*: b) where@@ -815,7 +816,7 @@ instance JSON Scientific where {-# INLINE fromValue #-}; fromValue = withScientific "Scientific" pure; {-# INLINE toValue #-}; toValue = Number;- {-# INLINE encodeJSON #-}; encodeJSON = JB.scientific;+ {-# INLINE encodeJSON #-}; encodeJSON = B.scientific'; -- | default instance prefer later key instance JSON a => JSON (FM.FlatMap T.Text a) where@@ -1109,17 +1110,17 @@ #define INT_JSON_INSTANCE(typ) \ instance JSON typ where \- {-# INLINE fromValue #-}; fromValue = withBoundedIntegral "/**/typ/**/" pure; \+ {-# INLINE fromValue #-}; fromValue = withBoundedIntegral " typ " pure; \ {-# INLINE toValue #-}; toValue = Number . fromIntegral; \ {-# INLINE encodeJSON #-}; encodeJSON = B.int; -INT_JSON_INSTANCE(Int )-INT_JSON_INSTANCE(Int8 )-INT_JSON_INSTANCE(Int16 )-INT_JSON_INSTANCE(Int32 )-INT_JSON_INSTANCE(Int64 )-INT_JSON_INSTANCE(Word )-INT_JSON_INSTANCE(Word8 )+INT_JSON_INSTANCE(Int)+INT_JSON_INSTANCE(Int8)+INT_JSON_INSTANCE(Int16)+INT_JSON_INSTANCE(Int32)+INT_JSON_INSTANCE(Int64)+INT_JSON_INSTANCE(Word)+INT_JSON_INSTANCE(Word8) INT_JSON_INSTANCE(Word16) INT_JSON_INSTANCE(Word32) INT_JSON_INSTANCE(Word64)@@ -1217,4 +1218,4 @@ {-# INLINE toValue #-} toValue = Number . realToFrac {-# INLINE encodeJSON #-}- encodeJSON = JB.scientific . realToFrac+ encodeJSON = B.scientific' . realToFrac
Z/Data/JSON/Builder.hs view
@@ -18,7 +18,6 @@ , array , array' , string- , scientific , prettyValue , prettyValue' -- * Builder helpers@@ -27,14 +26,12 @@ , Value(..) ) where -import Control.Monad import Z.Data.ASCII import qualified Z.Data.Builder as B import qualified Z.Data.Text as T import qualified Z.Data.Text.Print as T import Z.Data.Vector.Base as V import Z.Data.JSON.Value (Value(..))-import Data.Scientific (Scientific, base10Exponent, coefficient) -- | Use @:@ as separator to connect a label(no escape, only add quotes) with field builders. --@@ -54,7 +51,7 @@ value (Object kvs) = object kvs value (Array vs) = array vs value (String t) = string t-value (Number n) = scientific n+value (Number n) = B.scientific' n value (Bool True) = "true" value (Bool False) = "false" value _ = "null"@@ -93,19 +90,6 @@ {-# INLINE string #-} string = T.escapeTextJSON --- | This builder try to render integer when (0 <= e < 16), and scientific notation otherwise.-scientific :: Scientific -> B.Builder ()-{-# INLINE scientific #-}-scientific s- | e < 0 || e >= 16 = B.scientific s- | e == 0 = B.integer c- | otherwise = do- B.integer c- when (c /= 0) (replicateM_ e (B.encodePrim DIGIT_0))- where- e = base10Exponent s- c = coefficient s- -------------------------------------------------------------------------------- -- | 'ValuePretty\'' with 4 spaces indentation per level, e.g.@@ -159,7 +143,7 @@ prettyValue' c !ind (Object kvs) = objectPretty c ind kvs prettyValue' c !ind (Array vs) = arrayPretty c ind vs prettyValue' _ !ind (String t) = B.word8N ind SPACE >> string t-prettyValue' _ !ind (Number n) = B.word8N ind SPACE >> scientific n+prettyValue' _ !ind (Number n) = B.word8N ind SPACE >> B.scientific' n prettyValue' _ !ind (Bool True) = B.word8N ind SPACE >> "true" prettyValue' _ !ind (Bool False) = B.word8N ind SPACE >> "false" prettyValue' _ !ind _ = B.word8N ind SPACE >> "null"
Z/Data/Text/Print.hs view
@@ -47,6 +47,7 @@ , B.float , B.floatWith , B.scientific+ , B.scientific' , B.scientificWith -- * Helpers , B.paren, B.curly, B.square, B.angle, B.quotes, B.squotes@@ -55,7 +56,8 @@ ) where import Control.Monad-import qualified Data.Scientific as Sci+import Control.Exception (SomeException)+import Z.Data.ASCII import Data.Fixed import Data.Primitive.PrimArray import Data.Functor.Compose@@ -69,7 +71,12 @@ import Data.Proxy (Proxy(..)) import Data.Ratio (Ratio, numerator, denominator) import Data.Tagged (Tagged (..))+import qualified Data.Scientific as Sci import qualified Data.Semigroup as Semigroup+import Data.Time (Day, DiffTime, LocalTime, NominalDiffTime, TimeOfDay, UTCTime, ZonedTime)+import Data.Time.Calendar (CalendarDiffDays (..), DayOfWeek (..))+import Data.Time.LocalTime (CalendarDiffTime (..))+import Data.Time.Clock.System (SystemTime (..)) import Data.Typeable import Foreign.C.Types import GHC.Exts@@ -81,8 +88,7 @@ import Data.Version import System.Exit import Data.Primitive.Types-import qualified Z.Data.Builder.Base as B-import qualified Z.Data.Builder.Numeric as B+import qualified Z.Data.Builder as B import qualified Z.Data.Text.Base as T import Z.Data.Text.Base (Text(..)) import qualified Z.Data.Array as A@@ -460,3 +466,81 @@ deriving anyclass instance Print (f (g a)) => Print (Compose f g a) deriving anyclass instance (Print (f a), Print (g a)) => Print (Product f g a) deriving anyclass instance (Print (f a), Print (g a), Print a) => Print (Sum f g a)++--------------------------------------------------------------------------------++-- | @YYYY-MM-DDTHH:MM:SS.SSSZ@+instance Print UTCTime where+ {-# INLINE toUTF8BuilderP #-}+ toUTF8BuilderP _ = B.utcTime++-- | @YYYY-MM-DDTHH:MM:SS.SSSZ@+instance Print ZonedTime where+ {-# INLINE toUTF8BuilderP #-}+ toUTF8BuilderP _ = B.zonedTime++-- | @YYYY-MM-DD@+instance Print Day where+ {-# INLINE toUTF8BuilderP #-}+ toUTF8BuilderP _ = B.day++-- | @YYYY-MM-DDTHH:MM:SS.SSSZ@+instance Print LocalTime where+ {-# INLINE toUTF8BuilderP #-}+ toUTF8BuilderP _ = B.localTime++-- | @HH:MM:SS.SSS@+instance Print TimeOfDay where+ {-# INLINE toUTF8BuilderP #-}+ toUTF8BuilderP _ = B.timeOfDay++instance Print NominalDiffTime where+ {-# INLINE toUTF8BuilderP #-}+ toUTF8BuilderP _ = B.scientific' . realToFrac++instance Print DiffTime where+ {-# INLINE toUTF8BuilderP #-}+ toUTF8BuilderP _ = B.scientific' . realToFrac++instance Print SystemTime where+ {-# INLINE toUTF8BuilderP #-}+ toUTF8BuilderP p (MkSystemTime s ns) = parenWhen (p > 10) $ do+ "MkSystemTime {systemSeconds = "+ B.int s+ ", systemNanoseconds = "+ B.int ns+ "}"++instance Print CalendarDiffTime where+ {-# INLINE toUTF8BuilderP #-}+ toUTF8BuilderP p (CalendarDiffTime m nt) = parenWhen (p > 10) $ do+ B.encodePrim LETTER_P+ B.integer m+ B.encodePrim (LETTER_M, LETTER_T)+ B.scientific' (realToFrac nt)+ B.encodePrim LETTER_S++instance Print CalendarDiffDays where+ {-# INLINE toUTF8BuilderP #-}+ toUTF8BuilderP p (CalendarDiffDays m d) = parenWhen (p > 10) $ do+ B.encodePrim LETTER_P+ B.integer m+ B.encodePrim LETTER_M+ B.integer d+ B.encodePrim LETTER_D++instance Print DayOfWeek where+ {-# INLINE toUTF8BuilderP #-}+ toUTF8BuilderP _ Monday = "Monday"+ toUTF8BuilderP _ Tuesday = "Tuesday"+ toUTF8BuilderP _ Wednesday = "Wednesday"+ toUTF8BuilderP _ Thursday = "Thursday"+ toUTF8BuilderP _ Friday = "Friday"+ toUTF8BuilderP _ Saturday = "Saturday"+ toUTF8BuilderP _ Sunday = "Sunday"++--------------------------------------------------------------------------------++instance Print SomeException where+ {-# INLINE toUTF8BuilderP #-}+ toUTF8BuilderP p x = B.stringUTF8 $ showsPrec p x ""
Z/Data/Vector/Base.hs view
@@ -109,6 +109,7 @@ maximum, minimum, product, sum, all, any, replicate, traverse) import Test.QuickCheck.Arbitrary (Arbitrary(..), CoArbitrary(..))+import Test.QuickCheck.Gen (chooseInt) import Text.Read (Read(..)) import System.IO.Unsafe (unsafeDupablePerformIO) @@ -311,7 +312,12 @@ traverse = traverseVec instance Arbitrary a => Arbitrary (Vector a) where- arbitrary = pack <$> arbitrary+ arbitrary = do+ vs <- arbitrary+ let l = List.length vs+ s <- chooseInt (0, l)+ l' <- chooseInt (0, l - s)+ pure $ fromArr (pack vs) s l' shrink v = pack <$> shrink (unpack v) instance CoArbitrary a => CoArbitrary (Vector a) where@@ -489,7 +495,12 @@ readPrec = pack <$> readPrec instance (Prim a, Arbitrary a) => Arbitrary (PrimVector a) where- arbitrary = pack <$> arbitrary+ arbitrary = do+ vs <- arbitrary+ let l = List.length vs+ s <- chooseInt (0, l)+ l' <- chooseInt (0, l - s)+ pure $ fromArr (pack vs) s l' shrink v = pack <$> shrink (unpack v) instance (Prim a, CoArbitrary a) => CoArbitrary (PrimVector a) where@@ -714,7 +725,6 @@ pack :: Vec v a => [a] -> v a {-# INLINE pack #-} pack = packN defaultInitSize- -- | /O(n)/ Convert a list into a vector with an approximate size. --
Z/Data/Vector/Search.hs view
@@ -218,7 +218,7 @@ next = kmpNextTable needle search haystack@(Vec harr hoff hlen) reportPartial | nlen <= 0 = [0..hlen-1]- | nlen == 1 = case indexArr' narr 0 of+ | nlen == 1 = case indexArr' narr noff of (# x #) -> elemIndices x haystack | otherwise = kmp 0 0 where@@ -260,7 +260,7 @@ bloom = sundayBloom needle search haystack@(Vec harr hoff hlen) reportPartial | nlen <= 0 = [0..hlen-1]- | nlen == 1 = case indexArr' narr 0 of+ | nlen == 1 = case indexArr' narr noff of (# x #) -> elemIndices x haystack | otherwise = kmp 0 0 where@@ -278,7 +278,7 @@ j' -> kmp i j' search' haystack@(Vec harr hoff hlen) reportPartial | nlen <= 0 = [0..hlen-1]- | nlen == 1 = elemIndices (indexArr narr 0) haystack+ | nlen == 1 = elemIndices (indexArr narr noff) haystack | otherwise = sunday 0 0 where kmp !i !j | i >= hlen = if reportPartial && j /= 0 then [-j] else []@@ -328,7 +328,7 @@ next = kmpNextTable needle search haystack@(Vec harr hoff hlen) reportPartial | nlen <= 0 = [0..hlen-1]- | nlen == 1 = case indexArr' narr 0 of+ | nlen == 1 = case indexArr' narr noff of (# x #) -> elemIndices x haystack | otherwise = kmp 0 0 where@@ -357,7 +357,7 @@ bloom = sundayBloom needle search haystack@(Vec harr hoff hlen) reportPartial | nlen <= 0 = [0..hlen-1]- | nlen == 1 = case indexArr' narr 0 of+ | nlen == 1 = case indexArr' narr noff of (# x #) -> elemIndices x haystack | otherwise = kmp 0 0 where@@ -372,7 +372,7 @@ j' -> kmp i j' search' haystack@(Vec harr hoff hlen) reportPartial | nlen <= 0 = [0..hlen-1]- | nlen == 1 = elemIndices (indexArr narr 0) haystack+ | nlen == 1 = elemIndices (indexArr narr noff) haystack | otherwise = sunday 0 0 where kmp !i !j | i >= hlen = if reportPartial && j /= 0 then [-j] else []
Z/Data/Vector/Sort.hs view
@@ -49,6 +49,7 @@ , mergeDupAdjacentBy ) where +import Control.Monad import Control.Monad.ST import Data.Bits import Data.Int@@ -484,22 +485,40 @@ mergeDupAdjacentBy eq merger v@(Vec arr s l) | l == 0 = empty | l == 1 = v- | otherwise = createN l $ \ marr -> do- x0 <- indexArrM arr 0- writeArr marr 0 x0- go arr marr s 1 x0+ | otherwise =+ let i = findFirstDup (s+1) (indexArr arr s)+ in if i == end+ then v+ else createN l $ \ marr -> do+ let noDupLen = i - s+ when (noDupLen > 0) (copyArr marr 0 arr s noDupLen)+ x0 <- indexArrM arr i+ x1 <- indexArrM arr (i+1)+ let !x' = merger x0 x1+ writeArr marr noDupLen x'+ go marr (i+2) (noDupLen+1) x' where !end = s + l- go :: forall s. IArray v a -> MArr (IArray v) s a -> Int -> Int -> a -> ST s Int- go !arr' !marr !i !j !x++ findFirstDup :: Int -> a -> Int+ findFirstDup !i !x+ | i >= end = i+ | otherwise =+ let !x' = indexArr arr i+ in if x' `eq` x+ then (i-1)+ else findFirstDup (i+1) x'++ go :: forall s. MArr (IArray v) s a -> Int -> Int -> a -> ST s Int+ go !marr !i !j !x | i >= end = return j | otherwise = do- x' <- indexArrM arr' i+ x' <- indexArrM arr i if x `eq` x' then do let !x'' = merger x x' writeArr marr (j-1) x''- go arr' marr (i+1) j x''+ go marr (i+1) j x'' else do writeArr marr j x'- go arr' marr (i+1) (j+1) x'+ go marr (i+1) (j+1) x'
test/Z/Data/Vector/SortSpec.hs view
@@ -136,3 +136,8 @@ prop "vector radixSort should be stable" $ \ xs ys -> (V.radixSort . V.pack @V.Vector $ List.zipWith StableTest xs ys) === (V.pack $ List.sort $ List.zipWith StableTest xs ys)++ describe "vector mergeDupAdjacent . sort == List nub . sort" . modifyMaxSuccess (*10) . modifyMaxSize (*10) $ do+ prop "vector mergeDupAdjacent . sort == List nub . sort" $ \ xs ->+ (V.mergeDupAdjacent . V.mergeSort . V.pack @V.Vector @Int $ List.sort xs) ===+ (V.pack . List.nub $ List.sort xs)