**Packages**- package

Functions for finding prime numbers, checking whether a number is prime, finding the factors of a number etc.
Version 0.2.1

This package includes the Sieve of O'Neill and two generalizations of the Sieve of Eratosthenes. The Sieve of O'Neill is a fully incremental primality sieve based on priority queues. The other two are array based, and are not incremental. One sieves the smallest prime factor, and is useful if you want to factor a large quantity of small numbers. The other sieves Euler's Totient, which is the number of positive integers relatively prime and less than a given number.
Version 0.1.2

Instances of numeric classes for functions and tuples. Import Data.NumInstances to get all the instances. If you want only function or only tuple instances, import Data.NumInstances.Function or Data.NumInstances.Tuple.
Version 1.3

Num, Enum, Eq, Integral, Ord, Real, and Show instances for Lazy ByteStrings
Version 0.0.0.1

Combinators for creating bijections from a subset of an arbitrary type to a range of Ints, , e.g. for using libraries that require Int IDs.
Version 0.2.1

Instances of the numerical classes for a variety of different numbers: (computable) real numbers, arbitrary precision fixed numbers, arbitrary precision floating point numbers, differentiable numbers, symbolic numbers, natural numbers, interval arithmetic.
Version 3000.2.0.0

Convert numbers to number words in a number of languages. Each language has its own module. The module name is based on one of the ISO 639 Alpha codes. Each module contains one or more cardinal functions and a struct function. The cardinal functions directly convert cardinal numbers to a string-like representation of their spoken form. The struct functions convert numbers to a polymorphic representation of their grammatical structure. All language modules are implemented using the numerals-base package.
The use of this package is best understood with some examples. Because the results of conversion are polymorphic we need to choose a specific type. For these examples we'll use simple strings. But any type that has instances for Monoid and IsString will work. First some English number names, both British and US variants:
>>> import qualified Text.Numeral.Language.EN as EN >>> EN.uk_cardinal 123 :: Maybe String Just "one hundred and twenty-three" >>> EN.us_cardinal (10^50 + 42) :: Maybe String Just "one hundred quindecillion forty-two"
French, which contains some traces of a base 20 system:
>>> import qualified Text.Numeral.Language.FR as FR >>> FR.cardinal (-99) :: Maybe String Just "moins quatre-vingt-dix-neuf"
Conversions can fail. Alamblak, a language spoken by a few people in Papua New Guinea, has no representation for negative numbers:
>>> import qualified Text.Numeral.Language.AMP as AMP >>> AMP.cardinal (-3) :: Maybe String Nothing
Some languages have multiple scripts and methods for writing number names. Take Chinese for example, which can be written using Han characters or transcribed to the Latin script using Pinyin.
Traditional Chinese characters:
>>> import qualified Text.Numeral.Language.ZH as ZH >>> ZH.trad_cardinal 123456 :: Maybe String Just "AŒ, CÛ~”Am"
Simplified characters for use in financial contexts:
>>> ZH.finance_simpl_cardinal 123456 :: Maybe String Just "þ0Âß†/
þF"
Transcribed using Pinyin:
>>> ZH.pinyin_cardinal 123456 :: Maybe String Just "shíèrwàn snqin sìbÎi wÔshí liù"
Using the struct functions you can see the grammatical structure of number names. Because the results of these functions are polymorphic you need to specify a specific type.
>>> import qualified Text.Numeral.Language.NL as NL >>> NL.struct 123 :: Maybe Integer Just 123 >>> import Text.Numeral >>> NL.struct 123 :: Maybe Exp Just (Add (Lit 100) (Add (Lit 3) (Mul (Lit 2) (Lit 10))))
Compare with:
>>> NL.cardinal 123 :: Maybe String Just "honderddrieëntwintig"
100 (honderd) + (3 (drie) + (ën) 2 (twin) * 10 (tig))
Version 0.3.0.1

