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

Modulerebase-1.21.2Haskell2010

Rebase.GHC.Real

  • 3 types
  • 4 classes
  • 36 values
  • Packagerebase-1.21.2
  • Exports43
  • LanguageHaskell2010
  • LicenceMIT
  • SourceReal.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.

Constructors

Instances17NFData1, Lift, Enum, Eq, Fractional, Data, …
classclass (Num a, Ord a) => Real a where
#

Real numbers.

The Haskell report defines no laws for Real, however Real instances are customarily expected to adhere to the following law:

Coherence with fromRational

if the type also implements

Fractional

, then

fromRational

is a left inverse for

toRational

, i.e.

fromRational (toRational i) = i

The law does not hold for Float, Double, CFloat, CDouble, etc., because these types contain non-finite values, which cannot be roundtripped through Rational.

Methods

Instances77Real, …
  • Real IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Real NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Real CBoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CClockDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CLLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CPtrdiffDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CSCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CSUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CSigAtomicDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CTimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CUCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CUIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CUIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CUIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CULLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CULongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CUShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CWcharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Real WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Real Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Real Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Real Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Real Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Real CBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CBlkSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CCcDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CClockIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CDevDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CFsBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CFsFilCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CGidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CInoDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CModeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CNfdsDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CNlinkDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real COffDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CPidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CRLimDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CSocklenDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CSpeedDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CSsizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CTcflagDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CUidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real FdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Real Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Real Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Real Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Real DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    Beware that toRational generates garbage for non-finite arguments:

    Example2 expressions
    toRational (1/0)179769313 (and 300 more digits...) % 1toRational (0/0)269653970 (and 300 more digits...) % 1
  • Real FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    Beware that toRational generates garbage for non-finite arguments:

    Example2 expressions
    toRational (1/0 :: Float)340282366920938463463374607431768211456 % 1toRational (0/0 :: Float)510423550381407695195061911147652317184 % 1
  • Real IntDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Real WordDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Real CardinalityDefined in random-1.2.1.3 · System.Random.GFinite

    This is needed only as a superclass of Integral.

  • Real ScientificDefined in scientific-0.3.8.0 · Data.Scientific

    WARNING: toRational needs to compute the Integer magnitude: 10^e. If applied to a huge exponent this could fill up all space and crash your program!

    Avoid applying toRational (or realToFrac) to scientific numbers coming from an untrusted source and use toRealFloat instead. The latter guards against excessive space usage.

  • Real I8Defined in text-2.1.3 · Data.Text.Foreign
  • Real DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Real NominalDiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.NominalDiffTime
  • Integral a => Real (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Real a => Real (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Real a => Real (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • HasResolution a => Real (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • Real a => Real (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Real a => Real (Tagged s a)Defined in tagged-0.8.9 · Data.Tagged
  • Real (f (g a)) => Real (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
classclass (Real a, Enum a) => Integral a where
#

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.

Methods

  • quot :: a -> a -> ainfixl 7

    Integer division truncated toward zero.

    WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.

  • rem :: a -> a -> ainfixl 7

    Integer remainder, satisfying

    (x `quot` y)*y + (x `rem` y) == x

    WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.

  • div :: a -> a -> ainfixl 7

    Integer division truncated toward negative infinity.

    WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.

  • mod :: a -> a -> ainfixl 7

    Integer modulus, satisfying

    (x `div` y)*y + (x `mod` y) == x

    WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.

  • quotRem :: a -> a -> (a, a)

    Simultaneous quot and rem.

    WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.

  • divMod :: a -> a -> (a, a)

    simultaneous div and mod.

    WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.

  • toInteger :: a -> Integer

    Conversion to Integer.

Instances61Integral, …
  • Integral IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Integral NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Integral CBoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CLLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CPtrdiffDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CSCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CSigAtomicDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CUCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CUIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CUIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CUIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CULLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CULongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CUShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CWcharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Integral WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Integral Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Integral Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Integral Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Integral Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Integral CBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CBlkSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CClockIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CDevDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CFsBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CFsFilCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CGidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CInoDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CModeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CNfdsDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CNlinkDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral COffDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CPidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CRLimDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CSocklenDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CSsizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CTcflagDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CUidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral FdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Integral Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Integral Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Integral Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Integral IntDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Integral WordDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Integral CardinalityDefined in random-1.2.1.3 · System.Random.GFinite
  • Integral I8Defined in text-2.1.3 · Data.Text.Foreign
  • Integral a => Integral (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Integral a => Integral (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Integral a => Integral (Tagged s a)Defined in tagged-0.8.9 · Data.Tagged
  • Integral (f (g a)) => Integral (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
valuerealToFrac :: (Real a, Fractional b) => a -> b
#

General coercion to Fractional types.

WARNING: This function goes through the Rational type, which does not have values for NaN for example. This means it does not round-trip.

For Double it also behaves differently with or without -O0:

Prelude> realToFrac nan -- With -O0
-Infinity
Prelude> realToFrac nan
NaN
valuefromIntegral :: (Integral a, Num b) => a -> b
#

General coercion from Integral types.

WARNING: This function performs silent truncation if the result type is not at least as big as the argument's type.

classclass Num a => Fractional a where
#

Fractional numbers, supporting real division.

The Haskell Report defines no laws for Fractional. However, (+) and (*) are customarily expected to define a division ring and have the following properties:

recip gives the multiplicative inverse

x * recip x

=

recip x * x

=

fromInteger 1

Totality of toRational

toRational

is total

Coherence with toRational

if the type also implements

Real

, then

fromRational

is a left inverse for

toRational

, i.e.

fromRational (toRational i) = i

Note that it isn't customarily expected that a type instance of Fractional implement a field. However, all instances in base do.

Methods

Instances16Fractional, …
  • Fractional CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Fractional CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Fractional DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    This instance implements IEEE 754 standard with all its usual pitfalls about NaN, infinities and negative zero.

    Example4 expressions
    0 == (-0 :: Double)Truerecip 0 == recip (-0 :: Double)Falsemap (/ 0) [-1, 0, 1][-Infinity,NaN,Infinity]map (* 0) $ map (/ 0) [-1, 0, 1][NaN,NaN,NaN]
  • Fractional FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    This instance implements IEEE 754 standard with all its usual pitfalls about NaN, infinities and negative zero.

    Example4 expressions
    0 == (-0 :: Float)Truerecip 0 == recip (-0 :: Float)Falsemap (/ 0) [-1, 0, 1 :: Float][-Infinity,NaN,Infinity]map (* 0) $ map (/ 0) [-1, 0, 1 :: Float][NaN,NaN,NaN]
  • Fractional ScientificDefined in scientific-0.3.8.0 · Data.Scientific

    WARNING: recip and / will throw an error when their outputs are repeating decimals.

    These methods also compute Integer magnitudes (10^e). If these methods are applied to arguments which have huge exponents this could fill up all space and crash your program! So don't apply these methods to scientific numbers coming from untrusted sources.

    fromRational will throw an error when the input Rational is a repeating decimal. Consider using fromRationalRepetend for these rationals which will detect the repetition and indicate where it starts.

  • Fractional DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • Fractional NominalDiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.NominalDiffTime
  • RealFloat a => Fractional (Complex a)Defined in base-4.20.2.0 · Data.Complex
  • Fractional a => Fractional (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Fractional a => Fractional (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • Integral a => Fractional (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • HasResolution a => Fractional (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • Fractional a => Fractional (Op a b)Defined in base-4.20.2.0 · Data.Functor.Contravariant
  • Fractional a => Fractional (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Fractional a => Fractional (Tagged s a)Defined in tagged-0.8.9 · Data.Tagged
  • Fractional (f (g a)) => Fractional (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
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.

classclass (Real a, Fractional a) => RealFrac a where
#

Extracting components of fractions.

Methods

Instances14RealFrac, …
  • RealFrac CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • RealFrac CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • RealFrac DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    Beware that results for non-finite arguments are garbage:

    Example2 expressions
    [ f x | f <- [round, floor, ceiling], x <- [-1/0, 0/0, 1/0] ] :: [Int][0,0,0,0,0,0,0,0,0]map properFraction [-1/0, 0/0, 1/0] :: [(Int, Double)][(0,0.0),(0,0.0),(0,0.0)]

    and get even more non-sensical if you ask for Integer instead of Int.

  • RealFrac FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    Beware that results for non-finite arguments are garbage:

    Example2 expressions
    [ f x | f <- [round, floor, ceiling], x <- [-1/0, 0/0, 1/0 :: Float] ] :: [Int][0,0,0,0,0,0,0,0,0]map properFraction [-1/0, 0/0, 1/0] :: [(Int, Float)][(0,0.0),(0,0.0),(0,0.0)]

    and get even more non-sensical if you ask for Integer instead of Int.

  • RealFrac ScientificDefined in scientific-0.3.8.0 · Data.Scientific

    WARNING: the methods of the RealFrac instance need to compute the magnitude 10^e. If applied to a huge exponent this could take a long time. Even worse, when the destination type is unbounded (i.e. Integer) it could fill up all space and crash your program!

  • RealFrac DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTime
  • RealFrac NominalDiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.NominalDiffTime
  • Integral a => RealFrac (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • RealFrac a => RealFrac (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • RealFrac a => RealFrac (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • HasResolution a => RealFrac (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • RealFrac a => RealFrac (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • RealFrac a => RealFrac (Tagged s a)Defined in tagged-0.8.9 · Data.Tagged
  • RealFrac (f (g a)) => RealFrac (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
value(^) :: (Num a, Integral b) => a -> b -> a
#

raise a number to a non-negative integral power

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.

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.

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

Forms the ratio of two integral numbers.

valuegcd :: Integral a => a -> a -> a
#

gcd x y is the non-negative factor of both x and y of which every common factor of x and y is also a factor; for example gcd 4 2 = 2, gcd (-4) 6 = 2, gcd 0 4 = 4. gcd 0 0 = 0. (That is, the common divisor that is "greatest" in the divisibility preordering.)

Note: Since for signed fixed-width integer types, abs minBound < 0, the result may be negative if one of the arguments is minBound (and necessarily is if the other is 0 or minBound) for such types.

valuelcm :: Integral a => a -> a -> a
#

lcm x y is the smallest positive integer that both x and y divide.

valuereduce :: Integral a => a -> a -> Ratio a
#

reduce is a subsidiary function used only in this module. It normalises a ratio by dividing both numerator and denominator by their greatest common divisor.

valueshowSigned
  1. :: Real a
  2. => (a -> ShowS)

    a function that can show unsigned values

  3. -> Int

    the precedence of the enclosing context

  4. -> a

    the value to show

  5. -> ShowS
#

Converts a possibly-negative Real value to a string.