Z-Data: Array, vector and text

[ bsd3, data, library ] [ Propose Tags ]
This version is deprecated.

This package provides array, slice and text operations


[Skip to Readme]

Modules

[Last Documentation]

  • Z
    • Data
      • Z.Data.ASCII
      • Z.Data.Array
        • Z.Data.Array.Base
        • Z.Data.Array.Cast
        • Z.Data.Array.QQ
        • Z.Data.Array.Unaligned
        • Z.Data.Array.UnliftedArray
      • Z.Data.Builder
        • Z.Data.Builder.Base
        • Z.Data.Builder.Numeric
          • Z.Data.Builder.Numeric.DigitTable
        • Z.Data.Builder.Time
        • Z.Data.Builder.UUID
      • Z.Data.CBytes
      • Generics
        • 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.Parser.UUID
      • Z.Data.PrimRef
      • 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
      • Z.Foreign.CPtr

Flags

Manual Flags

NameDescriptionDefault
check-array-bound

Add bound check to operations in Z.Data.Array module.

Disabled
integer-simple

Use the simple integer library instead of integer-gmp

Disabled
use-avx2

Use AVX2 instructions(utf8 validation, base64 codec, etc).

Disabled
use-avx512

Use AVX512(AVX512F, AVX512VL, AVX512BW, AVX512VBMI) instructions(utf8 validation, base64 codec, etc).

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.1.1.0, 0.1.2.0, 0.1.3.0, 0.1.3.1, 0.1.4.0, 0.1.4.1, 0.1.4.2, 0.1.5.0, 0.1.6.0, 0.1.6.1, 0.1.7.0, 0.1.7.1, 0.1.7.2, 0.1.8.0, 0.1.9.0, 0.1.9.1, 0.2.0.0, 0.3.0.0, 0.4.0.0, 0.5.0.0, 0.6.0.0, 0.6.1.0, 0.7.0.0, 0.7.1.0, 0.7.2.0, 0.7.3.0, 0.7.4.0, 0.8.0.0, 0.8.1.0, 0.8.2.0, 0.8.3.0, 0.8.4.0, 0.8.5.0, 0.8.6.0, 0.8.6.1, 0.8.7.0, 0.8.8.0, 0.9.0.0, 1.0.0.0, 1.0.0.1, 1.1.0.0, 1.2.0.0, 1.2.1.0, 1.3.0.0, 1.3.0.1, 2.0.0.0, 2.0.0.1, 2.0.0.2, 2.0.1.0 (info)
Change log ChangeLog.md
Dependencies base (>=4.12 && <5.0), bytestring (>=0.10.4 && <0.12), case-insensitive (>=1.2 && <1.3), containers (>=0.6 && <0.7), deepseq (>=1.4 && <1.5), ghc-prim (>=0.5.3 && <0.8), hashable (>=1.3 && <1.4), integer-gmp (>=0.2 && <1.2), primitive (>=0.7.1 && <0.7.4), QuickCheck (>=2.10), random (>=1.2.0 && <1.3), scientific (>=0.3.7 && <0.4), tagged (>=0.8 && <0.9), template-haskell (>=2.14.0), time (>=1.9 && <2.0), unicode-collation (>=0.1.3 && <0.2), unordered-containers (>=0.2 && <0.3), uuid-types (>=1.0.4 && <2.0) [details]
License BSD-3-Clause
Copyright (c) Z.Haskell Contributors
Author Z.Haskell Contributors
Maintainer winterland1989@gmail.com
Category Data
Home page https://github.com/ZHaskell/z-data
Bug tracker https://github.com/ZHaskell/z-data/issues
Source repo head: git clone git://github.com/haskell-Z/z-data.git
Uploaded by lyndward at 2023-03-13T04:29:39Z
Distributions
Reverse Dependencies 5 direct, 0 indirect [details]
Downloads 16471 total (27 in the last 30 days)
Rating 2.5 (votes: 3) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2023-03-13 [all 2 reports]

Readme for Z-Data-1.3.0.0

