cabal-version: 2.2
name: scientific-notation
version: 0.1.0.0
synopsis: Scientific notation intended for tokenization
description:
This library provides a type used to represent a number in
scientific notation. This is most frequently useful when
tokenizing or parsing a language. Languages like JSON and SQL
support numberic literals written in scientific notation, even
though backends frequently reject numbers outside a given range.
This library provides a compact representation of numbers in
scientific notation. In the common case of the coefficient and
then exponent each being small enough to be represented by a
machine word, this library avoids the need for any indirections
to retrieve the number. Consider some tokenization scheme:
`data Token = ... | Number {-# UNPACK #-} !Scientific`.
In this case, the unboxed coefficient and exponent are unpacked
into the `Number` data constructor if they can each be represented
by a machine word.
.
The internal representation does not normalize numbers. That is,
parsing `300e-2` resulting in a representation that uses `300` and
`-2` rather than `3` and `0`.
This work is deferred with the expectation that a number in scientific
notation is consumed either zero or one times. This library is not
optimized for use-cases that consume a `Scientific` more than once
since normalization is reapplied every time.
.
The primary library that operates in this same space is `scientific`.
Compared to `scientific`, this library distinguishes itself from
`scientific` in the following ways:
.
* Correctness: `scientific` does not correctly handle large exponents. See
<https://github.com/basvandijk/scientific/issues/62 issue #62>.
.
* Parsing: The `scientific-notation` parser outperforms the `scientific`
parser that ships with `aeson` by a factor of five on small numbers.
homepage: https://github.com/andrewthad/scientific-notation
bug-reports: https://github.com/andrewthad/scientific-notation/issues
license: BSD-3-Clause
license-file: LICENSE
author: Andrew Martin
maintainer: andrew.thaddeus@gmail.com
copyright: 2019 Andrew Martin
category: Data
extra-source-files: CHANGELOG.md
library
exposed-modules: Data.Number.Scientific
build-depends:
, base >=4.12 && <5
, bytesmith >=0.2.0.1 && <0.3
hs-source-dirs: src
default-language: Haskell2010
test-suite test
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Main.hs
ghc-options: -Wall -O2
build-depends:
, QuickCheck >=2.13.1 && <2.14
, base >=4.12.0.0 && <5
, byteslice
, bytestring
, scientific-notation
, tasty >=1.2.3 && <1.3
, tasty-hunit >=0.10.0.2 && <0.11
, tasty-quickcheck
, primitive
, bytesmith
benchmark bench
type: exitcode-stdio-1.0
build-depends:
, base
, gauge >= 0.2.4
, byteslice >= 0.1.2
, scientific-notation
, primitive
, bytesmith
, aeson
, attoparsec
, bytestring
, scientific
, run-st
ghc-options: -Wall -O2
default-language: Haskell2010
hs-source-dirs: bench
main-is: Main.hs