GHC.Real

base-4.13.0.0: Basic libraries

Copyright | (c) The University of Glasgow 1994-2002
License | see libraries/base/LICENSE
Maintainer | cvs-ghc@haskell.org
Stability | internal
Portability | non-portable (GHC Extensions)
Safe Haskell | Trustworthy
Language | Haskell2010

GHC.Real

Description

The types `Ratio` and `Rational`, and the classes `Real`, `Fractional`, `Integral`, and `RealFrac`.

Synopsis

- divZeroError :: a
- ratioZeroDenominatorError :: a
- overflowError :: a
- underflowError :: a
- data Ratio a = !a :% !a
- type Rational = Ratio Integer
- ratioPrec :: Int
- ratioPrec1 :: Int
- infinity :: Rational
- notANumber :: Rational
- (%) :: Integral a => a -> a -> Ratio a
- numerator :: Ratio a -> a
- denominator :: Ratio a -> a
- reduce :: Integral a => a -> a -> Ratio a
- class (Num a, Ord a) => Real a where
  - toRational :: a -> Rational
- class (Real a, Enum a) => Integral a where
  - quot :: a -> a -> a
  - rem :: a -> a -> a
  - div :: a -> a -> a
  - mod :: a -> a -> a
  - quotRem :: a -> a -> (a, a)
  - divMod :: a -> a -> (a, a)
  - toInteger :: a -> Integer
- class Num a => Fractional a where
  - (/) :: a -> a -> a
  - recip :: a -> a
  - fromRational :: Rational -> a
- class (Real a, Fractional a) => RealFrac a where
  - properFraction :: Integral b => a -> (b, a)
  - truncate :: Integral b => a -> b
  - round :: Integral b => a -> b
  - ceiling :: Integral b => a -> b
  - floor :: Integral b => a -> b
- numericEnumFrom :: Fractional a => a -> [a]
- numericEnumFromThen :: Fractional a => a -> a -> [a]
- numericEnumFromTo :: (Ord a, Fractional a) => a -> a -> [a]
- numericEnumFromThenTo :: (Ord a, Fractional a) => a -> a -> a -> [a]
- fromIntegral :: (Integral a, Num b) => a -> b
- realToFrac :: (Real a, Fractional b) => a -> b
- showSigned :: Real a => (a -> ShowS) -> Int -> a -> ShowS
- even :: Integral a => a -> Bool
- odd :: Integral a => a -> Bool
- (^) :: (Num a, Integral b) => a -> b -> a
- (^^) :: (Fractional a, Integral b) => a -> b -> a
- (^%^) :: Integral a => Rational -> a -> Rational
- (^^%^^) :: Integral a => Rational -> a -> Rational
- gcd :: Integral a => a -> a -> a
- lcm :: Integral a => a -> a -> a
- gcdInt' :: Int -> Int -> Int
- gcdWord' :: Word -> Word -> Word
- integralEnumFrom :: (Integral a, Bounded a) => a -> [a]
- integralEnumFromThen :: (Integral a, Bounded a) => a -> a -> [a]
- integralEnumFromTo :: Integral a => a -> a -> [a]
- integralEnumFromThenTo :: Integral a => a -> a -> a -> [a]

# Documentation

divZeroError :: a Source #

ratioZeroDenominatorError :: a Source #

overflowError :: a Source #

underflowError :: a Source #

data Ratio a Source #

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 `Natural`'s.

Constructors

!a :% !a |

#### Instances

Instances details

Integral a => Enum (Ratio a) # | Since: base-2.0.1
Instance details Defined in GHC.Real Methods succ :: Ratio a -> Ratio a Source # pred :: Ratio a -> Ratio a Source # toEnum :: Int -> Ratio a Source # fromEnum :: Ratio a -> Int Source # enumFrom :: Ratio a -> [Ratio a] Source # enumFromThen :: Ratio a -> Ratio a -> [Ratio a] Source # enumFromTo :: Ratio a -> Ratio a -> [Ratio a] Source # enumFromThenTo :: Ratio a -> Ratio a -> Ratio a -> [Ratio a] Source #
Eq a => Eq (Ratio a) # | Since: base-2.1
Instance details Defined in GHC.Real Methods (==) :: Ratio a -> Ratio a -> Bool Source # (/=) :: Ratio a -> Ratio a -> Bool Source #
Integral a => Fractional (Ratio a) # | Since: base-2.0.1
Instance details Defined in GHC.Real Methods (/) :: Ratio a -> Ratio a -> Ratio a Source # recip :: Ratio a -> Ratio a Source # fromRational :: Rational -> Ratio a Source #
(Data a, Integral a) => Data (Ratio a) # | Since: base-4.0.0.0
Instance details Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Ratio a -> c (Ratio a) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Ratio a) Source # toConstr :: Ratio a -> Constr Source # dataTypeOf :: Ratio a -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Ratio a)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Ratio a)) Source # gmapT :: (forall b. Data b => b -> b) -> Ratio a -> Ratio a Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Ratio a -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Ratio a -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Ratio a -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Ratio a -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Ratio a -> m (Ratio a) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Ratio a -> m (Ratio a) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Ratio a -> m (Ratio a) Source #
Integral a => Num (Ratio a) # | Since: base-2.0.1
Instance details Defined in GHC.Real Methods (+) :: Ratio a -> Ratio a -> Ratio a Source # (-) :: Ratio a -> Ratio a -> Ratio a Source # (*) :: Ratio a -> Ratio a -> Ratio a Source # negate :: Ratio a -> Ratio a Source # abs :: Ratio a -> Ratio a Source # signum :: Ratio a -> Ratio a Source # fromInteger :: Integer -> Ratio a Source #
Integral a => Ord (Ratio a) # | Since: base-2.0.1
Instance details Defined in GHC.Real Methods compare :: Ratio a -> Ratio a -> Ordering Source # (<) :: Ratio a -> Ratio a -> Bool Source # (<=) :: Ratio a -> Ratio a -> Bool Source # (>) :: Ratio a -> Ratio a -> Bool Source # (>=) :: Ratio a -> Ratio a -> Bool Source # max :: Ratio a -> Ratio a -> Ratio a Source # min :: Ratio a -> Ratio a -> Ratio a Source #
(Integral a, Read a) => Read (Ratio a) # | Since: base-2.1
Instance details Defined in GHC.Read Methods readsPrec :: Int -> ReadS (Ratio a) Source # readList :: ReadS [Ratio a] Source # readPrec :: ReadPrec (Ratio a) Source # readListPrec :: ReadPrec [Ratio a] Source #
Integral a => Real (Ratio a) # | Since: base-2.0.1
Instance details Defined in GHC.Real Methods toRational :: Ratio a -> Rational Source #
Integral a => RealFrac (Ratio a) # | Since: base-2.0.1
Instance details Defined in GHC.Real Methods properFraction :: Integral b => Ratio a -> (b, Ratio a) Source # truncate :: Integral b => Ratio a -> b Source # round :: Integral b => Ratio a -> b Source # ceiling :: Integral b => Ratio a -> b Source # floor :: Integral b => Ratio a -> b Source #
Show a => Show (Ratio a) # | Since: base-2.0.1
Instance details Defined in GHC.Real Methods showsPrec :: Int -> Ratio a -> ShowS Source # show :: Ratio a -> String Source # showList :: [Ratio a] -> ShowS Source #
(Storable a, Integral a) => Storable (Ratio a) # | Since: base-4.8.0.0
Instance details Defined in Foreign.Storable Methods sizeOf :: Ratio a -> Int Source # alignment :: Ratio a -> Int Source # peekElemOff :: Ptr (Ratio a) -> Int -> IO (Ratio a) Source # pokeElemOff :: Ptr (Ratio a) -> Int -> Ratio a -> IO () Source # peekByteOff :: Ptr b -> Int -> IO (Ratio a) Source # pokeByteOff :: Ptr b -> Int -> Ratio a -> IO () Source # peek :: Ptr (Ratio a) -> IO (Ratio a) Source # poke :: Ptr (Ratio a) -> Ratio a -> IO () Source #

