scientific-notation: Scientific notation intended for tokenization

[ bsd3, data, library ] [ Propose Tags ]

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:

Versions [RSS] [faq],,,,
Change log
Dependencies base (>=4.12 && <5), bytebuild (>=0.3.5 && <0.4), bytesmith (==0.3.*), natural-arithmetic (>=0.1.1 && <0.2) [details]
License BSD-3-Clause
Copyright 2019 Andrew Martin
Author Andrew Martin
Category Data
Home page
Bug tracker
Uploaded by andrewthad at 2021-02-23T18:13:09Z
Distributions NixOS:
Downloads 1205 total (8 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2021-02-23 [all 1 reports]


[Index] [Quick Jump]


Maintainer's Corner

For package maintainers and hackage trustees