| Copyright | (c) 2018-2023 Kowainik |
|---|---|
| License | MIT |
| Maintainer | Kowainik <xrom.xkov@gmail.com> |
| Stability | Stable |
| Portability | Portable |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
Relude.Numeric
Contents
Description
Provides numerical data types and functions.
Since: 0.5.0
Synopsis
- xor :: Bits a => a -> a -> a
- toIntegralSized :: (Integral a, Integral b, Bits a, Bits b) => a -> Maybe b
- data Int
- data Int8
- data Int16
- data Int32
- data Int64
- data Word8
- data Word
- data Word64
- data Word32
- data Word16
- byteSwap16 :: Word16 -> Word16
- byteSwap32 :: Word32 -> Word32
- byteSwap64 :: Word64 -> Word64
- minInt :: Int
- maxInt :: Int
- data Float = F# Float#
- data Double = D# Double#
- class Fractional a => Floating a where
- class (RealFrac a, Floating a) => RealFloat a where
- floatRadix :: a -> Integer
- floatDigits :: a -> Int
- floatRange :: a -> (Int, Int)
- decodeFloat :: a -> (Integer, Int)
- encodeFloat :: Integer -> Int -> a
- isNaN :: a -> Bool
- isInfinite :: a -> Bool
- isDenormalized :: a -> Bool
- isNegativeZero :: a -> Bool
- isIEEE :: a -> Bool
- atan2 :: a -> a -> a
- data Integer
- class Num a where
- subtract :: Num a => a -> a -> a
- class (Real a, Enum a) => Integral a where
- type Rational = Ratio Integer
- class Num a => Fractional a where
- (/) :: a -> a -> a
- recip :: a -> a
- fromRational :: Rational -> a
- class (Num a, Ord a) => Real a where
- toRational :: a -> Rational
- class (Real a, Fractional a) => RealFrac a where
- data Ratio a
- even :: Integral a => a -> Bool
- fromIntegral :: (Integral a, Num b) => a -> b
- realToFrac :: (Real a, Fractional b) => a -> b
- (^) :: (Num a, Integral b) => a -> b -> a
- numerator :: Ratio a -> a
- denominator :: Ratio a -> a
- odd :: Integral a => a -> Bool
- (^^) :: (Fractional a, Integral b) => a -> b -> a
- gcd :: Integral a => a -> a -> a
- lcm :: Integral a => a -> a -> a
- data Natural
- integerToBounded :: forall a. (Integral a, Bounded a) => Integer -> Maybe a
- integerToNatural :: Integer -> Maybe Natural
Reexports
toIntegralSized :: (Integral a, Integral b, Bits a, Bits b) => a -> Maybe b #
Attempt to convert an Integral type a to an Integral type b using
the size of the types as measured by Bits methods.
A simpler version of this function is:
toIntegral :: (Integral a, Integral b) => a -> Maybe b
toIntegral x
| toInteger x == toInteger y = Just y
| otherwise = Nothing
where
y = fromIntegral xThis version requires going through Integer, which can be inefficient.
However, toIntegralSized is optimized to allow GHC to statically determine
the relative type sizes (as measured by bitSizeMaybe and isSigned) and
avoid going through Integer for many types. (The implementation uses
fromIntegral, which is itself optimized with rules for base types but may
go through Integer for some type pairs.)
Since: base-4.8.0.0
A fixed-precision integer type with at least the range [-2^29 .. 2^29-1].
The exact range for a given implementation can be determined by using
minBound and maxBound from the Bounded class.
Instances
| Data Int | Since: base-4.0.0.0 |
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Int -> c Int # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Int # dataTypeOf :: Int -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Int) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Int) # gmapT :: (forall b. Data b => b -> b) -> Int -> Int # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Int -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Int -> r # gmapQ :: (forall d. Data d => d -> u) -> Int -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Int -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Int -> m Int # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Int -> m Int # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Int -> m Int # | |
| Bits Int | Since: base-2.1 |
Defined in GHC.Bits | |
| FiniteBits Int | Since: base-4.6.0.0 |
Defined in GHC.Bits Methods finiteBitSize :: Int -> Int # countLeadingZeros :: Int -> Int # countTrailingZeros :: Int -> Int # | |
| Bounded Int | Since: base-2.1 |
| Enum Int | Since: base-2.1 |
| Num Int | Since: base-2.1 |
| Read Int | Since: base-2.1 |
| Integral Int | Since: base-2.0.1 |
| Real Int | Since: base-2.0.1 |
Defined in GHC.Real Methods toRational :: Int -> Rational # | |
| Show Int | Since: base-2.1 |
| NFData Int | |
Defined in Control.DeepSeq | |
| Eq Int | |
| Ord Int | |
| Hashable Int | |
Defined in Data.Hashable.Class | |
| Lift Int | |
| Generic1 (URec Int :: k -> Type) | |
| Foldable (UInt :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => UInt m -> m # foldMap :: Monoid m => (a -> m) -> UInt a -> m # foldMap' :: Monoid m => (a -> m) -> UInt a -> m # foldr :: (a -> b -> b) -> b -> UInt a -> b # foldr' :: (a -> b -> b) -> b -> UInt a -> b # foldl :: (b -> a -> b) -> b -> UInt a -> b # foldl' :: (b -> a -> b) -> b -> UInt a -> b # foldr1 :: (a -> a -> a) -> UInt a -> a # foldl1 :: (a -> a -> a) -> UInt a -> a # elem :: Eq a => a -> UInt a -> Bool # maximum :: Ord a => UInt a -> a # | |
| Traversable (UInt :: Type -> Type) | Since: base-4.9.0.0 |
| Functor (URec Int :: Type -> Type) | Since: base-4.9.0.0 |
| Generic (URec Int p) | |
| Show (URec Int p) | Since: base-4.9.0.0 |
| Eq (URec Int p) | Since: base-4.9.0.0 |
| Ord (URec Int p) | Since: base-4.9.0.0 |
| data URec Int (p :: k) | Used for marking occurrences of Since: base-4.9.0.0 |
| type Rep1 (URec Int :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| type Rep (URec Int p) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
8-bit signed integer type
Instances
| Data Int8 | Since: base-4.0.0.0 |
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Int8 -> c Int8 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Int8 # dataTypeOf :: Int8 -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Int8) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Int8) # gmapT :: (forall b. Data b => b -> b) -> Int8 -> Int8 # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Int8 -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Int8 -> r # gmapQ :: (forall d. Data d => d -> u) -> Int8 -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Int8 -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Int8 -> m Int8 # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Int8 -> m Int8 # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Int8 -> m Int8 # | |
| Bits Int8 | Since: base-2.1 |
Defined in GHC.Int Methods (.&.) :: Int8 -> Int8 -> Int8 # (.|.) :: Int8 -> Int8 -> Int8 # complement :: Int8 -> Int8 # shift :: Int8 -> Int -> Int8 # rotate :: Int8 -> Int -> Int8 # setBit :: Int8 -> Int -> Int8 # clearBit :: Int8 -> Int -> Int8 # complementBit :: Int8 -> Int -> Int8 # testBit :: Int8 -> Int -> Bool # bitSizeMaybe :: Int8 -> Maybe Int # shiftL :: Int8 -> Int -> Int8 # unsafeShiftL :: Int8 -> Int -> Int8 # shiftR :: Int8 -> Int -> Int8 # unsafeShiftR :: Int8 -> Int -> Int8 # rotateL :: Int8 -> Int -> Int8 # | |
| FiniteBits Int8 | Since: base-4.6.0.0 |
Defined in GHC.Int Methods finiteBitSize :: Int8 -> Int # countLeadingZeros :: Int8 -> Int # countTrailingZeros :: Int8 -> Int # | |
| Bounded Int8 | Since: base-2.1 |
| Enum Int8 | Since: base-2.1 |
| Ix Int8 | Since: base-2.1 |
| Num Int8 | Since: base-2.1 |
| Read Int8 | Since: base-2.1 |
| Integral Int8 | Since: base-2.1 |
| Real Int8 | Since: base-2.1 |
Defined in GHC.Int Methods toRational :: Int8 -> Rational # | |
| Show Int8 | Since: base-2.1 |
| NFData Int8 | |
Defined in Control.DeepSeq | |
| Eq Int8 | Since: base-2.1 |
| Ord Int8 | Since: base-2.1 |
| Hashable Int8 | |
Defined in Data.Hashable.Class | |
| Lift Int8 | |
16-bit signed integer type
Instances
| Data Int16 | Since: base-4.0.0.0 |
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Int16 -> c Int16 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Int16 # dataTypeOf :: Int16 -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Int16) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Int16) # gmapT :: (forall b. Data b => b -> b) -> Int16 -> Int16 # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Int16 -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Int16 -> r # gmapQ :: (forall d. Data d => d -> u) -> Int16 -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Int16 -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Int16 -> m Int16 # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Int16 -> m Int16 # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Int16 -> m Int16 # | |
| Bits Int16 | Since: base-2.1 |
Defined in GHC.Int Methods (.&.) :: Int16 -> Int16 -> Int16 # (.|.) :: Int16 -> Int16 -> Int16 # xor :: Int16 -> Int16 -> Int16 # complement :: Int16 -> Int16 # shift :: Int16 -> Int -> Int16 # rotate :: Int16 -> Int -> Int16 # setBit :: Int16 -> Int -> Int16 # clearBit :: Int16 -> Int -> Int16 # complementBit :: Int16 -> Int -> Int16 # testBit :: Int16 -> Int -> Bool # bitSizeMaybe :: Int16 -> Maybe Int # shiftL :: Int16 -> Int -> Int16 # unsafeShiftL :: Int16 -> Int -> Int16 # shiftR :: Int16 -> Int -> Int16 # unsafeShiftR :: Int16 -> Int -> Int16 # rotateL :: Int16 -> Int -> Int16 # | |
| FiniteBits Int16 | Since: base-4.6.0.0 |
Defined in GHC.Int Methods finiteBitSize :: Int16 -> Int # countLeadingZeros :: Int16 -> Int # countTrailingZeros :: Int16 -> Int # | |
| Bounded Int16 | Since: base-2.1 |
| Enum Int16 | Since: base-2.1 |
| Ix Int16 | Since: base-2.1 |
| Num Int16 | Since: base-2.1 |
| Read Int16 | Since: base-2.1 |
| Integral Int16 | Since: base-2.1 |
| Real Int16 | Since: base-2.1 |
Defined in GHC.Int Methods toRational :: Int16 -> Rational # | |
| Show Int16 | Since: base-2.1 |
| NFData Int16 | |
Defined in Control.DeepSeq | |
| Eq Int16 | Since: base-2.1 |
| Ord Int16 | Since: base-2.1 |
| Hashable Int16 | |
Defined in Data.Hashable.Class | |
| Lift Int16 | |
32-bit signed integer type
Instances
| Data Int32 | Since: base-4.0.0.0 |
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Int32 -> c Int32 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Int32 # dataTypeOf :: Int32 -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Int32) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Int32) # gmapT :: (forall b. Data b => b -> b) -> Int32 -> Int32 # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Int32 -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Int32 -> r # gmapQ :: (forall d. Data d => d -> u) -> Int32 -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Int32 -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Int32 -> m Int32 # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Int32 -> m Int32 # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Int32 -> m Int32 # | |
| Bits Int32 | Since: base-2.1 |
Defined in GHC.Int Methods (.&.) :: Int32 -> Int32 -> Int32 # (.|.) :: Int32 -> Int32 -> Int32 # xor :: Int32 -> Int32 -> Int32 # complement :: Int32 -> Int32 # shift :: Int32 -> Int -> Int32 # rotate :: Int32 -> Int -> Int32 # setBit :: Int32 -> Int -> Int32 # clearBit :: Int32 -> Int -> Int32 # complementBit :: Int32 -> Int -> Int32 # testBit :: Int32 -> Int -> Bool # bitSizeMaybe :: Int32 -> Maybe Int # shiftL :: Int32 -> Int -> Int32 # unsafeShiftL :: Int32 -> Int -> Int32 # shiftR :: Int32 -> Int -> Int32 # unsafeShiftR :: Int32 -> Int -> Int32 # rotateL :: Int32 -> Int -> Int32 # | |
| FiniteBits Int32 | Since: base-4.6.0.0 |
Defined in GHC.Int Methods finiteBitSize :: Int32 -> Int # countLeadingZeros :: Int32 -> Int # countTrailingZeros :: Int32 -> Int # | |
| Bounded Int32 | Since: base-2.1 |
| Enum Int32 | Since: base-2.1 |
| Ix Int32 | Since: base-2.1 |
| Num Int32 | Since: base-2.1 |
| Read Int32 | Since: base-2.1 |
| Integral Int32 | Since: base-2.1 |
| Real Int32 | Since: base-2.1 |
Defined in GHC.Int Methods toRational :: Int32 -> Rational # | |
| Show Int32 | Since: base-2.1 |
| NFData Int32 | |
Defined in Control.DeepSeq | |
| Eq Int32 | Since: base-2.1 |
| Ord Int32 | Since: base-2.1 |
| Hashable Int32 | |
Defined in Data.Hashable.Class | |
| Lift Int32 | |
64-bit signed integer type
Instances
| Data Int64 | Since: base-4.0.0.0 |
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Int64 -> c Int64 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Int64 # dataTypeOf :: Int64 -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Int64) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Int64) # gmapT :: (forall b. Data b => b -> b) -> Int64 -> Int64 # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Int64 -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Int64 -> r # gmapQ :: (forall d. Data d => d -> u) -> Int64 -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Int64 -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Int64 -> m Int64 # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Int64 -> m Int64 # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Int64 -> m Int64 # | |
| Bits Int64 | Since: base-2.1 |
Defined in GHC.Int Methods (.&.) :: Int64 -> Int64 -> Int64 # (.|.) :: Int64 -> Int64 -> Int64 # xor :: Int64 -> Int64 -> Int64 # complement :: Int64 -> Int64 # shift :: Int64 -> Int -> Int64 # rotate :: Int64 -> Int -> Int64 # setBit :: Int64 -> Int -> Int64 # clearBit :: Int64 -> Int -> Int64 # complementBit :: Int64 -> Int -> Int64 # testBit :: Int64 -> Int -> Bool # bitSizeMaybe :: Int64 -> Maybe Int # shiftL :: Int64 -> Int -> Int64 # unsafeShiftL :: Int64 -> Int -> Int64 # shiftR :: Int64 -> Int -> Int64 # unsafeShiftR :: Int64 -> Int -> Int64 # rotateL :: Int64 -> Int -> Int64 # | |
| FiniteBits Int64 | Since: base-4.6.0.0 |
Defined in GHC.Int Methods finiteBitSize :: Int64 -> Int # countLeadingZeros :: Int64 -> Int # countTrailingZeros :: Int64 -> Int # | |
| Bounded Int64 | Since: base-2.1 |
| Enum Int64 | Since: base-2.1 |
| Ix Int64 | Since: base-2.1 |
| Num Int64 | Since: base-2.1 |
| Read Int64 | Since: base-2.1 |
| Integral Int64 | Since: base-2.1 |
| Real Int64 | Since: base-2.1 |
Defined in GHC.Int Methods toRational :: Int64 -> Rational # | |
| Show Int64 | Since: base-2.1 |
| NFData Int64 | |
Defined in Control.DeepSeq | |
| Eq Int64 | Since: base-2.1 |
| Ord Int64 | Since: base-2.1 |
| Hashable Int64 | |
Defined in Data.Hashable.Class | |
| Lift Int64 | |
8-bit unsigned integer type
Instances
| Data Word8 | Since: base-4.0.0.0 |
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Word8 -> c Word8 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Word8 # dataTypeOf :: Word8 -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Word8) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Word8) # gmapT :: (forall b. Data b => b -> b) -> Word8 -> Word8 # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Word8 -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Word8 -> r # gmapQ :: (forall d. Data d => d -> u) -> Word8 -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Word8 -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Word8 -> m Word8 # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Word8 -> m Word8 # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Word8 -> m Word8 # | |
| Bits Word8 | Since: base-2.1 |
Defined in GHC.Word Methods (.&.) :: Word8 -> Word8 -> Word8 # (.|.) :: Word8 -> Word8 -> Word8 # xor :: Word8 -> Word8 -> Word8 # complement :: Word8 -> Word8 # shift :: Word8 -> Int -> Word8 # rotate :: Word8 -> Int -> Word8 # setBit :: Word8 -> Int -> Word8 # clearBit :: Word8 -> Int -> Word8 # complementBit :: Word8 -> Int -> Word8 # testBit :: Word8 -> Int -> Bool # bitSizeMaybe :: Word8 -> Maybe Int # shiftL :: Word8 -> Int -> Word8 # unsafeShiftL :: Word8 -> Int -> Word8 # shiftR :: Word8 -> Int -> Word8 # unsafeShiftR :: Word8 -> Int -> Word8 # rotateL :: Word8 -> Int -> Word8 # | |
| FiniteBits Word8 | Since: base-4.6.0.0 |
Defined in GHC.Word Methods finiteBitSize :: Word8 -> Int # countLeadingZeros :: Word8 -> Int # countTrailingZeros :: Word8 -> Int # | |
| Bounded Word8 | Since: base-2.1 |
| Enum Word8 | Since: base-2.1 |
| Ix Word8 | Since: base-2.1 |
| Num Word8 | Since: base-2.1 |
| Read Word8 | Since: base-2.1 |
| Integral Word8 | Since: base-2.1 |
| Real Word8 | Since: base-2.1 |
Defined in GHC.Word Methods toRational :: Word8 -> Rational # | |
| Show Word8 | Since: base-2.1 |
| NFData Word8 | |
Defined in Control.DeepSeq | |
| Eq Word8 | Since: base-2.1 |
| Ord Word8 | Since: base-2.1 |
| Hashable Word8 | |
Defined in Data.Hashable.Class | |
| Lift Word8 | |
Instances
| Data Word | Since: base-4.0.0.0 |
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Word -> c Word # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Word # dataTypeOf :: Word -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Word) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Word) # gmapT :: (forall b. Data b => b -> b) -> Word -> Word # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Word -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Word -> r # gmapQ :: (forall d. Data d => d -> u) -> Word -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Word -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Word -> m Word # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Word -> m Word # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Word -> m Word # | |
| Bits Word | Since: base-2.1 |
Defined in GHC.Bits Methods (.&.) :: Word -> Word -> Word # (.|.) :: Word -> Word -> Word # complement :: Word -> Word # shift :: Word -> Int -> Word # rotate :: Word -> Int -> Word # setBit :: Word -> Int -> Word # clearBit :: Word -> Int -> Word # complementBit :: Word -> Int -> Word # testBit :: Word -> Int -> Bool # bitSizeMaybe :: Word -> Maybe Int # shiftL :: Word -> Int -> Word # unsafeShiftL :: Word -> Int -> Word # shiftR :: Word -> Int -> Word # unsafeShiftR :: Word -> Int -> Word # rotateL :: Word -> Int -> Word # | |
| FiniteBits Word | Since: base-4.6.0.0 |
Defined in GHC.Bits Methods finiteBitSize :: Word -> Int # countLeadingZeros :: Word -> Int # countTrailingZeros :: Word -> Int # | |
| Bounded Word | Since: base-2.1 |
| Enum Word | Since: base-2.1 |
| Num Word | Since: base-2.1 |
| Read Word | Since: base-4.5.0.0 |
| Integral Word | Since: base-2.1 |
| Real Word | Since: base-2.1 |
Defined in GHC.Real Methods toRational :: Word -> Rational # | |
| Show Word | Since: base-2.1 |
| NFData Word | |
Defined in Control.DeepSeq | |
| Eq Word | |
| Ord Word | |
| Hashable Word | |
Defined in Data.Hashable.Class | |
| Lift Word | |
| Generic1 (URec Word :: k -> Type) | |
| Foldable (UWord :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => UWord m -> m # foldMap :: Monoid m => (a -> m) -> UWord a -> m # foldMap' :: Monoid m => (a -> m) -> UWord a -> m # foldr :: (a -> b -> b) -> b -> UWord a -> b # foldr' :: (a -> b -> b) -> b -> UWord a -> b # foldl :: (b -> a -> b) -> b -> UWord a -> b # foldl' :: (b -> a -> b) -> b -> UWord a -> b # foldr1 :: (a -> a -> a) -> UWord a -> a # foldl1 :: (a -> a -> a) -> UWord a -> a # elem :: Eq a => a -> UWord a -> Bool # maximum :: Ord a => UWord a -> a # minimum :: Ord a => UWord a -> a # | |
| Traversable (UWord :: Type -> Type) | Since: base-4.9.0.0 |
| Functor (URec Word :: Type -> Type) | Since: base-4.9.0.0 |
| Generic (URec Word p) | |
| Show (URec Word p) | Since: base-4.9.0.0 |
| Eq (URec Word p) | Since: base-4.9.0.0 |
| Ord (URec Word p) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| data URec Word (p :: k) | Used for marking occurrences of Since: base-4.9.0.0 |
| type Rep1 (URec Word :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| type Rep (URec Word p) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
64-bit unsigned integer type
Instances
| Data Word64 | Since: base-4.0.0.0 |
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Word64 -> c Word64 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Word64 # toConstr :: Word64 -> Constr # dataTypeOf :: Word64 -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Word64) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Word64) # gmapT :: (forall b. Data b => b -> b) -> Word64 -> Word64 # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Word64 -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Word64 -> r # gmapQ :: (forall d. Data d => d -> u) -> Word64 -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Word64 -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Word64 -> m Word64 # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Word64 -> m Word64 # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Word64 -> m Word64 # | |
| Bits Word64 | Since: base-2.1 |
Defined in GHC.Word Methods (.&.) :: Word64 -> Word64 -> Word64 # (.|.) :: Word64 -> Word64 -> Word64 # xor :: Word64 -> Word64 -> Word64 # complement :: Word64 -> Word64 # shift :: Word64 -> Int -> Word64 # rotate :: Word64 -> Int -> Word64 # setBit :: Word64 -> Int -> Word64 # clearBit :: Word64 -> Int -> Word64 # complementBit :: Word64 -> Int -> Word64 # testBit :: Word64 -> Int -> Bool # bitSizeMaybe :: Word64 -> Maybe Int # shiftL :: Word64 -> Int -> Word64 # unsafeShiftL :: Word64 -> Int -> Word64 # shiftR :: Word64 -> Int -> Word64 # unsafeShiftR :: Word64 -> Int -> Word64 # rotateL :: Word64 -> Int -> Word64 # | |
| FiniteBits Word64 | Since: base-4.6.0.0 |
Defined in GHC.Word Methods finiteBitSize :: Word64 -> Int # countLeadingZeros :: Word64 -> Int # countTrailingZeros :: Word64 -> Int # | |
| Bounded Word64 | Since: base-2.1 |
| Enum Word64 | Since: base-2.1 |
Defined in GHC.Word | |
| Ix Word64 | Since: base-2.1 |
| Num Word64 | Since: base-2.1 |
| Read Word64 | Since: base-2.1 |
| Integral Word64 | Since: base-2.1 |
| Real Word64 | Since: base-2.1 |
Defined in GHC.Word Methods toRational :: Word64 -> Rational # | |
| Show Word64 | Since: base-2.1 |
| NFData Word64 | |
Defined in Control.DeepSeq | |
| Eq Word64 | Since: base-2.1 |
| Ord Word64 | Since: base-2.1 |
| Hashable Word64 | |
Defined in Data.Hashable.Class | |
| Lift Word64 | |
32-bit unsigned integer type
Instances
| Data Word32 | Since: base-4.0.0.0 |
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Word32 -> c Word32 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Word32 # toConstr :: Word32 -> Constr # dataTypeOf :: Word32 -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Word32) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Word32) # gmapT :: (forall b. Data b => b -> b) -> Word32 -> Word32 # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Word32 -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Word32 -> r # gmapQ :: (forall d. Data d => d -> u) -> Word32 -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Word32 -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Word32 -> m Word32 # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Word32 -> m Word32 # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Word32 -> m Word32 # | |
| Bits Word32 | Since: base-2.1 |
Defined in GHC.Word Methods (.&.) :: Word32 -> Word32 -> Word32 # (.|.) :: Word32 -> Word32 -> Word32 # xor :: Word32 -> Word32 -> Word32 # complement :: Word32 -> Word32 # shift :: Word32 -> Int -> Word32 # rotate :: Word32 -> Int -> Word32 # setBit :: Word32 -> Int -> Word32 # clearBit :: Word32 -> Int -> Word32 # complementBit :: Word32 -> Int -> Word32 # testBit :: Word32 -> Int -> Bool # bitSizeMaybe :: Word32 -> Maybe Int # shiftL :: Word32 -> Int -> Word32 # unsafeShiftL :: Word32 -> Int -> Word32 # shiftR :: Word32 -> Int -> Word32 # unsafeShiftR :: Word32 -> Int -> Word32 # rotateL :: Word32 -> Int -> Word32 # | |
| FiniteBits Word32 | Since: base-4.6.0.0 |
Defined in GHC.Word Methods finiteBitSize :: Word32 -> Int # countLeadingZeros :: Word32 -> Int # countTrailingZeros :: Word32 -> Int # | |
| Bounded Word32 | Since: base-2.1 |
| Enum Word32 | Since: base-2.1 |
Defined in GHC.Word | |
| Ix Word32 | Since: base-2.1 |
| Num Word32 | Since: base-2.1 |
| Read Word32 | Since: base-2.1 |
| Integral Word32 | Since: base-2.1 |
| Real Word32 | Since: base-2.1 |
Defined in GHC.Word Methods toRational :: Word32 -> Rational # | |
| Show Word32 | Since: base-2.1 |
| NFData Word32 | |
Defined in Control.DeepSeq | |
| Eq Word32 | Since: base-2.1 |
| Ord Word32 | Since: base-2.1 |
| Hashable Word32 | |
Defined in Data.Hashable.Class | |
| Lift Word32 | |
16-bit unsigned integer type
Instances
| Data Word16 | Since: base-4.0.0.0 |
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Word16 -> c Word16 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Word16 # toConstr :: Word16 -> Constr # dataTypeOf :: Word16 -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Word16) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Word16) # gmapT :: (forall b. Data b => b -> b) -> Word16 -> Word16 # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Word16 -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Word16 -> r # gmapQ :: (forall d. Data d => d -> u) -> Word16 -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Word16 -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Word16 -> m Word16 # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Word16 -> m Word16 # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Word16 -> m Word16 # | |
| Bits Word16 | Since: base-2.1 |
Defined in GHC.Word Methods (.&.) :: Word16 -> Word16 -> Word16 # (.|.) :: Word16 -> Word16 -> Word16 # xor :: Word16 -> Word16 -> Word16 # complement :: Word16 -> Word16 # shift :: Word16 -> Int -> Word16 # rotate :: Word16 -> Int -> Word16 # setBit :: Word16 -> Int -> Word16 # clearBit :: Word16 -> Int -> Word16 # complementBit :: Word16 -> Int -> Word16 # testBit :: Word16 -> Int -> Bool # bitSizeMaybe :: Word16 -> Maybe Int # shiftL :: Word16 -> Int -> Word16 # unsafeShiftL :: Word16 -> Int -> Word16 # shiftR :: Word16 -> Int -> Word16 # unsafeShiftR :: Word16 -> Int -> Word16 # rotateL :: Word16 -> Int -> Word16 # | |
| FiniteBits Word16 | Since: base-4.6.0.0 |
Defined in GHC.Word Methods finiteBitSize :: Word16 -> Int # countLeadingZeros :: Word16 -> Int # countTrailingZeros :: Word16 -> Int # | |
| Bounded Word16 | Since: base-2.1 |
| Enum Word16 | Since: base-2.1 |
Defined in GHC.Word | |
| Ix Word16 | Since: base-2.1 |
| Num Word16 | Since: base-2.1 |
| Read Word16 | Since: base-2.1 |
| Integral Word16 | Since: base-2.1 |
| Real Word16 | Since: base-2.1 |
Defined in GHC.Word Methods toRational :: Word16 -> Rational # | |
| Show Word16 | Since: base-2.1 |
| NFData Word16 | |
Defined in Control.DeepSeq | |
| Eq Word16 | Since: base-2.1 |
| Ord Word16 | Since: base-2.1 |
| Hashable Word16 | |
Defined in Data.Hashable.Class | |
| Lift Word16 | |
byteSwap16 :: Word16 -> Word16 #
Reverse order of bytes in Word16.
Since: base-4.7.0.0
byteSwap32 :: Word32 -> Word32 #
Reverse order of bytes in Word32.
Since: base-4.7.0.0
byteSwap64 :: Word64 -> Word64 #
Reverse order of bytes in Word64.
Since: base-4.7.0.0
Single-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE single-precision type.
Instances
| Data Float | Since: base-4.0.0.0 |
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Float -> c Float # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Float # dataTypeOf :: Float -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Float) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Float) # gmapT :: (forall b. Data b => b -> b) -> Float -> Float # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Float -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Float -> r # gmapQ :: (forall d. Data d => d -> u) -> Float -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Float -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Float -> m Float # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Float -> m Float # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Float -> m Float # | |
| Floating Float | Since: base-2.1 |
| RealFloat Float | Since: base-2.1 |
Defined in GHC.Float Methods floatRadix :: Float -> Integer # floatDigits :: Float -> Int # floatRange :: Float -> (Int, Int) # decodeFloat :: Float -> (Integer, Int) # encodeFloat :: Integer -> Int -> Float # significand :: Float -> Float # scaleFloat :: Int -> Float -> Float # isInfinite :: Float -> Bool # isDenormalized :: Float -> Bool # isNegativeZero :: Float -> Bool # | |
| Read Float | Since: base-2.1 |
| NFData Float | |
Defined in Control.DeepSeq | |
| Eq Float | Note that due to the presence of
Also note that
|
| Ord Float | Note that due to the presence of
Also note that, due to the same,
|
| Hashable Float | Note: prior to The Since: hashable-1.3.0.0 |
Defined in Data.Hashable.Class | |
| Lift Float | |
| Generic1 (URec Float :: k -> Type) | |
| Foldable (UFloat :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => UFloat m -> m # foldMap :: Monoid m => (a -> m) -> UFloat a -> m # foldMap' :: Monoid m => (a -> m) -> UFloat a -> m # foldr :: (a -> b -> b) -> b -> UFloat a -> b # foldr' :: (a -> b -> b) -> b -> UFloat a -> b # foldl :: (b -> a -> b) -> b -> UFloat a -> b # foldl' :: (b -> a -> b) -> b -> UFloat a -> b # foldr1 :: (a -> a -> a) -> UFloat a -> a # foldl1 :: (a -> a -> a) -> UFloat a -> a # elem :: Eq a => a -> UFloat a -> Bool # maximum :: Ord a => UFloat a -> a # minimum :: Ord a => UFloat a -> a # | |
| Traversable (UFloat :: Type -> Type) | Since: base-4.9.0.0 |
| Functor (URec Float :: Type -> Type) | Since: base-4.9.0.0 |
| Generic (URec Float p) | |
| Show (URec Float p) | |
| Eq (URec Float p) | |
| Ord (URec Float p) | |
Defined in GHC.Generics | |
| data URec Float (p :: k) | Used for marking occurrences of Since: base-4.9.0.0 |
| type Rep1 (URec Float :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| type Rep (URec Float p) | |
Defined in GHC.Generics | |
Double-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE double-precision type.
Instances
| Data Double | Since: base-4.0.0.0 |
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Double -> c Double # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Double # toConstr :: Double -> Constr # dataTypeOf :: Double -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Double) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Double) # gmapT :: (forall b. Data b => b -> b) -> Double -> Double # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Double -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Double -> r # gmapQ :: (forall d. Data d => d -> u) -> Double -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Double -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Double -> m Double # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Double -> m Double # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Double -> m Double # | |
| Floating Double | Since: base-2.1 |
| RealFloat Double | Since: base-2.1 |
Defined in GHC.Float Methods floatRadix :: Double -> Integer # floatDigits :: Double -> Int # floatRange :: Double -> (Int, Int) # decodeFloat :: Double -> (Integer, Int) # encodeFloat :: Integer -> Int -> Double # significand :: Double -> Double # scaleFloat :: Int -> Double -> Double # isInfinite :: Double -> Bool # isDenormalized :: Double -> Bool # isNegativeZero :: Double -> Bool # | |
| Read Double | Since: base-2.1 |
| NFData Double | |
Defined in Control.DeepSeq | |
| Eq Double | Note that due to the presence of
Also note that
|
| Ord Double | Note that due to the presence of
Also note that, due to the same,
|
| Hashable Double | Note: prior to The Since: hashable-1.3.0.0 |
Defined in Data.Hashable.Class | |
| Lift Double | |
| Generic1 (URec Double :: k -> Type) | |
| Foldable (UDouble :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => UDouble m -> m # foldMap :: Monoid m => (a -> m) -> UDouble a -> m # foldMap' :: Monoid m => (a -> m) -> UDouble a -> m # foldr :: (a -> b -> b) -> b -> UDouble a -> b # foldr' :: (a -> b -> b) -> b -> UDouble a -> b # foldl :: (b -> a -> b) -> b -> UDouble a -> b # foldl' :: (b -> a -> b) -> b -> UDouble a -> b # foldr1 :: (a -> a -> a) -> UDouble a -> a # foldl1 :: (a -> a -> a) -> UDouble a -> a # elem :: Eq a => a -> UDouble a -> Bool # maximum :: Ord a => UDouble a -> a # minimum :: Ord a => UDouble a -> a # | |
| Traversable (UDouble :: Type -> Type) | Since: base-4.9.0.0 |
| Functor (URec Double :: Type -> Type) | Since: base-4.9.0.0 |
| Generic (URec Double p) | |
| Show (URec Double p) | Since: base-4.9.0.0 |
| Eq (URec Double p) | Since: base-4.9.0.0 |
| Ord (URec Double p) | Since: base-4.9.0.0 |
Defined in GHC.Generics Methods compare :: URec Double p -> URec Double p -> Ordering # (<) :: URec Double p -> URec Double p -> Bool # (<=) :: URec Double p -> URec Double p -> Bool # (>) :: URec Double p -> URec Double p -> Bool # (>=) :: URec Double p -> URec Double p -> Bool # | |
| data URec Double (p :: k) | Used for marking occurrences of Since: base-4.9.0.0 |
| type Rep1 (URec Double :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| type Rep (URec Double p) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
class Fractional a => Floating a where #
Trigonometric and hyperbolic functions and related functions.
The Haskell Report defines no laws for Floating. However, (, +)(
and *)exp are customarily expected to define an exponential field and have
the following properties:
exp (a + b)=exp a * exp bexp (fromInteger 0)=fromInteger 1
Minimal complete definition
pi, exp, log, sin, cos, asin, acos, atan, sinh, cosh, asinh, acosh, atanh
Instances
class (RealFrac a, Floating a) => RealFloat a where #
Efficient, machine-independent access to the components of a floating-point number.
Minimal complete definition
floatRadix, floatDigits, floatRange, decodeFloat, encodeFloat, isNaN, isInfinite, isDenormalized, isNegativeZero, isIEEE
Methods
floatRadix :: a -> Integer #
a constant function, returning the radix of the representation
(often 2)
floatDigits :: a -> Int #
a constant function, returning the number of digits of
floatRadix in the significand
floatRange :: a -> (Int, Int) #
a constant function, returning the lowest and highest values the exponent may assume
decodeFloat :: a -> (Integer, Int) #
The function decodeFloat applied to a real floating-point
number returns the significand expressed as an Integer and an
appropriately scaled exponent (an Int). If
yields decodeFloat x(m,n), then x is equal in value to m*b^^n, where b
is the floating-point radix, and furthermore, either m and n
are both zero or else b^(d-1) <= , where abs m < b^dd is
the value of .
In particular, floatDigits x. If the type
contains a negative zero, also decodeFloat 0 = (0,0).
The result of decodeFloat (-0.0) = (0,0) is unspecified if either of
decodeFloat x or isNaN x is isInfinite xTrue.
encodeFloat :: Integer -> Int -> a #
encodeFloat performs the inverse of decodeFloat in the
sense that for finite x with the exception of -0.0,
.
uncurry encodeFloat (decodeFloat x) = x is one of the two closest representable
floating-point numbers to encodeFloat m nm*b^^n (or ±Infinity if overflow
occurs); usually the closer, but if m contains too many bits,
the result may be rounded in the wrong direction.
True if the argument is an IEEE "not-a-number" (NaN) value
isInfinite :: a -> Bool #
True if the argument is an IEEE infinity or negative infinity
isDenormalized :: a -> Bool #
True if the argument is too small to be represented in
normalized format
isNegativeZero :: a -> Bool #
True if the argument is an IEEE negative zero
True if the argument is an IEEE floating point number
a version of arctangent taking two real floating-point arguments.
For real floating x and y, computes the angle
(from the positive x-axis) of the vector from the origin to the
point atan2 y x(x,y). returns a value in the range [atan2 y x-pi,
pi]. It follows the Common Lisp semantics for the origin when
signed zeroes are supported. , with atan2 y 1y in a type
that is RealFloat, should return the same value as .
A default definition of atan yatan2 is provided, but implementors
can provide a more accurate implementation.
Instances
Arbitrary precision integers. In contrast with fixed-size integral types
such as Int, the Integer type represents the entire infinite range of
integers.
Integers are stored in a kind of sign-magnitude form, hence do not expect two's complement form when using bit operations.
If the value is small (fit into an Int), IS constructor is used.
Otherwise Integer and IN constructors are used to store a BigNat
representing respectively the positive or the negative value magnitude.
Invariant: Integer and IN are used iff value doesn't fit in IS
Instances
| Data Integer | Since: base-4.0.0.0 |
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Integer -> c Integer # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Integer # toConstr :: Integer -> Constr # dataTypeOf :: Integer -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Integer) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Integer) # gmapT :: (forall b. Data b => b -> b) -> Integer -> Integer # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Integer -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Integer -> r # gmapQ :: (forall d. Data d => d -> u) -> Integer -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Integer -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Integer -> m Integer # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Integer -> m Integer # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Integer -> m Integer # | |
| Bits Integer | Since: base-2.1 |
Defined in GHC.Bits Methods (.&.) :: Integer -> Integer -> Integer # (.|.) :: Integer -> Integer -> Integer # xor :: Integer -> Integer -> Integer # complement :: Integer -> Integer # shift :: Integer -> Int -> Integer # rotate :: Integer -> Int -> Integer # setBit :: Integer -> Int -> Integer # clearBit :: Integer -> Int -> Integer # complementBit :: Integer -> Int -> Integer # testBit :: Integer -> Int -> Bool # bitSizeMaybe :: Integer -> Maybe Int # shiftL :: Integer -> Int -> Integer # unsafeShiftL :: Integer -> Int -> Integer # shiftR :: Integer -> Int -> Integer # unsafeShiftR :: Integer -> Int -> Integer # rotateL :: Integer -> Int -> Integer # | |
| Enum Integer | Since: base-2.1 |
| Num Integer | Since: base-2.1 |
| Read Integer | Since: base-2.1 |
| Integral Integer | Since: base-2.0.1 |
Defined in GHC.Real | |
| Real Integer | Since: base-2.0.1 |
Defined in GHC.Real Methods toRational :: Integer -> Rational # | |
| Show Integer | Since: base-2.1 |
| NFData Integer | |
Defined in Control.DeepSeq | |
| Eq Integer | |
| Ord Integer | |
| Hashable Integer | |
Defined in Data.Hashable.Class | |
| Lift Integer | |
Basic numeric class.
The Haskell Report defines no laws for Num. However, ( and +)( are
customarily expected to define a ring and have the following properties:*)
- Associativity of
(+) (x + y) + z=x + (y + z)- Commutativity of
(+) x + y=y + xis the additive identityfromInteger0x + fromInteger 0=xnegategives the additive inversex + negate x=fromInteger 0- Associativity of
(*) (x * y) * z=x * (y * z)is the multiplicative identityfromInteger1x * fromInteger 1=xandfromInteger 1 * x=x- Distributivity of
(with respect to*)(+) a * (b + c)=(a * b) + (a * c)and(b + c) * a=(b * a) + (c * a)- Coherence with
toInteger - if the type also implements
Integral, thenfromIntegeris a left inverse fortoInteger, i.e.fromInteger (toInteger i) == i
Note that it isn't customarily expected that a type instance of both Num
and Ord implement an ordered ring. Indeed, in base only Integer and
Rational do.
Methods
Unary negation.
Absolute value.
Sign of a number.
The functions abs and signum should satisfy the law:
abs x * signum x == x
For real numbers, the signum is either -1 (negative), 0 (zero)
or 1 (positive).
fromInteger :: Integer -> a #
Conversion from an Integer.
An integer literal represents the application of the function
fromInteger to the appropriate value of type Integer,
so such literals have type (.Num a) => a
Instances
| Num Int16 | Since: base-2.1 |
| Num Int32 | Since: base-2.1 |
| Num Int64 | Since: base-2.1 |
| Num Int8 | Since: base-2.1 |
| Num Word16 | Since: base-2.1 |
| Num Word32 | Since: base-2.1 |
| Num Word64 | Since: base-2.1 |
| Num Word8 | Since: base-2.1 |
| Num Integer | Since: base-2.1 |
| Num Natural | Note that Since: base-4.8.0.0 |
| Num Int | Since: base-2.1 |
| Num Word | Since: base-2.1 |
| RealFloat a => Num (Complex a) | Since: base-2.1 |
| Num a => Num (Identity a) | Since: base-4.9.0.0 |
Defined in Data.Functor.Identity | |
| Num a => Num (Down a) | Since: base-4.11.0.0 |
| Num a => Num (Max a) | Since: base-4.9.0.0 |
| Num a => Num (Min a) | Since: base-4.9.0.0 |
| Num a => Num (Product a) | Since: base-4.7.0.0 |
Defined in Data.Semigroup.Internal | |
| Num a => Num (Sum a) | Since: base-4.7.0.0 |
| Integral a => Num (Ratio a) | Since: base-2.0.1 |
| Num a => Num (Op a b) | |
| Num a => Num (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const | |
| (Applicative f, Num a) => Num (Ap f a) | Note that even if the underlying Commutativity:
Additive inverse:
Distributivity:
Since: base-4.12.0.0 |
| Num (f a) => Num (Alt f a) | Since: base-4.8.0.0 |
class (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 ywithrem x y=fromInteger 0org (rem x y)<g yx=y * div x y + mod x ywithmod x y=fromInteger 0orf (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 -> a infixl 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.
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.
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.
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.
WARNING: This function is partial (because it throws when 0 is passed as
the divisor) for all the integer types in base.
WARNING: This function is partial (because it throws when 0 is passed as
the divisor) for all the integer types in base.
conversion to Integer
Instances
| Integral Int16 | Since: base-2.1 |
| Integral Int32 | Since: base-2.1 |
| Integral Int64 | Since: base-2.1 |
| Integral Int8 | Since: base-2.1 |
| Integral Word16 | Since: base-2.1 |
| Integral Word32 | Since: base-2.1 |
| Integral Word64 | Since: base-2.1 |
| Integral Word8 | Since: base-2.1 |
| Integral Integer | Since: base-2.0.1 |
Defined in GHC.Real | |
| Integral Natural | Since: base-4.8.0.0 |
Defined in GHC.Real | |
| Integral Int | Since: base-2.0.1 |
| Integral Word | Since: base-2.1 |
| Integral a => Integral (Identity a) | Since: base-4.9.0.0 |
Defined in Data.Functor.Identity Methods quot :: Identity a -> Identity a -> Identity a # rem :: Identity a -> Identity a -> Identity a # div :: Identity a -> Identity a -> Identity a # mod :: Identity a -> Identity a -> Identity a # quotRem :: Identity a -> Identity a -> (Identity a, Identity a) # divMod :: Identity a -> Identity a -> (Identity a, Identity a) # | |
| Integral a => Integral (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods quot :: Const a b -> Const a b -> Const a b # rem :: Const a b -> Const a b -> Const a b # div :: Const a b -> Const a b -> Const a b # mod :: Const a b -> Const a b -> Const a b # quotRem :: Const a b -> Const a b -> (Const a b, Const a b) # divMod :: Const a b -> Const a b -> (Const a b, Const a b) # | |
class 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:*)
recipgives the multiplicative inversex * recip x=recip x * x=fromInteger 1- Totality of
toRational toRationalis total- Coherence with
toRational - if the type also implements
Real, thenfromRationalis a left inverse fortoRational, 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.
Minimal complete definition
fromRational, (recip | (/))
Methods
Fractional division.
Reciprocal fraction.
fromRational :: Rational -> a #
Conversion from a Rational (that is ).
A floating literal stands for an application of Ratio IntegerfromRational
to a value of type Rational, so such literals have type
(.Fractional a) => a
Instances
| RealFloat a => Fractional (Complex a) | Since: base-2.1 |
| Fractional a => Fractional (Identity a) | Since: base-4.9.0.0 |
| Fractional a => Fractional (Down a) | Since: base-4.14.0.0 |
| Integral a => Fractional (Ratio a) | Since: base-2.0.1 |
| Fractional a => Fractional (Op a b) | |
| Fractional a => Fractional (Const a b) | Since: base-4.9.0.0 |
class (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, thenfromRationalis a left inverse fortoRational, i.e.fromRational (toRational i) = i
Methods
toRational :: a -> Rational #
the rational equivalent of its real argument with full precision
Instances
| Real Int16 | Since: base-2.1 |
Defined in GHC.Int Methods toRational :: Int16 -> Rational # | |
| Real Int32 | Since: base-2.1 |
Defined in GHC.Int Methods toRational :: Int32 -> Rational # | |
| Real Int64 | Since: base-2.1 |
Defined in GHC.Int Methods toRational :: Int64 -> Rational # | |
| Real Int8 | Since: base-2.1 |
Defined in GHC.Int Methods toRational :: Int8 -> Rational # | |
| Real Word16 | Since: base-2.1 |
Defined in GHC.Word Methods toRational :: Word16 -> Rational # | |
| Real Word32 | Since: base-2.1 |
Defined in GHC.Word Methods toRational :: Word32 -> Rational # | |
| Real Word64 | Since: base-2.1 |
Defined in GHC.Word Methods toRational :: Word64 -> Rational # | |
| Real Word8 | Since: base-2.1 |
Defined in GHC.Word Methods toRational :: Word8 -> Rational # | |
| Real Integer | Since: base-2.0.1 |
Defined in GHC.Real Methods toRational :: Integer -> Rational # | |
| Real Natural | Since: base-4.8.0.0 |
Defined in GHC.Real Methods toRational :: Natural -> Rational # | |
| Real Int | Since: base-2.0.1 |
Defined in GHC.Real Methods toRational :: Int -> Rational # | |
| Real Word | Since: base-2.1 |
Defined in GHC.Real Methods toRational :: Word -> Rational # | |
| Real a => Real (Identity a) | Since: base-4.9.0.0 |
Defined in Data.Functor.Identity Methods toRational :: Identity a -> Rational # | |
| Real a => Real (Down a) | Since: base-4.14.0.0 |
Defined in Data.Ord Methods toRational :: Down a -> Rational # | |
| Integral a => Real (Ratio a) | Since: base-2.0.1 |
Defined in GHC.Real Methods toRational :: Ratio a -> Rational # | |
| Real a => Real (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods toRational :: Const a b -> Rational # | |
class (Real a, Fractional a) => RealFrac a where #
Extracting components of fractions.
Minimal complete definition
Methods
properFraction :: Integral b => a -> (b, a) #
The function properFraction takes a real fractional number x
and returns a pair (n,f) such that x = n+f, and:
nis an integral number with the same sign asx; andfis a fraction with the same type and sign asx, and with absolute value less than1.
The default definitions of the ceiling, floor, truncate
and round functions are in terms of properFraction.
truncate :: Integral b => a -> b #
returns the integer nearest truncate xx between zero and x
round :: Integral b => a -> b #
returns the nearest integer to round xx;
the even integer if x is equidistant between two integers
ceiling :: Integral b => a -> b #
returns the least integer not less than ceiling xx
floor :: Integral b => a -> b #
returns the greatest integer not greater than floor xx
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.
Instances
| NFData1 Ratio | Available on Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
| Integral a => Lift (Ratio a :: Type) | |
| (Data a, Integral a) => Data (Ratio a) | Since: base-4.0.0.0 |
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) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Ratio a) # toConstr :: Ratio a -> Constr # dataTypeOf :: Ratio a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Ratio a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Ratio a)) # gmapT :: (forall b. Data b => b -> b) -> Ratio a -> Ratio a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Ratio a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Ratio a -> r # gmapQ :: (forall d. Data d => d -> u) -> Ratio a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Ratio a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Ratio a -> m (Ratio a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Ratio a -> m (Ratio a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Ratio a -> m (Ratio a) # | |
| Integral a => Enum (Ratio a) | Since: base-2.0.1 |
| Integral a => Num (Ratio a) | Since: base-2.0.1 |
| (Integral a, Read a) => Read (Ratio a) | Since: base-2.1 |
| Integral a => Fractional (Ratio a) | Since: base-2.0.1 |
| Integral a => Real (Ratio a) | Since: base-2.0.1 |
Defined in GHC.Real Methods toRational :: Ratio a -> Rational # | |
| Integral a => RealFrac (Ratio a) | Since: base-2.0.1 |
| Show a => Show (Ratio a) | Since: base-2.0.1 |
| NFData a => NFData (Ratio a) | |
Defined in Control.DeepSeq | |
| Eq a => Eq (Ratio a) | Since: base-2.1 |
| Integral a => Ord (Ratio a) | Since: base-2.0.1 |
| Hashable a => Hashable (Ratio a) | |
Defined in Data.Hashable.Class | |
fromIntegral :: (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.
realToFrac :: (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
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 #
Extract the denominator of the ratio in reduced form: the numerator and denominator have no common factor and the denominator is positive.
(^^) :: (Fractional a, Integral b) => a -> b -> a infixr 8 #
raise a number to an integral power
gcd :: Integral a => a -> a -> a #
is the non-negative factor of both gcd x yx 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 44. = gcd 0 00.
(That is, the common divisor that is "greatest" in the divisibility
preordering.)
Note: Since for signed fixed-width integer types, ,
the result may be negative if one of the arguments is abs minBound < 0 (and
necessarily is if the other is minBound0 or ) for such types.minBound
lcm :: Integral a => a -> a -> a #
is the smallest positive integer that both lcm x yx and y divide.
Natural number
Invariant: numbers <= 0xffffffffffffffff use the NS constructor
Instances
| Data Natural | Since: base-4.8.0.0 |
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Natural -> c Natural # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Natural # toConstr :: Natural -> Constr # dataTypeOf :: Natural -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Natural) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Natural) # gmapT :: (forall b. Data b => b -> b) -> Natural -> Natural # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Natural -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Natural -> r # gmapQ :: (forall d. Data d => d -> u) -> Natural -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Natural -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Natural -> m Natural # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Natural -> m Natural # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Natural -> m Natural # | |
| Bits Natural | Since: base-4.8.0 |
Defined in GHC.Bits Methods (.&.) :: Natural -> Natural -> Natural # (.|.) :: Natural -> Natural -> Natural # xor :: Natural -> Natural -> Natural # complement :: Natural -> Natural # shift :: Natural -> Int -> Natural # rotate :: Natural -> Int -> Natural # setBit :: Natural -> Int -> Natural # clearBit :: Natural -> Int -> Natural # complementBit :: Natural -> Int -> Natural # testBit :: Natural -> Int -> Bool # bitSizeMaybe :: Natural -> Maybe Int # shiftL :: Natural -> Int -> Natural # unsafeShiftL :: Natural -> Int -> Natural # shiftR :: Natural -> Int -> Natural # unsafeShiftR :: Natural -> Int -> Natural # rotateL :: Natural -> Int -> Natural # | |
| Enum Natural | Since: base-4.8.0.0 |
| Num Natural | Note that Since: base-4.8.0.0 |
| Read Natural | Since: base-4.8.0.0 |
| Integral Natural | Since: base-4.8.0.0 |
Defined in GHC.Real | |
| Real Natural | Since: base-4.8.0.0 |
Defined in GHC.Real Methods toRational :: Natural -> Rational # | |
| Show Natural | Since: base-4.8.0.0 |
| NFData Natural | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
| Eq Natural | |
| Ord Natural | |
| Hashable Natural | |
Defined in Data.Hashable.Class | |
| TestCoercion SNat | Since: base-4.18.0.0 |
Defined in GHC.TypeNats | |
| TestEquality SNat | Since: base-4.18.0.0 |
Defined in GHC.TypeNats | |
| Lift Natural | |
| type Compare (a :: Natural) (b :: Natural) | |
Defined in Data.Type.Ord | |
Combinators
integerToBounded :: forall a. (Integral a, Bounded a) => Integer -> Maybe a Source #
Transforms an integer number to a bounded integral.
It returns Nothing for integers outside the bound of the return type.
>>>integerToBounded @Int 42Just 42
>>>integerToBounded @Int8 1024Nothing
>>>integerToBounded @Int (toInteger (minBound :: Int))Just (-9223372036854775808)>>>integerToBounded @Int $ (toInteger (minBound :: Int)) - 1Nothing
>>>integerToBounded @Int (toInteger (maxBound :: Int))Just 9223372036854775807>>>integerToBounded @Int $ (toInteger (maxBound :: Int)) + 1Nothing
If you want to convert Int or Word to a bounded type, take a look at
toIntegralSized function instead.
Since: 0.5.0