type Rational = Ratio Integer Source #

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

ratioPrec :: Int Source #

ratioPrec1 :: Int Source #

infinity :: Rational Source #

notANumber :: Rational Source #

(%) :: Integral a => a -> a -> Ratio a infixl 7 Source #

Forms the ratio of two integral numbers.

numerator :: Ratio a -> a Source #

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

denominator :: Ratio a -> a Source #

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

reduce :: Integral a => a -> a -> Ratio a Source #

`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.

class (Num a, Ord a) => Real a where Source #

Methods

toRational :: a -> Rational Source #

the rational equivalent of its real argument with full precision

#### Instances

Instances details

Real Double # | Since: base-2.1
Instance details Defined in GHC.Float Methods toRational :: Double -> Rational Source #
Real Float # | Since: base-2.1
Instance details Defined in GHC.Float Methods toRational :: Float -> Rational Source #
Real Int # | Since: base-2.0.1
Instance details Defined in GHC.Real Methods toRational :: Int -> Rational Source #
Real Int8 # | Since: base-2.1
Instance details Defined in GHC.Int Methods toRational :: Int8 -> Rational Source #
Real Int16 # | Since: base-2.1
Instance details Defined in GHC.Int Methods toRational :: Int16 -> Rational Source #
Real Int32 # | Since: base-2.1
Instance details Defined in GHC.Int Methods toRational :: Int32 -> Rational Source #
Real Int64 # | Since: base-2.1
Instance details Defined in GHC.Int Methods toRational :: Int64 -> Rational Source #
Real Integer # | Since: base-2.0.1
Instance details Defined in GHC.Real Methods toRational :: Integer -> Rational Source #
Real Natural # | Since: base-4.8.0.0
Instance details Defined in GHC.Real Methods toRational :: Natural -> Rational Source #
Real Word # | Since: base-2.1
Instance details Defined in GHC.Real Methods toRational :: Word -> Rational Source #
Real Word8 # | Since: base-2.1
Instance details Defined in GHC.Word Methods toRational :: Word8 -> Rational Source #
Real Word16 # | Since: base-2.1
Instance details Defined in GHC.Word Methods toRational :: Word16 -> Rational Source #
Real Word32 # | Since: base-2.1
Instance details Defined in GHC.Word Methods toRational :: Word32 -> Rational Source #
Real Word64 # | Since: base-2.1
Instance details Defined in GHC.Word Methods toRational :: Word64 -> Rational Source #
Real IntPtr # |
Instance details Defined in Foreign.Ptr Methods toRational :: IntPtr -> Rational Source #
Real WordPtr # |
Instance details Defined in Foreign.Ptr Methods toRational :: WordPtr -> Rational Source #
Real CUIntMax # |
Instance details Defined in Foreign.C.Types Methods toRational :: CUIntMax -> Rational Source #
Real CIntMax # |
Instance details Defined in Foreign.C.Types Methods toRational :: CIntMax -> Rational Source #
Real CUIntPtr # |
Instance details Defined in Foreign.C.Types Methods toRational :: CUIntPtr -> Rational Source #
Real CIntPtr # |
Instance details Defined in Foreign.C.Types Methods toRational :: CIntPtr -> Rational Source #
Real CSUSeconds # |
Instance details Defined in Foreign.C.Types Methods toRational :: CSUSeconds -> Rational Source #
Real CUSeconds # |
Instance details Defined in Foreign.C.Types Methods toRational :: CUSeconds -> Rational Source #
Real CTime # |
Instance details Defined in Foreign.C.Types Methods toRational :: CTime -> Rational Source #
Real CClock # |
Instance details Defined in Foreign.C.Types Methods toRational :: CClock -> Rational Source #
Real CSigAtomic # |
Instance details Defined in Foreign.C.Types Methods toRational :: CSigAtomic -> Rational Source #
Real CWchar # |
Instance details Defined in Foreign.C.Types Methods toRational :: CWchar -> Rational Source #
Real CSize # |
Instance details Defined in Foreign.C.Types Methods toRational :: CSize -> Rational Source #
Real CPtrdiff # |
Instance details Defined in Foreign.C.Types Methods toRational :: CPtrdiff -> Rational Source #
Real CDouble # |
Instance details Defined in Foreign.C.Types Methods toRational :: CDouble -> Rational Source #
Real CFloat # |
Instance details Defined in Foreign.C.Types Methods toRational :: CFloat -> Rational Source #
Real CBool # |
Instance details Defined in Foreign.C.Types Methods toRational :: CBool -> Rational Source #
Real CULLong # |
Instance details Defined in Foreign.C.Types Methods toRational :: CULLong -> Rational Source #
Real CLLong # |
Instance details Defined in Foreign.C.Types Methods toRational :: CLLong -> Rational Source #
Real CULong # |
Instance details Defined in Foreign.C.Types Methods toRational :: CULong -> Rational Source #
Real CLong # |
Instance details Defined in Foreign.C.Types Methods toRational :: CLong -> Rational Source #
Real CUInt # |
Instance details Defined in Foreign.C.Types Methods toRational :: CUInt -> Rational Source #
Real CInt # |
Instance details Defined in Foreign.C.Types Methods toRational :: CInt -> Rational Source #
Real CUShort # |
Instance details Defined in Foreign.C.Types Methods toRational :: CUShort -> Rational Source #
Real CShort # |
Instance details Defined in Foreign.C.Types Methods toRational :: CShort -> Rational Source #
Real CUChar # |
Instance details Defined in Foreign.C.Types Methods toRational :: CUChar -> Rational Source #
Real CSChar # |
Instance details Defined in Foreign.C.Types Methods toRational :: CSChar -> Rational Source #
Real CChar # |
Instance details Defined in Foreign.C.Types Methods toRational :: CChar -> Rational Source #
Real Fd # |
Instance details Defined in System.Posix.Types Methods toRational :: Fd -> Rational Source #
Real CKey # |
Instance details Defined in System.Posix.Types Methods toRational :: CKey -> Rational Source #
Real CId # |
Instance details Defined in System.Posix.Types Methods toRational :: CId -> Rational Source #
Real CFsFilCnt # |
Instance details Defined in System.Posix.Types Methods toRational :: CFsFilCnt -> Rational Source #
Real CFsBlkCnt # |
Instance details Defined in System.Posix.Types Methods toRational :: CFsBlkCnt -> Rational Source #
Real CClockId # |
Instance details Defined in System.Posix.Types Methods toRational :: CClockId -> Rational Source #
Real CBlkCnt # |
Instance details Defined in System.Posix.Types Methods toRational :: CBlkCnt -> Rational Source #
Real CBlkSize # |
Instance details Defined in System.Posix.Types Methods toRational :: CBlkSize -> Rational Source #
Real CRLim # |
Instance details Defined in System.Posix.Types Methods toRational :: CRLim -> Rational Source #
Real CTcflag # |
Instance details Defined in System.Posix.Types Methods toRational :: CTcflag -> Rational Source #
Real CSpeed # |
Instance details Defined in System.Posix.Types Methods toRational :: CSpeed -> Rational Source #
Real CCc # |
Instance details Defined in System.Posix.Types Methods toRational :: CCc -> Rational Source #
Real CUid # |
Instance details Defined in System.Posix.Types Methods toRational :: CUid -> Rational Source #
Real CNlink # |
Instance details Defined in System.Posix.Types Methods toRational :: CNlink -> Rational Source #
Real CGid # |
Instance details Defined in System.Posix.Types Methods toRational :: CGid -> Rational Source #
Real CSsize # |
Instance details Defined in System.Posix.Types Methods toRational :: CSsize -> Rational Source #
Real CPid # |
Instance details Defined in System.Posix.Types Methods toRational :: CPid -> Rational Source #
Real COff # |
Instance details Defined in System.Posix.Types Methods toRational :: COff -> Rational Source #
Real CMode # |
Instance details Defined in System.Posix.Types Methods toRational :: CMode -> Rational Source #
Real CIno # |
Instance details Defined in System.Posix.Types Methods toRational :: CIno -> Rational Source #
Real CDev # |
Instance details Defined in System.Posix.Types Methods toRational :: CDev -> Rational Source #
Integral a => Real (Ratio a) # | Since: base-2.0.1
Instance details Defined in GHC.Real Methods toRational :: Ratio a -> Rational Source #
Real a => Real (Identity a) # | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Identity Methods toRational :: Identity a -> Rational Source #
HasResolution a => Real (Fixed a) # | Since: base-2.1
Instance details Defined in Data.Fixed Methods toRational :: Fixed a -> Rational Source #
Real a => Real (Const a b) # | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Const Methods toRational :: Const a b -> Rational Source #

class (Real a, Enum a) => Integral a where Source #

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`.

