HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulebase-4.20.2.0Haskell2010

Data.Ratio

Standard functions on rational numbers

  • 2 types
  • 4 values
  • Packagebase-4.20.2.0
  • Exports6
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceRatio.hs
datadata Ratio a
#

Rational numbers, with numerator and denominator of some Integral type.

Note that Ratio's instances inherit the deficiencies from the type parameter's. For example, Ratio Natural's Num instance has similar problems to Numeric.Natural.Natural's.

Instances11Enum, Eq, Fractional, Data, Num, Ord, …
typetype Rational = Ratio Integer
#

Arbitrary-precision rational numbers, represented as a ratio of two Integer values. A rational number may be constructed using the % operator.

value(%) :: Integral a => a -> a -> Ratio a
#

Forms the ratio of two integral numbers.

valuenumerator :: Ratio a -> a
#

Extract the numerator of the ratio in reduced form: the numerator and denominator have no common factor and the denominator is positive.

valuedenominator :: Ratio a -> a
#

Extract the denominator of the ratio in reduced form: the numerator and denominator have no common factor and the denominator is positive.