Integral -package:aeson-optics -package:optics-core -package:lens-aeson -is:module

Integral numbers, supporting integer division. The Haskell Report defines no laws for Integral. However, Integral instances are customarily expected to define a Euclidean domain and have the following properties for the div/mod and quot/rem pairs, given suitable Euclidean functions f and g:
  • x = y * quot x y + rem x y with rem x y = fromInteger 0 or g (rem x y) < g y
  • x = y * div x y + mod x y with mod x y = fromInteger 0 or f (mod x y) < f y
An example of a suitable Euclidean function, for Integer's instance, is abs. In addition, toInteger should be total, and fromInteger should be a left inverse for it, i.e. fromInteger (toInteger i) = i.
Integral numbers, supporting integer division. The Haskell Report defines no laws for Integral. However, Integral instances are customarily expected to define a Euclidean domain and have the following properties for the div/mod and quot/rem pairs, given suitable Euclidean functions f and g:
  • x = y * quot x y + rem x y with rem x y = fromInteger 0 or g (rem x y) < g y
  • x = y * div x y + mod x y with mod x y = fromInteger 0 or f (mod x y) < f y
An example of a suitable Euclidean function, for Integer's instance, is abs.
Integral numbers, supporting integer division.
An Integral is anything that satisfies the law:
\a b -> b == zero || b * (a `div` b) + (a `mod` b) == a
>>> 3 `divMod` 2
(1,1)
>>> (-3) `divMod` 2
(-2,1)
>>> (-3) `quotRem` 2
(-1,-1)
Integral Literal support e.g. 123 :: Integer 123 :: Word8
Integral numbers, supporting integer division. The Haskell Report defines no laws for Integral. However, Integral instances are customarily expected to define a Euclidean domain and have the following properties for the 'div'/'mod' and 'quot'/'rem' pairs, given suitable Euclidean functions f and g:
  • x = y * quot x y + rem x y with rem x y = fromInteger 0 or g (rem x y) < g y
  • x = y * div x y + mod x y with mod x y = fromInteger 0 or f (mod x y) < f y
An example of a suitable Euclidean function, for Integer's instance, is abs.
This ReifiedPrism can be used to model the fact that every Integral type is a subset of Integer. Embedding through the ReifiedPrism only succeeds if the Integer would pass through unmodified when re-extracted.
Generates a random integral number in the given [inclusive,inclusive] range. When the generator tries to shrink, it will shrink towards the origin of the specified Range. For example, the following generator will produce a number between 1970 and 2100, but will shrink towards 2000:
integral (Range.constantFrom 2000 1970 2100) :: Gen Int
Some sample outputs from this generator might look like:
=== Outcome ===
1973
=== Shrinks ===
2000
1987
1980
1976
1974
=== Outcome ===
2061
=== Shrinks ===
2000
2031
2046
2054
2058
2060
Integration using the rectangle rule.
Constructor for a simple integral type.
Integral symbol. Use integralFromTo if you want to specify the limits of the integral.
helper function to create a FieldInteger
Memoize an integral type.
matches an Integral value Note that the combinator (rPair . integral . integral) is ill-defined because the parse canwell. not tell where it is supposed to split the sequence of digits to produced two ints.
Integrate the input signal over time.
  • Depends: before now.
Compute an indefinite integral of the polynomial, setting the constant term to zero.
>>> integral (3 * X^2 + 3) :: UPoly Double
1.0 * X^3 + 0.0 * X^2 + 3.0 * X + 0.0
Compute an indefinite integral of the polynomial with respect to the i-th variable, setting the constant term to zero.
>>> :set -XDataKinds

>>> integral 0 (3 * X^2 + 2 * Y) :: UMultiPoly 2 Double
1.0 * X^3 + 2.0 * X * Y

>>> integral 1 (3 * X^2 + 2 * Y) :: UMultiPoly 2 Double
3.0 * X^2 * Y + 1.0 * Y^2
Compute an indefinite integral of the polynomial with respect to the i-th variable, setting the constant term to zero.
>>> :set -XDataKinds

>>> integral 0 (3 * X^2 + 2 * Y) :: UMultiPoly 2 Double
1.0 * X^3 + 2.0 * X * Y

>>> integral 1 (3 * X^2 + 2 * Y) :: UMultiPoly 2 Double
3.0 * X^2 * Y + 1.0 * Y^2
Compute an indefinite integral of the polynomial, setting the constant term to zero.
>>> integral (3 * X^2 + 3) :: UPoly Double
1.0 * X^3 + 0.0 * X^2 + 3.0 * X + 0.0
Compute an indefinite integral of the polynomial, setting the constant term to zero.
>>> integral (3 * X^2 + 3) :: UPoly Double
1.0 * X^3 + 3.0 * X
Compute an indefinite integral of the polynomial, setting the constant term to zero.
>>> integral (3 * X^2 + 3) :: UPoly Double
1.0 * X^3 + 3.0 * X