Minimal complete definition

quotRem, toInteger

Methods

quot :: a -> a -> a infixl 7 Source #

integer division truncated toward zero

rem :: a -> a -> a infixl 7 Source #

integer remainder, satisfying

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

div :: a -> a -> a infixl 7 Source #

integer division truncated toward negative infinity

mod :: a -> a -> a infixl 7 Source #

integer modulus, satisfying

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

quotRem :: a -> a -> (a, a) Source #

simultaneous `quot` and `rem`

divMod :: a -> a -> (a, a) Source #

simultaneous `div` and `mod`

toInteger :: a -> Integer Source #

conversion to `Integer`

#### Instances

Instances details

Integral Int # | Since: base-2.0.1
Instance details Defined in GHC.Real Methods quot :: Int -> Int -> Int Source # rem :: Int -> Int -> Int Source # div :: Int -> Int -> Int Source # mod :: Int -> Int -> Int Source # quotRem :: Int -> Int -> (Int, Int) Source # divMod :: Int -> Int -> (Int, Int) Source # toInteger :: Int -> Integer Source #
Integral Int8 # | Since: base-2.1
Instance details Defined in GHC.Int Methods quot :: Int8 -> Int8 -> Int8 Source # rem :: Int8 -> Int8 -> Int8 Source # div :: Int8 -> Int8 -> Int8 Source # mod :: Int8 -> Int8 -> Int8 Source # quotRem :: Int8 -> Int8 -> (Int8, Int8) Source # divMod :: Int8 -> Int8 -> (Int8, Int8) Source # toInteger :: Int8 -> Integer Source #
Integral Int16 # | Since: base-2.1
Instance details Defined in GHC.Int Methods quot :: Int16 -> Int16 -> Int16 Source # rem :: Int16 -> Int16 -> Int16 Source # div :: Int16 -> Int16 -> Int16 Source # mod :: Int16 -> Int16 -> Int16 Source # quotRem :: Int16 -> Int16 -> (Int16, Int16) Source # divMod :: Int16 -> Int16 -> (Int16, Int16) Source # toInteger :: Int16 -> Integer Source #
Integral Int32 # | Since: base-2.1
Instance details Defined in GHC.Int Methods quot :: Int32 -> Int32 -> Int32 Source # rem :: Int32 -> Int32 -> Int32 Source # div :: Int32 -> Int32 -> Int32 Source # mod :: Int32 -> Int32 -> Int32 Source # quotRem :: Int32 -> Int32 -> (Int32, Int32) Source # divMod :: Int32 -> Int32 -> (Int32, Int32) Source # toInteger :: Int32 -> Integer Source #
Integral Int64 # | Since: base-2.1
Instance details Defined in GHC.Int Methods quot :: Int64 -> Int64 -> Int64 Source # rem :: Int64 -> Int64 -> Int64 Source # div :: Int64 -> Int64 -> Int64 Source # mod :: Int64 -> Int64 -> Int64 Source # quotRem :: Int64 -> Int64 -> (Int64, Int64) Source # divMod :: Int64 -> Int64 -> (Int64, Int64) Source # toInteger :: Int64 -> Integer Source #
Integral Integer # | Since: base-2.0.1
Instance details Defined in GHC.Real Methods quot :: Integer -> Integer -> Integer Source # rem :: Integer -> Integer -> Integer Source # div :: Integer -> Integer -> Integer Source # mod :: Integer -> Integer -> Integer Source # quotRem :: Integer -> Integer -> (Integer, Integer) Source # divMod :: Integer -> Integer -> (Integer, Integer) Source # toInteger :: Integer -> Integer Source #
Integral Natural # | Since: base-4.8.0.0
Instance details Defined in GHC.Real Methods quot :: Natural -> Natural -> Natural Source # rem :: Natural -> Natural -> Natural Source # div :: Natural -> Natural -> Natural Source # mod :: Natural -> Natural -> Natural Source # quotRem :: Natural -> Natural -> (Natural, Natural) Source # divMod :: Natural -> Natural -> (Natural, Natural) Source # toInteger :: Natural -> Integer Source #
Integral Word # | Since: base-2.1
Instance details Defined in GHC.Real Methods quot :: Word -> Word -> Word Source # rem :: Word -> Word -> Word Source # div :: Word -> Word -> Word Source # mod :: Word -> Word -> Word Source # quotRem :: Word -> Word -> (Word, Word) Source # divMod :: Word -> Word -> (Word, Word) Source # toInteger :: Word -> Integer Source #
Integral Word8 # | Since: base-2.1
Instance details Defined in GHC.Word Methods quot :: Word8 -> Word8 -> Word8 Source # rem :: Word8 -> Word8 -> Word8 Source # div :: Word8 -> Word8 -> Word8 Source # mod :: Word8 -> Word8 -> Word8 Source # quotRem :: Word8 -> Word8 -> (Word8, Word8) Source # divMod :: Word8 -> Word8 -> (Word8, Word8) Source # toInteger :: Word8 -> Integer Source #
Integral Word16 # | Since: base-2.1
Instance details Defined in GHC.Word Methods quot :: Word16 -> Word16 -> Word16 Source # rem :: Word16 -> Word16 -> Word16 Source # div :: Word16 -> Word16 -> Word16 Source # mod :: Word16 -> Word16 -> Word16 Source # quotRem :: Word16 -> Word16 -> (Word16, Word16) Source # divMod :: Word16 -> Word16 -> (Word16, Word16) Source # toInteger :: Word16 -> Integer Source #
Integral Word32 # | Since: base-2.1
Instance details Defined in GHC.Word Methods quot :: Word32 -> Word32 -> Word32 Source # rem :: Word32 -> Word32 -> Word32 Source # div :: Word32 -> Word32 -> Word32 Source # mod :: Word32 -> Word32 -> Word32 Source # quotRem :: Word32 -> Word32 -> (Word32, Word32) Source # divMod :: Word32 -> Word32 -> (Word32, Word32) Source # toInteger :: Word32 -> Integer Source #
Integral Word64 # | Since: base-2.1
Instance details Defined in GHC.Word Methods quot :: Word64 -> Word64 -> Word64 Source # rem :: Word64 -> Word64 -> Word64 Source # div :: Word64 -> Word64 -> Word64 Source # mod :: Word64 -> Word64 -> Word64 Source # quotRem :: Word64 -> Word64 -> (Word64, Word64) Source # divMod :: Word64 -> Word64 -> (Word64, Word64) Source # toInteger :: Word64 -> Integer Source #
Integral IntPtr # |
Instance details Defined in Foreign.Ptr Methods quot :: IntPtr -> IntPtr -> IntPtr Source # rem :: IntPtr -> IntPtr -> IntPtr Source # div :: IntPtr -> IntPtr -> IntPtr Source # mod :: IntPtr -> IntPtr -> IntPtr Source # quotRem :: IntPtr -> IntPtr -> (IntPtr, IntPtr) Source # divMod :: IntPtr -> IntPtr -> (IntPtr, IntPtr) Source # toInteger :: IntPtr -> Integer Source #
Integral WordPtr # |
Instance details Defined in Foreign.Ptr Methods quot :: WordPtr -> WordPtr -> WordPtr Source # rem :: WordPtr -> WordPtr -> WordPtr Source # div :: WordPtr -> WordPtr -> WordPtr Source # mod :: WordPtr -> WordPtr -> WordPtr Source # quotRem :: WordPtr -> WordPtr -> (WordPtr, WordPtr) Source # divMod :: WordPtr -> WordPtr -> (WordPtr, WordPtr) Source # toInteger :: WordPtr -> Integer Source #
Integral CUIntMax # |
Instance details Defined in Foreign.C.Types Methods quot :: CUIntMax -> CUIntMax -> CUIntMax Source # rem :: CUIntMax -> CUIntMax -> CUIntMax Source # div :: CUIntMax -> CUIntMax -> CUIntMax Source # mod :: CUIntMax -> CUIntMax -> CUIntMax Source # quotRem :: CUIntMax -> CUIntMax -> (CUIntMax, CUIntMax) Source # divMod :: CUIntMax -> CUIntMax -> (CUIntMax, CUIntMax) Source # toInteger :: CUIntMax -> Integer Source #
Integral CIntMax # |
Instance details Defined in Foreign.C.Types Methods quot :: CIntMax -> CIntMax -> CIntMax Source # rem :: CIntMax -> CIntMax -> CIntMax Source # div :: CIntMax -> CIntMax -> CIntMax Source # mod :: CIntMax -> CIntMax -> CIntMax Source # quotRem :: CIntMax -> CIntMax -> (CIntMax, CIntMax) Source # divMod :: CIntMax -> CIntMax -> (CIntMax, CIntMax) Source # toInteger :: CIntMax -> Integer Source #
Integral CUIntPtr # |
Instance details Defined in Foreign.C.Types Methods quot :: CUIntPtr -> CUIntPtr -> CUIntPtr Source # rem :: CUIntPtr -> CUIntPtr -> CUIntPtr Source # div :: CUIntPtr -> CUIntPtr -> CUIntPtr Source # mod :: CUIntPtr -> CUIntPtr -> CUIntPtr Source # quotRem :: CUIntPtr -> CUIntPtr -> (CUIntPtr, CUIntPtr) Source # divMod :: CUIntPtr -> CUIntPtr -> (CUIntPtr, CUIntPtr) Source # toInteger :: CUIntPtr -> Integer Source #
Integral CIntPtr # |
Instance details Defined in Foreign.C.Types Methods quot :: CIntPtr -> CIntPtr -> CIntPtr Source # rem :: CIntPtr -> CIntPtr -> CIntPtr Source # div :: CIntPtr -> CIntPtr -> CIntPtr Source # mod :: CIntPtr -> CIntPtr -> CIntPtr Source # quotRem :: CIntPtr -> CIntPtr -> (CIntPtr, CIntPtr) Source # divMod :: CIntPtr -> CIntPtr -> (CIntPtr, CIntPtr) Source # toInteger :: CIntPtr -> Integer Source #
Integral CSigAtomic # |
Instance details Defined in Foreign.C.Types Methods quot :: CSigAtomic -> CSigAtomic -> CSigAtomic Source # rem :: CSigAtomic -> CSigAtomic -> CSigAtomic Source # div :: CSigAtomic -> CSigAtomic -> CSigAtomic Source # mod :: CSigAtomic -> CSigAtomic -> CSigAtomic Source # quotRem :: CSigAtomic -> CSigAtomic -> (CSigAtomic, CSigAtomic) Source # divMod :: CSigAtomic -> CSigAtomic -> (CSigAtomic, CSigAtomic) Source # toInteger :: CSigAtomic -> Integer Source #
Integral CWchar # |
Instance details Defined in Foreign.C.Types Methods quot :: CWchar -> CWchar -> CWchar Source # rem :: CWchar -> CWchar -> CWchar Source # div :: CWchar -> CWchar -> CWchar Source # mod :: CWchar -> CWchar -> CWchar Source # quotRem :: CWchar -> CWchar -> (CWchar, CWchar) Source # divMod :: CWchar -> CWchar -> (CWchar, CWchar) Source # toInteger :: CWchar -> Integer Source #
Integral CSize # |
Instance details Defined in Foreign.C.Types Methods quot :: CSize -> CSize -> CSize Source # rem :: CSize -> CSize -> CSize Source # div :: CSize -> CSize -> CSize Source # mod :: CSize -> CSize -> CSize Source # quotRem :: CSize -> CSize -> (CSize, CSize) Source # divMod :: CSize -> CSize -> (CSize, CSize) Source # toInteger :: CSize -> Integer Source #
Integral CPtrdiff # |
Instance details Defined in Foreign.C.Types Methods quot :: CPtrdiff -> CPtrdiff -> CPtrdiff Source # rem :: CPtrdiff -> CPtrdiff -> CPtrdiff Source # div :: CPtrdiff -> CPtrdiff -> CPtrdiff Source # mod :: CPtrdiff -> CPtrdiff -> CPtrdiff Source # quotRem :: CPtrdiff -> CPtrdiff -> (CPtrdiff, CPtrdiff) Source # divMod :: CPtrdiff -> CPtrdiff -> (CPtrdiff, CPtrdiff) Source # toInteger :: CPtrdiff -> Integer Source #
Integral CBool # |
Instance details Defined in Foreign.C.Types Methods quot :: CBool -> CBool -> CBool Source # rem :: CBool -> CBool -> CBool Source # div :: CBool -> CBool -> CBool Source # mod :: CBool -> CBool -> CBool Source # quotRem :: CBool -> CBool -> (CBool, CBool) Source # divMod :: CBool -> CBool -> (CBool, CBool) Source # toInteger :: CBool -> Integer Source #
Integral CULLong # |
Instance details Defined in Foreign.C.Types Methods quot :: CULLong -> CULLong -> CULLong Source # rem :: CULLong -> CULLong -> CULLong Source # div :: CULLong -> CULLong -> CULLong Source # mod :: CULLong -> CULLong -> CULLong Source # quotRem :: CULLong -> CULLong -> (CULLong, CULLong) Source # divMod :: CULLong -> CULLong -> (CULLong, CULLong) Source # toInteger :: CULLong -> Integer Source #
Integral CLLong # |
Instance details Defined in Foreign.C.Types Methods quot :: CLLong -> CLLong -> CLLong Source # rem :: CLLong -> CLLong -> CLLong Source # div :: CLLong -> CLLong -> CLLong Source # mod :: CLLong -> CLLong -> CLLong Source # quotRem :: CLLong -> CLLong -> (CLLong, CLLong) Source # divMod :: CLLong -> CLLong -> (CLLong, CLLong) Source # toInteger :: CLLong -> Integer Source #
Integral CULong # |
Instance details Defined in Foreign.C.Types Methods quot :: CULong -> CULong -> CULong Source # rem :: CULong -> CULong -> CULong Source # div :: CULong -> CULong -> CULong Source # mod :: CULong -> CULong -> CULong Source # quotRem :: CULong -> CULong -> (CULong, CULong) Source # divMod :: CULong -> CULong -> (CULong, CULong) Source # toInteger :: CULong -> Integer Source #
Integral CLong # |
Instance details Defined in Foreign.C.Types Methods quot :: CLong -> CLong -> CLong Source # rem :: CLong -> CLong -> CLong Source # div :: CLong -> CLong -> CLong Source # mod :: CLong -> CLong -> CLong Source # quotRem :: CLong -> CLong -> (CLong, CLong) Source # divMod :: CLong -> CLong -> (CLong, CLong) Source # toInteger :: CLong -> Integer Source #
Integral CUInt # |
Instance details Defined in Foreign.C.Types Methods quot :: CUInt -> CUInt -> CUInt Source # rem :: CUInt -> CUInt -> CUInt Source # div :: CUInt -> CUInt -> CUInt Source # mod :: CUInt -> CUInt -> CUInt Source # quotRem :: CUInt -> CUInt -> (CUInt, CUInt) Source # divMod :: CUInt -> CUInt -> (CUInt, CUInt) Source # toInteger :: CUInt -> Integer Source #
Integral CInt # |
Instance details Defined in Foreign.C.Types Methods quot :: CInt -> CInt -> CInt Source # rem :: CInt -> CInt -> CInt Source # div :: CInt -> CInt -> CInt Source # mod :: CInt -> CInt -> CInt Source # quotRem :: CInt -> CInt -> (CInt, CInt) Source # divMod :: CInt -> CInt -> (CInt, CInt) Source # toInteger :: CInt -> Integer Source #
Integral CUShort # |
Instance details Defined in Foreign.C.Types Methods quot :: CUShort -> CUShort -> CUShort Source # rem :: CUShort -> CUShort -> CUShort Source # div :: CUShort -> CUShort -> CUShort Source # mod :: CUShort -> CUShort -> CUShort Source # quotRem :: CUShort -> CUShort -> (CUShort, CUShort) Source # divMod :: CUShort -> CUShort -> (CUShort, CUShort) Source # toInteger :: CUShort -> Integer Source #
Integral CShort # |
Instance details Defined in Foreign.C.Types Methods quot :: CShort -> CShort -> CShort Source # rem :: CShort -> CShort -> CShort Source # div :: CShort -> CShort -> CShort Source # mod :: CShort -> CShort -> CShort Source # quotRem :: CShort -> CShort -> (CShort, CShort) Source # divMod :: CShort -> CShort -> (CShort, CShort) Source # toInteger :: CShort -> Integer Source #
Integral CUChar # |
Instance details Defined in Foreign.C.Types Methods quot :: CUChar -> CUChar -> CUChar Source # rem :: CUChar -> CUChar -> CUChar Source # div :: CUChar -> CUChar -> CUChar Source # mod :: CUChar -> CUChar -> CUChar Source # quotRem :: CUChar -> CUChar -> (CUChar, CUChar) Source # divMod :: CUChar -> CUChar -> (CUChar, CUChar) Source # toInteger :: CUChar -> Integer Source #
Integral CSChar # |
Instance details Defined in Foreign.C.Types Methods quot :: CSChar -> CSChar -> CSChar Source # rem :: CSChar -> CSChar -> CSChar Source # div :: CSChar -> CSChar -> CSChar Source # mod :: CSChar -> CSChar -> CSChar Source # quotRem :: CSChar -> CSChar -> (CSChar, CSChar) Source # divMod :: CSChar -> CSChar -> (CSChar, CSChar) Source # toInteger :: CSChar -> Integer Source #
Integral CChar # |
Instance details Defined in Foreign.C.Types Methods quot :: CChar -> CChar -> CChar Source # rem :: CChar -> CChar -> CChar Source # div :: CChar -> CChar -> CChar Source # mod :: CChar -> CChar -> CChar Source # quotRem :: CChar -> CChar -> (CChar, CChar) Source # divMod :: CChar -> CChar -> (CChar, CChar) Source # toInteger :: CChar -> Integer Source #
Integral Fd # |
Instance details Defined in System.Posix.Types Methods quot :: Fd -> Fd -> Fd Source # rem :: Fd -> Fd -> Fd Source # div :: Fd -> Fd -> Fd Source # mod :: Fd -> Fd -> Fd Source # quotRem :: Fd -> Fd -> (Fd, Fd) Source # divMod :: Fd -> Fd -> (Fd, Fd) Source # toInteger :: Fd -> Integer Source #
Integral CKey # |
Instance details Defined in System.Posix.Types Methods quot :: CKey -> CKey -> CKey Source # rem :: CKey -> CKey -> CKey Source # div :: CKey -> CKey -> CKey Source # mod :: CKey -> CKey -> CKey Source # quotRem :: CKey -> CKey -> (CKey, CKey) Source # divMod :: CKey -> CKey -> (CKey, CKey) Source # toInteger :: CKey -> Integer Source #
Integral CId # |
Instance details Defined in System.Posix.Types Methods quot :: CId -> CId -> CId Source # rem :: CId -> CId -> CId Source # div :: CId -> CId -> CId Source # mod :: CId -> CId -> CId Source # quotRem :: CId -> CId -> (CId, CId) Source # divMod :: CId -> CId -> (CId, CId) Source # toInteger :: CId -> Integer Source #
Integral CFsFilCnt # |
Instance details Defined in System.Posix.Types Methods quot :: CFsFilCnt -> CFsFilCnt -> CFsFilCnt Source # rem :: CFsFilCnt -> CFsFilCnt -> CFsFilCnt Source # div :: CFsFilCnt -> CFsFilCnt -> CFsFilCnt Source # mod :: CFsFilCnt -> CFsFilCnt -> CFsFilCnt Source # quotRem :: CFsFilCnt -> CFsFilCnt -> (CFsFilCnt, CFsFilCnt) Source # divMod :: CFsFilCnt -> CFsFilCnt -> (CFsFilCnt, CFsFilCnt) Source # toInteger :: CFsFilCnt -> Integer Source #
Integral CFsBlkCnt # |
Instance details Defined in System.Posix.Types Methods quot :: CFsBlkCnt -> CFsBlkCnt -> CFsBlkCnt Source # rem :: CFsBlkCnt -> CFsBlkCnt -> CFsBlkCnt Source # div :: CFsBlkCnt -> CFsBlkCnt -> CFsBlkCnt Source # mod :: CFsBlkCnt -> CFsBlkCnt -> CFsBlkCnt Source # quotRem :: CFsBlkCnt -> CFsBlkCnt -> (CFsBlkCnt, CFsBlkCnt) Source # divMod :: CFsBlkCnt -> CFsBlkCnt -> (CFsBlkCnt, CFsBlkCnt) Source # toInteger :: CFsBlkCnt -> Integer Source #
Integral CClockId # |
Instance details Defined in System.Posix.Types Methods quot :: CClockId -> CClockId -> CClockId Source # rem :: CClockId -> CClockId -> CClockId Source # div :: CClockId -> CClockId -> CClockId Source # mod :: CClockId -> CClockId -> CClockId Source # quotRem :: CClockId -> CClockId -> (CClockId, CClockId) Source # divMod :: CClockId -> CClockId -> (CClockId, CClockId) Source # toInteger :: CClockId -> Integer Source #
Integral CBlkCnt # |
Instance details Defined in System.Posix.Types Methods quot :: CBlkCnt -> CBlkCnt -> CBlkCnt Source # rem :: CBlkCnt -> CBlkCnt -> CBlkCnt Source # div :: CBlkCnt -> CBlkCnt -> CBlkCnt Source # mod :: CBlkCnt -> CBlkCnt -> CBlkCnt Source # quotRem :: CBlkCnt -> CBlkCnt -> (CBlkCnt, CBlkCnt) Source # divMod :: CBlkCnt -> CBlkCnt -> (CBlkCnt, CBlkCnt) Source # toInteger :: CBlkCnt -> Integer Source #
Integral CBlkSize # |
Instance details Defined in System.Posix.Types Methods quot :: CBlkSize -> CBlkSize -> CBlkSize Source # rem :: CBlkSize -> CBlkSize -> CBlkSize Source # div :: CBlkSize -> CBlkSize -> CBlkSize Source # mod :: CBlkSize -> CBlkSize -> CBlkSize Source # quotRem :: CBlkSize -> CBlkSize -> (CBlkSize, CBlkSize) Source # divMod :: CBlkSize -> CBlkSize -> (CBlkSize, CBlkSize) Source # toInteger :: CBlkSize -> Integer Source #
Integral CRLim # |
Instance details Defined in System.Posix.Types Methods quot :: CRLim -> CRLim -> CRLim Source # rem :: CRLim -> CRLim -> CRLim Source # div :: CRLim -> CRLim -> CRLim Source # mod :: CRLim -> CRLim -> CRLim Source # quotRem :: CRLim -> CRLim -> (CRLim, CRLim) Source # divMod :: CRLim -> CRLim -> (CRLim, CRLim) Source # toInteger :: CRLim -> Integer Source #
Integral CTcflag # |
Instance details Defined in System.Posix.Types Methods quot :: CTcflag -> CTcflag -> CTcflag Source # rem :: CTcflag -> CTcflag -> CTcflag Source # div :: CTcflag -> CTcflag -> CTcflag Source # mod :: CTcflag -> CTcflag -> CTcflag Source # quotRem :: CTcflag -> CTcflag -> (CTcflag, CTcflag) Source # divMod :: CTcflag -> CTcflag -> (CTcflag, CTcflag) Source # toInteger :: CTcflag -> Integer Source #
Integral CUid # |
Instance details Defined in System.Posix.Types Methods quot :: CUid -> CUid -> CUid Source # rem :: CUid -> CUid -> CUid Source # div :: CUid -> CUid -> CUid Source # mod :: CUid -> CUid -> CUid Source # quotRem :: CUid -> CUid -> (CUid, CUid) Source # divMod :: CUid -> CUid -> (CUid, CUid) Source # toInteger :: CUid -> Integer Source #
Integral CNlink # |
Instance details Defined in System.Posix.Types Methods quot :: CNlink -> CNlink -> CNlink Source # rem :: CNlink -> CNlink -> CNlink Source # div :: CNlink -> CNlink -> CNlink Source # mod :: CNlink -> CNlink -> CNlink Source # quotRem :: CNlink -> CNlink -> (CNlink, CNlink) Source # divMod :: CNlink -> CNlink -> (CNlink, CNlink) Source # toInteger :: CNlink -> Integer Source #
Integral CGid # |
Instance details Defined in System.Posix.Types Methods quot :: CGid -> CGid -> CGid Source # rem :: CGid -> CGid -> CGid Source # div :: CGid -> CGid -> CGid Source # mod :: CGid -> CGid -> CGid Source # quotRem :: CGid -> CGid -> (CGid, CGid) Source # divMod :: CGid -> CGid -> (CGid, CGid) Source # toInteger :: CGid -> Integer Source #
Integral CSsize # |
Instance details Defined in System.Posix.Types Methods quot :: CSsize -> CSsize -> CSsize Source # rem :: CSsize -> CSsize -> CSsize Source # div :: CSsize -> CSsize -> CSsize Source # mod :: CSsize -> CSsize -> CSsize Source # quotRem :: CSsize -> CSsize -> (CSsize, CSsize) Source # divMod :: CSsize -> CSsize -> (CSsize, CSsize) Source # toInteger :: CSsize -> Integer Source #
Integral CPid # |
Instance details Defined in System.Posix.Types Methods quot :: CPid -> CPid -> CPid Source # rem :: CPid -> CPid -> CPid Source # div :: CPid -> CPid -> CPid Source # mod :: CPid -> CPid -> CPid Source # quotRem :: CPid -> CPid -> (CPid, CPid) Source # divMod :: CPid -> CPid -> (CPid, CPid) Source # toInteger :: CPid -> Integer Source #
Integral COff # |
Instance details Defined in System.Posix.Types Methods quot :: COff -> COff -> COff Source # rem :: COff -> COff -> COff Source # div :: COff -> COff -> COff Source # mod :: COff -> COff -> COff Source # quotRem :: COff -> COff -> (COff, COff) Source # divMod :: COff -> COff -> (COff, COff) Source # toInteger :: COff -> Integer Source #
Integral CMode # |
Instance details Defined in System.Posix.Types Methods quot :: CMode -> CMode -> CMode Source # rem :: CMode -> CMode -> CMode Source # div :: CMode -> CMode -> CMode Source # mod :: CMode -> CMode -> CMode Source # quotRem :: CMode -> CMode -> (CMode, CMode) Source # divMod :: CMode -> CMode -> (CMode, CMode) Source # toInteger :: CMode -> Integer Source #
Integral CIno # |
Instance details Defined in System.Posix.Types Methods quot :: CIno -> CIno -> CIno Source # rem :: CIno -> CIno -> CIno Source # div :: CIno -> CIno -> CIno Source # mod :: CIno -> CIno -> CIno Source # quotRem :: CIno -> CIno -> (CIno, CIno) Source # divMod :: CIno -> CIno -> (CIno, CIno) Source # toInteger :: CIno -> Integer Source #
Integral CDev # |
Instance details Defined in System.Posix.Types Methods quot :: CDev -> CDev -> CDev Source # rem :: CDev -> CDev -> CDev Source # div :: CDev -> CDev -> CDev Source # mod :: CDev -> CDev -> CDev Source # quotRem :: CDev -> CDev -> (CDev, CDev) Source # divMod :: CDev -> CDev -> (CDev, CDev) Source # toInteger :: CDev -> Integer Source #
Integral a => Integral (Identity a) # | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Identity Methods quot :: Identity a -> Identity a -> Identity a Source # rem :: Identity a -> Identity a -> Identity a Source # div :: Identity a -> Identity a -> Identity a Source # mod :: Identity a -> Identity a -> Identity a Source # quotRem :: Identity a -> Identity a -> (Identity a, Identity a) Source # divMod :: Identity a -> Identity a -> (Identity a, Identity a) Source # toInteger :: Identity a -> Integer Source #
Integral a => Integral (Const a b) # | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Const Methods quot :: Const a b -> Const a b -> Const a b Source # rem :: Const a b -> Const a b -> Const a b Source # div :: Const a b -> Const a b -> Const a b Source # mod :: Const a b -> Const a b -> Const a b Source # quotRem :: Const a b -> Const a b -> (Const a b, Const a b) Source # divMod :: Const a b -> Const a b -> (Const a b, Const a b) Source # toInteger :: Const a b -> Integer Source #