[back to package description]

Z-Data

Hackage Linux Build Status macOS Build Status Windows Build Status ARM Build Status Gitter chat

This package is part of ZHaskell project, providing basic data structures and functions:

  • Array, vector(array slice), sorting, searching
  • Text based UTF-8, basic unicode manipulating, regex
  • FFI utilties
  • Fast parsing and building monad
  • JSON encoding and decoding

Requirements

  • A working haskell compiler system, GHC(>=8.6), cabal-install(>=2.4), here're some options:
    • Mac users can get them via homebew: brew install ghc cabal-install.
    • Windows users can get them via chocolatey: choco install ghc cabal.
    • Ubuntu users are recommended to use this ppa.
  • A working C/C++ compiler support C++11, here're some options:
    • Mac users can use the clang comes with the XCode or XCode Command Line Tools:
      • You can install XCode from app store, or XCode Command Line Tools with sudo xcode-select --install.
      • If you came across compiling issues like this, consider removing redundant SDKs, e.g. sudo rm -rf /Library/Developer/CommandLineTools/SDKs
    • Windows users can use the mingw's one comes with GHC, you can use it by adding your_path_to_ghc\mingw\bin to your PATH.
    • Ubuntu users can install gcc/g++ by running sudo apt install build-essential.
  • Tests need hspec-discover.

Example usage

> import qualified Z.Data.Vector as V
> import qualified Z.Data.Array as A
>
> -- convert from list
> let v = V.pack [1..10] :: V.PrimVector Int  
> -- vector combinators works on arrays as well
> let a = V.pack [1..10] :: A.Array Int   
> -- slicing vector(slice) is O(1)
> V.take 3 v                              
[1,2,3]
-- slicing array is not O(1)
> V.drop 3 a                              
fromListN 7 [4,5,6,7,8,9,10]
>
> V.intersperse 10 v
[1,10,2,10,3,10,4,10,5,10,6,10,7,10,8,10,9,10,10]
>
> V.mergeSort (V.intersperse 10 v) 
[1,2,3,4,5,6,7,8,9,10,10,10,10,10,10,10,10,10,10]
> -- Generic KMP search on vectors
> V.indices (V.singleton 10) (V.intersperse 10 v) True   
[1,3,5,7,9,11,13,15,17,18]
>
> -- quoter for writing numeric vector literals
> :set -XQuasiQuotes 
> :t [V.vecWord|1,2,3,4,5,4,3,2,1|]                     
[V.vecWord|1,2,3,4,5,4,3,2,1|] :: V.PrimVector Word
>
> import qualified Z.Data.Builder as B
> import qualified Z.Data.Text as T
> :set -XOverloadedStrings 
>
> -- Builders can be used with OverloadedStrings
> B.build $ "builders: " >> B.hex (3 :: Word16) >> B.comma >> B.double 1.2345678
[98,117,105,108,100,101,114,115,58,32,48,48,48,51,44,49,46,50,51,52,53,54,55,56]
> 
> B.buildText $ "builders: " >> B.hex (3 :: Word16) >> B.comma >> B.double 1.2345678
"builders: 0003,1.2345678"
>
> import qualified Z.Data.JSON as JSON
> import GHC.Generics
> 
> JSON.parseValue "[1,2,3,4,5]"
([],Right (Array [Number 1.0,Number 2.0,Number 3.0,Number 4.0,Number 5.0]))
>
> -- JSON module support deriving through Generic
> :set -XDeriveAnyClass -XDeriveGeneric
> data Foo = Foo {foo :: Double} deriving (JSON.JSON, Generic)
> JSON.toValue (Foo 0.01)
Object [("foo",Number 1.0e-2)]
> JSON.encodeText (Foo 0.01)
"{\"foo\":1.0e-2}"

Dev guide

# get code
git clone --recursive git@github.com:ZHaskell/z-data.git 
cd z-data
# build
cabal build
# test
cabal test --test-show-details=direct
# install 
cabal install
# generate document
cabal haddock