Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Rational
- data NRational
- oppositeRational :: LorentzRational r => (r ': s) :-> (r ': s)
- gcdEuclid :: (Natural ': (Natural ': s)) :-> (Natural ': s)
- euclidExtendedNormalization :: forall s. (Rational ': s) :-> (Rational ': s)
- reduce :: (LorentzRational r, KnownList s, KnownList (ToTs s)) => (r ': s) :-> (r ': s)
- tripleMul :: forall r a s. (ArithOpHs Mul a a a, Unwrappabled r ~ (a, Natural), LorentzRational r) => (r ': (r ': (r ': s))) :-> (r ': s)
- mkRational :: (Integer, Natural) -> Either Text Rational
- (%!) :: Integer -> Natural -> Rational
- mkNRational :: (Natural, Natural) -> Either Text NRational
- (%%!) :: Natural -> Natural -> NRational
- class Unwrappable r => LorentzRational r
- mkRational_ :: (forall s0. ErrInstr (("numerator" :! Integer, "denominator" :! Natural) ': s0)) -> (Integer ': (Natural ': s)) :-> (Rational ': s)
- numerator :: (LorentzRational r, Unwrappabled r ~ (a, Natural)) => (r ': s) :-> (a ': s)
- denominator :: (LorentzRational r, Unwrappabled r ~ (a, Natural)) => (r ': s) :-> (Natural ': s)
- constructRational :: (LorentzRational r, Unwrappabled r ~ (a, Natural)) => (a ': (Natural ': s)) :-> (r ': s)
- deconstructRational :: (LorentzRational r, Unwrappabled r ~ (a, Natural)) => (r ': s) :-> (a ': (Natural ': s))
- uncheckedPairToRational :: (LorentzRational r, Unwrappabled r ~ (a, Natural)) => ((a, Natural) ': s) :-> (r ': s)
- unsafePairToRational :: (LorentzRational r, Unwrappabled r ~ (a, Natural)) => ((a, Natural) ': s) :-> (r ': s)
- pairToRational :: (LorentzRational r, Unwrappabled r ~ (a, Natural), KnownValue r) => ((a, Natural) ': s) :-> (Maybe r ': s)
Documentation
Instances
Instances
Common functions
oppositeRational :: LorentzRational r => (r ': s) :-> (r ': s) Source #
gcdEuclid :: (Natural ': (Natural ': s)) :-> (Natural ': s) Source #
For a given Natural
values, calculates their gcd, using Euclid algorithm.
euclidExtendedNormalization :: forall s. (Rational ': s) :-> (Rational ': s) Source #
Reduce Rational
value, using extended Euclid algorithm.
Consumes slightly more gas, than reduce
, but contract with it is cheaper in terms of origination.
reduce :: (LorentzRational r, KnownList s, KnownList (ToTs s)) => (r ': s) :-> (r ': s) Source #
tripleMul :: forall r a s. (ArithOpHs Mul a a a, Unwrappabled r ~ (a, Natural), LorentzRational r) => (r ': (r ': (r ': s))) :-> (r ': s) Source #
Special multiplication helper, in case you want to multiply three 'Rational values'
given values (a b) * (c d) * (e / f)
performs (a * c * e) / (b * d * f)
.
Constructor functions for Rational
Constructor functions for NRational
Rational specific typeclasses
class Unwrappable r => LorentzRational r Source #
Instances
Constructors
mkRational_ :: (forall s0. ErrInstr (("numerator" :! Integer, "denominator" :! Natural) ': s0)) -> (Integer ': (Natural ': s)) :-> (Rational ': s) Source #
numerator :: (LorentzRational r, Unwrappabled r ~ (a, Natural)) => (r ': s) :-> (a ': s) Source #
denominator :: (LorentzRational r, Unwrappabled r ~ (a, Natural)) => (r ': s) :-> (Natural ': s) Source #
constructRational :: (LorentzRational r, Unwrappabled r ~ (a, Natural)) => (a ': (Natural ': s)) :-> (r ': s) Source #
deconstructRational :: (LorentzRational r, Unwrappabled r ~ (a, Natural)) => (r ': s) :-> (a ': (Natural ': s)) Source #
uncheckedPairToRational :: (LorentzRational r, Unwrappabled r ~ (a, Natural)) => ((a, Natural) ': s) :-> (r ': s) Source #
unsafePairToRational :: (LorentzRational r, Unwrappabled r ~ (a, Natural)) => ((a, Natural) ': s) :-> (r ': s) Source #
pairToRational :: (LorentzRational r, Unwrappabled r ~ (a, Natural), KnownValue r) => ((a, Natural) ': s) :-> (Maybe r ': s) Source #
Orphan instances
CustomErrorHasDoc "zero_denominator" Source # | |
(LorentzRational r, Unwrappabled r ~ (a, Natural), ArithOpHs EDiv a Natural (Maybe (a, Natural)), ArithOpHs Add a Natural a, ArithOpHs Add Natural a a) => LorentzRounding r a Source # | |