Z-Data: Array, vector and text

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

This package provides array, slice and text operations


[Skip to Readme]

Properties

Versions 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.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
Change log ChangeLog.md
Dependencies base (>=4.12 && <5.0), case-insensitive (>=1.2 && <1.3), deepseq (>=1.4 && <1.5), ghc-prim (>=0.5.3 && <0.6.2), hashable (>=1.3 && <1.4), integer-gmp (>=0.2 && <1.1), integer-simple (>=0.1 && <0.5), primitive (>=0.7.1 && <0.7.2), QuickCheck (>=2.10), scientific (>=0.3 && <0.4), tagged (>=0.8 && <0.9), template-haskell (>=2.14.0), time (>=1.8), unordered-containers (>=0.2 && <0.3) [details]
License BSD-3-Clause
Copyright (c) Dong Han, 2017-2020 (c) Tao He, 2017-2020
Author Dong Han, Tao He
Maintainer winterland1989@gmail.com
Category Data
Home page https://github.com/haskell-Z/z-data
Bug tracker https://github.com/haskell-Z/z-data/issues
Source repo head: git clone git://github.com/haskell-Z/z-data.git
Uploaded by winterland at 2020-10-09T14:12:51Z

Modules

[Index] [Quick Jump]

Flags

Automatic Flags
NameDescriptionDefault
integer-simple

Use the simple integer library instead of integer-gmp

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


Readme for Z-Data-0.1.6.0

[back to package description]

Z-Data

Linux Build Status MacOS Build Status Windows Build Status

This package provides basic data structures and functions:

Requirements

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.buildBytes $ "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]
> 
> T.validate . B.buildBytes $ "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.FromValue, JSON.ToValue, JSON.EncodeJSON, 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:haskell-Z/z-data.git 
cd z-data
# build
cabal build
# test
cabal run Z-Data-Test
# install 
cabal install
# generate document
cabal haddock