Copyright | (C) Frank Staals |
---|---|
License | see the LICENSE file |
Maintainer | Frank Staals |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- newtype RealNumber (p :: Nat) = RealNumber Rational
- data AsFixed p
- asFixed :: KnownNat p => RealNumber p -> AsFixed (NatPrec p)
- toFixed :: KnownNat p => RealNumber p -> Fixed (NatPrec p)
- fromFixed :: KnownNat p => Fixed (NatPrec p) -> RealNumber p
- data Nat
Documentation
newtype RealNumber (p :: Nat) Source #
Real Numbers represented using Rational numbers. The number type itself is exact in the sense that we can represent any rational number.
The parameter, a natural number, represents the precision (in number of decimals behind the period) with which we display the numbers when printing them (using Show).
If the number cannot be displayed exactly a '~' is printed after the number.
Instances
Converting to and from RealNumber's
Fixed-precision representation of a RealNumber
. If there's insufficient
precision to accurately represent the RealNumber
then the Lossy
constructor
will be used.
asFixed :: KnownNat p => RealNumber p -> AsFixed (NatPrec p) Source #
Cast RealNumber
to a fixed-precision number. Data-loss caused by insufficient
precision will be marked by the Lossy
constructor.
toFixed :: KnownNat p => RealNumber p -> Fixed (NatPrec p) Source #
Cast RealNumber
to a fixed-precision number. Data is silently lost if there's
insufficient precision.
fromFixed :: KnownNat p => Fixed (NatPrec p) -> RealNumber p Source #
Cast a fixed-precision number to a RealNumber
.
(Kind) This is the kind of type-level natural numbers.
Instances
KnownNat n => HasResolution (n :: Nat) | For example, |
Defined in Data.Fixed resolution :: p n -> Integer # | |
KnownNat n => Dim (n :: Nat) | |
Defined in Linear.V reflectDim :: p n -> Int # | |
KnownNat n => Reifies (n :: Nat) Integer | |
Defined in Data.Reflection | |
Finite (V n) | |
1 <= n => Field1 (V n a) (V n a) a a | |
2 <= n => Field2 (V n a) (V n a) a a | |
3 <= n => Field3 (V n a) (V n a) a a | |
4 <= n => Field4 (V n a) (V n a) a a | |
5 <= n => Field5 (V n a) (V n a) a a | |
6 <= n => Field6 (V n a) (V n a) a a | |
7 <= n => Field7 (V n a) (V n a) a a | |
8 <= n => Field8 (V n a) (V n a) a a | |
9 <= n => Field9 (V n a) (V n a) a a | |
10 <= n => Field10 (V n a) (V n a) a a | |
11 <= n => Field11 (V n a) (V n a) a a | |
12 <= n => Field12 (V n a) (V n a) a a | |
13 <= n => Field13 (V n a) (V n a) a a | |
14 <= n => Field14 (V n a) (V n a) a a | |
15 <= n => Field15 (V n a) (V n a) a a | |
16 <= n => Field16 (V n a) (V n a) a a | |
17 <= n => Field17 (V n a) (V n a) a a | |
18 <= n => Field18 (V n a) (V n a) a a | |
19 <= n => Field19 (V n a) (V n a) a a | |
type Size (V n) | |