class Num a => Fractional a where Source #

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`

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

Minimal complete definition

fromRational, (recip | (/))

Methods

(/) :: a -> a -> a infixl 7 Source #

Fractional division.

recip :: a -> a Source #

Reciprocal fraction.

fromRational :: Rational -> a Source #

Conversion from a `Rational` (that is ``Ratio` `Integer``). A floating literal stands for an application of `fromRational` to a value of type `Rational`, so such literals have type `(`Fractional` a) => a`.

#### Instances

Instances details

Fractional Double # | Note that due to the presence of `NaN`, not all elements of `Double` have an multiplicative inverse.
    >>> 0/0 * (recip 0/0 :: Double)
    NaN
Since: base-2.1
Instance details Defined in GHC.Float Methods (/) :: Double -> Double -> Double Source # recip :: Double -> Double Source # fromRational :: Rational -> Double Source #
Fractional Float # | Note that due to the presence of `NaN`, not all elements of `Float` have an multiplicative inverse.
    >>> 0/0 * (recip 0/0 :: Float)
    NaN
Since: base-2.1
Instance details Defined in GHC.Float Methods (/) :: Float -> Float -> Float Source # recip :: Float -> Float Source # fromRational :: Rational -> Float Source #
Fractional CDouble # |
Instance details Defined in Foreign.C.Types Methods (/) :: CDouble -> CDouble -> CDouble Source # recip :: CDouble -> CDouble Source # fromRational :: Rational -> CDouble Source #
Fractional CFloat # |
Instance details Defined in Foreign.C.Types Methods (/) :: CFloat -> CFloat -> CFloat Source # recip :: CFloat -> CFloat Source # fromRational :: Rational -> CFloat Source #
Integral a => Fractional (Ratio a) # | Since: base-2.0.1
Instance details Defined in GHC.Real Methods (/) :: Ratio a -> Ratio a -> Ratio a Source # recip :: Ratio a -> Ratio a Source # fromRational :: Rational -> Ratio a Source #
Fractional a => Fractional (Identity a) # | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Identity Methods (/) :: Identity a -> Identity a -> Identity a Source # recip :: Identity a -> Identity a Source # fromRational :: Rational -> Identity a Source #
HasResolution a => Fractional (Fixed a) # | Since: base-2.1
Instance details Defined in Data.Fixed Methods (/) :: Fixed a -> Fixed a -> Fixed a Source # recip :: Fixed a -> Fixed a Source # fromRational :: Rational -> Fixed a Source #
RealFloat a => Fractional (Complex a) # | Since: base-2.1
Instance details Defined in Data.Complex Methods (/) :: Complex a -> Complex a -> Complex a Source # recip :: Complex a -> Complex a Source # fromRational :: Rational -> Complex a Source #
Fractional a => Fractional (Op a b) # |
Instance details Defined in Data.Functor.Contravariant Methods (/) :: Op a b -> Op a b -> Op a b Source # recip :: Op a b -> Op a b Source # fromRational :: Rational -> Op a b Source #
Fractional a => Fractional (Const a b) # | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Const Methods (/) :: Const a b -> Const a b -> Const a b Source # recip :: Const a b -> Const a b Source # fromRational :: Rational -> Const a b Source #

class (Real a, Fractional a) => RealFrac a where Source #

Extracting components of fractions.

Minimal complete definition

properFraction

Methods

properFraction :: Integral b => a -> (b, a) Source #

The function `properFraction` takes a real fractional number `x` and returns a pair `(n,f)` such that `x = n+f`, and:

- `n` is an integral number with the same sign as `x`; and
- `f` is a fraction with the same type and sign as `x`, and with absolute value less than `1`.

The default definitions of the `ceiling`, `floor`, `truncate` and `round` functions are in terms of `properFraction`.

truncate :: Integral b => a -> b Source #

``truncate` x` returns the integer nearest `x` between zero and `x`

round :: Integral b => a -> b Source #

``round` x` returns the nearest integer to `x`; the even integer if `x` is equidistant between two integers

ceiling :: Integral b => a -> b Source #

``ceiling` x` returns the least integer not less than `x`

floor :: Integral b => a -> b Source #

``floor` x` returns the greatest integer not greater than `x`

#### Instances

Instances details

RealFrac Double # | Since: base-2.1
Instance details Defined in GHC.Float Methods properFraction :: Integral b => Double -> (b, Double) Source # truncate :: Integral b => Double -> b Source # round :: Integral b => Double -> b Source # ceiling :: Integral b => Double -> b Source # floor :: Integral b => Double -> b Source #
RealFrac Float # | Since: base-2.1
Instance details Defined in GHC.Float Methods properFraction :: Integral b => Float -> (b, Float) Source # truncate :: Integral b => Float -> b Source # round :: Integral b => Float -> b Source # ceiling :: Integral b => Float -> b Source # floor :: Integral b => Float -> b Source #
RealFrac CDouble # |
Instance details Defined in Foreign.C.Types Methods properFraction :: Integral b => CDouble -> (b, CDouble) Source # truncate :: Integral b => CDouble -> b Source # round :: Integral b => CDouble -> b Source # ceiling :: Integral b => CDouble -> b Source # floor :: Integral b => CDouble -> b Source #
RealFrac CFloat # |
Instance details Defined in Foreign.C.Types Methods properFraction :: Integral b => CFloat -> (b, CFloat) Source # truncate :: Integral b => CFloat -> b Source # round :: Integral b => CFloat -> b Source # ceiling :: Integral b => CFloat -> b Source # floor :: Integral b => CFloat -> b Source #
Integral a => RealFrac (Ratio a) # | Since: base-2.0.1
Instance details Defined in GHC.Real Methods properFraction :: Integral b => Ratio a -> (b, Ratio a) Source # truncate :: Integral b => Ratio a -> b Source # round :: Integral b => Ratio a -> b Source # ceiling :: Integral b => Ratio a -> b Source # floor :: Integral b => Ratio a -> b Source #
RealFrac a => RealFrac (Identity a) # | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Identity Methods properFraction :: Integral b => Identity a -> (b, Identity a) Source # truncate :: Integral b => Identity a -> b Source # round :: Integral b => Identity a -> b Source # ceiling :: Integral b => Identity a -> b Source # floor :: Integral b => Identity a -> b Source #
HasResolution a => RealFrac (Fixed a) # | Since: base-2.1
Instance details Defined in Data.Fixed Methods properFraction :: Integral b => Fixed a -> (b, Fixed a) Source # truncate :: Integral b => Fixed a -> b Source # round :: Integral b => Fixed a -> b Source # ceiling :: Integral b => Fixed a -> b Source # floor :: Integral b => Fixed a -> b Source #
RealFrac a => RealFrac (Const a b) # | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Const Methods properFraction :: Integral b0 => Const a b -> (b0, Const a b) Source # truncate :: Integral b0 => Const a b -> b0 Source # round :: Integral b0 => Const a b -> b0 Source # ceiling :: Integral b0 => Const a b -> b0 Source # floor :: Integral b0 => Const a b -> b0 Source #

numericEnumFrom :: Fractional a => a -> [a] Source #

numericEnumFromThen :: Fractional a => a -> a -> [a] Source #

numericEnumFromTo :: (Ord a, Fractional a) => a -> a -> [a] Source #

numericEnumFromThenTo :: (Ord a, Fractional a) => a -> a -> a -> [a] Source #

fromIntegral :: (Integral a, Num b) => a -> b Source #

general coercion from integral types

realToFrac :: (Real a, Fractional b) => a -> b Source #

general coercion to fractional types

showSigned Source #

Arguments

:: Real a |
=> (a -> ShowS) | a function that can show unsigned values
-> Int | the precedence of the enclosing context
-> a | the value to show
-> ShowS |

Converts a possibly-negative `Real` value to a string.

even :: Integral a => a -> Bool Source #

odd :: Integral a => a -> Bool Source #

(^) :: (Num a, Integral b) => a -> b -> a infixr 8 Source #

raise a number to a non-negative integral power

(^^) :: (Fractional a, Integral b) => a -> b -> a infixr 8 Source #

raise a number to an integral power

(^%^) :: Integral a => Rational -> a -> Rational Source #

(^^%^^) :: Integral a => Rational -> a -> Rational Source #

gcd :: Integral a => a -> a -> a Source #

``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.

lcm :: Integral a => a -> a -> a Source #

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

gcdInt' :: Int -> Int -> Int Source #

gcdWord' :: Word -> Word -> Word Source #

integralEnumFrom :: (Integral a, Bounded a) => a -> [a] Source #

integralEnumFromThen :: (Integral a, Bounded a) => a -> a -> [a] Source #

integralEnumFromTo :: Integral a => a -> a -> [a] Source #

integralEnumFromThenTo :: Integral a => a -> a -> a -> [a] Source #