Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module introduces Rat
kind and all necessary functional.
Synopsis
- data Rat = Nat ::% Nat
- type (:%) = (::%)
- type family (m :: Nat) % (n :: Nat) :: Rat where ...
- type family (a :: k1) * (b :: k2) :: MulK k1 k2
- type family (a :: k1) / (b :: k2) :: DivK k1 k2
- type family MulK (k1 :: Type) (k2 :: Type) :: Type
- type family DivK (k1 :: Type) (k2 :: Type) :: Type
- type family Gcd (m :: Nat) (n :: Nat) :: Nat where ...
- type family Normalize (r :: Rat) :: Rat where ...
- type family DivRat (m :: Rat) (n :: Rat) :: Rat where ...
- type family (m :: Rat) >=% (n :: Rat) :: Bool where ...
- type RatioNat = Ratio Natural
- class KnownRat (r :: Rat) where
- withRuntimeDivRat :: forall (a :: Rat) (b :: Rat) r. (KnownRat a, KnownRat b) => (KnownRat (a / b) => r) -> r
- type KnownDivRat a b = (KnownRat a, KnownRat b, KnownRat (a / b))
Documentation
Data structure represents the rational number.
Rational number can be represented as a pair of
natural numbers n
and m
where m
is nor equal
to zero.
Instances
SeriesP ([] :: [Rat]) Source # | |
Defined in Time.Series | |
SeriesF ([] :: [Rat]) Source # | |
Defined in Time.Series | |
(KnownRatName unit, SeriesP (nextUnit ': units), DescendingConstraint (IsDescending (unit ': (nextUnit ': units)))) => SeriesP (unit ': (nextUnit ': units)) Source # | |
Defined in Time.Series | |
KnownRatName unit => SeriesP (unit ': ([] :: [Rat])) Source # | |
Defined in Time.Series | |
(KnownRatName unit, SeriesF (nextUnit ': units), DescendingConstraint (IsDescending (unit ': (nextUnit ': units)))) => SeriesF (unit ': (nextUnit ': units)) Source # | |
Defined in Time.Series | |
KnownRatName unit => SeriesF (unit ': ([] :: [Rat])) Source # | |
Defined in Time.Series | |
type DivK Nat Rat Source # | |
Defined in Time.Rational | |
type DivK Rat Nat Source # | |
Defined in Time.Rational | |
type DivK Rat Rat Source # | |
Defined in Time.Rational | |
type MulK Nat Rat Source # | |
Defined in Time.Rational | |
type MulK Rat Nat Source # | |
Defined in Time.Rational | |
type MulK Rat Rat Source # | |
Defined in Time.Rational | |
type (a :: Nat) / (b :: Rat) Source # | |
type (a :: Rat) / (b :: Nat) Source # | |
Defined in Time.Rational | |
type (a :: Rat) / (b :: Rat) Source # | |
Defined in Time.Rational | |
type (a :: Nat) * (b :: Rat) Source # | |
Defined in Time.Rational | |
type (a :: Rat) * (b :: Nat) Source # | |
Defined in Time.Rational | |
type (a :: Rat) * (b :: Rat) Source # | |
Defined in Time.Rational |
type family (a :: k1) * (b :: k2) :: MulK k1 k2 Source #
Overloaded multiplication.
type family (a :: k1) / (b :: k2) :: DivK k1 k2 Source #
Overloaded division.
type family MulK (k1 :: Type) (k2 :: Type) :: Type Source #
The result kind of overloaded multiplication.
type family DivK (k1 :: Type) (k2 :: Type) :: Type Source #
The result kind of overloaded division.
type family Gcd (m :: Nat) (n :: Nat) :: Nat where ... Source #
Greatest common divisor for type-level naturals.
Example:
>>>
:kind! Gcd 9 11
Gcd 9 11 :: Nat = 1
>>>
:kind! Gcd 9 12
Gcd 9 12 :: Nat = 3
type family Normalize (r :: Rat) :: Rat where ... Source #
Normalization of type-level rational.
Example:
>>>
:kind! Normalize (9 % 11)
Normalize (9 % 11) :: Rat = 9 :% 11
>>>
:kind! Normalize (9 % 12)
Normalize (9 % 12) :: Rat = 3 :% 4
type family DivRat (m :: Rat) (n :: Rat) :: Rat where ... Source #
type family (m :: Rat) >=% (n :: Rat) :: Bool where ... infix 4 Source #
Comparison of type-level rationals, as a function.
>>>
:kind! (1 :% 42) >=% (5 :% 42)
(1 :% 42) >=% (5 :% 42) :: Bool = 'False
>>>
:kind! (5 :% 42) >=% (1 :% 42)
(5 :% 42) >=% (1 :% 42) :: Bool = 'True
>>>
:kind! (42 :% 1) >=% (42 :% 1)
(42 :% 1) >=% (42 :% 1) :: Bool = 'True
type RatioNat = Ratio Natural Source #
Rational numbers, with numerator and denominator of Natural
type.
class KnownRat (r :: Rat) where Source #
This class gives the integer associated with a type-level rational.