Safe Haskell | None |
---|---|
Language | Haskell2010 |
Integral classes
Synopsis
- class Distributive a => Integral a where
- class ToIntegral a b where
- toIntegral :: a -> b
- type ToInteger a = ToIntegral a Integer
- toInteger :: ToInteger a => a -> Integer
- class FromIntegral a b where
- fromIntegral_ :: b -> a
- class FromInteger a where
- fromInteger :: Integer -> a
- fromIntegral :: (FromInteger b, ToInteger a) => a -> b
- even :: (Eq a, Integral a) => a -> Bool
- odd :: (Eq a, Integral a) => a -> Bool
- (^) :: (Ord b, Multiplicative a, Integral b) => a -> b -> a
- (^^) :: (Divisive a, Subtractive b, Integral b, Ord b) => a -> b -> a
Documentation
class Distributive a => Integral a where Source #
Integral laws
b == zero || b * (a `div` b) + (a `mod` b) == a
div :: a -> a -> a infixl 7 Source #
mod :: a -> a -> a infixl 7 Source #
Instances
class ToIntegral a b where Source #
toIntegral is kept separate from Integral to help with compatability issues. > toIntegral a == a
Nothing
toIntegral :: a -> b Source #
toIntegral :: a ~ b => a -> b Source #
Instances
type ToInteger a = ToIntegral a Integer Source #
class FromIntegral a b where Source #
fromIntegral abstracts the codomain type, compared with the preludes Integral type. > fromIntegral_ a == a
fromIntegral is widely used as general coercion, hence the underscore for the operator.
Nothing
fromIntegral_ :: b -> a Source #
fromIntegral_ :: a ~ b => b -> a Source #
Instances
class FromInteger a where Source #
ghc defaulting rules and, it seems, -XExtendedDefaultRules do not permit multiple parameter typeclasses to be in the mix when types are resolved, hence the simpler `type FromInteger a = FromIntegral a Integer` does not suffice.
Nothing
fromInteger :: Integer -> a Source #
fromInteger :: FromIntegral a Integer => Integer -> a Source #
Instances
fromIntegral :: (FromInteger b, ToInteger a) => a -> b Source #
general coercion via Integer