This package contains machinery to construct functions that convert numbers to number words. It allows you to write a function which converts a number like 142 to the string "one hundred and forty-two".
The documentation for the Text.Numeral module contains an high level overview of the package.
If you just want to convert numbers to number words in a specific language you should probably use the numerals package. That package also contains numerous examples on how to use the functions in this package.
Version 0.3

Various floating point limit related constants.
Version 0.1.0.0

Revisiting the Numeric Classes
The Prelude for Haskell 98 offers a well-considered set of numeric classes which covers the standard numeric types (Integer, Int, Rational, Float, Double, Complex) quite well. But they offer limited extensibility and have a few other flaws. In this proposal we will revisit these classes, addressing the following concerns:
1: The current Prelude defines no semantics for the fundamental operations. For instance, presumably addition should be associative (or come as close as feasible), but this is not mentioned anywhere. 2: There are some superfluous superclasses. For instance, Eq and Show are superclasses of Num. Consider the data type data IntegerFunction a = IF (a -> Integer) One can reasonably define all the methods of Algebra.Ring.C for IntegerFunction a (satisfying good semantics), but it is impossible to define non-bottom instances of Eq and Show. In general, superclass relationship should indicate some semantic connection between the two classes. 3: In a few cases, there is a mix of semantic operations and representation-specific operations. toInteger, toRational, and the various operations in RealFloating (decodeFloat, ...) are the main examples. 4: In some cases, the hierarchy is not finely-grained enough: Operations that are often defined independently are lumped together. For instance, in a financial application one might want a type "Dollar", or in a graphics application one might want a type "Vector". It is reasonable to add two Vectors or Dollars, but not, in general, reasonable to multiply them. But the programmer is currently forced to define a method for '(*)' when she defines a method for '(+)'.
In specifying the semantics of type classes, I will state laws as follows:
> (a + b) + c === a + (b + c)
The intended meaning is extensional equality: The rest of the program should behave in the same way if one side is replaced with the other. Unfortunately, the laws are frequently violated by standard instances; the law above, for instance, fails for Float:
> (1e20 + (-1e20)) + 1.0 = 1.0
> 1e20 + ((-1e20) + 1.0) = 0.0
For inexact number types like floating point types, thus these laws should be interpreted as guidelines rather than absolute rules. In particular, the compiler is not allowed to use them for optimization. Unless stated otherwise, default definitions should also be taken as laws.
Thanks to Brian Boutel, Joe English, William Lee Irwin II, Marcin Kowalczyk, Ketil Malde, Tom Schrijvers, Ken Shan, and Henning Thielemann for helpful comments.
Usage:
Write modules in the following style:
> [-# LANGUAGE NoImplicitPrelude #-]
> module MyModule where
> ... various specific imports ...
> import NumericPrelude
Importing NumericPrelude is almost the same as
> import NumericPrelude.Numeric
> import NumericPrelude.Base .
Instead of the NoImplicitPrelude pragma you could also write import Prelude () but this will yield problems with numeric literals.
There are two wrapper types that allow types to be used with both Haskell98 and NumericPrelude type classes that are initially implemented for only one of them.
Scope & Limitations/TODO:
* It might be desireable to split Ord up into Poset and Ord (a total ordering). This is not addressed here.
* In some cases, this hierarchy may not yet be fine-grained enough. For instance, time spans ("5 minutes") can be added to times ("12:34"), but two times are not addable. ("12:34 + 8:23") As it stands, users have to use a different operator for adding time spans to times than for adding two time spans. Similar issues arise for vector space et al. This is a consciously-made tradeoff, but might be changed. This becomes most serious when dealing with quantities with units like length/distance^2, for which (*) as defined here is useless. (One way to see the issue: should f x y = iterate (x *) y have principal type (Ring.C a) => a -> a -> [a] or something like (Ring.C a, Module a b) => a -> b -> [b] ?)
* I stuck with the Haskell 98 names. In some cases I find them lacking. Neglecting backwards compatibility, we have renamed classes as follows: Num --> Additive, Ring, Absolute Integral --> ToInteger, IntegralDomain, RealIntegral Fractional --> Field Floating --> Algebraic, Transcendental Real --> ToRational RealFrac --> RealRing, RealField RealFloat --> RealTranscendental
Additional standard libraries might include Enum, IEEEFloat (including the bulk of the functions in Haskell 98's RealFloat class), VectorSpace, Ratio, and Lattice.
Version 0.4.0.3

List based linear algebra, similtaneous linear equations, eigenvalues and eigenvectors, roots of polynomials, transcendent functions with arbitrary precision implemented by continued fractions, quantum operations, tensors
Version 0.2

Package provides function to perform numeric integration and differentiation, function interpolation.
Changes in 0.2.0.0
* Equation solvers now use custom return type.
* Function to solve equations using Ridder and Newton methods.
* New function to test approximate equality for doubles.
* QuadRes contains best approximation achieved even if required accuracy is not obtained
* Improve convergence test when integral converges to zero. Convergence is still poor
Version 0.2.0.0

Handy common number functions
Version 1.0.0

This package provides unary type level representations of the (positive and negative) integers and basic operations (addition, subtraction, multiplication, division) on these. Due to the unary implementation the practical size of the NumTypes is severely limited making them unsuitable for large-cardinality applications. If you will be working with integers beyond (-20, 20) this package probably isn't for you. It is, however, eminently suitable for applications such as representing physical dimensions (see the Dimensional library). Requires GHC 6.6.1 or later.
Version 1.0.1

This package provides unary type level representations of the (positive and negative) integers and basic operations (addition, subtraction, multiplication, division) on these. Due to the unary implementation the practical size of the NumTypes is severely limited making them unsuitable for large-cardinality applications. If you will be working with integers beyond (-20, 20) this package probably isn't for you. The numtype-tf packade differs from the numtype package in that the NumTypes are implemented using type families rather than functional dependencies. Requires GHC 7.0 or later.
Version 0.1.1

Any applicative functor can be given numeric instances in a boilerplate way. The *applicative-numbers* package provides an include file that makes it a snap to define these instances. See Data.Numeric.Function for an example.
Project wiki page: http://haskell.org/haskellwiki/applicative-numbers
Copyright 2009-2013 Conal Elliott; BSD3 license.
Instances of Num classes for applicative functors. To be #include'd after defining APPLICATIVE as the applicative functor name and CONSTRAINTS as a list of constraints, which must carry its own trailing comma if non-empty. The APPLICATIVE symbol gets #undef'd at the end of the include file, so that multiple includes are convenient.
For instance,
@ #define INSTANCE_Ord #define INSTANCE_Enum
#define APPLICATIVE Vec2 #include "ApplicativeNumeric-inc.hs"
#define APPLICATIVE Vec3 #include "ApplicativeNumeric-inc.hs"
#define APPLICATIVE Vec4 #include "ApplicativeNumeric-inc.hs" @
You'll also have to import pure and liftA2 from Control.Applicative and specify the FlexibleContexts language extension (due to an implementation hack).
Some instances are generated only if a corresponding CPP symbol is defined: INSTANCE_Eq, INSTANCE_Ord, INSTANCE_Show, INSTANCE_Enum
Version 0.1.2

This library allows an Attoparsec parser to receive input incrementally from an enumerator. This could be used for parsing large files, or implementing binary network protocols.
> (-# LANGUAGE OverloadedStrings #-)
> import Control.Applicative
> import Data.Attoparsec
> import Data.Attoparsec.Enumerator
> import Data.Enumerator
> import Data.Enumerator.Binary (enumHandle)
> import Data.Enumerator.List
> import System.IO
> parser = string "foo" <|> string "bar"
> main = do
> xy <- run_ (enumHandle 1 stdin $$ do
> x <- iterParser parser
> y <- iterParser parser
> return (x, y))
> print xy
Version 0.3.1

This package has been deprecated. You recommend that you use either attoparsec-enumerator or attoparsec-conduit packages.
Version 0.2.0.1