Copyright | (c) The University of Glasgow 2001 |
---|---|
License | BSD-style (see the file libraries/base/LICENSE) |
Maintainer | libraries@haskell.org |
Stability | stable |
Portability | portable |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
The Prelude: a standard module. The Prelude is imported by default into all Haskell modules unless either there is an explicit import statement for it, or the NoImplicitPrelude extension is enabled.
Synopsis
- data Bool
- (&&) :: Bool -> Bool -> Bool
- (||) :: Bool -> Bool -> Bool
- not :: Bool -> Bool
- otherwise :: Bool
- data Maybe a
- maybe :: b -> (a -> b) -> Maybe a -> b
- data Either a b
- either :: (a -> c) -> (b -> c) -> Either a b -> c
- data Ordering
- data Char
- type String = [Char]
- fst :: (a, b) -> a
- snd :: (a, b) -> b
- curry :: ((a, b) -> c) -> a -> b -> c
- uncurry :: (a -> b -> c) -> (a, b) -> c
- class Eq a where
- class Eq a => Ord a where
- class Enum a where
- succ :: a -> a
- pred :: a -> a
- toEnum :: Int -> a
- fromEnum :: a -> Int
- enumFrom :: a -> [a]
- enumFromThen :: a -> a -> [a]
- enumFromTo :: a -> a -> [a]
- enumFromThenTo :: a -> a -> a -> [a]
- class Bounded a where
- data Int
- data Integer
- data Float
- data Double
- type Rational = Ratio Integer
- data Word
- class Num a where
- class (Num a, Ord a) => Real a where
- toRational :: a -> Rational
- class (Real a, Enum a) => Integral a where
- class Num a => Fractional a where
- (/) :: a -> a -> a
- recip :: a -> a
- fromRational :: Rational -> a
- class Fractional a => Floating a where
- class (Real a, Fractional a) => RealFrac 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
- exponent :: a -> Int
- significand :: a -> a
- scaleFloat :: Int -> a -> a
- isNaN :: a -> Bool
- isInfinite :: a -> Bool
- isDenormalized :: a -> Bool
- isNegativeZero :: a -> Bool
- isIEEE :: a -> Bool
- atan2 :: a -> a -> a
- subtract :: Num a => a -> a -> a
- even :: Integral a => a -> Bool
- odd :: Integral a => a -> Bool
- gcd :: Integral a => a -> a -> a
- lcm :: Integral a => a -> a -> a
- (^) :: (Num a, Integral b) => a -> b -> a
- (^^) :: (Fractional a, Integral b) => a -> b -> a
- fromIntegral :: (Integral a, Num b) => a -> b
- realToFrac :: (Real a, Fractional b) => a -> b
- class Semigroup a where
- (<>) :: a -> a -> a
- class Semigroup a => Monoid a where
- class Functor (f :: Type -> Type) where
- (<$>) :: Functor f => (a -> b) -> f a -> f b
- class Functor f => Applicative (f :: Type -> Type) where
- class Applicative m => Monad (m :: Type -> Type) where
- class Monad m => MonadFail (m :: Type -> Type) where
- mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m ()
- sequence_ :: (Foldable t, Monad m) => t (m a) -> m ()
- (=<<) :: Monad m => (a -> m b) -> m a -> m b
- class Foldable (t :: Type -> Type) where
- foldMap :: Monoid m => (a -> m) -> t a -> m
- foldr :: (a -> b -> b) -> b -> t a -> b
- foldl :: (b -> a -> b) -> b -> t a -> b
- foldl' :: (b -> a -> b) -> b -> t a -> b
- foldr1 :: (a -> a -> a) -> t a -> a
- foldl1 :: (a -> a -> a) -> t a -> a
- elem :: Eq a => a -> t a -> Bool
- maximum :: Ord a => t a -> a
- minimum :: Ord a => t a -> a
- sum :: Num a => t a -> a
- product :: Num a => t a -> a
- class (Functor t, Foldable t) => Traversable (t :: Type -> Type) where
- traverse :: Applicative f => (a -> f b) -> t a -> f (t b)
- sequenceA :: Applicative f => t (f a) -> f (t a)
- mapM :: Monad m => (a -> m b) -> t a -> m (t b)
- sequence :: Monad m => t (m a) -> m (t a)
- id :: a -> a
- const :: a -> b -> a
- (.) :: (b -> c) -> (a -> b) -> a -> c
- flip :: (a -> b -> c) -> b -> a -> c
- ($) :: (a -> b) -> a -> b
- until :: (a -> Bool) -> (a -> a) -> a -> a
- asTypeOf :: a -> a -> a
- error :: HasCallStack => [Char] -> a
- errorWithoutStackTrace :: [Char] -> a
- undefined :: HasCallStack => a
- seq :: a -> b -> b
- ($!) :: (a -> b) -> a -> b
- map :: (a -> b) -> [a] -> [b]
- (++) :: [a] -> [a] -> [a]
- filter :: (a -> Bool) -> [a] -> [a]
- head :: HasCallStack => [a] -> a
- last :: HasCallStack => [a] -> a
- tail :: HasCallStack => [a] -> [a]
- init :: HasCallStack => [a] -> [a]
- (!!) :: HasCallStack => [a] -> Int -> a
- null :: Foldable t => t a -> Bool
- length :: Foldable t => t a -> Int
- reverse :: [a] -> [a]
- and :: Foldable t => t Bool -> Bool
- or :: Foldable t => t Bool -> Bool
- any :: Foldable t => (a -> Bool) -> t a -> Bool
- all :: Foldable t => (a -> Bool) -> t a -> Bool
- concat :: Foldable t => t [a] -> [a]
- concatMap :: Foldable t => (a -> [b]) -> t a -> [b]
- scanl :: (b -> a -> b) -> b -> [a] -> [b]
- scanl1 :: (a -> a -> a) -> [a] -> [a]
- scanr :: (a -> b -> b) -> b -> [a] -> [b]
- scanr1 :: (a -> a -> a) -> [a] -> [a]
- iterate :: (a -> a) -> a -> [a]
- repeat :: a -> [a]
- replicate :: Int -> a -> [a]
- cycle :: HasCallStack => [a] -> [a]
- take :: Int -> [a] -> [a]
- drop :: Int -> [a] -> [a]
- takeWhile :: (a -> Bool) -> [a] -> [a]
- dropWhile :: (a -> Bool) -> [a] -> [a]
- span :: (a -> Bool) -> [a] -> ([a], [a])
- break :: (a -> Bool) -> [a] -> ([a], [a])
- splitAt :: Int -> [a] -> ([a], [a])
- notElem :: (Foldable t, Eq a) => a -> t a -> Bool
- lookup :: Eq a => a -> [(a, b)] -> Maybe b
- zip :: [a] -> [b] -> [(a, b)]
- zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]
- zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
- zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
- unzip :: [(a, b)] -> ([a], [b])
- unzip3 :: [(a, b, c)] -> ([a], [b], [c])
- lines :: String -> [String]
- words :: String -> [String]
- unlines :: [String] -> String
- unwords :: [String] -> String
- type ShowS = String -> String
- class Show a where
- shows :: Show a => a -> ShowS
- showChar :: Char -> ShowS
- showString :: String -> ShowS
- showParen :: Bool -> ShowS -> ShowS
- type ReadS a = String -> [(a, String)]
- class Read a where
- reads :: Read a => ReadS a
- readParen :: Bool -> ReadS a -> ReadS a
- read :: Read a => String -> a
- lex :: ReadS String
- data IO a
- putChar :: Char -> IO ()
- putStr :: String -> IO ()
- putStrLn :: String -> IO ()
- print :: Show a => a -> IO ()
- getChar :: IO Char
- getLine :: IO String
- getContents :: IO String
- interact :: (String -> String) -> IO ()
- type FilePath = String
- readFile :: FilePath -> IO String
- writeFile :: FilePath -> String -> IO ()
- appendFile :: FilePath -> String -> IO ()
- readIO :: Read a => String -> IO a
- readLn :: Read a => IO a
- type IOError = IOException
- ioError :: HasCallStack => IOError -> IO a
- userError :: String -> IOError
- class a ~# b => (a :: k) ~ (b :: k)
Standard types, classes and related functions
Basic data types
Instances
The Maybe
type encapsulates an optional value. A value of type
either contains a value of type Maybe
aa
(represented as
),
or it is empty (represented as Just
aNothing
). Using Maybe
is a good way to
deal with errors or exceptional cases without resorting to drastic
measures such as error
.
The Maybe
type is also a monad. It is a simple kind of error
monad, where all errors are represented by Nothing
. A richer
error monad can be built using the Either
type.
Instances
Eq1 Maybe Source # | Since: base-4.9.0.0 | ||||
Ord1 Maybe Source # | Since: base-4.9.0.0 | ||||
Defined in Data.Functor.Classes | |||||
Read1 Maybe Source # | Since: base-4.9.0.0 | ||||
Defined in Data.Functor.Classes liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Maybe a) Source # liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Maybe a] Source # liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Maybe a) Source # liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Maybe a] Source # | |||||
Show1 Maybe Source # | Since: base-4.9.0.0 | ||||
Alternative Maybe Source # | Picks the leftmost Since: base-2.1 | ||||
Applicative Maybe Source # | Since: base-2.1 | ||||
Functor Maybe Source # | Since: base-2.1 | ||||
Monad Maybe Source # | Since: base-2.1 | ||||
MonadPlus Maybe Source # | Picks the leftmost Since: base-2.1 | ||||
MonadFail Maybe Source # | Since: base-4.9.0.0 | ||||
MonadFix Maybe Source # | Since: base-2.1 | ||||
MonadZip Maybe Source # | Since: ghc-internal-4.8.0.0 | ||||
Foldable Maybe Source # | Since: base-2.1 | ||||
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => Maybe m -> m Source # foldMap :: Monoid m => (a -> m) -> Maybe a -> m Source # foldMap' :: Monoid m => (a -> m) -> Maybe a -> m Source # foldr :: (a -> b -> b) -> b -> Maybe a -> b Source # foldr' :: (a -> b -> b) -> b -> Maybe a -> b Source # foldl :: (b -> a -> b) -> b -> Maybe a -> b Source # foldl' :: (b -> a -> b) -> b -> Maybe a -> b Source # foldr1 :: (a -> a -> a) -> Maybe a -> a Source # foldl1 :: (a -> a -> a) -> Maybe a -> a Source # toList :: Maybe a -> [a] Source # null :: Maybe a -> Bool Source # length :: Maybe a -> Int Source # elem :: Eq a => a -> Maybe a -> Bool Source # maximum :: Ord a => Maybe a -> a Source # minimum :: Ord a => Maybe a -> a Source # | |||||
Traversable Maybe Source # | Since: base-2.1 | ||||
Defined in GHC.Internal.Data.Traversable | |||||
Generic1 Maybe Source # | |||||
Defined in GHC.Internal.Generics
| |||||
Lift a => Lift (Maybe a :: Type) Source # | |||||
Semigroup a => Monoid (Maybe a) Source # | Lift a semigroup into Since 4.11.0: constraint on inner Since: base-2.1 | ||||
Semigroup a => Semigroup (Maybe a) Source # | Since: base-4.9.0.0 | ||||
Data a => Data (Maybe a) Source # | Since: base-4.0.0.0 | ||||
Defined in GHC.Internal.Data.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Maybe a -> c (Maybe a) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Maybe a) Source # toConstr :: Maybe a -> Constr Source # dataTypeOf :: Maybe a -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Maybe a)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Maybe a)) Source # gmapT :: (forall b. Data b => b -> b) -> Maybe a -> Maybe a Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Maybe a -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Maybe a -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Maybe a -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Maybe a -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a) Source # | |||||
Generic (Maybe a) Source # | |||||
Defined in GHC.Internal.Generics
| |||||
SingKind a => SingKind (Maybe a) | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Generics
| |||||
Read a => Read (Maybe a) Source # | Since: base-2.1 | ||||
Show a => Show (Maybe a) Source # | Since: base-2.1 | ||||
Eq a => Eq (Maybe a) Source # | Since: base-2.1 | ||||
Ord a => Ord (Maybe a) Source # | Since: base-2.1 | ||||
SingI ('Nothing :: Maybe a) | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Generics | |||||
SingI a2 => SingI ('Just a2 :: Maybe a1) | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Generics | |||||
type Rep1 Maybe Source # | Since: base-4.6.0.0 | ||||
Defined in GHC.Internal.Generics | |||||
type DemoteRep (Maybe a) Source # | |||||
Defined in GHC.Internal.Generics | |||||
type Rep (Maybe a) Source # | Since: base-4.6.0.0 | ||||
Defined in GHC.Internal.Generics | |||||
data Sing (b :: Maybe a) Source # | |||||
maybe :: b -> (a -> b) -> Maybe a -> b Source #
The maybe
function takes a default value, a function, and a Maybe
value. If the Maybe
value is Nothing
, the function returns the
default value. Otherwise, it applies the function to the value inside
the Just
and returns the result.
Examples
Basic usage:
>>>
maybe False odd (Just 3)
True
>>>
maybe False odd Nothing
False
Read an integer from a string using readMaybe
. If we succeed,
return twice the integer; that is, apply (*2)
to it. If instead
we fail to parse an integer, return 0
by default:
>>>
import GHC.Internal.Text.Read ( readMaybe )
>>>
maybe 0 (*2) (readMaybe "5")
10>>>
maybe 0 (*2) (readMaybe "")
0
Apply show
to a Maybe Int
. If we have Just n
, we want to show
the underlying Int
n
. But if we have Nothing
, we return the
empty string instead of (for example) "Nothing":
>>>
maybe "" show (Just 5)
"5">>>
maybe "" show Nothing
""
The Either
type represents values with two possibilities: a value of
type
is either Either
a b
or Left
a
.Right
b
The Either
type is sometimes used to represent a value which is
either correct or an error; by convention, the Left
constructor is
used to hold an error value and the Right
constructor is used to
hold a correct value (mnemonic: "right" also means "correct").
Examples
The type
is the type of values which can be either
a Either
String
Int
String
or an Int
. The Left
constructor can be used only on
String
s, and the Right
constructor can be used only on Int
s:
>>>
let s = Left "foo" :: Either String Int
>>>
s
Left "foo">>>
let n = Right 3 :: Either String Int
>>>
n
Right 3>>>
:type s
s :: Either String Int>>>
:type n
n :: Either String Int
The fmap
from our Functor
instance will ignore Left
values, but
will apply the supplied function to values contained in a Right
:
>>>
let s = Left "foo" :: Either String Int
>>>
let n = Right 3 :: Either String Int
>>>
fmap (*2) s
Left "foo">>>
fmap (*2) n
Right 6
The Monad
instance for Either
allows us to chain together multiple
actions which may fail, and fail overall if any of the individual
steps failed. First we'll write a function that can either parse an
Int
from a Char
, or fail.
>>>
import Data.Char ( digitToInt, isDigit )
>>>
:{
let parseEither :: Char -> Either String Int parseEither c | isDigit c = Right (digitToInt c) | otherwise = Left "parse error">>>
:}
The following should work, since both '1'
and '2'
can be
parsed as Int
s.
>>>
:{
let parseMultiple :: Either String Int parseMultiple = do x <- parseEither '1' y <- parseEither '2' return (x + y)>>>
:}
>>>
parseMultiple
Right 3
But the following should fail overall, since the first operation where
we attempt to parse 'm'
as an Int
will fail:
>>>
:{
let parseMultiple :: Either String Int parseMultiple = do x <- parseEither 'm' y <- parseEither '2' return (x + y)>>>
:}
>>>
parseMultiple
Left "parse error"
Instances
Bifoldable Either Source # | Since: base-4.10.0.0 | ||||
Bifoldable1 Either Source # | |||||
Bifunctor Either Source # | Since: base-4.8.0.0 | ||||
Bitraversable Either Source # | Since: base-4.10.0.0 | ||||
Defined in Data.Bitraversable bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Either a b -> f (Either c d) Source # | |||||
Eq2 Either Source # | Since: base-4.9.0.0 | ||||
Ord2 Either Source # | Since: base-4.9.0.0 | ||||
Defined in Data.Functor.Classes | |||||
Read2 Either Source # | Since: base-4.9.0.0 | ||||
Defined in Data.Functor.Classes liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (Either a b) Source # liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [Either a b] Source # liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (Either a b) Source # liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [Either a b] Source # | |||||
Show2 Either Source # | Since: base-4.9.0.0 | ||||
Generic1 (Either a :: Type -> Type) Source # | |||||
Defined in GHC.Internal.Generics
| |||||
(Lift a, Lift b) => Lift (Either a b :: Type) Source # | |||||
Eq a => Eq1 (Either a) Source # | Since: base-4.9.0.0 | ||||
Ord a => Ord1 (Either a) Source # | Since: base-4.9.0.0 | ||||
Defined in Data.Functor.Classes | |||||
Read a => Read1 (Either a) Source # | Since: base-4.9.0.0 | ||||
Defined in Data.Functor.Classes liftReadsPrec :: (Int -> ReadS a0) -> ReadS [a0] -> Int -> ReadS (Either a a0) Source # liftReadList :: (Int -> ReadS a0) -> ReadS [a0] -> ReadS [Either a a0] Source # liftReadPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec (Either a a0) Source # liftReadListPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec [Either a a0] Source # | |||||
Show a => Show1 (Either a) Source # | Since: base-4.9.0.0 | ||||
Applicative (Either e) Source # | Since: base-3.0 | ||||
Defined in GHC.Internal.Data.Either | |||||
Functor (Either a) Source # | Since: base-3.0 | ||||
Monad (Either e) Source # | Since: base-4.4.0.0 | ||||
MonadFix (Either e) Source # | Since: base-4.3.0.0 | ||||
Foldable (Either a) Source # | Since: base-4.7.0.0 | ||||
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => Either a m -> m Source # foldMap :: Monoid m => (a0 -> m) -> Either a a0 -> m Source # foldMap' :: Monoid m => (a0 -> m) -> Either a a0 -> m Source # foldr :: (a0 -> b -> b) -> b -> Either a a0 -> b Source # foldr' :: (a0 -> b -> b) -> b -> Either a a0 -> b Source # foldl :: (b -> a0 -> b) -> b -> Either a a0 -> b Source # foldl' :: (b -> a0 -> b) -> b -> Either a a0 -> b Source # foldr1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 Source # foldl1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 Source # toList :: Either a a0 -> [a0] Source # null :: Either a a0 -> Bool Source # length :: Either a a0 -> Int Source # elem :: Eq a0 => a0 -> Either a a0 -> Bool Source # maximum :: Ord a0 => Either a a0 -> a0 Source # minimum :: Ord a0 => Either a a0 -> a0 Source # | |||||
Traversable (Either a) Source # | Since: base-4.7.0.0 | ||||
Defined in GHC.Internal.Data.Traversable | |||||
Semigroup (Either a b) Source # | Since: base-4.9.0.0 | ||||
(Data a, Data b) => Data (Either a b) Source # | Since: base-4.0.0.0 | ||||
Defined in GHC.Internal.Data.Data gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> Either a b -> c (Either a b) Source # gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Either a b) Source # toConstr :: Either a b -> Constr Source # dataTypeOf :: Either a b -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Either a b)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Either a b)) Source # gmapT :: (forall b0. Data b0 => b0 -> b0) -> Either a b -> Either a b Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Either a b -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Either a b -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Either a b -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Either a b -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Either a b -> m (Either a b) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Either a b -> m (Either a b) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Either a b -> m (Either a b) Source # | |||||
Generic (Either a b) Source # | |||||
Defined in GHC.Internal.Generics
| |||||
(Read a, Read b) => Read (Either a b) Source # | Since: base-3.0 | ||||
(Show a, Show b) => Show (Either a b) Source # | Since: base-3.0 | ||||
(Eq a, Eq b) => Eq (Either a b) Source # | Since: base-2.1 | ||||
(Ord a, Ord b) => Ord (Either a b) Source # | Since: base-2.1 | ||||
Defined in GHC.Internal.Data.Either compare :: Either a b -> Either a b -> Ordering Source # (<) :: Either a b -> Either a b -> Bool Source # (<=) :: Either a b -> Either a b -> Bool Source # (>) :: Either a b -> Either a b -> Bool Source # (>=) :: Either a b -> Either a b -> Bool Source # | |||||
type Rep1 (Either a :: Type -> Type) Source # | Since: base-4.6.0.0 | ||||
Defined in GHC.Internal.Generics type Rep1 (Either a :: Type -> Type) = D1 ('MetaData "Either" "GHC.Internal.Data.Either" "ghc-internal" 'False) (C1 ('MetaCons "Left" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: C1 ('MetaCons "Right" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1)) | |||||
type Rep (Either a b) Source # | Since: base-4.6.0.0 | ||||
Defined in GHC.Internal.Generics type Rep (Either a b) = D1 ('MetaData "Either" "GHC.Internal.Data.Either" "ghc-internal" 'False) (C1 ('MetaCons "Left" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: C1 ('MetaCons "Right" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 b))) |
either :: (a -> c) -> (b -> c) -> Either a b -> c Source #
Case analysis for the Either
type.
If the value is
, apply the first function to Left
aa
;
if it is
, apply the second function to Right
bb
.
Examples
We create two values of type
, one using the
Either
String
Int
Left
constructor and another using the Right
constructor. Then
we apply "either" the length
function (if we have a String
)
or the "times-two" function (if we have an Int
):
>>>
let s = Left "foo" :: Either String Int
>>>
let n = Right 3 :: Either String Int
>>>
either length (*2) s
3>>>
either length (*2) n
6
Instances
Monoid Ordering Source # | Since: base-2.1 |
Semigroup Ordering Source # | Since: base-4.9.0.0 |
Data Ordering Source # | Since: base-4.0.0.0 |
Defined in GHC.Internal.Data.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Ordering -> c Ordering Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Ordering Source # toConstr :: Ordering -> Constr Source # dataTypeOf :: Ordering -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Ordering) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Ordering) Source # gmapT :: (forall b. Data b => b -> b) -> Ordering -> Ordering Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Ordering -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Ordering -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Ordering -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Ordering -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Ordering -> m Ordering Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Ordering -> m Ordering Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Ordering -> m Ordering Source # | |
Bounded Ordering Source # | Since: base-2.1 |
Enum Ordering Source # | Since: base-2.1 |
Defined in GHC.Internal.Enum succ :: Ordering -> Ordering Source # pred :: Ordering -> Ordering Source # toEnum :: Int -> Ordering Source # fromEnum :: Ordering -> Int Source # enumFrom :: Ordering -> [Ordering] Source # enumFromThen :: Ordering -> Ordering -> [Ordering] Source # enumFromTo :: Ordering -> Ordering -> [Ordering] Source # enumFromThenTo :: Ordering -> Ordering -> Ordering -> [Ordering] Source # | |
Generic Ordering Source # | |
Defined in GHC.Internal.Generics | |
Ix Ordering Source # | Since: base-2.1 |
Defined in GHC.Internal.Ix | |
Read Ordering Source # | Since: base-2.1 |
Show Ordering Source # | Since: base-2.1 |
Eq Ordering Source # | |
Ord Ordering Source # | |
Defined in GHC.Classes | |
type Rep Ordering Source # | Since: base-4.6.0.0 |
The character type Char
represents Unicode codespace
and its elements are code points as in definitions
D9 and D10 of the Unicode Standard.
Character literals in Haskell are single-quoted: 'Q'
, 'Я'
or 'Ω'
.
To represent a single quote itself use '\''
, and to represent a backslash
use '\\'
. The full grammar can be found in the section 2.6 of the
Haskell 2010 Language Report.
To specify a character by its code point one can use decimal, hexadecimal
or octal notation: '\65'
, '\x41'
and '\o101'
are all alternative forms
of 'A'
. The largest code point is '\x10ffff'
.
There is a special escape syntax for ASCII control characters:
Escape | Alternatives | Meaning |
---|---|---|
'\NUL' | '\0' | null character |
'\SOH' | '\1' | start of heading |
'\STX' | '\2' | start of text |
'\ETX' | '\3' | end of text |
'\EOT' | '\4' | end of transmission |
'\ENQ' | '\5' | enquiry |
'\ACK' | '\6' | acknowledge |
'\BEL' | '\7' , '\a' | bell (alert) |
'\BS' | '\8' , '\b' | backspace |
'\HT' | '\9' , '\t' | horizontal tab |
'\LF' | '\10' , '\n' | line feed (new line) |
'\VT' | '\11' , '\v' | vertical tab |
'\FF' | '\12' , '\f' | form feed |
'\CR' | '\13' , '\r' | carriage return |
'\SO' | '\14' | shift out |
'\SI' | '\15' | shift in |
'\DLE' | '\16' | data link escape |
'\DC1' | '\17' | device control 1 |
'\DC2' | '\18' | device control 2 |
'\DC3' | '\19' | device control 3 |
'\DC4' | '\20' | device control 4 |
'\NAK' | '\21' | negative acknowledge |
'\SYN' | '\22' | synchronous idle |
'\ETB' | '\23' | end of transmission block |
'\CAN' | '\24' | cancel |
'\EM' | '\25' | end of medium |
'\SUB' | '\26' | substitute |
'\ESC' | '\27' | escape |
'\FS' | '\28' | file separator |
'\GS' | '\29' | group separator |
'\RS' | '\30' | record separator |
'\US' | '\31' | unit separator |
'\SP' | '\32' , ' ' | space |
'\DEL' | '\127' | delete |
Instances
IsChar Char Source # | Since: base-2.1 | ||||
PrintfArg Char Source # | Since: base-2.1 | ||||
Defined in Text.Printf formatArg :: Char -> FieldFormatter Source # parseFormat :: Char -> ModifierParser Source # | |||||
Data Char Source # | Since: base-4.0.0.0 | ||||
Defined in GHC.Internal.Data.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Char -> c Char Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Char Source # toConstr :: Char -> Constr Source # dataTypeOf :: Char -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Char) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Char) Source # gmapT :: (forall b. Data b => b -> b) -> Char -> Char Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Char -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Char -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Char -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Char -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Char -> m Char Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Char -> m Char Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Char -> m Char Source # | |||||
Bounded Char Source # | Since: base-2.1 | ||||
Enum Char Source # | Since: base-2.1 | ||||
Storable Char Source # | Since: base-2.1 | ||||
Defined in GHC.Internal.Foreign.Storable sizeOf :: Char -> Int Source # alignment :: Char -> Int Source # peekElemOff :: Ptr Char -> Int -> IO Char Source # pokeElemOff :: Ptr Char -> Int -> Char -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Char Source # pokeByteOff :: Ptr b -> Int -> Char -> IO () Source # | |||||
Ix Char Source # | Since: base-2.1 | ||||
Read Char Source # | Since: base-2.1 | ||||
Show Char Source # | Since: base-2.1 | ||||
Eq Char Source # | |||||
Ord Char Source # | |||||
TestCoercion SChar Source # | Since: base-4.18.0.0 | ||||
Defined in GHC.Internal.TypeLits | |||||
TestEquality SChar Source # | Since: base-4.18.0.0 | ||||
Defined in GHC.Internal.TypeLits | |||||
Lift Char Source # | |||||
Generic1 (URec Char :: k -> Type) Source # | |||||
Defined in GHC.Internal.Generics
| |||||
Eq1 (UChar :: Type -> Type) Source # | Since: base-4.21.0.0 | ||||
Ord1 (UChar :: Type -> Type) Source # | Since: base-4.21.0.0 | ||||
Defined in Data.Functor.Classes | |||||
Show1 (UChar :: Type -> Type) Source # | Since: base-4.21.0.0 | ||||
Foldable (UChar :: Type -> Type) Source # | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => UChar m -> m Source # foldMap :: Monoid m => (a -> m) -> UChar a -> m Source # foldMap' :: Monoid m => (a -> m) -> UChar a -> m Source # foldr :: (a -> b -> b) -> b -> UChar a -> b Source # foldr' :: (a -> b -> b) -> b -> UChar a -> b Source # foldl :: (b -> a -> b) -> b -> UChar a -> b Source # foldl' :: (b -> a -> b) -> b -> UChar a -> b Source # foldr1 :: (a -> a -> a) -> UChar a -> a Source # foldl1 :: (a -> a -> a) -> UChar a -> a Source # toList :: UChar a -> [a] Source # null :: UChar a -> Bool Source # length :: UChar a -> Int Source # elem :: Eq a => a -> UChar a -> Bool Source # maximum :: Ord a => UChar a -> a Source # minimum :: Ord a => UChar a -> a Source # | |||||
Traversable (UChar :: Type -> Type) Source # | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Traversable | |||||
Functor (URec Char :: Type -> Type) Source # | Since: base-4.9.0.0 | ||||
Generic (URec Char p) Source # | |||||
Defined in GHC.Internal.Generics
| |||||
Show (URec Char p) Source # | Since: base-4.9.0.0 | ||||
Eq (URec Char p) Source # | Since: base-4.9.0.0 | ||||
Ord (URec Char p) Source # | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Generics compare :: URec Char p -> URec Char p -> Ordering Source # (<) :: URec Char p -> URec Char p -> Bool Source # (<=) :: URec Char p -> URec Char p -> Bool Source # (>) :: URec Char p -> URec Char p -> Bool Source # (>=) :: URec Char p -> URec Char p -> Bool Source # | |||||
data URec Char (p :: k) Source # | Used for marking occurrences of Since: base-4.9.0.0 | ||||
type Compare (a :: Char) (b :: Char) Source # | |||||
Defined in GHC.Internal.Data.Type.Ord | |||||
type Rep1 (URec Char :: k -> Type) Source # | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Generics | |||||
type Rep (URec Char p) Source # | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Generics |
String
is an alias for a list of characters.
String constants in Haskell are values of type String
.
That means if you write a string literal like "hello world"
,
it will have the type [Char]
, which is the same as String
.
Note: You can ask the compiler to automatically infer different types
with the -XOverloadedStrings
language extension, for example
"hello world" :: Text
. See IsString
for more information.
Because String
is just a list of characters, you can use normal list functions
to do basic string manipulation. See Data.List for operations on lists.
Performance considerations
[Char]
is a relatively memory-inefficient type.
It is a linked list of boxed word-size characters, internally it looks something like:
╭─────┬───┬──╮ ╭─────┬───┬──╮ ╭─────┬───┬──╮ ╭────╮ │ (:) │ │ ─┼─>│ (:) │ │ ─┼─>│ (:) │ │ ─┼─>│ [] │ ╰─────┴─┼─┴──╯ ╰─────┴─┼─┴──╯ ╰─────┴─┼─┴──╯ ╰────╯ v v v 'a' 'b' 'c'
The String
"abc" will use 5*3+1 = 16
(in general 5n+1
)
words of space in memory.
Furthermore, operations like (++)
(string concatenation) are O(n)
(in the left argument).
For historical reasons, the base
library uses String
in a lot of places
for the conceptual simplicity, but library code dealing with user-data
should use the text
package for Unicode text, or the the
bytestring package
for binary data.
Tuples
curry :: ((a, b) -> c) -> a -> b -> c Source #
Convert an uncurried function to a curried function.
Examples
>>>
curry fst 1 2
1
uncurry :: (a -> b -> c) -> (a, b) -> c Source #
uncurry
converts a curried function to a function on pairs.
Examples
>>>
uncurry (+) (1,2)
3
>>>
uncurry ($) (show, 1)
"1"
>>>
map (uncurry max) [(1,2), (3,4), (6,8)]
[2,4,8]
Basic type classes
The Eq
class defines equality (==
) and inequality (/=
).
All the basic datatypes exported by the Prelude are instances of Eq
,
and Eq
may be derived for any datatype whose constituents are also
instances of Eq
.
The Haskell Report defines no laws for Eq
. However, instances are
encouraged to follow these properties:
Instances
Eq ByteArray Source # | Since: base-4.17.0.0 |
Eq Timeout Source # | |
Eq BigNat # | |
Eq Void Source # | Since: base-4.8.0.0 |
Eq ByteOrder Source # | Since: base-4.11.0.0 |
Eq ClosureType Source # | |
Defined in GHC.Internal.ClosureTypes (==) :: ClosureType -> ClosureType -> Bool Source # (/=) :: ClosureType -> ClosureType -> Bool Source # | |
Eq BlockReason Source # | Since: base-4.3.0.0 |
Defined in GHC.Internal.Conc.Sync (==) :: BlockReason -> BlockReason -> Bool Source # (/=) :: BlockReason -> BlockReason -> Bool Source # | |
Eq ThreadId Source # | Since: base-4.2.0.0 |
Eq ThreadStatus Source # | Since: base-4.3.0.0 |
Defined in GHC.Internal.Conc.Sync (==) :: ThreadStatus -> ThreadStatus -> Bool Source # (/=) :: ThreadStatus -> ThreadStatus -> Bool Source # | |
Eq Constr Source # | Equality of constructors Since: base-4.0.0.0 |
Eq ConstrRep Source # | Since: base-4.0.0.0 |
Eq DataRep Source # | Since: base-4.0.0.0 |
Eq Fixity Source # | Since: base-4.0.0.0 |
Eq All Source # | Since: base-2.1 |
Eq Any Source # | Since: base-2.1 |
Eq SomeTypeRep Source # | |
Defined in GHC.Internal.Data.Typeable.Internal (==) :: SomeTypeRep -> SomeTypeRep -> Bool Source # (/=) :: SomeTypeRep -> SomeTypeRep -> Bool Source # | |
Eq Unique Source # | |
Eq Version Source # | Since: base-2.1 |
Eq ControlMessage Source # | Since: base-4.4.0.0 |
Eq Event Source # | Since: base-4.4.0.0 |
Eq EventLifetime Source # | Since: base-4.8.0.0 |
Eq Lifetime Source # | Since: base-4.8.1.0 |
Eq FdKey Source # | Since: base-4.4.0.0 |
Eq State Source # | Since: base-4.4.0.0 |
Eq TimeoutKey Source # | |
Defined in GHC.Internal.Event.TimeOut (==) :: TimeoutKey -> TimeoutKey -> Bool Source # (/=) :: TimeoutKey -> TimeoutKey -> Bool Source # | |
Eq State Source # | Since: base-4.7.0.0 |
Eq Unique Source # | Since: base-4.4.0.0 |
Eq ErrorCall Source # | Since: base-4.7.0.0 |
Eq ArithException Source # | Since: base-3.0 |
Defined in GHC.Internal.Exception.Type (==) :: ArithException -> ArithException -> Bool Source # (/=) :: ArithException -> ArithException -> Bool Source # | |
Eq SpecConstrAnnotation Source # | Since: base-4.3.0.0 |
Defined in GHC.Internal.Exts (==) :: SpecConstrAnnotation -> SpecConstrAnnotation -> Bool Source # (/=) :: SpecConstrAnnotation -> SpecConstrAnnotation -> Bool Source # | |
Eq Fingerprint Source # | Since: base-4.4.0.0 |
Defined in GHC.Internal.Fingerprint.Type (==) :: Fingerprint -> Fingerprint -> Bool Source # (/=) :: Fingerprint -> Fingerprint -> Bool Source # | |
Eq Errno Source # | Since: base-2.1 |
Eq CBool Source # | |
Eq CChar Source # | |
Eq CClock Source # | |
Eq CDouble Source # | |
Eq CFloat Source # | |
Eq CInt Source # | |
Eq CIntMax Source # | |
Eq CIntPtr Source # | |
Eq CLLong Source # | |
Eq CLong Source # | |
Eq CPtrdiff Source # | |
Eq CSChar Source # | |
Eq CSUSeconds Source # | |
Defined in GHC.Internal.Foreign.C.Types (==) :: CSUSeconds -> CSUSeconds -> Bool Source # (/=) :: CSUSeconds -> CSUSeconds -> Bool Source # | |
Eq CShort Source # | |
Eq CSigAtomic Source # | |
Defined in GHC.Internal.Foreign.C.Types (==) :: CSigAtomic -> CSigAtomic -> Bool Source # (/=) :: CSigAtomic -> CSigAtomic -> Bool Source # | |
Eq CSize Source # | |
Eq CTime Source # | |
Eq CUChar Source # | |
Eq CUInt Source # | |
Eq CUIntMax Source # | |
Eq CUIntPtr Source # | |
Eq CULLong Source # | |
Eq CULong Source # | |
Eq CUSeconds Source # | |
Eq CUShort Source # | |
Eq CWchar Source # | |
Eq IntPtr Source # | |
Eq WordPtr Source # | |
Eq ForeignSrcLang Source # | |
Defined in GHC.Internal.ForeignSrcLang (==) :: ForeignSrcLang -> ForeignSrcLang -> Bool Source # (/=) :: ForeignSrcLang -> ForeignSrcLang -> Bool Source # | |
Eq Associativity Source # | Since: base-4.6.0.0 |
Defined in GHC.Internal.Generics (==) :: Associativity -> Associativity -> Bool Source # (/=) :: Associativity -> Associativity -> Bool Source # | |
Eq DecidedStrictness Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics (==) :: DecidedStrictness -> DecidedStrictness -> Bool Source # (/=) :: DecidedStrictness -> DecidedStrictness -> Bool Source # | |
Eq Fixity Source # | Since: base-4.6.0.0 |
Eq SourceStrictness Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics (==) :: SourceStrictness -> SourceStrictness -> Bool Source # (/=) :: SourceStrictness -> SourceStrictness -> Bool Source # | |
Eq SourceUnpackedness Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics (==) :: SourceUnpackedness -> SourceUnpackedness -> Bool Source # (/=) :: SourceUnpackedness -> SourceUnpackedness -> Bool Source # | |
Eq MaskingState Source # | Since: base-4.3.0.0 |
Defined in GHC.Internal.IO (==) :: MaskingState -> MaskingState -> Bool Source # (/=) :: MaskingState -> MaskingState -> Bool Source # | |
Eq BufferState Source # | Since: base-4.2.0.0 |
Defined in GHC.Internal.IO.Buffer (==) :: BufferState -> BufferState -> Bool Source # (/=) :: BufferState -> BufferState -> Bool Source # | |
Eq IODeviceType Source # | Since: base-4.2.0.0 |
Defined in GHC.Internal.IO.Device (==) :: IODeviceType -> IODeviceType -> Bool Source # (/=) :: IODeviceType -> IODeviceType -> Bool Source # | |
Eq SeekMode Source # | Since: base-4.2.0.0 |
Eq CodingProgress Source # | Since: base-4.4.0.0 |
Defined in GHC.Internal.IO.Encoding.Types (==) :: CodingProgress -> CodingProgress -> Bool Source # (/=) :: CodingProgress -> CodingProgress -> Bool Source # | |
Eq ArrayException Source # | Since: base-4.2.0.0 |
Defined in GHC.Internal.IO.Exception (==) :: ArrayException -> ArrayException -> Bool Source # (/=) :: ArrayException -> ArrayException -> Bool Source # | |
Eq AsyncException Source # | Since: base-4.2.0.0 |
Defined in GHC.Internal.IO.Exception (==) :: AsyncException -> AsyncException -> Bool Source # (/=) :: AsyncException -> AsyncException -> Bool Source # | |
Eq ExitCode Source # | |
Eq IOErrorType Source # | Since: base-4.1.0.0 |
Defined in GHC.Internal.IO.Exception (==) :: IOErrorType -> IOErrorType -> Bool Source # (/=) :: IOErrorType -> IOErrorType -> Bool Source # | |
Eq IOException Source # | Since: base-4.1.0.0 |
Defined in GHC.Internal.IO.Exception (==) :: IOException -> IOException -> Bool Source # (/=) :: IOException -> IOException -> Bool Source # | |
Eq HandlePosn Source # | Since: base-4.1.0.0 |
Defined in GHC.Internal.IO.Handle (==) :: HandlePosn -> HandlePosn -> Bool Source # (/=) :: HandlePosn -> HandlePosn -> Bool Source # | |
Eq BufferMode Source # | Since: base-4.2.0.0 |
Defined in GHC.Internal.IO.Handle.Types (==) :: BufferMode -> BufferMode -> Bool Source # (/=) :: BufferMode -> BufferMode -> Bool Source # | |
Eq Handle Source # | Since: base-4.1.0.0 |
Eq Newline Source # | Since: base-4.2.0.0 |
Eq NewlineMode Source # | Since: base-4.2.0.0 |
Defined in GHC.Internal.IO.Handle.Types (==) :: NewlineMode -> NewlineMode -> Bool Source # (/=) :: NewlineMode -> NewlineMode -> Bool Source # | |
Eq IOMode Source # | Since: base-4.2.0.0 |
Eq IoSubSystem Source # | |
Defined in GHC.Internal.IO.SubSystem (==) :: IoSubSystem -> IoSubSystem -> Bool Source # (/=) :: IoSubSystem -> IoSubSystem -> Bool Source # | |
Eq InfoProv Source # | |
Eq Int16 Source # | Since: base-2.1 |
Eq Int32 Source # | Since: base-2.1 |
Eq Int64 Source # | Since: base-2.1 |
Eq Int8 Source # | Since: base-2.1 |
Eq Extension Source # | |
Eq IoManagerFlag Source # | |
Defined in GHC.Internal.RTS.Flags (==) :: IoManagerFlag -> IoManagerFlag -> Bool Source # (/=) :: IoManagerFlag -> IoManagerFlag -> Bool Source # | |
Eq StackEntry Source # | |
Defined in GHC.Internal.Stack.CloneStack (==) :: StackEntry -> StackEntry -> Bool Source # (/=) :: StackEntry -> StackEntry -> Bool Source # | |
Eq SrcLoc Source # | Since: base-4.9.0.0 |
Eq CBlkCnt Source # | |
Eq CBlkSize Source # | |
Eq CCc Source # | |
Eq CClockId Source # | |
Eq CDev Source # | |
Eq CFsBlkCnt Source # | |
Eq CFsFilCnt Source # | |
Eq CGid Source # | |
Eq CId Source # | |
Eq CIno Source # | |
Eq CKey Source # | |
Eq CMode Source # | |
Eq CNfds Source # | |
Eq CNlink Source # | |
Eq COff Source # | |
Eq CPid Source # | |
Eq CRLim Source # | |
Eq CSocklen Source # | |
Eq CSpeed Source # | |
Eq CSsize Source # | |
Eq CTcflag Source # | |
Eq CTimer Source # | |
Eq CUid Source # | |
Eq Fd Source # | |
Eq AnnLookup Source # | |
Eq AnnTarget Source # | |
Eq Bang Source # | |
Eq BndrVis Source # | |
Eq Body Source # | |
Eq Bytes Source # | |
Eq Callconv Source # | |
Eq Clause Source # | |
Eq Con Source # | |
Eq Dec Source # | |
Eq DecidedStrictness Source # | |
Defined in GHC.Internal.TH.Syntax (==) :: DecidedStrictness -> DecidedStrictness -> Bool Source # (/=) :: DecidedStrictness -> DecidedStrictness -> Bool Source # | |
Eq DerivClause Source # | |
Defined in GHC.Internal.TH.Syntax (==) :: DerivClause -> DerivClause -> Bool Source # (/=) :: DerivClause -> DerivClause -> Bool Source # | |
Eq DerivStrategy Source # | |
Defined in GHC.Internal.TH.Syntax (==) :: DerivStrategy -> DerivStrategy -> Bool Source # (/=) :: DerivStrategy -> DerivStrategy -> Bool Source # | |
Eq DocLoc Source # | |
Eq Exp Source # | |
Eq FamilyResultSig Source # | |
Defined in GHC.Internal.TH.Syntax (==) :: FamilyResultSig -> FamilyResultSig -> Bool Source # (/=) :: FamilyResultSig -> FamilyResultSig -> Bool Source # | |
Eq Fixity Source # | |
Eq FixityDirection Source # | |
Defined in GHC.Internal.TH.Syntax (==) :: FixityDirection -> FixityDirection -> Bool Source # (/=) :: FixityDirection -> FixityDirection -> Bool Source # | |
Eq Foreign Source # | |
Eq FunDep Source # | |
Eq Guard Source # | |
Eq Info Source # | |
Eq InjectivityAnn Source # | |
Defined in GHC.Internal.TH.Syntax (==) :: InjectivityAnn -> InjectivityAnn -> Bool Source # (/=) :: InjectivityAnn -> InjectivityAnn -> Bool Source # | |
Eq Inline Source # | |
Eq Lit Source # | |
Eq Loc Source # | |
Eq Match Source # | |
Eq ModName Source # | |
Eq Module Source # | |
Eq ModuleInfo Source # | |
Defined in GHC.Internal.TH.Syntax (==) :: ModuleInfo -> ModuleInfo -> Bool Source # (/=) :: ModuleInfo -> ModuleInfo -> Bool Source # | |
Eq Name Source # | |
Eq NameFlavour Source # | |
Defined in GHC.Internal.TH.Syntax (==) :: NameFlavour -> NameFlavour -> Bool Source # (/=) :: NameFlavour -> NameFlavour -> Bool Source # | |
Eq NameSpace Source # | |
Eq NamespaceSpecifier Source # | |
Defined in GHC.Internal.TH.Syntax (==) :: NamespaceSpecifier -> NamespaceSpecifier -> Bool Source # (/=) :: NamespaceSpecifier -> NamespaceSpecifier -> Bool Source # | |
Eq OccName Source # | |
Eq Overlap Source # | |
Eq Pat Source # | |
Eq PatSynArgs Source # | |
Defined in GHC.Internal.TH.Syntax (==) :: PatSynArgs -> PatSynArgs -> Bool Source # (/=) :: PatSynArgs -> PatSynArgs -> Bool Source # | |
Eq PatSynDir Source # | |
Eq Phases Source # | |
Eq PkgName Source # | |
Eq Pragma Source # | |
Eq Range Source # | |
Eq Role Source # | |
Eq RuleBndr Source # | |
Eq RuleMatch Source # | |
Eq Safety Source # | |
Eq SourceStrictness Source # | |
Defined in GHC.Internal.TH.Syntax (==) :: SourceStrictness -> SourceStrictness -> Bool Source # (/=) :: SourceStrictness -> SourceStrictness -> Bool Source # | |
Eq SourceUnpackedness Source # | |
Defined in GHC.Internal.TH.Syntax (==) :: SourceUnpackedness -> SourceUnpackedness -> Bool Source # (/=) :: SourceUnpackedness -> SourceUnpackedness -> Bool Source # | |
Eq Specificity Source # | |
Defined in GHC.Internal.TH.Syntax (==) :: Specificity -> Specificity -> Bool Source # (/=) :: Specificity -> Specificity -> Bool Source # | |
Eq Stmt Source # | |
Eq TyLit Source # | |
Eq TySynEqn Source # | |
Eq Type Source # | |
Eq TypeFamilyHead Source # | |
Defined in GHC.Internal.TH.Syntax (==) :: TypeFamilyHead -> TypeFamilyHead -> Bool Source # (/=) :: TypeFamilyHead -> TypeFamilyHead -> Bool Source # | |
Eq Lexeme Source # | Since: base-2.1 |
Eq Number Source # | Since: base-4.6.0.0 |
Eq SomeChar Source # | |
Eq SomeSymbol Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.TypeLits (==) :: SomeSymbol -> SomeSymbol -> Bool Source # (/=) :: SomeSymbol -> SomeSymbol -> Bool Source # | |
Eq SomeNat Source # | Since: base-4.7.0.0 |
Eq GeneralCategory Source # | Since: base-2.1 |
Defined in GHC.Internal.Unicode (==) :: GeneralCategory -> GeneralCategory -> Bool Source # (/=) :: GeneralCategory -> GeneralCategory -> Bool Source # | |
Eq Word16 Source # | Since: base-2.1 |
Eq Word32 Source # | Since: base-2.1 |
Eq Word64 Source # | Since: base-2.1 |
Eq Word8 Source # | Since: base-2.1 |
Eq Module Source # | |
Eq Ordering Source # | |
Eq TrName Source # | |
Eq TyCon Source # | |
Eq Integer # | |
Eq Natural # | |
Eq () Source # | |
Eq Bool Source # | |
Eq Char Source # | |
Eq Double Source # | Note that due to the presence of
Also note that
|
Eq Float Source # | Note that due to the presence of
Also note that
|
Eq Int Source # | |
Eq Word Source # | |
Eq (Chan a) Source # | Since: base-4.4.0.0 |
Eq (MutableByteArray s) Source # | Since: base-4.17.0.0 |
Defined in Data.Array.Byte (==) :: MutableByteArray s -> MutableByteArray s -> Bool Source # (/=) :: MutableByteArray s -> MutableByteArray s -> Bool Source # | |
Eq a => Eq (Complex a) Source # | Since: base-2.1 |
Eq a => Eq (First a) Source # | Since: base-4.9.0.0 |
Eq a => Eq (Last a) Source # | Since: base-4.9.0.0 |
Eq a => Eq (Max a) Source # | Since: base-4.9.0.0 |
Eq a => Eq (Min a) Source # | Since: base-4.9.0.0 |
Eq m => Eq (WrappedMonoid m) Source # | Since: base-4.9.0.0 |
Defined in Data.Semigroup (==) :: WrappedMonoid m -> WrappedMonoid m -> Bool Source # (/=) :: WrappedMonoid m -> WrappedMonoid m -> Bool Source # | |
Eq a => Eq (NonEmpty a) Source # | Since: base-4.9.0.0 |
Eq (TVar a) Source # | Since: base-4.8.0.0 |
Eq a => Eq (And a) Source # | Since: base-4.16 |
Eq a => Eq (Iff a) Source # | Since: base-4.16 |
Eq a => Eq (Ior a) Source # | Since: base-4.16 |
Eq a => Eq (Xor a) Source # | Since: base-4.16 |
Eq a => Eq (Identity a) Source # | Since: base-4.8.0.0 |
Eq a => Eq (First a) Source # | Since: base-2.1 |
Eq a => Eq (Last a) Source # | Since: base-2.1 |
Eq a => Eq (Down a) Source # | Since: base-4.6.0.0 |
Eq a => Eq (Dual a) Source # | Since: base-2.1 |
Eq a => Eq (Product a) Source # | Since: base-2.1 |
Eq a => Eq (Sum a) Source # | Since: base-2.1 |
Eq (ConstPtr a) Source # | |
Eq (ForeignPtr a) Source # | Since: base-2.1 |
Defined in GHC.Internal.ForeignPtr (==) :: ForeignPtr a -> ForeignPtr a -> Bool Source # (/=) :: ForeignPtr a -> ForeignPtr a -> Bool Source # | |
Eq a => Eq (ZipList a) Source # | Since: base-4.7.0.0 |
Eq p => Eq (Par1 p) Source # | Since: base-4.7.0.0 |
Eq (IOPort a) Source # | Since: base-4.1.0.0 |
Eq (IORef a) Source # | Pointer equality. Since: base-4.0.0.0 |
Eq (MVar a) Source # | Compares the underlying pointers. Since: base-4.1.0.0 |
Eq (FunPtr a) Source # | |
Eq (Ptr a) Source # | Since: base-2.1 |
Eq a => Eq (Ratio a) Source # | Since: base-2.1 |
Eq (StablePtr a) Source # | Since: base-2.1 |
Eq (StableName a) Source # | Since: base-2.1 |
Defined in GHC.Internal.StableName (==) :: StableName a -> StableName a -> Bool Source # (/=) :: StableName a -> StableName a -> Bool Source # | |
Eq flag => Eq (TyVarBndr flag) Source # | |
Eq (SChar c) Source # | Since: base-4.19.0.0 |
Eq (SSymbol s) Source # | Since: base-4.19.0.0 |
Eq (SNat n) Source # | Since: base-4.19.0.0 |
Eq a => Eq (Maybe a) Source # | Since: base-2.1 |
Eq a => Eq (Solo a) Source # | |
Eq a => Eq [a] Source # | |
Eq (Fixed a) Source # | Since: base-2.1 |
Eq a => Eq (Arg a b) Source # | Note that
Since: base-4.9.0.0 |
(Ix i, Eq e) => Eq (Array i e) Source # | Since: base-2.1 |
(Eq a, Eq b) => Eq (Either a b) Source # | Since: base-2.1 |
Eq (Proxy s) Source # | Since: base-4.7.0.0 |
Eq (TypeRep a) Source # | Since: base-2.1 |
Eq (U1 p) Source # | Since: base-4.9.0.0 |
Eq (V1 p) Source # | Since: base-4.9.0.0 |
Eq (IOArray i e) Source # | Since: base-4.1.0.0 |
Eq (STRef s a) Source # | Pointer equality. Since: base-2.1 |
(Eq a, Eq b) => Eq (a, b) Source # | |
Eq (STArray s i e) Source # | Since: base-2.1 |
Eq a => Eq (Const a b) Source # | Since: base-4.9.0.0 |
Eq (f a) => Eq (Ap f a) Source # | Since: base-4.12.0.0 |
Eq (f a) => Eq (Alt f a) Source # | Since: base-4.8.0.0 |
Eq (Coercion a b) Source # | Since: base-4.7.0.0 |
Eq (a :~: b) Source # | Since: base-4.7.0.0 |
Eq (OrderingI a b) Source # | |
(Generic1 f, Eq (Rep1 f a)) => Eq (Generically1 f a) Source # | Since: base-4.18.0.0 |
Defined in GHC.Internal.Generics (==) :: Generically1 f a -> Generically1 f a -> Bool Source # (/=) :: Generically1 f a -> Generically1 f a -> Bool Source # | |
Eq (f p) => Eq (Rec1 f p) Source # | Since: base-4.7.0.0 |
Eq (URec (Ptr ()) p) Source # | Since: base-4.9.0.0 |
Eq (URec Char p) Source # | Since: base-4.9.0.0 |
Eq (URec Double p) Source # | Since: base-4.9.0.0 |
Eq (URec Float p) Source # | |
Eq (URec Int p) Source # | Since: base-4.9.0.0 |
Eq (URec Word p) Source # | Since: base-4.9.0.0 |
(Eq a, Eq b, Eq c) => Eq (a, b, c) Source # | |
(Eq (f a), Eq (g a)) => Eq (Product f g a) Source # | Since: base-4.18.0.0 |
(Eq (f a), Eq (g a)) => Eq (Sum f g a) Source # | Since: base-4.18.0.0 |
Eq (a :~~: b) Source # | Since: base-4.10.0.0 |
(Eq (f p), Eq (g p)) => Eq ((f :*: g) p) Source # | Since: base-4.7.0.0 |
(Eq (f p), Eq (g p)) => Eq ((f :+: g) p) Source # | Since: base-4.7.0.0 |
Eq c => Eq (K1 i c p) Source # | Since: base-4.7.0.0 |
(Eq a, Eq b, Eq c, Eq d) => Eq (a, b, c, d) Source # | |
Eq (f (g a)) => Eq (Compose f g a) Source # | Since: base-4.18.0.0 |
Eq (f (g p)) => Eq ((f :.: g) p) Source # | Since: base-4.7.0.0 |
Eq (f p) => Eq (M1 i c f p) Source # | Since: base-4.7.0.0 |
(Eq a, Eq b, Eq c, Eq d, Eq e) => Eq (a, b, c, d, e) Source # | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f) => Eq (a, b, c, d, e, f) Source # | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g) => Eq (a, b, c, d, e, f, g) Source # | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h) => Eq (a, b, c, d, e, f, g, h) Source # | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i) => Eq (a, b, c, d, e, f, g, h, i) Source # | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j) => Eq (a, b, c, d, e, f, g, h, i, j) Source # | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k) => Eq (a, b, c, d, e, f, g, h, i, j, k) Source # | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l) => Eq (a, b, c, d, e, f, g, h, i, j, k, l) Source # | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m) => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m) Source # | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n) => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source # | |
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n, Eq o) => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source # | |
class Eq a => Ord a where Source #
The Ord
class is used for totally ordered datatypes.
Instances of Ord
can be derived for any user-defined datatype whose
constituent types are in Ord
. The declared order of the constructors in
the data declaration determines the ordering in derived Ord
instances. The
Ordering
datatype allows a single comparison to determine the precise
ordering of two objects.
Ord
, as defined by the Haskell report, implements a total order and has the
following properties:
- Comparability
x <= y || y <= x
=True
- Transitivity
- if
x <= y && y <= z
=True
, thenx <= z
=True
- Reflexivity
x <= x
=True
- Antisymmetry
- if
x <= y && y <= x
=True
, thenx == y
=True
The following operator interactions are expected to hold:
x >= y
=y <= x
x < y
=x <= y && x /= y
x > y
=y < x
x < y
=compare x y == LT
x > y
=compare x y == GT
x == y
=compare x y == EQ
min x y == if x <= y then x else y
=True
max x y == if x >= y then x else y
=True
Note that (7.) and (8.) do not require min
and max
to return either of
their arguments. The result is merely required to equal one of the
arguments in terms of (==)
. Users who expect a stronger guarantee are advised
to write their own min and/or max functions.
The nuance of the above distinction is not always fully internalized by
developers, and in the past (tracing back to the Haskell 1.4 Report) the
specification for Ord
asserted the stronger property that (min x y, max x
y) = (x, y)
or (y, x)
, or in other words, that min
and max
will
return one of their arguments, using argument order as the tie-breaker if
the arguments are equal by comparison. A few list and
Foldable
functions have behavior that is best understood
with this assumption in mind: all variations of minimumBy
and maximumBy
(which can't use min
and max
in their implementations) are written such
that minimumBy
and compare
maximumBy
are respectively
equivalent to compare
minimum
and maximum
(which do use min
and max
) only if
min
and max
adhere to this tie-breaking convention. Otherwise, if there
are multiple least or largest elements in a container, minimum
and
maximum
may not return the same one that minimumBy
and
compare
maximumBy
do (though they should return something that is
equal). (This is relevant for types with non-extensional equality, like
compare
Arg
, but also in cases where the precise reference held
matters for memory-management reasons.) Unless there is a reason to deviate,
it is less confusing for implementors of Ord
to respect this same
convention (as the default definitions of min
and max
do).
Minimal complete definition: either compare
or <=
.
Using compare
can be more efficient for complex types.
compare :: a -> a -> Ordering Source #
(<) :: a -> a -> Bool infix 4 Source #
(<=) :: a -> a -> Bool infix 4 Source #
(>) :: a -> a -> Bool infix 4 Source #
Instances
Ord ByteArray Source # | Non-lexicographic ordering. This compares the lengths of the byte arrays first and uses a lexicographic ordering if the lengths are equal. Subject to change between major versions. Since: base-4.17.0.0 |
Defined in Data.Array.Byte | |
Ord BigNat # | |
Defined in GHC.Num.BigNat | |
Ord Void Source # | Since: base-4.8.0.0 |
Ord ByteOrder Source # | Since: base-4.11.0.0 |
Defined in GHC.Internal.ByteOrder | |
Ord ClosureType Source # | |
Defined in GHC.Internal.ClosureTypes compare :: ClosureType -> ClosureType -> Ordering Source # (<) :: ClosureType -> ClosureType -> Bool Source # (<=) :: ClosureType -> ClosureType -> Bool Source # (>) :: ClosureType -> ClosureType -> Bool Source # (>=) :: ClosureType -> ClosureType -> Bool Source # max :: ClosureType -> ClosureType -> ClosureType Source # min :: ClosureType -> ClosureType -> ClosureType Source # | |
Ord BlockReason Source # | Since: base-4.3.0.0 |
Defined in GHC.Internal.Conc.Sync compare :: BlockReason -> BlockReason -> Ordering Source # (<) :: BlockReason -> BlockReason -> Bool Source # (<=) :: BlockReason -> BlockReason -> Bool Source # (>) :: BlockReason -> BlockReason -> Bool Source # (>=) :: BlockReason -> BlockReason -> Bool Source # max :: BlockReason -> BlockReason -> BlockReason Source # min :: BlockReason -> BlockReason -> BlockReason Source # | |
Ord ThreadId Source # | Since: base-4.2.0.0 |
Defined in GHC.Internal.Conc.Sync | |
Ord ThreadStatus Source # | Since: base-4.3.0.0 |
Defined in GHC.Internal.Conc.Sync compare :: ThreadStatus -> ThreadStatus -> Ordering Source # (<) :: ThreadStatus -> ThreadStatus -> Bool Source # (<=) :: ThreadStatus -> ThreadStatus -> Bool Source # (>) :: ThreadStatus -> ThreadStatus -> Bool Source # (>=) :: ThreadStatus -> ThreadStatus -> Bool Source # max :: ThreadStatus -> ThreadStatus -> ThreadStatus Source # min :: ThreadStatus -> ThreadStatus -> ThreadStatus Source # | |
Ord All Source # | Since: base-2.1 |
Ord Any Source # | Since: base-2.1 |
Ord SomeTypeRep Source # | |
Defined in GHC.Internal.Data.Typeable.Internal compare :: SomeTypeRep -> SomeTypeRep -> Ordering Source # (<) :: SomeTypeRep -> SomeTypeRep -> Bool Source # (<=) :: SomeTypeRep -> SomeTypeRep -> Bool Source # (>) :: SomeTypeRep -> SomeTypeRep -> Bool Source # (>=) :: SomeTypeRep -> SomeTypeRep -> Bool Source # max :: SomeTypeRep -> SomeTypeRep -> SomeTypeRep Source # min :: SomeTypeRep -> SomeTypeRep -> SomeTypeRep Source # | |
Ord Unique Source # | |
Defined in GHC.Internal.Data.Unique | |
Ord Version Source # | Since: base-2.1 |
Defined in GHC.Internal.Data.Version | |
Ord TimeoutKey Source # | |
Defined in GHC.Internal.Event.TimeOut compare :: TimeoutKey -> TimeoutKey -> Ordering Source # (<) :: TimeoutKey -> TimeoutKey -> Bool Source # (<=) :: TimeoutKey -> TimeoutKey -> Bool Source # (>) :: TimeoutKey -> TimeoutKey -> Bool Source # (>=) :: TimeoutKey -> TimeoutKey -> Bool Source # max :: TimeoutKey -> TimeoutKey -> TimeoutKey Source # min :: TimeoutKey -> TimeoutKey -> TimeoutKey Source # | |
Ord Unique Source # | Since: base-4.4.0.0 |
Defined in GHC.Internal.Event.Unique | |
Ord ErrorCall Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Exception | |
Ord ArithException Source # | Since: base-3.0 |
Defined in GHC.Internal.Exception.Type compare :: ArithException -> ArithException -> Ordering Source # (<) :: ArithException -> ArithException -> Bool Source # (<=) :: ArithException -> ArithException -> Bool Source # (>) :: ArithException -> ArithException -> Bool Source # (>=) :: ArithException -> ArithException -> Bool Source # max :: ArithException -> ArithException -> ArithException Source # min :: ArithException -> ArithException -> ArithException Source # | |
Ord Fingerprint Source # | Since: base-4.4.0.0 |
Defined in GHC.Internal.Fingerprint.Type compare :: Fingerprint -> Fingerprint -> Ordering Source # (<) :: Fingerprint -> Fingerprint -> Bool Source # (<=) :: Fingerprint -> Fingerprint -> Bool Source # (>) :: Fingerprint -> Fingerprint -> Bool Source # (>=) :: Fingerprint -> Fingerprint -> Bool Source # max :: Fingerprint -> Fingerprint -> Fingerprint Source # min :: Fingerprint -> Fingerprint -> Fingerprint Source # | |
Ord CBool Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CChar Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CClock Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CDouble Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CFloat Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CInt Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CIntMax Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CIntPtr Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CLLong Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CLong Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CPtrdiff Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CSChar Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CSUSeconds Source # | |
Defined in GHC.Internal.Foreign.C.Types compare :: CSUSeconds -> CSUSeconds -> Ordering Source # (<) :: CSUSeconds -> CSUSeconds -> Bool Source # (<=) :: CSUSeconds -> CSUSeconds -> Bool Source # (>) :: CSUSeconds -> CSUSeconds -> Bool Source # (>=) :: CSUSeconds -> CSUSeconds -> Bool Source # max :: CSUSeconds -> CSUSeconds -> CSUSeconds Source # min :: CSUSeconds -> CSUSeconds -> CSUSeconds Source # | |
Ord CShort Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CSigAtomic Source # | |
Defined in GHC.Internal.Foreign.C.Types compare :: CSigAtomic -> CSigAtomic -> Ordering Source # (<) :: CSigAtomic -> CSigAtomic -> Bool Source # (<=) :: CSigAtomic -> CSigAtomic -> Bool Source # (>) :: CSigAtomic -> CSigAtomic -> Bool Source # (>=) :: CSigAtomic -> CSigAtomic -> Bool Source # max :: CSigAtomic -> CSigAtomic -> CSigAtomic Source # min :: CSigAtomic -> CSigAtomic -> CSigAtomic Source # | |
Ord CSize Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CTime Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CUChar Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CUInt Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CUIntMax Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CUIntPtr Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CULLong Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CULong Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CUSeconds Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CUShort Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord CWchar Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Ord IntPtr Source # | |
Defined in GHC.Internal.Foreign.Ptr | |
Ord WordPtr Source # | |
Defined in GHC.Internal.Foreign.Ptr | |
Ord Associativity Source # | Since: base-4.6.0.0 |
Defined in GHC.Internal.Generics compare :: Associativity -> Associativity -> Ordering Source # (<) :: Associativity -> Associativity -> Bool Source # (<=) :: Associativity -> Associativity -> Bool Source # (>) :: Associativity -> Associativity -> Bool Source # (>=) :: Associativity -> Associativity -> Bool Source # max :: Associativity -> Associativity -> Associativity Source # min :: Associativity -> Associativity -> Associativity Source # | |
Ord DecidedStrictness Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics compare :: DecidedStrictness -> DecidedStrictness -> Ordering Source # (<) :: DecidedStrictness -> DecidedStrictness -> Bool Source # (<=) :: DecidedStrictness -> DecidedStrictness -> Bool Source # (>) :: DecidedStrictness -> DecidedStrictness -> Bool Source # (>=) :: DecidedStrictness -> DecidedStrictness -> Bool Source # max :: DecidedStrictness -> DecidedStrictness -> DecidedStrictness Source # min :: DecidedStrictness -> DecidedStrictness -> DecidedStrictness Source # | |
Ord Fixity Source # | Since: base-4.6.0.0 |
Defined in GHC.Internal.Generics | |
Ord SourceStrictness Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics compare :: SourceStrictness -> SourceStrictness -> Ordering Source # (<) :: SourceStrictness -> SourceStrictness -> Bool Source # (<=) :: SourceStrictness -> SourceStrictness -> Bool Source # (>) :: SourceStrictness -> SourceStrictness -> Bool Source # (>=) :: SourceStrictness -> SourceStrictness -> Bool Source # max :: SourceStrictness -> SourceStrictness -> SourceStrictness Source # min :: SourceStrictness -> SourceStrictness -> SourceStrictness Source # | |
Ord SourceUnpackedness Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics compare :: SourceUnpackedness -> SourceUnpackedness -> Ordering Source # (<) :: SourceUnpackedness -> SourceUnpackedness -> Bool Source # (<=) :: SourceUnpackedness -> SourceUnpackedness -> Bool Source # (>) :: SourceUnpackedness -> SourceUnpackedness -> Bool Source # (>=) :: SourceUnpackedness -> SourceUnpackedness -> Bool Source # max :: SourceUnpackedness -> SourceUnpackedness -> SourceUnpackedness Source # min :: SourceUnpackedness -> SourceUnpackedness -> SourceUnpackedness Source # | |
Ord SeekMode Source # | Since: base-4.2.0.0 |
Defined in GHC.Internal.IO.Device | |
Ord ArrayException Source # | Since: base-4.2.0.0 |
Defined in GHC.Internal.IO.Exception compare :: ArrayException -> ArrayException -> Ordering Source # (<) :: ArrayException -> ArrayException -> Bool Source # (<=) :: ArrayException -> ArrayException -> Bool Source # (>) :: ArrayException -> ArrayException -> Bool Source # (>=) :: ArrayException -> ArrayException -> Bool Source # max :: ArrayException -> ArrayException -> ArrayException Source # min :: ArrayException -> ArrayException -> ArrayException Source # | |
Ord AsyncException Source # | Since: base-4.2.0.0 |
Defined in GHC.Internal.IO.Exception compare :: AsyncException -> AsyncException -> Ordering Source # (<) :: AsyncException -> AsyncException -> Bool Source # (<=) :: AsyncException -> AsyncException -> Bool Source # (>) :: AsyncException -> AsyncException -> Bool Source # (>=) :: AsyncException -> AsyncException -> Bool Source # max :: AsyncException -> AsyncException -> AsyncException Source # min :: AsyncException -> AsyncException -> AsyncException Source # | |
Ord ExitCode Source # | |
Defined in GHC.Internal.IO.Exception | |
Ord BufferMode Source # | Since: base-4.2.0.0 |
Defined in GHC.Internal.IO.Handle.Types compare :: BufferMode -> BufferMode -> Ordering Source # (<) :: BufferMode -> BufferMode -> Bool Source # (<=) :: BufferMode -> BufferMode -> Bool Source # (>) :: BufferMode -> BufferMode -> Bool Source # (>=) :: BufferMode -> BufferMode -> Bool Source # max :: BufferMode -> BufferMode -> BufferMode Source # min :: BufferMode -> BufferMode -> BufferMode Source # | |
Ord Newline Source # | Since: base-4.3.0.0 |
Defined in GHC.Internal.IO.Handle.Types | |
Ord NewlineMode Source # | Since: base-4.3.0.0 |
Defined in GHC.Internal.IO.Handle.Types compare :: NewlineMode -> NewlineMode -> Ordering Source # (<) :: NewlineMode -> NewlineMode -> Bool Source # (<=) :: NewlineMode -> NewlineMode -> Bool Source # (>) :: NewlineMode -> NewlineMode -> Bool Source # (>=) :: NewlineMode -> NewlineMode -> Bool Source # max :: NewlineMode -> NewlineMode -> NewlineMode Source # min :: NewlineMode -> NewlineMode -> NewlineMode Source # | |
Ord IOMode Source # | Since: base-4.2.0.0 |
Defined in GHC.Internal.IO.IOMode | |
Ord Int16 Source # | Since: base-2.1 |
Defined in GHC.Internal.Int | |
Ord Int32 Source # | Since: base-2.1 |
Defined in GHC.Internal.Int | |
Ord Int64 Source # | Since: base-2.1 |
Defined in GHC.Internal.Int | |
Ord Int8 Source # | Since: base-2.1 |
Ord Extension Source # | |
Defined in GHC.Internal.LanguageExtensions | |
Ord CBlkCnt Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Ord CBlkSize Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Ord CCc Source # | |
Ord CClockId Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Ord CDev Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Ord CFsBlkCnt Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Ord CFsFilCnt Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Ord CGid Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Ord CId Source # | |
Ord CIno Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Ord CKey Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Ord CMode Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Ord CNfds Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Ord CNlink Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Ord COff Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Ord CPid Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Ord CRLim Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Ord CSocklen Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Ord CSpeed Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Ord CSsize Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Ord CTcflag Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Ord CTimer Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Ord CUid Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Ord Fd Source # | |
Ord AnnLookup Source # | |
Defined in GHC.Internal.TH.Syntax | |
Ord AnnTarget Source # | |
Defined in GHC.Internal.TH.Syntax | |
Ord Bang Source # | |
Ord BndrVis Source # | |
Ord Body Source # | |
Ord Bytes Source # | |
Defined in GHC.Internal.TH.Syntax | |
Ord Callconv Source # | |
Defined in GHC.Internal.TH.Syntax | |
Ord Clause Source # | |
Defined in GHC.Internal.TH.Syntax | |
Ord Con Source # | |
Ord Dec Source # | |
Ord DecidedStrictness Source # | |
Defined in GHC.Internal.TH.Syntax compare :: DecidedStrictness -> DecidedStrictness -> Ordering Source # (<) :: DecidedStrictness -> DecidedStrictness -> Bool Source # (<=) :: DecidedStrictness -> DecidedStrictness -> Bool Source # (>) :: DecidedStrictness -> DecidedStrictness -> Bool Source # (>=) :: DecidedStrictness -> DecidedStrictness -> Bool Source # max :: DecidedStrictness -> DecidedStrictness -> DecidedStrictness Source # min :: DecidedStrictness -> DecidedStrictness -> DecidedStrictness Source # | |
Ord DerivClause Source # | |
Defined in GHC.Internal.TH.Syntax compare :: DerivClause -> DerivClause -> Ordering Source # (<) :: DerivClause -> DerivClause -> Bool Source # (<=) :: DerivClause -> DerivClause -> Bool Source # (>) :: DerivClause -> DerivClause -> Bool Source # (>=) :: DerivClause -> DerivClause -> Bool Source # max :: DerivClause -> DerivClause -> DerivClause Source # min :: DerivClause -> DerivClause -> DerivClause Source # | |
Ord DerivStrategy Source # | |
Defined in GHC.Internal.TH.Syntax compare :: DerivStrategy -> DerivStrategy -> Ordering Source # (<) :: DerivStrategy -> DerivStrategy -> Bool Source # (<=) :: DerivStrategy -> DerivStrategy -> Bool Source # (>) :: DerivStrategy -> DerivStrategy -> Bool Source # (>=) :: DerivStrategy -> DerivStrategy -> Bool Source # max :: DerivStrategy -> DerivStrategy -> DerivStrategy Source # min :: DerivStrategy -> DerivStrategy -> DerivStrategy Source # | |
Ord DocLoc Source # | |
Defined in GHC.Internal.TH.Syntax | |
Ord Exp Source # | |
Ord FamilyResultSig Source # | |
Defined in GHC.Internal.TH.Syntax compare :: FamilyResultSig -> FamilyResultSig -> Ordering Source # (<) :: FamilyResultSig -> FamilyResultSig -> Bool Source # (<=) :: FamilyResultSig -> FamilyResultSig -> Bool Source # (>) :: FamilyResultSig -> FamilyResultSig -> Bool Source # (>=) :: FamilyResultSig -> FamilyResultSig -> Bool Source # max :: FamilyResultSig -> FamilyResultSig -> FamilyResultSig Source # min :: FamilyResultSig -> FamilyResultSig -> FamilyResultSig Source # | |
Ord Fixity Source # | |
Defined in GHC.Internal.TH.Syntax | |
Ord FixityDirection Source # | |
Defined in GHC.Internal.TH.Syntax compare :: FixityDirection -> FixityDirection -> Ordering Source # (<) :: FixityDirection -> FixityDirection -> Bool Source # (<=) :: FixityDirection -> FixityDirection -> Bool Source # (>) :: FixityDirection -> FixityDirection -> Bool Source # (>=) :: FixityDirection -> FixityDirection -> Bool Source # max :: FixityDirection -> FixityDirection -> FixityDirection Source # min :: FixityDirection -> FixityDirection -> FixityDirection Source # | |
Ord Foreign Source # | |
Ord FunDep Source # | |
Defined in GHC.Internal.TH.Syntax | |
Ord Guard Source # | |
Defined in GHC.Internal.TH.Syntax | |
Ord Info Source # | |
Ord InjectivityAnn Source # | |
Defined in GHC.Internal.TH.Syntax compare :: InjectivityAnn -> InjectivityAnn -> Ordering Source # (<) :: InjectivityAnn -> InjectivityAnn -> Bool Source # (<=) :: InjectivityAnn -> InjectivityAnn -> Bool Source # (>) :: InjectivityAnn -> InjectivityAnn -> Bool Source # (>=) :: InjectivityAnn -> InjectivityAnn -> Bool Source # max :: InjectivityAnn -> InjectivityAnn -> InjectivityAnn Source # min :: InjectivityAnn -> InjectivityAnn -> InjectivityAnn Source # | |
Ord Inline Source # | |
Defined in GHC.Internal.TH.Syntax | |
Ord Lit Source # | |
Ord Loc Source # | |
Ord Match Source # | |
Defined in GHC.Internal.TH.Syntax | |
Ord ModName Source # | |
Ord Module Source # | |
Defined in GHC.Internal.TH.Syntax | |
Ord ModuleInfo Source # | |
Defined in GHC.Internal.TH.Syntax compare :: ModuleInfo -> ModuleInfo -> Ordering Source # (<) :: ModuleInfo -> ModuleInfo -> Bool Source # (<=) :: ModuleInfo -> ModuleInfo -> Bool Source # (>) :: ModuleInfo -> ModuleInfo -> Bool Source # (>=) :: ModuleInfo -> ModuleInfo -> Bool Source # max :: ModuleInfo -> ModuleInfo -> ModuleInfo Source # min :: ModuleInfo -> ModuleInfo -> ModuleInfo Source # | |
Ord Name Source # | |
Ord NameFlavour Source # | |
Defined in GHC.Internal.TH.Syntax compare :: NameFlavour -> NameFlavour -> Ordering Source # (<) :: NameFlavour -> NameFlavour -> Bool Source # (<=) :: NameFlavour -> NameFlavour -> Bool Source # (>) :: NameFlavour -> NameFlavour -> Bool Source # (>=) :: NameFlavour -> NameFlavour -> Bool Source # max :: NameFlavour -> NameFlavour -> NameFlavour Source # min :: NameFlavour -> NameFlavour -> NameFlavour Source # | |
Ord NameSpace Source # | |
Defined in GHC.Internal.TH.Syntax | |
Ord NamespaceSpecifier Source # | |
Defined in GHC.Internal.TH.Syntax compare :: NamespaceSpecifier -> NamespaceSpecifier -> Ordering Source # (<) :: NamespaceSpecifier -> NamespaceSpecifier -> Bool Source # (<=) :: NamespaceSpecifier -> NamespaceSpecifier -> Bool Source # (>) :: NamespaceSpecifier -> NamespaceSpecifier -> Bool Source # (>=) :: NamespaceSpecifier -> NamespaceSpecifier -> Bool Source # max :: NamespaceSpecifier -> NamespaceSpecifier -> NamespaceSpecifier Source # min :: NamespaceSpecifier -> NamespaceSpecifier -> NamespaceSpecifier Source # | |
Ord OccName Source # | |
Ord Overlap Source # | |
Ord Pat Source # | |
Ord PatSynArgs Source # | |
Defined in GHC.Internal.TH.Syntax compare :: PatSynArgs -> PatSynArgs -> Ordering Source # (<) :: PatSynArgs -> PatSynArgs -> Bool Source # (<=) :: PatSynArgs -> PatSynArgs -> Bool Source # (>) :: PatSynArgs -> PatSynArgs -> Bool Source # (>=) :: PatSynArgs -> PatSynArgs -> Bool Source # max :: PatSynArgs -> PatSynArgs -> PatSynArgs Source # min :: PatSynArgs -> PatSynArgs -> PatSynArgs Source # | |
Ord PatSynDir Source # | |
Defined in GHC.Internal.TH.Syntax | |
Ord Phases Source # | |
Defined in GHC.Internal.TH.Syntax | |
Ord PkgName Source # | |
Ord Pragma Source # | |
Defined in GHC.Internal.TH.Syntax | |
Ord Range Source # | |
Defined in GHC.Internal.TH.Syntax | |
Ord Role Source # | |
Ord RuleBndr Source # | |
Defined in GHC.Internal.TH.Syntax | |
Ord RuleMatch Source # | |
Defined in GHC.Internal.TH.Syntax | |
Ord Safety Source # | |
Defined in GHC.Internal.TH.Syntax | |
Ord SourceStrictness Source # | |
Defined in GHC.Internal.TH.Syntax compare :: SourceStrictness -> SourceStrictness -> Ordering Source # (<) :: SourceStrictness -> SourceStrictness -> Bool Source # (<=) :: SourceStrictness -> SourceStrictness -> Bool Source # (>) :: SourceStrictness -> SourceStrictness -> Bool Source # (>=) :: SourceStrictness -> SourceStrictness -> Bool Source # max :: SourceStrictness -> SourceStrictness -> SourceStrictness Source # min :: SourceStrictness -> SourceStrictness -> SourceStrictness Source # | |
Ord SourceUnpackedness Source # | |
Defined in GHC.Internal.TH.Syntax compare :: SourceUnpackedness -> SourceUnpackedness -> Ordering Source # (<) :: SourceUnpackedness -> SourceUnpackedness -> Bool Source # (<=) :: SourceUnpackedness -> SourceUnpackedness -> Bool Source # (>) :: SourceUnpackedness -> SourceUnpackedness -> Bool Source # (>=) :: SourceUnpackedness -> SourceUnpackedness -> Bool Source # max :: SourceUnpackedness -> SourceUnpackedness -> SourceUnpackedness Source # min :: SourceUnpackedness -> SourceUnpackedness -> SourceUnpackedness Source # | |
Ord Specificity Source # | |
Defined in GHC.Internal.TH.Syntax compare :: Specificity -> Specificity -> Ordering Source # (<) :: Specificity -> Specificity -> Bool Source # (<=) :: Specificity -> Specificity -> Bool Source # (>) :: Specificity -> Specificity -> Bool Source # (>=) :: Specificity -> Specificity -> Bool Source # max :: Specificity -> Specificity -> Specificity Source # min :: Specificity -> Specificity -> Specificity Source # | |
Ord Stmt Source # | |
Ord TyLit Source # | |
Defined in GHC.Internal.TH.Syntax | |
Ord TySynEqn Source # | |
Defined in GHC.Internal.TH.Syntax | |
Ord Type Source # | |
Ord TypeFamilyHead Source # | |
Defined in GHC.Internal.TH.Syntax compare :: TypeFamilyHead -> TypeFamilyHead -> Ordering Source # (<) :: TypeFamilyHead -> TypeFamilyHead -> Bool Source # (<=) :: TypeFamilyHead -> TypeFamilyHead -> Bool Source # (>) :: TypeFamilyHead -> TypeFamilyHead -> Bool Source # (>=) :: TypeFamilyHead -> TypeFamilyHead -> Bool Source # max :: TypeFamilyHead -> TypeFamilyHead -> TypeFamilyHead Source # min :: TypeFamilyHead -> TypeFamilyHead -> TypeFamilyHead Source # | |
Ord SomeChar Source # | |
Defined in GHC.Internal.TypeLits | |
Ord SomeSymbol Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.TypeLits compare :: SomeSymbol -> SomeSymbol -> Ordering Source # (<) :: SomeSymbol -> SomeSymbol -> Bool Source # (<=) :: SomeSymbol -> SomeSymbol -> Bool Source # (>) :: SomeSymbol -> SomeSymbol -> Bool Source # (>=) :: SomeSymbol -> SomeSymbol -> Bool Source # max :: SomeSymbol -> SomeSymbol -> SomeSymbol Source # min :: SomeSymbol -> SomeSymbol -> SomeSymbol Source # | |
Ord SomeNat Source # | Since: base-4.7.0.0 |
Ord GeneralCategory Source # | Since: base-2.1 |
Defined in GHC.Internal.Unicode compare :: GeneralCategory -> GeneralCategory -> Ordering Source # (<) :: GeneralCategory -> GeneralCategory -> Bool Source # (<=) :: GeneralCategory -> GeneralCategory -> Bool Source # (>) :: GeneralCategory -> GeneralCategory -> Bool Source # (>=) :: GeneralCategory -> GeneralCategory -> Bool Source # max :: GeneralCategory -> GeneralCategory -> GeneralCategory Source # min :: GeneralCategory -> GeneralCategory -> GeneralCategory Source # | |
Ord Word16 Source # | Since: base-2.1 |
Defined in GHC.Internal.Word | |
Ord Word32 Source # | Since: base-2.1 |
Defined in GHC.Internal.Word | |
Ord Word64 Source # | Since: base-2.1 |
Defined in GHC.Internal.Word | |
Ord Word8 Source # | Since: base-2.1 |
Defined in GHC.Internal.Word | |
Ord Ordering Source # | |
Defined in GHC.Classes | |
Ord TyCon Source # | |
Defined in GHC.Classes | |
Ord Integer # | |
Ord Natural # | |
Ord () Source # | |
Ord Bool Source # | |
Ord Char Source # | |
Ord Double Source # | IEEE 754 IEEE 754-2008, section 5.11 requires that if at least one of arguments of
IEEE 754-2008, section 5.10 defines Thus, users must be extremely cautious when using Moving further, the behaviour of IEEE 754-2008 compliant |
Defined in GHC.Classes | |
Ord Float Source # | See |
Defined in GHC.Classes | |
Ord Int Source # | |
Ord Word Source # | |
Ord a => Ord (First a) Source # | Since: base-4.9.0.0 |
Ord a => Ord (Last a) Source # | Since: base-4.9.0.0 |
Defined in Data.Semigroup | |
Ord a => Ord (Max a) Source # | Since: base-4.9.0.0 |
Defined in Data.Semigroup | |
Ord a => Ord (Min a) Source # | Since: base-4.9.0.0 |
Defined in Data.Semigroup | |
Ord m => Ord (WrappedMonoid m) Source # | Since: base-4.9.0.0 |
Defined in Data.Semigroup compare :: WrappedMonoid m -> WrappedMonoid m -> Ordering Source # (<) :: WrappedMonoid m -> WrappedMonoid m -> Bool Source # (<=) :: WrappedMonoid m -> WrappedMonoid m -> Bool Source # (>) :: WrappedMonoid m -> WrappedMonoid m -> Bool Source # (>=) :: WrappedMonoid m -> WrappedMonoid m -> Bool Source # max :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m Source # min :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m Source # | |
Ord a => Ord (NonEmpty a) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Base compare :: NonEmpty a -> NonEmpty a -> Ordering Source # (<) :: NonEmpty a -> NonEmpty a -> Bool Source # (<=) :: NonEmpty a -> NonEmpty a -> Bool Source # (>) :: NonEmpty a -> NonEmpty a -> Bool Source # (>=) :: NonEmpty a -> NonEmpty a -> Bool Source # | |
Ord a => Ord (Identity a) Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.Data.Functor.Identity compare :: Identity a -> Identity a -> Ordering Source # (<) :: Identity a -> Identity a -> Bool Source # (<=) :: Identity a -> Identity a -> Bool Source # (>) :: Identity a -> Identity a -> Bool Source # (>=) :: Identity a -> Identity a -> Bool Source # | |
Ord a => Ord (First a) Source # | Since: base-2.1 |
Defined in GHC.Internal.Data.Monoid | |
Ord a => Ord (Last a) Source # | Since: base-2.1 |
Defined in GHC.Internal.Data.Monoid | |
Ord a => Ord (Down a) Source # | Since: base-4.6.0.0 |
Defined in GHC.Internal.Data.Ord | |
Ord a => Ord (Dual a) Source # | Since: base-2.1 |
Defined in GHC.Internal.Data.Semigroup.Internal | |
Ord a => Ord (Product a) Source # | Since: base-2.1 |
Defined in GHC.Internal.Data.Semigroup.Internal | |
Ord a => Ord (Sum a) Source # | Since: base-2.1 |
Defined in GHC.Internal.Data.Semigroup.Internal | |
Ord (ConstPtr a) Source # | |
Defined in GHC.Internal.Foreign.C.ConstPtr compare :: ConstPtr a -> ConstPtr a -> Ordering Source # (<) :: ConstPtr a -> ConstPtr a -> Bool Source # (<=) :: ConstPtr a -> ConstPtr a -> Bool Source # (>) :: ConstPtr a -> ConstPtr a -> Bool Source # (>=) :: ConstPtr a -> ConstPtr a -> Bool Source # | |
Ord (ForeignPtr a) Source # | Since: base-2.1 |
Defined in GHC.Internal.ForeignPtr compare :: ForeignPtr a -> ForeignPtr a -> Ordering Source # (<) :: ForeignPtr a -> ForeignPtr a -> Bool Source # (<=) :: ForeignPtr a -> ForeignPtr a -> Bool Source # (>) :: ForeignPtr a -> ForeignPtr a -> Bool Source # (>=) :: ForeignPtr a -> ForeignPtr a -> Bool Source # max :: ForeignPtr a -> ForeignPtr a -> ForeignPtr a Source # min :: ForeignPtr a -> ForeignPtr a -> ForeignPtr a Source # | |
Ord a => Ord (ZipList a) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Functor.ZipList | |
Ord p => Ord (Par1 p) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Generics | |
Ord (FunPtr a) Source # | |
Defined in GHC.Internal.Ptr | |
Ord (Ptr a) Source # | Since: base-2.1 |
Defined in GHC.Internal.Ptr | |
Integral a => Ord (Ratio a) Source # | Since: base-2.0.1 |
Ord flag => Ord (TyVarBndr flag) Source # | |
Defined in GHC.Internal.TH.Syntax compare :: TyVarBndr flag -> TyVarBndr flag -> Ordering Source # (<) :: TyVarBndr flag -> TyVarBndr flag -> Bool Source # (<=) :: TyVarBndr flag -> TyVarBndr flag -> Bool Source # (>) :: TyVarBndr flag -> TyVarBndr flag -> Bool Source # (>=) :: TyVarBndr flag -> TyVarBndr flag -> Bool Source # max :: TyVarBndr flag -> TyVarBndr flag -> TyVarBndr flag Source # min :: TyVarBndr flag -> TyVarBndr flag -> TyVarBndr flag Source # | |
Ord (SChar c) Source # | Since: base-4.19.0.0 |
Ord (SSymbol s) Source # | Since: base-4.19.0.0 |
Defined in GHC.Internal.TypeLits | |
Ord (SNat n) Source # | Since: base-4.19.0.0 |
Defined in GHC.Internal.TypeNats | |
Ord a => Ord (Maybe a) Source # | Since: base-2.1 |
Ord a => Ord (Solo a) Source # | |
Defined in GHC.Classes | |
Ord a => Ord [a] Source # | |
Ord (Fixed a) Source # | Since: base-2.1 |
Ord a => Ord (Arg a b) Source # | Note that Since: base-4.9.0.0 |
(Ix i, Ord e) => Ord (Array i e) Source # | Since: base-2.1 |
Defined in GHC.Internal.Arr | |
(Ord a, Ord b) => Ord (Either a b) Source # | Since: base-2.1 |
Defined in GHC.Internal.Data.Either compare :: Either a b -> Either a b -> Ordering Source # (<) :: Either a b -> Either a b -> Bool Source # (<=) :: Either a b -> Either a b -> Bool Source # (>) :: Either a b -> Either a b -> Bool Source # (>=) :: Either a b -> Either a b -> Bool Source # | |
Ord (Proxy s) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Data.Proxy | |
Ord (TypeRep a) Source # | Since: base-4.4.0.0 |
Defined in GHC.Internal.Data.Typeable.Internal | |
Ord (U1 p) Source # | Since: base-4.7.0.0 |
Ord (V1 p) Source # | Since: base-4.9.0.0 |
(Ord a, Ord b) => Ord (a, b) Source # | |
Defined in GHC.Classes | |
Ord a => Ord (Const a b) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Const | |
Ord (f a) => Ord (Ap f a) Source # | Since: base-4.12.0.0 |
Defined in GHC.Internal.Data.Monoid | |
Ord (f a) => Ord (Alt f a) Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.Data.Semigroup.Internal | |
Ord (Coercion a b) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Data.Type.Coercion compare :: Coercion a b -> Coercion a b -> Ordering Source # (<) :: Coercion a b -> Coercion a b -> Bool Source # (<=) :: Coercion a b -> Coercion a b -> Bool Source # (>) :: Coercion a b -> Coercion a b -> Bool Source # (>=) :: Coercion a b -> Coercion a b -> Bool Source # max :: Coercion a b -> Coercion a b -> Coercion a b Source # min :: Coercion a b -> Coercion a b -> Coercion a b Source # | |
Ord (a :~: b) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Data.Type.Equality | |
(Generic1 f, Ord (Rep1 f a)) => Ord (Generically1 f a) Source # | Since: base-4.18.0.0 |
Defined in GHC.Internal.Generics compare :: Generically1 f a -> Generically1 f a -> Ordering Source # (<) :: Generically1 f a -> Generically1 f a -> Bool Source # (<=) :: Generically1 f a -> Generically1 f a -> Bool Source # (>) :: Generically1 f a -> Generically1 f a -> Bool Source # (>=) :: Generically1 f a -> Generically1 f a -> Bool Source # max :: Generically1 f a -> Generically1 f a -> Generically1 f a Source # min :: Generically1 f a -> Generically1 f a -> Generically1 f a Source # | |
Ord (f p) => Ord (Rec1 f p) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Generics | |
Ord (URec (Ptr ()) p) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics compare :: URec (Ptr ()) p -> URec (Ptr ()) p -> Ordering Source # (<) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool Source # (<=) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool Source # (>) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool Source # (>=) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool Source # max :: URec (Ptr ()) p -> URec (Ptr ()) p -> URec (Ptr ()) p Source # min :: URec (Ptr ()) p -> URec (Ptr ()) p -> URec (Ptr ()) p Source # | |
Ord (URec Char p) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics compare :: URec Char p -> URec Char p -> Ordering Source # (<) :: URec Char p -> URec Char p -> Bool Source # (<=) :: URec Char p -> URec Char p -> Bool Source # (>) :: URec Char p -> URec Char p -> Bool Source # (>=) :: URec Char p -> URec Char p -> Bool Source # | |
Ord (URec Double p) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics compare :: URec Double p -> URec Double p -> Ordering Source # (<) :: URec Double p -> URec Double p -> Bool Source # (<=) :: URec Double p -> URec Double p -> Bool Source # (>) :: URec Double p -> URec Double p -> Bool Source # (>=) :: URec Double p -> URec Double p -> Bool Source # max :: URec Double p -> URec Double p -> URec Double p Source # min :: URec Double p -> URec Double p -> URec Double p Source # | |
Ord (URec Float p) Source # | |
Defined in GHC.Internal.Generics compare :: URec Float p -> URec Float p -> Ordering Source # (<) :: URec Float p -> URec Float p -> Bool Source # (<=) :: URec Float p -> URec Float p -> Bool Source # (>) :: URec Float p -> URec Float p -> Bool Source # (>=) :: URec Float p -> URec Float p -> Bool Source # max :: URec Float p -> URec Float p -> URec Float p Source # min :: URec Float p -> URec Float p -> URec Float p Source # | |
Ord (URec Int p) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics compare :: URec Int p -> URec Int p -> Ordering Source # (<) :: URec Int p -> URec Int p -> Bool Source # (<=) :: URec Int p -> URec Int p -> Bool Source # (>) :: URec Int p -> URec Int p -> Bool Source # (>=) :: URec Int p -> URec Int p -> Bool Source # | |
Ord (URec Word p) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics compare :: URec Word p -> URec Word p -> Ordering Source # (<) :: URec Word p -> URec Word p -> Bool Source # (<=) :: URec Word p -> URec Word p -> Bool Source # (>) :: URec Word p -> URec Word p -> Bool Source # (>=) :: URec Word p -> URec Word p -> Bool Source # | |
(Ord a, Ord b, Ord c) => Ord (a, b, c) Source # | |
Defined in GHC.Classes | |
(Ord (f a), Ord (g a)) => Ord (Product f g a) Source # | Since: base-4.18.0.0 |
Defined in Data.Functor.Product compare :: Product f g a -> Product f g a -> Ordering Source # (<) :: Product f g a -> Product f g a -> Bool Source # (<=) :: Product f g a -> Product f g a -> Bool Source # (>) :: Product f g a -> Product f g a -> Bool Source # (>=) :: Product f g a -> Product f g a -> Bool Source # max :: Product f g a -> Product f g a -> Product f g a Source # min :: Product f g a -> Product f g a -> Product f g a Source # | |
(Ord (f a), Ord (g a)) => Ord (Sum f g a) Source # | Since: base-4.18.0.0 |
Defined in Data.Functor.Sum | |
Ord (a :~~: b) Source # | Since: base-4.10.0.0 |
Defined in GHC.Internal.Data.Type.Equality compare :: (a :~~: b) -> (a :~~: b) -> Ordering Source # (<) :: (a :~~: b) -> (a :~~: b) -> Bool Source # (<=) :: (a :~~: b) -> (a :~~: b) -> Bool Source # (>) :: (a :~~: b) -> (a :~~: b) -> Bool Source # (>=) :: (a :~~: b) -> (a :~~: b) -> Bool Source # | |
(Ord (f p), Ord (g p)) => Ord ((f :*: g) p) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Generics compare :: (f :*: g) p -> (f :*: g) p -> Ordering Source # (<) :: (f :*: g) p -> (f :*: g) p -> Bool Source # (<=) :: (f :*: g) p -> (f :*: g) p -> Bool Source # (>) :: (f :*: g) p -> (f :*: g) p -> Bool Source # (>=) :: (f :*: g) p -> (f :*: g) p -> Bool Source # | |
(Ord (f p), Ord (g p)) => Ord ((f :+: g) p) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Generics compare :: (f :+: g) p -> (f :+: g) p -> Ordering Source # (<) :: (f :+: g) p -> (f :+: g) p -> Bool Source # (<=) :: (f :+: g) p -> (f :+: g) p -> Bool Source # (>) :: (f :+: g) p -> (f :+: g) p -> Bool Source # (>=) :: (f :+: g) p -> (f :+: g) p -> Bool Source # | |
Ord c => Ord (K1 i c p) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Generics | |
(Ord a, Ord b, Ord c, Ord d) => Ord (a, b, c, d) Source # | |
Defined in GHC.Classes compare :: (a, b, c, d) -> (a, b, c, d) -> Ordering Source # (<) :: (a, b, c, d) -> (a, b, c, d) -> Bool Source # (<=) :: (a, b, c, d) -> (a, b, c, d) -> Bool Source # (>) :: (a, b, c, d) -> (a, b, c, d) -> Bool Source # (>=) :: (a, b, c, d) -> (a, b, c, d) -> Bool Source # max :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) Source # min :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) Source # | |
Ord (f (g a)) => Ord (Compose f g a) Source # | Since: base-4.18.0.0 |
Defined in Data.Functor.Compose compare :: Compose f g a -> Compose f g a -> Ordering Source # (<) :: Compose f g a -> Compose f g a -> Bool Source # (<=) :: Compose f g a -> Compose f g a -> Bool Source # (>) :: Compose f g a -> Compose f g a -> Bool Source # (>=) :: Compose f g a -> Compose f g a -> Bool Source # max :: Compose f g a -> Compose f g a -> Compose f g a Source # min :: Compose f g a -> Compose f g a -> Compose f g a Source # | |
Ord (f (g p)) => Ord ((f :.: g) p) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Generics compare :: (f :.: g) p -> (f :.: g) p -> Ordering Source # (<) :: (f :.: g) p -> (f :.: g) p -> Bool Source # (<=) :: (f :.: g) p -> (f :.: g) p -> Bool Source # (>) :: (f :.: g) p -> (f :.: g) p -> Bool Source # (>=) :: (f :.: g) p -> (f :.: g) p -> Bool Source # | |
Ord (f p) => Ord (M1 i c f p) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Generics compare :: M1 i c f p -> M1 i c f p -> Ordering Source # (<) :: M1 i c f p -> M1 i c f p -> Bool Source # (<=) :: M1 i c f p -> M1 i c f p -> Bool Source # (>) :: M1 i c f p -> M1 i c f p -> Bool Source # (>=) :: M1 i c f p -> M1 i c f p -> Bool Source # | |
(Ord a, Ord b, Ord c, Ord d, Ord e) => Ord (a, b, c, d, e) Source # | |
Defined in GHC.Classes compare :: (a, b, c, d, e) -> (a, b, c, d, e) -> Ordering Source # (<) :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool Source # (<=) :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool Source # (>) :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool Source # (>=) :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool Source # max :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) Source # min :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) Source # | |
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f) => Ord (a, b, c, d, e, f) Source # | |
Defined in GHC.Classes compare :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> Ordering Source # (<) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> Bool Source # (<=) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> Bool Source # (>) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> Bool Source # (>=) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> Bool Source # max :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) Source # min :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) Source # | |
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g) => Ord (a, b, c, d, e, f, g) Source # | |
Defined in GHC.Classes compare :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> Ordering Source # (<) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> Bool Source # (<=) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> Bool Source # (>) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> Bool Source # (>=) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> Bool Source # max :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) Source # min :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) Source # | |
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h) => Ord (a, b, c, d, e, f, g, h) Source # | |
Defined in GHC.Classes compare :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> Ordering Source # (<) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> Bool Source # (<=) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> Bool Source # (>) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> Bool Source # (>=) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> Bool Source # max :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) Source # min :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) Source # | |
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i) => Ord (a, b, c, d, e, f, g, h, i) Source # | |
Defined in GHC.Classes compare :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> Ordering Source # (<) :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> Bool Source # (<=) :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> Bool Source # (>) :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> Bool Source # (>=) :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> Bool Source # max :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) Source # min :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) Source # | |
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j) => Ord (a, b, c, d, e, f, g, h, i, j) Source # | |
Defined in GHC.Classes compare :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> Ordering Source # (<) :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> Bool Source # (<=) :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> Bool Source # (>) :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> Bool Source # (>=) :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> Bool Source # max :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) Source # min :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) Source # | |
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k) => Ord (a, b, c, d, e, f, g, h, i, j, k) Source # | |
Defined in GHC.Classes compare :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> Ordering Source # (<) :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> Bool Source # (<=) :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> Bool Source # (>) :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> Bool Source # (>=) :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> Bool Source # max :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) Source # min :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) Source # | |
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l) => Ord (a, b, c, d, e, f, g, h, i, j, k, l) Source # | |
Defined in GHC.Classes compare :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> Ordering Source # (<) :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> Bool Source # (<=) :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> Bool Source # (>) :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> Bool Source # (>=) :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> Bool Source # max :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) Source # min :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) Source # | |
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l, Ord m) => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m) Source # | |
Defined in GHC.Classes compare :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Ordering Source # (<) :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Bool Source # (<=) :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Bool Source # (>) :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Bool Source # (>=) :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Bool Source # max :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) Source # min :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) Source # | |
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n) => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source # | |
Defined in GHC.Classes compare :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Ordering Source # (<) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Bool Source # (<=) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Bool Source # (>) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Bool Source # (>=) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Bool Source # max :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source # min :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source # | |
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n, Ord o) => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source # | |
Defined in GHC.Classes compare :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Ordering Source # (<) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Bool Source # (<=) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Bool Source # (>) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Bool Source # (>=) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Bool Source # max :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source # min :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source # |
Class Enum
defines operations on sequentially ordered types.
The enumFrom
... methods are used in Haskell's translation of
arithmetic sequences.
Instances of Enum
may be derived for any enumeration type (types
whose constructors have no fields). The nullary constructors are
assumed to be numbered left-to-right by fromEnum
from 0
through n-1
.
See Chapter 10 of the Haskell Report for more details.
For any type that is an instance of class Bounded
as well as Enum
,
the following should hold:
- The calls
andsucc
maxBound
should result in a runtime error.pred
minBound
fromEnum
andtoEnum
should give a runtime error if the result value is not representable in the result type. For example,
is an error.toEnum
7 ::Bool
enumFrom
andenumFromThen
should be defined with an implicit bound, thus:
enumFrom x = enumFromTo x maxBound enumFromThen x y = enumFromThenTo x y bound where bound | fromEnum y >= fromEnum x = maxBound | otherwise = minBound
Successor of a value. For numeric types, succ
adds 1.
Predecessor of a value. For numeric types, pred
subtracts 1.
Convert from an Int
.
Convert to an Int
.
It is implementation-dependent what fromEnum
returns when
applied to a value that is too large to fit in an Int
.
Used in Haskell's translation of [n..]
with [n..] = enumFrom n
,
a possible implementation being enumFrom n = n : enumFrom (succ n)
.
Examples
enumFrom 4 :: [Integer] = [4,5,6,7,...]
enumFrom 6 :: [Int] = [6,7,8,9,...,maxBound :: Int]
enumFromThen :: a -> a -> [a] Source #
Used in Haskell's translation of [n,n'..]
with [n,n'..] = enumFromThen n n'
, a possible implementation being
enumFromThen n n' = n : n' : worker (f x) (f x n')
,
worker s v = v : worker s (s v)
, x = fromEnum n' - fromEnum n
and
f n y | n > 0 = f (n - 1) (succ y) | n < 0 = f (n + 1) (pred y) | otherwise = y
Examples
enumFromThen 4 6 :: [Integer] = [4,6,8,10...]
enumFromThen 6 2 :: [Int] = [6,2,-2,-6,...,minBound :: Int]
enumFromTo :: a -> a -> [a] Source #
Used in Haskell's translation of [n..m]
with
[n..m] = enumFromTo n m
, a possible implementation being
enumFromTo n m | n <= m = n : enumFromTo (succ n) m | otherwise = []
Examples
enumFromTo 6 10 :: [Int] = [6,7,8,9,10]
enumFromTo 42 1 :: [Integer] = []
enumFromThenTo :: a -> a -> a -> [a] Source #
Used in Haskell's translation of [n,n'..m]
with
[n,n'..m] = enumFromThenTo n n' m
, a possible implementation
being enumFromThenTo n n' m = worker (f x) (c x) n m
,
x = fromEnum n' - fromEnum n
, c x = bool (>=) ((x 0)
f n y | n > 0 = f (n - 1) (succ y) | n < 0 = f (n + 1) (pred y) | otherwise = y
and
worker s c v m | c v m = v : worker s c (s v) m | otherwise = []
Examples
enumFromThenTo 4 2 -6 :: [Integer] = [4,2,0,-2,-4,-6]
enumFromThenTo 6 8 2 :: [Int] = []
Instances
Enum ByteOrder Source # | Since: base-4.11.0.0 |
Defined in GHC.Internal.ByteOrder succ :: ByteOrder -> ByteOrder Source # pred :: ByteOrder -> ByteOrder Source # toEnum :: Int -> ByteOrder Source # fromEnum :: ByteOrder -> Int Source # enumFrom :: ByteOrder -> [ByteOrder] Source # enumFromThen :: ByteOrder -> ByteOrder -> [ByteOrder] Source # enumFromTo :: ByteOrder -> ByteOrder -> [ByteOrder] Source # enumFromThenTo :: ByteOrder -> ByteOrder -> ByteOrder -> [ByteOrder] Source # | |
Enum ClosureType Source # | |
Defined in GHC.Internal.ClosureTypes succ :: ClosureType -> ClosureType Source # pred :: ClosureType -> ClosureType Source # toEnum :: Int -> ClosureType Source # fromEnum :: ClosureType -> Int Source # enumFrom :: ClosureType -> [ClosureType] Source # enumFromThen :: ClosureType -> ClosureType -> [ClosureType] Source # enumFromTo :: ClosureType -> ClosureType -> [ClosureType] Source # enumFromThenTo :: ClosureType -> ClosureType -> ClosureType -> [ClosureType] Source # | |
Enum CBool Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CBool -> CBool Source # pred :: CBool -> CBool Source # toEnum :: Int -> CBool Source # fromEnum :: CBool -> Int Source # enumFrom :: CBool -> [CBool] Source # enumFromThen :: CBool -> CBool -> [CBool] Source # enumFromTo :: CBool -> CBool -> [CBool] Source # enumFromThenTo :: CBool -> CBool -> CBool -> [CBool] Source # | |
Enum CChar Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CChar -> CChar Source # pred :: CChar -> CChar Source # toEnum :: Int -> CChar Source # fromEnum :: CChar -> Int Source # enumFrom :: CChar -> [CChar] Source # enumFromThen :: CChar -> CChar -> [CChar] Source # enumFromTo :: CChar -> CChar -> [CChar] Source # enumFromThenTo :: CChar -> CChar -> CChar -> [CChar] Source # | |
Enum CClock Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CClock -> CClock Source # pred :: CClock -> CClock Source # toEnum :: Int -> CClock Source # fromEnum :: CClock -> Int Source # enumFrom :: CClock -> [CClock] Source # enumFromThen :: CClock -> CClock -> [CClock] Source # enumFromTo :: CClock -> CClock -> [CClock] Source # enumFromThenTo :: CClock -> CClock -> CClock -> [CClock] Source # | |
Enum CDouble Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CDouble -> CDouble Source # pred :: CDouble -> CDouble Source # toEnum :: Int -> CDouble Source # fromEnum :: CDouble -> Int Source # enumFrom :: CDouble -> [CDouble] Source # enumFromThen :: CDouble -> CDouble -> [CDouble] Source # enumFromTo :: CDouble -> CDouble -> [CDouble] Source # enumFromThenTo :: CDouble -> CDouble -> CDouble -> [CDouble] Source # | |
Enum CFloat Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CFloat -> CFloat Source # pred :: CFloat -> CFloat Source # toEnum :: Int -> CFloat Source # fromEnum :: CFloat -> Int Source # enumFrom :: CFloat -> [CFloat] Source # enumFromThen :: CFloat -> CFloat -> [CFloat] Source # enumFromTo :: CFloat -> CFloat -> [CFloat] Source # enumFromThenTo :: CFloat -> CFloat -> CFloat -> [CFloat] Source # | |
Enum CInt Source # | |
Enum CIntMax Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CIntMax -> CIntMax Source # pred :: CIntMax -> CIntMax Source # toEnum :: Int -> CIntMax Source # fromEnum :: CIntMax -> Int Source # enumFrom :: CIntMax -> [CIntMax] Source # enumFromThen :: CIntMax -> CIntMax -> [CIntMax] Source # enumFromTo :: CIntMax -> CIntMax -> [CIntMax] Source # enumFromThenTo :: CIntMax -> CIntMax -> CIntMax -> [CIntMax] Source # | |
Enum CIntPtr Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CIntPtr -> CIntPtr Source # pred :: CIntPtr -> CIntPtr Source # toEnum :: Int -> CIntPtr Source # fromEnum :: CIntPtr -> Int Source # enumFrom :: CIntPtr -> [CIntPtr] Source # enumFromThen :: CIntPtr -> CIntPtr -> [CIntPtr] Source # enumFromTo :: CIntPtr -> CIntPtr -> [CIntPtr] Source # enumFromThenTo :: CIntPtr -> CIntPtr -> CIntPtr -> [CIntPtr] Source # | |
Enum CLLong Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CLLong -> CLLong Source # pred :: CLLong -> CLLong Source # toEnum :: Int -> CLLong Source # fromEnum :: CLLong -> Int Source # enumFrom :: CLLong -> [CLLong] Source # enumFromThen :: CLLong -> CLLong -> [CLLong] Source # enumFromTo :: CLLong -> CLLong -> [CLLong] Source # enumFromThenTo :: CLLong -> CLLong -> CLLong -> [CLLong] Source # | |
Enum CLong Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CLong -> CLong Source # pred :: CLong -> CLong Source # toEnum :: Int -> CLong Source # fromEnum :: CLong -> Int Source # enumFrom :: CLong -> [CLong] Source # enumFromThen :: CLong -> CLong -> [CLong] Source # enumFromTo :: CLong -> CLong -> [CLong] Source # enumFromThenTo :: CLong -> CLong -> CLong -> [CLong] Source # | |
Enum CPtrdiff Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CPtrdiff -> CPtrdiff Source # pred :: CPtrdiff -> CPtrdiff Source # toEnum :: Int -> CPtrdiff Source # fromEnum :: CPtrdiff -> Int Source # enumFrom :: CPtrdiff -> [CPtrdiff] Source # enumFromThen :: CPtrdiff -> CPtrdiff -> [CPtrdiff] Source # enumFromTo :: CPtrdiff -> CPtrdiff -> [CPtrdiff] Source # enumFromThenTo :: CPtrdiff -> CPtrdiff -> CPtrdiff -> [CPtrdiff] Source # | |
Enum CSChar Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CSChar -> CSChar Source # pred :: CSChar -> CSChar Source # toEnum :: Int -> CSChar Source # fromEnum :: CSChar -> Int Source # enumFrom :: CSChar -> [CSChar] Source # enumFromThen :: CSChar -> CSChar -> [CSChar] Source # enumFromTo :: CSChar -> CSChar -> [CSChar] Source # enumFromThenTo :: CSChar -> CSChar -> CSChar -> [CSChar] Source # | |
Enum CSUSeconds Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CSUSeconds -> CSUSeconds Source # pred :: CSUSeconds -> CSUSeconds Source # toEnum :: Int -> CSUSeconds Source # fromEnum :: CSUSeconds -> Int Source # enumFrom :: CSUSeconds -> [CSUSeconds] Source # enumFromThen :: CSUSeconds -> CSUSeconds -> [CSUSeconds] Source # enumFromTo :: CSUSeconds -> CSUSeconds -> [CSUSeconds] Source # enumFromThenTo :: CSUSeconds -> CSUSeconds -> CSUSeconds -> [CSUSeconds] Source # | |
Enum CShort Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CShort -> CShort Source # pred :: CShort -> CShort Source # toEnum :: Int -> CShort Source # fromEnum :: CShort -> Int Source # enumFrom :: CShort -> [CShort] Source # enumFromThen :: CShort -> CShort -> [CShort] Source # enumFromTo :: CShort -> CShort -> [CShort] Source # enumFromThenTo :: CShort -> CShort -> CShort -> [CShort] Source # | |
Enum CSigAtomic Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CSigAtomic -> CSigAtomic Source # pred :: CSigAtomic -> CSigAtomic Source # toEnum :: Int -> CSigAtomic Source # fromEnum :: CSigAtomic -> Int Source # enumFrom :: CSigAtomic -> [CSigAtomic] Source # enumFromThen :: CSigAtomic -> CSigAtomic -> [CSigAtomic] Source # enumFromTo :: CSigAtomic -> CSigAtomic -> [CSigAtomic] Source # enumFromThenTo :: CSigAtomic -> CSigAtomic -> CSigAtomic -> [CSigAtomic] Source # | |
Enum CSize Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CSize -> CSize Source # pred :: CSize -> CSize Source # toEnum :: Int -> CSize Source # fromEnum :: CSize -> Int Source # enumFrom :: CSize -> [CSize] Source # enumFromThen :: CSize -> CSize -> [CSize] Source # enumFromTo :: CSize -> CSize -> [CSize] Source # enumFromThenTo :: CSize -> CSize -> CSize -> [CSize] Source # | |
Enum CTime Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CTime -> CTime Source # pred :: CTime -> CTime Source # toEnum :: Int -> CTime Source # fromEnum :: CTime -> Int Source # enumFrom :: CTime -> [CTime] Source # enumFromThen :: CTime -> CTime -> [CTime] Source # enumFromTo :: CTime -> CTime -> [CTime] Source # enumFromThenTo :: CTime -> CTime -> CTime -> [CTime] Source # | |
Enum CUChar Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CUChar -> CUChar Source # pred :: CUChar -> CUChar Source # toEnum :: Int -> CUChar Source # fromEnum :: CUChar -> Int Source # enumFrom :: CUChar -> [CUChar] Source # enumFromThen :: CUChar -> CUChar -> [CUChar] Source # enumFromTo :: CUChar -> CUChar -> [CUChar] Source # enumFromThenTo :: CUChar -> CUChar -> CUChar -> [CUChar] Source # | |
Enum CUInt Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CUInt -> CUInt Source # pred :: CUInt -> CUInt Source # toEnum :: Int -> CUInt Source # fromEnum :: CUInt -> Int Source # enumFrom :: CUInt -> [CUInt] Source # enumFromThen :: CUInt -> CUInt -> [CUInt] Source # enumFromTo :: CUInt -> CUInt -> [CUInt] Source # enumFromThenTo :: CUInt -> CUInt -> CUInt -> [CUInt] Source # | |
Enum CUIntMax Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CUIntMax -> CUIntMax Source # pred :: CUIntMax -> CUIntMax Source # toEnum :: Int -> CUIntMax Source # fromEnum :: CUIntMax -> Int Source # enumFrom :: CUIntMax -> [CUIntMax] Source # enumFromThen :: CUIntMax -> CUIntMax -> [CUIntMax] Source # enumFromTo :: CUIntMax -> CUIntMax -> [CUIntMax] Source # enumFromThenTo :: CUIntMax -> CUIntMax -> CUIntMax -> [CUIntMax] Source # | |
Enum CUIntPtr Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CUIntPtr -> CUIntPtr Source # pred :: CUIntPtr -> CUIntPtr Source # toEnum :: Int -> CUIntPtr Source # fromEnum :: CUIntPtr -> Int Source # enumFrom :: CUIntPtr -> [CUIntPtr] Source # enumFromThen :: CUIntPtr -> CUIntPtr -> [CUIntPtr] Source # enumFromTo :: CUIntPtr -> CUIntPtr -> [CUIntPtr] Source # enumFromThenTo :: CUIntPtr -> CUIntPtr -> CUIntPtr -> [CUIntPtr] Source # | |
Enum CULLong Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CULLong -> CULLong Source # pred :: CULLong -> CULLong Source # toEnum :: Int -> CULLong Source # fromEnum :: CULLong -> Int Source # enumFrom :: CULLong -> [CULLong] Source # enumFromThen :: CULLong -> CULLong -> [CULLong] Source # enumFromTo :: CULLong -> CULLong -> [CULLong] Source # enumFromThenTo :: CULLong -> CULLong -> CULLong -> [CULLong] Source # | |
Enum CULong Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CULong -> CULong Source # pred :: CULong -> CULong Source # toEnum :: Int -> CULong Source # fromEnum :: CULong -> Int Source # enumFrom :: CULong -> [CULong] Source # enumFromThen :: CULong -> CULong -> [CULong] Source # enumFromTo :: CULong -> CULong -> [CULong] Source # enumFromThenTo :: CULong -> CULong -> CULong -> [CULong] Source # | |
Enum CUSeconds Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CUSeconds -> CUSeconds Source # pred :: CUSeconds -> CUSeconds Source # toEnum :: Int -> CUSeconds Source # fromEnum :: CUSeconds -> Int Source # enumFrom :: CUSeconds -> [CUSeconds] Source # enumFromThen :: CUSeconds -> CUSeconds -> [CUSeconds] Source # enumFromTo :: CUSeconds -> CUSeconds -> [CUSeconds] Source # enumFromThenTo :: CUSeconds -> CUSeconds -> CUSeconds -> [CUSeconds] Source # | |
Enum CUShort Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CUShort -> CUShort Source # pred :: CUShort -> CUShort Source # toEnum :: Int -> CUShort Source # fromEnum :: CUShort -> Int Source # enumFrom :: CUShort -> [CUShort] Source # enumFromThen :: CUShort -> CUShort -> [CUShort] Source # enumFromTo :: CUShort -> CUShort -> [CUShort] Source # enumFromThenTo :: CUShort -> CUShort -> CUShort -> [CUShort] Source # | |
Enum CWchar Source # | |
Defined in GHC.Internal.Foreign.C.Types succ :: CWchar -> CWchar Source # pred :: CWchar -> CWchar Source # toEnum :: Int -> CWchar Source # fromEnum :: CWchar -> Int Source # enumFrom :: CWchar -> [CWchar] Source # enumFromThen :: CWchar -> CWchar -> [CWchar] Source # enumFromTo :: CWchar -> CWchar -> [CWchar] Source # enumFromThenTo :: CWchar -> CWchar -> CWchar -> [CWchar] Source # | |
Enum IntPtr Source # | |
Defined in GHC.Internal.Foreign.Ptr succ :: IntPtr -> IntPtr Source # pred :: IntPtr -> IntPtr Source # toEnum :: Int -> IntPtr Source # fromEnum :: IntPtr -> Int Source # enumFrom :: IntPtr -> [IntPtr] Source # enumFromThen :: IntPtr -> IntPtr -> [IntPtr] Source # enumFromTo :: IntPtr -> IntPtr -> [IntPtr] Source # enumFromThenTo :: IntPtr -> IntPtr -> IntPtr -> [IntPtr] Source # | |
Enum WordPtr Source # | |
Defined in GHC.Internal.Foreign.Ptr succ :: WordPtr -> WordPtr Source # pred :: WordPtr -> WordPtr Source # toEnum :: Int -> WordPtr Source # fromEnum :: WordPtr -> Int Source # enumFrom :: WordPtr -> [WordPtr] Source # enumFromThen :: WordPtr -> WordPtr -> [WordPtr] Source # enumFromTo :: WordPtr -> WordPtr -> [WordPtr] Source # enumFromThenTo :: WordPtr -> WordPtr -> WordPtr -> [WordPtr] Source # | |
Enum Associativity Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics succ :: Associativity -> Associativity Source # pred :: Associativity -> Associativity Source # toEnum :: Int -> Associativity Source # fromEnum :: Associativity -> Int Source # enumFrom :: Associativity -> [Associativity] Source # enumFromThen :: Associativity -> Associativity -> [Associativity] Source # enumFromTo :: Associativity -> Associativity -> [Associativity] Source # enumFromThenTo :: Associativity -> Associativity -> Associativity -> [Associativity] Source # | |
Enum DecidedStrictness Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics succ :: DecidedStrictness -> DecidedStrictness Source # pred :: DecidedStrictness -> DecidedStrictness Source # toEnum :: Int -> DecidedStrictness Source # fromEnum :: DecidedStrictness -> Int Source # enumFrom :: DecidedStrictness -> [DecidedStrictness] Source # enumFromThen :: DecidedStrictness -> DecidedStrictness -> [DecidedStrictness] Source # enumFromTo :: DecidedStrictness -> DecidedStrictness -> [DecidedStrictness] Source # enumFromThenTo :: DecidedStrictness -> DecidedStrictness -> DecidedStrictness -> [DecidedStrictness] Source # | |
Enum SourceStrictness Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics succ :: SourceStrictness -> SourceStrictness Source # pred :: SourceStrictness -> SourceStrictness Source # toEnum :: Int -> SourceStrictness Source # fromEnum :: SourceStrictness -> Int Source # enumFrom :: SourceStrictness -> [SourceStrictness] Source # enumFromThen :: SourceStrictness -> SourceStrictness -> [SourceStrictness] Source # enumFromTo :: SourceStrictness -> SourceStrictness -> [SourceStrictness] Source # enumFromThenTo :: SourceStrictness -> SourceStrictness -> SourceStrictness -> [SourceStrictness] Source # | |
Enum SourceUnpackedness Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics succ :: SourceUnpackedness -> SourceUnpackedness Source # pred :: SourceUnpackedness -> SourceUnpackedness Source # toEnum :: Int -> SourceUnpackedness Source # fromEnum :: SourceUnpackedness -> Int Source # enumFrom :: SourceUnpackedness -> [SourceUnpackedness] Source # enumFromThen :: SourceUnpackedness -> SourceUnpackedness -> [SourceUnpackedness] Source # enumFromTo :: SourceUnpackedness -> SourceUnpackedness -> [SourceUnpackedness] Source # enumFromThenTo :: SourceUnpackedness -> SourceUnpackedness -> SourceUnpackedness -> [SourceUnpackedness] Source # | |
Enum SeekMode Source # | Since: base-4.2.0.0 |
Defined in GHC.Internal.IO.Device succ :: SeekMode -> SeekMode Source # pred :: SeekMode -> SeekMode Source # toEnum :: Int -> SeekMode Source # fromEnum :: SeekMode -> Int Source # enumFrom :: SeekMode -> [SeekMode] Source # enumFromThen :: SeekMode -> SeekMode -> [SeekMode] Source # enumFromTo :: SeekMode -> SeekMode -> [SeekMode] Source # enumFromThenTo :: SeekMode -> SeekMode -> SeekMode -> [SeekMode] Source # | |
Enum IOMode Source # | Since: base-4.2.0.0 |
Defined in GHC.Internal.IO.IOMode succ :: IOMode -> IOMode Source # pred :: IOMode -> IOMode Source # toEnum :: Int -> IOMode Source # fromEnum :: IOMode -> Int Source # enumFrom :: IOMode -> [IOMode] Source # enumFromThen :: IOMode -> IOMode -> [IOMode] Source # enumFromTo :: IOMode -> IOMode -> [IOMode] Source # enumFromThenTo :: IOMode -> IOMode -> IOMode -> [IOMode] Source # | |
Enum Int16 Source # | Since: base-2.1 |
Defined in GHC.Internal.Int succ :: Int16 -> Int16 Source # pred :: Int16 -> Int16 Source # toEnum :: Int -> Int16 Source # fromEnum :: Int16 -> Int Source # enumFrom :: Int16 -> [Int16] Source # enumFromThen :: Int16 -> Int16 -> [Int16] Source # enumFromTo :: Int16 -> Int16 -> [Int16] Source # enumFromThenTo :: Int16 -> Int16 -> Int16 -> [Int16] Source # | |
Enum Int32 Source # | Since: base-2.1 |
Defined in GHC.Internal.Int succ :: Int32 -> Int32 Source # pred :: Int32 -> Int32 Source # toEnum :: Int -> Int32 Source # fromEnum :: Int32 -> Int Source # enumFrom :: Int32 -> [Int32] Source # enumFromThen :: Int32 -> Int32 -> [Int32] Source # enumFromTo :: Int32 -> Int32 -> [Int32] Source # enumFromThenTo :: Int32 -> Int32 -> Int32 -> [Int32] Source # | |
Enum Int64 Source # | Since: base-2.1 |
Defined in GHC.Internal.Int succ :: Int64 -> Int64 Source # pred :: Int64 -> Int64 Source # toEnum :: Int -> Int64 Source # fromEnum :: Int64 -> Int Source # enumFrom :: Int64 -> [Int64] Source # enumFromThen :: Int64 -> Int64 -> [Int64] Source # enumFromTo :: Int64 -> Int64 -> [Int64] Source # enumFromThenTo :: Int64 -> Int64 -> Int64 -> [Int64] Source # | |
Enum Int8 Source # | Since: base-2.1 |
Enum Extension Source # | |
Defined in GHC.Internal.LanguageExtensions succ :: Extension -> Extension Source # pred :: Extension -> Extension Source # toEnum :: Int -> Extension Source # fromEnum :: Extension -> Int Source # enumFrom :: Extension -> [Extension] Source # enumFromThen :: Extension -> Extension -> [Extension] Source # enumFromTo :: Extension -> Extension -> [Extension] Source # enumFromThenTo :: Extension -> Extension -> Extension -> [Extension] Source # | |
Enum DoCostCentres Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.RTS.Flags succ :: DoCostCentres -> DoCostCentres Source # pred :: DoCostCentres -> DoCostCentres Source # toEnum :: Int -> DoCostCentres Source # fromEnum :: DoCostCentres -> Int Source # enumFrom :: DoCostCentres -> [DoCostCentres] Source # enumFromThen :: DoCostCentres -> DoCostCentres -> [DoCostCentres] Source # enumFromTo :: DoCostCentres -> DoCostCentres -> [DoCostCentres] Source # enumFromThenTo :: DoCostCentres -> DoCostCentres -> DoCostCentres -> [DoCostCentres] Source # | |
Enum DoHeapProfile Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.RTS.Flags succ :: DoHeapProfile -> DoHeapProfile Source # pred :: DoHeapProfile -> DoHeapProfile Source # toEnum :: Int -> DoHeapProfile Source # fromEnum :: DoHeapProfile -> Int Source # enumFrom :: DoHeapProfile -> [DoHeapProfile] Source # enumFromThen :: DoHeapProfile -> DoHeapProfile -> [DoHeapProfile] Source # enumFromTo :: DoHeapProfile -> DoHeapProfile -> [DoHeapProfile] Source # enumFromThenTo :: DoHeapProfile -> DoHeapProfile -> DoHeapProfile -> [DoHeapProfile] Source # | |
Enum DoTrace Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.RTS.Flags succ :: DoTrace -> DoTrace Source # pred :: DoTrace -> DoTrace Source # toEnum :: Int -> DoTrace Source # fromEnum :: DoTrace -> Int Source # enumFrom :: DoTrace -> [DoTrace] Source # enumFromThen :: DoTrace -> DoTrace -> [DoTrace] Source # enumFromTo :: DoTrace -> DoTrace -> [DoTrace] Source # enumFromThenTo :: DoTrace -> DoTrace -> DoTrace -> [DoTrace] Source # | |
Enum GiveGCStats Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.RTS.Flags succ :: GiveGCStats -> GiveGCStats Source # pred :: GiveGCStats -> GiveGCStats Source # toEnum :: Int -> GiveGCStats Source # fromEnum :: GiveGCStats -> Int Source # enumFrom :: GiveGCStats -> [GiveGCStats] Source # enumFromThen :: GiveGCStats -> GiveGCStats -> [GiveGCStats] Source # enumFromTo :: GiveGCStats -> GiveGCStats -> [GiveGCStats] Source # enumFromThenTo :: GiveGCStats -> GiveGCStats -> GiveGCStats -> [GiveGCStats] Source # | |
Enum IoManagerFlag Source # | |
Defined in GHC.Internal.RTS.Flags succ :: IoManagerFlag -> IoManagerFlag Source # pred :: IoManagerFlag -> IoManagerFlag Source # toEnum :: Int -> IoManagerFlag Source # fromEnum :: IoManagerFlag -> Int Source # enumFrom :: IoManagerFlag -> [IoManagerFlag] Source # enumFromThen :: IoManagerFlag -> IoManagerFlag -> [IoManagerFlag] Source # enumFromTo :: IoManagerFlag -> IoManagerFlag -> [IoManagerFlag] Source # enumFromThenTo :: IoManagerFlag -> IoManagerFlag -> IoManagerFlag -> [IoManagerFlag] Source # | |
Enum CBlkCnt Source # | |
Defined in GHC.Internal.System.Posix.Types succ :: CBlkCnt -> CBlkCnt Source # pred :: CBlkCnt -> CBlkCnt Source # toEnum :: Int -> CBlkCnt Source # fromEnum :: CBlkCnt -> Int Source # enumFrom :: CBlkCnt -> [CBlkCnt] Source # enumFromThen :: CBlkCnt -> CBlkCnt -> [CBlkCnt] Source # enumFromTo :: CBlkCnt -> CBlkCnt -> [CBlkCnt] Source # enumFromThenTo :: CBlkCnt -> CBlkCnt -> CBlkCnt -> [CBlkCnt] Source # | |
Enum CBlkSize Source # | |
Defined in GHC.Internal.System.Posix.Types succ :: CBlkSize -> CBlkSize Source # pred :: CBlkSize -> CBlkSize Source # toEnum :: Int -> CBlkSize Source # fromEnum :: CBlkSize -> Int Source # enumFrom :: CBlkSize -> [CBlkSize] Source # enumFromThen :: CBlkSize -> CBlkSize -> [CBlkSize] Source # enumFromTo :: CBlkSize -> CBlkSize -> [CBlkSize] Source # enumFromThenTo :: CBlkSize -> CBlkSize -> CBlkSize -> [CBlkSize] Source # | |
Enum CCc Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Enum CClockId Source # | |
Defined in GHC.Internal.System.Posix.Types succ :: CClockId -> CClockId Source # pred :: CClockId -> CClockId Source # toEnum :: Int -> CClockId Source # fromEnum :: CClockId -> Int Source # enumFrom :: CClockId -> [CClockId] Source # enumFromThen :: CClockId -> CClockId -> [CClockId] Source # enumFromTo :: CClockId -> CClockId -> [CClockId] Source # enumFromThenTo :: CClockId -> CClockId -> CClockId -> [CClockId] Source # | |
Enum CDev Source # | |
Enum CFsBlkCnt Source # | |
Defined in GHC.Internal.System.Posix.Types succ :: CFsBlkCnt -> CFsBlkCnt Source # pred :: CFsBlkCnt -> CFsBlkCnt Source # toEnum :: Int -> CFsBlkCnt Source # fromEnum :: CFsBlkCnt -> Int Source # enumFrom :: CFsBlkCnt -> [CFsBlkCnt] Source # enumFromThen :: CFsBlkCnt -> CFsBlkCnt -> [CFsBlkCnt] Source # enumFromTo :: CFsBlkCnt -> CFsBlkCnt -> [CFsBlkCnt] Source # enumFromThenTo :: CFsBlkCnt -> CFsBlkCnt -> CFsBlkCnt -> [CFsBlkCnt] Source # | |
Enum CFsFilCnt Source # | |
Defined in GHC.Internal.System.Posix.Types succ :: CFsFilCnt -> CFsFilCnt Source # pred :: CFsFilCnt -> CFsFilCnt Source # toEnum :: Int -> CFsFilCnt Source # fromEnum :: CFsFilCnt -> Int Source # enumFrom :: CFsFilCnt -> [CFsFilCnt] Source # enumFromThen :: CFsFilCnt -> CFsFilCnt -> [CFsFilCnt] Source # enumFromTo :: CFsFilCnt -> CFsFilCnt -> [CFsFilCnt] Source # enumFromThenTo :: CFsFilCnt -> CFsFilCnt -> CFsFilCnt -> [CFsFilCnt] Source # | |
Enum CGid Source # | |
Enum CId Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Enum CIno Source # | |
Enum CKey Source # | |
Enum CMode Source # | |
Defined in GHC.Internal.System.Posix.Types succ :: CMode -> CMode Source # pred :: CMode -> CMode Source # toEnum :: Int -> CMode Source # fromEnum :: CMode -> Int Source # enumFrom :: CMode -> [CMode] Source # enumFromThen :: CMode -> CMode -> [CMode] Source # enumFromTo :: CMode -> CMode -> [CMode] Source # enumFromThenTo :: CMode -> CMode -> CMode -> [CMode] Source # | |
Enum CNfds Source # | |
Defined in GHC.Internal.System.Posix.Types succ :: CNfds -> CNfds Source # pred :: CNfds -> CNfds Source # toEnum :: Int -> CNfds Source # fromEnum :: CNfds -> Int Source # enumFrom :: CNfds -> [CNfds] Source # enumFromThen :: CNfds -> CNfds -> [CNfds] Source # enumFromTo :: CNfds -> CNfds -> [CNfds] Source # enumFromThenTo :: CNfds -> CNfds -> CNfds -> [CNfds] Source # | |
Enum CNlink Source # | |
Defined in GHC.Internal.System.Posix.Types succ :: CNlink -> CNlink Source # pred :: CNlink -> CNlink Source # toEnum :: Int -> CNlink Source # fromEnum :: CNlink -> Int Source # enumFrom :: CNlink -> [CNlink] Source # enumFromThen :: CNlink -> CNlink -> [CNlink] Source # enumFromTo :: CNlink -> CNlink -> [CNlink] Source # enumFromThenTo :: CNlink -> CNlink -> CNlink -> [CNlink] Source # | |
Enum COff Source # | |
Enum CPid Source # | |
Enum CRLim Source # | |
Defined in GHC.Internal.System.Posix.Types succ :: CRLim -> CRLim Source # pred :: CRLim -> CRLim Source # toEnum :: Int -> CRLim Source # fromEnum :: CRLim -> Int Source # enumFrom :: CRLim -> [CRLim] Source # enumFromThen :: CRLim -> CRLim -> [CRLim] Source # enumFromTo :: CRLim -> CRLim -> [CRLim] Source # enumFromThenTo :: CRLim -> CRLim -> CRLim -> [CRLim] Source # | |
Enum CSocklen Source # | |
Defined in GHC.Internal.System.Posix.Types succ :: CSocklen -> CSocklen Source # pred :: CSocklen -> CSocklen Source # toEnum :: Int -> CSocklen Source # fromEnum :: CSocklen -> Int Source # enumFrom :: CSocklen -> [CSocklen] Source # enumFromThen :: CSocklen -> CSocklen -> [CSocklen] Source # enumFromTo :: CSocklen -> CSocklen -> [CSocklen] Source # enumFromThenTo :: CSocklen -> CSocklen -> CSocklen -> [CSocklen] Source # | |
Enum CSpeed Source # | |
Defined in GHC.Internal.System.Posix.Types succ :: CSpeed -> CSpeed Source # pred :: CSpeed -> CSpeed Source # toEnum :: Int -> CSpeed Source # fromEnum :: CSpeed -> Int Source # enumFrom :: CSpeed -> [CSpeed] Source # enumFromThen :: CSpeed -> CSpeed -> [CSpeed] Source # enumFromTo :: CSpeed -> CSpeed -> [CSpeed] Source # enumFromThenTo :: CSpeed -> CSpeed -> CSpeed -> [CSpeed] Source # | |
Enum CSsize Source # | |
Defined in GHC.Internal.System.Posix.Types succ :: CSsize -> CSsize Source # pred :: CSsize -> CSsize Source # toEnum :: Int -> CSsize Source # fromEnum :: CSsize -> Int Source # enumFrom :: CSsize -> [CSsize] Source # enumFromThen :: CSsize -> CSsize -> [CSsize] Source # enumFromTo :: CSsize -> CSsize -> [CSsize] Source # enumFromThenTo :: CSsize -> CSsize -> CSsize -> [CSsize] Source # | |
Enum CTcflag Source # | |
Defined in GHC.Internal.System.Posix.Types succ :: CTcflag -> CTcflag Source # pred :: CTcflag -> CTcflag Source # toEnum :: Int -> CTcflag Source # fromEnum :: CTcflag -> Int Source # enumFrom :: CTcflag -> [CTcflag] Source # enumFromThen :: CTcflag -> CTcflag -> [CTcflag] Source # enumFromTo :: CTcflag -> CTcflag -> [CTcflag] Source # enumFromThenTo :: CTcflag -> CTcflag -> CTcflag -> [CTcflag] Source # | |
Enum CUid Source # | |
Enum Fd Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Enum GeneralCategory Source # | Since: base-2.1 |
Defined in GHC.Internal.Unicode succ :: GeneralCategory -> GeneralCategory Source # pred :: GeneralCategory -> GeneralCategory Source # toEnum :: Int -> GeneralCategory Source # fromEnum :: GeneralCategory -> Int Source # enumFrom :: GeneralCategory -> [GeneralCategory] Source # enumFromThen :: GeneralCategory -> GeneralCategory -> [GeneralCategory] Source # enumFromTo :: GeneralCategory -> GeneralCategory -> [GeneralCategory] Source # enumFromThenTo :: GeneralCategory -> GeneralCategory -> GeneralCategory -> [GeneralCategory] Source # | |
Enum Word16 Source # | Since: base-2.1 |
Defined in GHC.Internal.Word succ :: Word16 -> Word16 Source # pred :: Word16 -> Word16 Source # toEnum :: Int -> Word16 Source # fromEnum :: Word16 -> Int Source # enumFrom :: Word16 -> [Word16] Source # enumFromThen :: Word16 -> Word16 -> [Word16] Source # enumFromTo :: Word16 -> Word16 -> [Word16] Source # enumFromThenTo :: Word16 -> Word16 -> Word16 -> [Word16] Source # | |
Enum Word32 Source # | Since: base-2.1 |
Defined in GHC.Internal.Word succ :: Word32 -> Word32 Source # pred :: Word32 -> Word32 Source # toEnum :: Int -> Word32 Source # fromEnum :: Word32 -> Int Source # enumFrom :: Word32 -> [Word32] Source # enumFromThen :: Word32 -> Word32 -> [Word32] Source # enumFromTo :: Word32 -> Word32 -> [Word32] Source # enumFromThenTo :: Word32 -> Word32 -> Word32 -> [Word32] Source # | |
Enum Word64 Source # | Since: base-2.1 |
Defined in GHC.Internal.Word succ :: Word64 -> Word64 Source # pred :: Word64 -> Word64 Source # toEnum :: Int -> Word64 Source # fromEnum :: Word64 -> Int Source # enumFrom :: Word64 -> [Word64] Source # enumFromThen :: Word64 -> Word64 -> [Word64] Source # enumFromTo :: Word64 -> Word64 -> [Word64] Source # enumFromThenTo :: Word64 -> Word64 -> Word64 -> [Word64] Source # | |
Enum Word8 Source # | Since: base-2.1 |
Defined in GHC.Internal.Word succ :: Word8 -> Word8 Source # pred :: Word8 -> Word8 Source # toEnum :: Int -> Word8 Source # fromEnum :: Word8 -> Int Source # enumFrom :: Word8 -> [Word8] Source # enumFromThen :: Word8 -> Word8 -> [Word8] Source # enumFromTo :: Word8 -> Word8 -> [Word8] Source # enumFromThenTo :: Word8 -> Word8 -> Word8 -> [Word8] Source # | |
Enum Ordering Source # | Since: base-2.1 |
Defined in GHC.Internal.Enum succ :: Ordering -> Ordering Source # pred :: Ordering -> Ordering Source # toEnum :: Int -> Ordering Source # fromEnum :: Ordering -> Int Source # enumFrom :: Ordering -> [Ordering] Source # enumFromThen :: Ordering -> Ordering -> [Ordering] Source # enumFromTo :: Ordering -> Ordering -> [Ordering] Source # enumFromThenTo :: Ordering -> Ordering -> Ordering -> [Ordering] Source # | |
Enum Integer Source # | Since: base-2.1 |
Defined in GHC.Internal.Enum succ :: Integer -> Integer Source # pred :: Integer -> Integer Source # toEnum :: Int -> Integer Source # fromEnum :: Integer -> Int Source # enumFrom :: Integer -> [Integer] Source # enumFromThen :: Integer -> Integer -> [Integer] Source # enumFromTo :: Integer -> Integer -> [Integer] Source # enumFromThenTo :: Integer -> Integer -> Integer -> [Integer] Source # | |
Enum Natural Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.Enum succ :: Natural -> Natural Source # pred :: Natural -> Natural Source # toEnum :: Int -> Natural Source # fromEnum :: Natural -> Int Source # enumFrom :: Natural -> [Natural] Source # enumFromThen :: Natural -> Natural -> [Natural] Source # enumFromTo :: Natural -> Natural -> [Natural] Source # enumFromThenTo :: Natural -> Natural -> Natural -> [Natural] Source # | |
Enum () Source # | Since: base-2.1 |
Enum Bool Source # | Since: base-2.1 |
Enum Char Source # | Since: base-2.1 |
Enum Int Source # | Since: base-2.1 |
Defined in GHC.Internal.Enum | |
Enum Levity Source # | Since: base-4.16.0.0 |
Defined in GHC.Internal.Enum succ :: Levity -> Levity Source # pred :: Levity -> Levity Source # toEnum :: Int -> Levity Source # fromEnum :: Levity -> Int Source # enumFrom :: Levity -> [Levity] Source # enumFromThen :: Levity -> Levity -> [Levity] Source # enumFromTo :: Levity -> Levity -> [Levity] Source # enumFromThenTo :: Levity -> Levity -> Levity -> [Levity] Source # | |
Enum VecCount Source # | Since: base-4.10.0.0 |
Defined in GHC.Internal.Enum succ :: VecCount -> VecCount Source # pred :: VecCount -> VecCount Source # toEnum :: Int -> VecCount Source # fromEnum :: VecCount -> Int Source # enumFrom :: VecCount -> [VecCount] Source # enumFromThen :: VecCount -> VecCount -> [VecCount] Source # enumFromTo :: VecCount -> VecCount -> [VecCount] Source # enumFromThenTo :: VecCount -> VecCount -> VecCount -> [VecCount] Source # | |
Enum VecElem Source # | Since: base-4.10.0.0 |
Defined in GHC.Internal.Enum succ :: VecElem -> VecElem Source # pred :: VecElem -> VecElem Source # toEnum :: Int -> VecElem Source # fromEnum :: VecElem -> Int Source # enumFrom :: VecElem -> [VecElem] Source # enumFromThen :: VecElem -> VecElem -> [VecElem] Source # enumFromTo :: VecElem -> VecElem -> [VecElem] Source # enumFromThenTo :: VecElem -> VecElem -> VecElem -> [VecElem] Source # | |
Enum Word Source # | Since: base-2.1 |
Enum a => Enum (First a) Source # | Since: base-4.9.0.0 |
Defined in Data.Semigroup succ :: First a -> First a Source # pred :: First a -> First a Source # toEnum :: Int -> First a Source # fromEnum :: First a -> Int Source # enumFrom :: First a -> [First a] Source # enumFromThen :: First a -> First a -> [First a] Source # enumFromTo :: First a -> First a -> [First a] Source # enumFromThenTo :: First a -> First a -> First a -> [First a] Source # | |
Enum a => Enum (Last a) Source # | Since: base-4.9.0.0 |
Defined in Data.Semigroup succ :: Last a -> Last a Source # pred :: Last a -> Last a Source # toEnum :: Int -> Last a Source # fromEnum :: Last a -> Int Source # enumFrom :: Last a -> [Last a] Source # enumFromThen :: Last a -> Last a -> [Last a] Source # enumFromTo :: Last a -> Last a -> [Last a] Source # enumFromThenTo :: Last a -> Last a -> Last a -> [Last a] Source # | |
Enum a => Enum (Max a) Source # | Since: base-4.9.0.0 |
Defined in Data.Semigroup succ :: Max a -> Max a Source # pred :: Max a -> Max a Source # toEnum :: Int -> Max a Source # fromEnum :: Max a -> Int Source # enumFrom :: Max a -> [Max a] Source # enumFromThen :: Max a -> Max a -> [Max a] Source # enumFromTo :: Max a -> Max a -> [Max a] Source # enumFromThenTo :: Max a -> Max a -> Max a -> [Max a] Source # | |
Enum a => Enum (Min a) Source # | Since: base-4.9.0.0 |
Defined in Data.Semigroup succ :: Min a -> Min a Source # pred :: Min a -> Min a Source # toEnum :: Int -> Min a Source # fromEnum :: Min a -> Int Source # enumFrom :: Min a -> [Min a] Source # enumFromThen :: Min a -> Min a -> [Min a] Source # enumFromTo :: Min a -> Min a -> [Min a] Source # enumFromThenTo :: Min a -> Min a -> Min a -> [Min a] Source # | |
Enum a => Enum (WrappedMonoid a) Source # | Since: base-4.9.0.0 |
Defined in Data.Semigroup succ :: WrappedMonoid a -> WrappedMonoid a Source # pred :: WrappedMonoid a -> WrappedMonoid a Source # toEnum :: Int -> WrappedMonoid a Source # fromEnum :: WrappedMonoid a -> Int Source # enumFrom :: WrappedMonoid a -> [WrappedMonoid a] Source # enumFromThen :: WrappedMonoid a -> WrappedMonoid a -> [WrappedMonoid a] Source # enumFromTo :: WrappedMonoid a -> WrappedMonoid a -> [WrappedMonoid a] Source # enumFromThenTo :: WrappedMonoid a -> WrappedMonoid a -> WrappedMonoid a -> [WrappedMonoid a] Source # | |
Enum a => Enum (And a) Source # | Since: base-4.16 |
Defined in GHC.Internal.Data.Bits succ :: And a -> And a Source # pred :: And a -> And a Source # toEnum :: Int -> And a Source # fromEnum :: And a -> Int Source # enumFrom :: And a -> [And a] Source # enumFromThen :: And a -> And a -> [And a] Source # enumFromTo :: And a -> And a -> [And a] Source # enumFromThenTo :: And a -> And a -> And a -> [And a] Source # | |
Enum a => Enum (Iff a) Source # | Since: base-4.16 |
Defined in GHC.Internal.Data.Bits succ :: Iff a -> Iff a Source # pred :: Iff a -> Iff a Source # toEnum :: Int -> Iff a Source # fromEnum :: Iff a -> Int Source # enumFrom :: Iff a -> [Iff a] Source # enumFromThen :: Iff a -> Iff a -> [Iff a] Source # enumFromTo :: Iff a -> Iff a -> [Iff a] Source # enumFromThenTo :: Iff a -> Iff a -> Iff a -> [Iff a] Source # | |
Enum a => Enum (Ior a) Source # | Since: base-4.16 |
Defined in GHC.Internal.Data.Bits succ :: Ior a -> Ior a Source # pred :: Ior a -> Ior a Source # toEnum :: Int -> Ior a Source # fromEnum :: Ior a -> Int Source # enumFrom :: Ior a -> [Ior a] Source # enumFromThen :: Ior a -> Ior a -> [Ior a] Source # enumFromTo :: Ior a -> Ior a -> [Ior a] Source # enumFromThenTo :: Ior a -> Ior a -> Ior a -> [Ior a] Source # | |
Enum a => Enum (Xor a) Source # | Since: base-4.16 |
Defined in GHC.Internal.Data.Bits succ :: Xor a -> Xor a Source # pred :: Xor a -> Xor a Source # toEnum :: Int -> Xor a Source # fromEnum :: Xor a -> Int Source # enumFrom :: Xor a -> [Xor a] Source # enumFromThen :: Xor a -> Xor a -> [Xor a] Source # enumFromTo :: Xor a -> Xor a -> [Xor a] Source # enumFromThenTo :: Xor a -> Xor a -> Xor a -> [Xor a] Source # | |
Enum a => Enum (Identity a) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Identity succ :: Identity a -> Identity a Source # pred :: Identity a -> Identity a Source # toEnum :: Int -> Identity a Source # fromEnum :: Identity a -> Int Source # enumFrom :: Identity a -> [Identity a] Source # enumFromThen :: Identity a -> Identity a -> [Identity a] Source # enumFromTo :: Identity a -> Identity a -> [Identity a] Source # enumFromThenTo :: Identity a -> Identity a -> Identity a -> [Identity a] Source # | |
(Enum a, Bounded a, Eq a) => Enum (Down a) Source # | Swaps Since: base-4.18.0.0 |
Defined in GHC.Internal.Data.Ord succ :: Down a -> Down a Source # pred :: Down a -> Down a Source # toEnum :: Int -> Down a Source # fromEnum :: Down a -> Int Source # enumFrom :: Down a -> [Down a] Source # enumFromThen :: Down a -> Down a -> [Down a] Source # enumFromTo :: Down a -> Down a -> [Down a] Source # enumFromThenTo :: Down a -> Down a -> Down a -> [Down a] Source # | |
Integral a => Enum (Ratio a) Source # | Since: base-2.0.1 |
Defined in GHC.Internal.Real 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 # | |
Enum a => Enum (Solo a) Source # | |
Defined in GHC.Internal.Enum succ :: Solo a -> Solo a Source # pred :: Solo a -> Solo a Source # toEnum :: Int -> Solo a Source # fromEnum :: Solo a -> Int Source # enumFrom :: Solo a -> [Solo a] Source # enumFromThen :: Solo a -> Solo a -> [Solo a] Source # enumFromTo :: Solo a -> Solo a -> [Solo a] Source # enumFromThenTo :: Solo a -> Solo a -> Solo a -> [Solo a] Source # | |
Enum (Fixed a) Source # | Recall that, for numeric types,
and likewise
In other words,
and similarly
This is worth bearing in mind when defining [1..10] :: [Pico] evaluates to However, this is not true. On the contrary, similarly to the above
implementations of [1.000000000000, 1.00000000001, 1.00000000002, ..., 10.000000000000] and contains Since: base-2.1 |
Defined in Data.Fixed succ :: Fixed a -> Fixed a Source # pred :: Fixed a -> Fixed a Source # toEnum :: Int -> Fixed a Source # fromEnum :: Fixed a -> Int Source # enumFrom :: Fixed a -> [Fixed a] Source # enumFromThen :: Fixed a -> Fixed a -> [Fixed a] Source # enumFromTo :: Fixed a -> Fixed a -> [Fixed a] Source # enumFromThenTo :: Fixed a -> Fixed a -> Fixed a -> [Fixed a] Source # | |
Enum (Proxy s) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Data.Proxy succ :: Proxy s -> Proxy s Source # pred :: Proxy s -> Proxy s Source # toEnum :: Int -> Proxy s Source # fromEnum :: Proxy s -> Int Source # enumFrom :: Proxy s -> [Proxy s] Source # enumFromThen :: Proxy s -> Proxy s -> [Proxy s] Source # enumFromTo :: Proxy s -> Proxy s -> [Proxy s] Source # enumFromThenTo :: Proxy s -> Proxy s -> Proxy s -> [Proxy s] Source # | |
Enum a => Enum (Const a b) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Const succ :: Const a b -> Const a b Source # pred :: Const a b -> Const a b Source # toEnum :: Int -> Const a b Source # fromEnum :: Const a b -> Int Source # enumFrom :: Const a b -> [Const a b] Source # enumFromThen :: Const a b -> Const a b -> [Const a b] Source # enumFromTo :: Const a b -> Const a b -> [Const a b] Source # enumFromThenTo :: Const a b -> Const a b -> Const a b -> [Const a b] Source # | |
Enum (f a) => Enum (Ap f a) Source # | Since: base-4.12.0.0 |
Defined in GHC.Internal.Data.Monoid succ :: Ap f a -> Ap f a Source # pred :: Ap f a -> Ap f a Source # toEnum :: Int -> Ap f a Source # fromEnum :: Ap f a -> Int Source # enumFrom :: Ap f a -> [Ap f a] Source # enumFromThen :: Ap f a -> Ap f a -> [Ap f a] Source # enumFromTo :: Ap f a -> Ap f a -> [Ap f a] Source # enumFromThenTo :: Ap f a -> Ap f a -> Ap f a -> [Ap f a] Source # | |
Enum (f a) => Enum (Alt f a) Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.Data.Semigroup.Internal succ :: Alt f a -> Alt f a Source # pred :: Alt f a -> Alt f a Source # toEnum :: Int -> Alt f a Source # fromEnum :: Alt f a -> Int Source # enumFrom :: Alt f a -> [Alt f a] Source # enumFromThen :: Alt f a -> Alt f a -> [Alt f a] Source # enumFromTo :: Alt f a -> Alt f a -> [Alt f a] Source # enumFromThenTo :: Alt f a -> Alt f a -> Alt f a -> [Alt f a] Source # | |
Coercible a b => Enum (Coercion a b) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Data.Type.Coercion succ :: Coercion a b -> Coercion a b Source # pred :: Coercion a b -> Coercion a b Source # toEnum :: Int -> Coercion a b Source # fromEnum :: Coercion a b -> Int Source # enumFrom :: Coercion a b -> [Coercion a b] Source # enumFromThen :: Coercion a b -> Coercion a b -> [Coercion a b] Source # enumFromTo :: Coercion a b -> Coercion a b -> [Coercion a b] Source # enumFromThenTo :: Coercion a b -> Coercion a b -> Coercion a b -> [Coercion a b] Source # | |
a ~ b => Enum (a :~: b) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Data.Type.Equality succ :: (a :~: b) -> a :~: b Source # pred :: (a :~: b) -> a :~: b Source # toEnum :: Int -> a :~: b Source # fromEnum :: (a :~: b) -> Int Source # enumFrom :: (a :~: b) -> [a :~: b] Source # enumFromThen :: (a :~: b) -> (a :~: b) -> [a :~: b] Source # enumFromTo :: (a :~: b) -> (a :~: b) -> [a :~: b] Source # enumFromThenTo :: (a :~: b) -> (a :~: b) -> (a :~: b) -> [a :~: b] Source # | |
a ~~ b => Enum (a :~~: b) Source # | Since: base-4.10.0.0 |
Defined in GHC.Internal.Data.Type.Equality succ :: (a :~~: b) -> a :~~: b Source # pred :: (a :~~: b) -> a :~~: b Source # toEnum :: Int -> a :~~: b Source # fromEnum :: (a :~~: b) -> Int Source # enumFrom :: (a :~~: b) -> [a :~~: b] Source # enumFromThen :: (a :~~: b) -> (a :~~: b) -> [a :~~: b] Source # enumFromTo :: (a :~~: b) -> (a :~~: b) -> [a :~~: b] Source # enumFromThenTo :: (a :~~: b) -> (a :~~: b) -> (a :~~: b) -> [a :~~: b] Source # | |
Enum (f (g a)) => Enum (Compose f g a) Source # | Since: base-4.19.0.0 |
Defined in Data.Functor.Compose succ :: Compose f g a -> Compose f g a Source # pred :: Compose f g a -> Compose f g a Source # toEnum :: Int -> Compose f g a Source # fromEnum :: Compose f g a -> Int Source # enumFrom :: Compose f g a -> [Compose f g a] Source # enumFromThen :: Compose f g a -> Compose f g a -> [Compose f g a] Source # enumFromTo :: Compose f g a -> Compose f g a -> [Compose f g a] Source # enumFromThenTo :: Compose f g a -> Compose f g a -> Compose f g a -> [Compose f g a] Source # |
class Bounded a where Source #
The Bounded
class is used to name the upper and lower limits of a
type. Ord
is not a superclass of Bounded
since types that are not
totally ordered may also have upper and lower bounds.
The Bounded
class may be derived for any enumeration type;
minBound
is the first constructor listed in the data
declaration
and maxBound
is the last.
Bounded
may also be derived for single-constructor datatypes whose
constituent types are in Bounded
.
Instances
Bounded ByteOrder Source # | Since: base-4.11.0.0 |
Bounded All Source # | Since: base-2.1 |
Bounded Any Source # | Since: base-2.1 |
Bounded CBool Source # | |
Bounded CChar Source # | |
Bounded CInt Source # | |
Bounded CIntMax Source # | |
Bounded CIntPtr Source # | |
Bounded CLLong Source # | |
Bounded CLong Source # | |
Bounded CPtrdiff Source # | |
Bounded CSChar Source # | |
Bounded CShort Source # | |
Bounded CSigAtomic Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Bounded CSize Source # | |
Bounded CUChar Source # | |
Bounded CUInt Source # | |
Bounded CUIntMax Source # | |
Bounded CUIntPtr Source # | |
Bounded CULLong Source # | |
Bounded CULong Source # | |
Bounded CUShort Source # | |
Bounded CWchar Source # | |
Bounded IntPtr Source # | |
Bounded WordPtr Source # | |
Bounded Associativity Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics | |
Bounded DecidedStrictness Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics | |
Bounded SourceStrictness Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics | |
Bounded SourceUnpackedness Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics | |
Bounded Int16 Source # | Since: base-2.1 |
Bounded Int32 Source # | Since: base-2.1 |
Bounded Int64 Source # | Since: base-2.1 |
Bounded Int8 Source # | Since: base-2.1 |
Bounded Extension Source # | |
Bounded CBlkCnt Source # | |
Bounded CBlkSize Source # | |
Bounded CClockId Source # | |
Bounded CDev Source # | |
Bounded CFsBlkCnt Source # | |
Bounded CFsFilCnt Source # | |
Bounded CGid Source # | |
Bounded CId Source # | |
Bounded CIno Source # | |
Bounded CKey Source # | |
Bounded CMode Source # | |
Bounded CNfds Source # | |
Bounded CNlink Source # | |
Bounded COff Source # | |
Bounded CPid Source # | |
Bounded CRLim Source # | |
Bounded CSocklen Source # | |
Bounded CSsize Source # | |
Bounded CTcflag Source # | |
Bounded CUid Source # | |
Bounded Fd Source # | |
Bounded GeneralCategory Source # | Since: base-2.1 |
Defined in GHC.Internal.Unicode | |
Bounded Word16 Source # | Since: base-2.1 |
Bounded Word32 Source # | Since: base-2.1 |
Bounded Word64 Source # | Since: base-2.1 |
Bounded Word8 Source # | Since: base-2.1 |
Bounded Ordering Source # | Since: base-2.1 |
Bounded () Source # | Since: base-2.1 |
Bounded Bool Source # | Since: base-2.1 |
Bounded Char Source # | Since: base-2.1 |
Bounded Int Source # | Since: base-2.1 |
Bounded Levity Source # | Since: base-4.16.0.0 |
Bounded VecCount Source # | Since: base-4.10.0.0 |
Bounded VecElem Source # | Since: base-4.10.0.0 |
Bounded Word Source # | Since: base-2.1 |
Bounded a => Bounded (First a) Source # | Since: base-4.9.0.0 |
Bounded a => Bounded (Last a) Source # | Since: base-4.9.0.0 |
Bounded a => Bounded (Max a) Source # | Since: base-4.9.0.0 |
Bounded a => Bounded (Min a) Source # | Since: base-4.9.0.0 |
Bounded m => Bounded (WrappedMonoid m) Source # | Since: base-4.9.0.0 |
Defined in Data.Semigroup minBound :: WrappedMonoid m Source # maxBound :: WrappedMonoid m Source # | |
Bounded a => Bounded (And a) Source # | Since: base-4.16 |
Bounded a => Bounded (Iff a) Source # | Since: base-4.16 |
Bounded a => Bounded (Ior a) Source # | Since: base-4.16 |
Bounded a => Bounded (Xor a) Source # | Since: base-4.16 |
Bounded a => Bounded (Identity a) Source # | Since: base-4.9.0.0 |
Bounded a => Bounded (Down a) Source # | Swaps Since: base-4.14.0.0 |
Bounded a => Bounded (Dual a) Source # | Since: base-2.1 |
Bounded a => Bounded (Product a) Source # | Since: base-2.1 |
Bounded a => Bounded (Sum a) Source # | Since: base-2.1 |
Bounded a => Bounded (Solo a) Source # | |
Bounded (Proxy t) Source # | Since: base-4.7.0.0 |
(Bounded a, Bounded b) => Bounded (a, b) Source # | Since: base-2.1 |
Bounded a => Bounded (Const a b) Source # | Since: base-4.9.0.0 |
(Applicative f, Bounded a) => Bounded (Ap f a) Source # | Since: base-4.12.0.0 |
Coercible a b => Bounded (Coercion a b) Source # | Since: base-4.7.0.0 |
a ~ b => Bounded (a :~: b) Source # | Since: base-4.7.0.0 |
(Bounded a, Bounded b, Bounded c) => Bounded (a, b, c) Source # | Since: base-2.1 |
a ~~ b => Bounded (a :~~: b) Source # | Since: base-4.10.0.0 |
(Bounded a, Bounded b, Bounded c, Bounded d) => Bounded (a, b, c, d) Source # | Since: base-2.1 |
Bounded (f (g a)) => Bounded (Compose f g a) Source # | Since: base-4.19.0.0 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e) => Bounded (a, b, c, d, e) Source # | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f) => Bounded (a, b, c, d, e, f) Source # | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g) => Bounded (a, b, c, d, e, f, g) Source # | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h) => Bounded (a, b, c, d, e, f, g, h) Source # | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i) => Bounded (a, b, c, d, e, f, g, h, i) Source # | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j) => Bounded (a, b, c, d, e, f, g, h, i, j) Source # | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k) => Bounded (a, b, c, d, e, f, g, h, i, j, k) Source # | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l) => Bounded (a, b, c, d, e, f, g, h, i, j, k, l) Source # | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l, Bounded m) => Bounded (a, b, c, d, e, f, g, h, i, j, k, l, m) Source # | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l, Bounded m, Bounded n) => Bounded (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source # | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l, Bounded m, Bounded n, Bounded o) => Bounded (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source # | Since: base-2.1 |
Numbers
GHC.Internal.Numeric types
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
PrintfArg Int Source # | Since: base-2.1 | ||||
Defined in Text.Printf formatArg :: Int -> FieldFormatter Source # parseFormat :: Int -> ModifierParser Source # | |||||
Bits Int Source # | Since: base-2.1 | ||||
Defined in GHC.Internal.Bits (.&.) :: Int -> Int -> Int Source # (.|.) :: Int -> Int -> Int Source # xor :: Int -> Int -> Int Source # complement :: Int -> Int Source # shift :: Int -> Int -> Int Source # rotate :: Int -> Int -> Int Source # setBit :: Int -> Int -> Int Source # clearBit :: Int -> Int -> Int Source # complementBit :: Int -> Int -> Int Source # testBit :: Int -> Int -> Bool Source # bitSizeMaybe :: Int -> Maybe Int Source # bitSize :: Int -> Int Source # isSigned :: Int -> Bool Source # shiftL :: Int -> Int -> Int Source # unsafeShiftL :: Int -> Int -> Int Source # shiftR :: Int -> Int -> Int Source # unsafeShiftR :: Int -> Int -> Int Source # rotateL :: Int -> Int -> Int Source # | |||||
FiniteBits Int Source # | Since: base-4.6.0.0 | ||||
Defined in GHC.Internal.Bits finiteBitSize :: Int -> Int Source # countLeadingZeros :: Int -> Int Source # countTrailingZeros :: Int -> Int Source # | |||||
Data Int Source # | Since: base-4.0.0.0 | ||||
Defined in GHC.Internal.Data.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Int -> c Int Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Int Source # toConstr :: Int -> Constr Source # dataTypeOf :: Int -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Int) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Int) Source # gmapT :: (forall b. Data b => b -> b) -> Int -> Int Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Int -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Int -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Int -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Int -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Int -> m Int Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Int -> m Int Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Int -> m Int Source # | |||||
Bounded Int Source # | Since: base-2.1 | ||||
Enum Int Source # | Since: base-2.1 | ||||
Defined in GHC.Internal.Enum | |||||
Storable Int Source # | Since: base-2.1 | ||||
Defined in GHC.Internal.Foreign.Storable | |||||
Ix Int Source # | Since: base-2.1 | ||||
Num Int Source # | Since: base-2.1 | ||||
Read Int Source # | Since: base-2.1 | ||||
Integral Int Source # | Since: base-2.0.1 | ||||
Real Int Source # | Since: base-2.0.1 | ||||
Defined in GHC.Internal.Real toRational :: Int -> Rational Source # | |||||
Show Int Source # | Since: base-2.1 | ||||
Eq Int Source # | |||||
Ord Int Source # | |||||
Lift Int Source # | |||||
Generic1 (URec Int :: k -> Type) Source # | |||||
Defined in GHC.Internal.Generics
| |||||
Eq1 (UInt :: Type -> Type) Source # | Since: base-4.21.0.0 | ||||
Ord1 (UInt :: Type -> Type) Source # | Since: base-4.21.0.0 | ||||
Defined in Data.Functor.Classes | |||||
Show1 (UInt :: Type -> Type) Source # | Since: base-4.21.0.0 | ||||
Foldable (UInt :: Type -> Type) Source # | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => UInt m -> m Source # foldMap :: Monoid m => (a -> m) -> UInt a -> m Source # foldMap' :: Monoid m => (a -> m) -> UInt a -> m Source # foldr :: (a -> b -> b) -> b -> UInt a -> b Source # foldr' :: (a -> b -> b) -> b -> UInt a -> b Source # foldl :: (b -> a -> b) -> b -> UInt a -> b Source # foldl' :: (b -> a -> b) -> b -> UInt a -> b Source # foldr1 :: (a -> a -> a) -> UInt a -> a Source # foldl1 :: (a -> a -> a) -> UInt a -> a Source # toList :: UInt a -> [a] Source # null :: UInt a -> Bool Source # length :: UInt a -> Int Source # elem :: Eq a => a -> UInt a -> Bool Source # maximum :: Ord a => UInt a -> a Source # minimum :: Ord a => UInt a -> a Source # | |||||
Traversable (UInt :: Type -> Type) Source # | Since: base-4.9.0.0 | ||||
Functor (URec Int :: Type -> Type) Source # | Since: base-4.9.0.0 | ||||
Generic (URec Int p) Source # | |||||
Defined in GHC.Internal.Generics
| |||||
Show (URec Int p) Source # | Since: base-4.9.0.0 | ||||
Eq (URec Int p) Source # | Since: base-4.9.0.0 | ||||
Ord (URec Int p) Source # | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Generics compare :: URec Int p -> URec Int p -> Ordering Source # (<) :: URec Int p -> URec Int p -> Bool Source # (<=) :: URec Int p -> URec Int p -> Bool Source # (>) :: URec Int p -> URec Int p -> Bool Source # (>=) :: URec Int p -> URec Int p -> Bool Source # | |||||
data URec Int (p :: k) Source # | Used for marking occurrences of Since: base-4.9.0.0 | ||||
type Rep1 (URec Int :: k -> Type) Source # | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Generics | |||||
type Rep (URec Int p) Source # | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Generics |
Instances
PrintfArg Integer Source # | Since: base-2.1 |
Defined in Text.Printf formatArg :: Integer -> FieldFormatter Source # parseFormat :: Integer -> ModifierParser Source # | |
Bits Integer Source # | Since: base-2.1 |
Defined in GHC.Internal.Bits (.&.) :: Integer -> Integer -> Integer Source # (.|.) :: Integer -> Integer -> Integer Source # xor :: Integer -> Integer -> Integer Source # complement :: Integer -> Integer Source # shift :: Integer -> Int -> Integer Source # rotate :: Integer -> Int -> Integer Source # bit :: Int -> Integer Source # setBit :: Integer -> Int -> Integer Source # clearBit :: Integer -> Int -> Integer Source # complementBit :: Integer -> Int -> Integer Source # testBit :: Integer -> Int -> Bool Source # bitSizeMaybe :: Integer -> Maybe Int Source # bitSize :: Integer -> Int Source # isSigned :: Integer -> Bool Source # shiftL :: Integer -> Int -> Integer Source # unsafeShiftL :: Integer -> Int -> Integer Source # shiftR :: Integer -> Int -> Integer Source # unsafeShiftR :: Integer -> Int -> Integer Source # rotateL :: Integer -> Int -> Integer Source # | |
Data Integer Source # | Since: base-4.0.0.0 |
Defined in GHC.Internal.Data.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Integer -> c Integer Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Integer Source # toConstr :: Integer -> Constr Source # dataTypeOf :: Integer -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Integer) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Integer) Source # gmapT :: (forall b. Data b => b -> b) -> Integer -> Integer Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Integer -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Integer -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Integer -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Integer -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Integer -> m Integer Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Integer -> m Integer Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Integer -> m Integer Source # | |
Enum Integer Source # | Since: base-2.1 |
Defined in GHC.Internal.Enum succ :: Integer -> Integer Source # pred :: Integer -> Integer Source # toEnum :: Int -> Integer Source # fromEnum :: Integer -> Int Source # enumFrom :: Integer -> [Integer] Source # enumFromThen :: Integer -> Integer -> [Integer] Source # enumFromTo :: Integer -> Integer -> [Integer] Source # enumFromThenTo :: Integer -> Integer -> Integer -> [Integer] Source # | |
Ix Integer Source # | Since: base-2.1 |
Num Integer Source # | Since: base-2.1 |
Defined in GHC.Internal.Num | |
Read Integer Source # | Since: base-2.1 |
Integral Integer Source # | Since: base-2.0.1 |
Defined in GHC.Internal.Real 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 # | |
Real Integer Source # | Since: base-2.0.1 |
Defined in GHC.Internal.Real toRational :: Integer -> Rational Source # | |
Show Integer Source # | Since: base-2.1 |
Eq Integer # | |
Ord Integer # | |
Lift Integer Source # | |
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
PrintfArg Float Source # | Since: base-2.1 | ||||
Defined in Text.Printf formatArg :: Float -> FieldFormatter Source # parseFormat :: Float -> ModifierParser Source # | |||||
Data Float Source # | Since: base-4.0.0.0 | ||||
Defined in GHC.Internal.Data.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Float -> c Float Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Float Source # toConstr :: Float -> Constr Source # dataTypeOf :: Float -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Float) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Float) Source # gmapT :: (forall b. Data b => b -> b) -> Float -> Float Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Float -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Float -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Float -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Float -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Float -> m Float Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Float -> m Float Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Float -> m Float Source # | |||||
Floating Float Source # | Since: base-2.1 | ||||
Defined in GHC.Internal.Float exp :: Float -> Float Source # log :: Float -> Float Source # sqrt :: Float -> Float Source # (**) :: Float -> Float -> Float Source # logBase :: Float -> Float -> Float Source # sin :: Float -> Float Source # cos :: Float -> Float Source # tan :: Float -> Float Source # asin :: Float -> Float Source # acos :: Float -> Float Source # atan :: Float -> Float Source # sinh :: Float -> Float Source # cosh :: Float -> Float Source # tanh :: Float -> Float Source # asinh :: Float -> Float Source # acosh :: Float -> Float Source # atanh :: Float -> Float Source # log1p :: Float -> Float Source # expm1 :: Float -> Float Source # | |||||
RealFloat Float Source # | Since: base-2.1 | ||||
Defined in GHC.Internal.Float floatRadix :: Float -> Integer Source # floatDigits :: Float -> Int Source # floatRange :: Float -> (Int, Int) Source # decodeFloat :: Float -> (Integer, Int) Source # encodeFloat :: Integer -> Int -> Float Source # exponent :: Float -> Int Source # significand :: Float -> Float Source # scaleFloat :: Int -> Float -> Float Source # isNaN :: Float -> Bool Source # isInfinite :: Float -> Bool Source # isDenormalized :: Float -> Bool Source # isNegativeZero :: Float -> Bool Source # | |||||
Storable Float Source # | Since: base-2.1 | ||||
Defined in GHC.Internal.Foreign.Storable sizeOf :: Float -> Int Source # alignment :: Float -> Int Source # peekElemOff :: Ptr Float -> Int -> IO Float Source # pokeElemOff :: Ptr Float -> Int -> Float -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Float Source # pokeByteOff :: Ptr b -> Int -> Float -> IO () Source # | |||||
Read Float Source # | Since: base-2.1 | ||||
Eq Float Source # | Note that due to the presence of
Also note that
| ||||
Ord Float Source # | See | ||||
Defined in GHC.Classes | |||||
Lift Float Source # | |||||
Generic1 (URec Float :: k -> Type) Source # | |||||
Defined in GHC.Internal.Generics
| |||||
Eq1 (UFloat :: Type -> Type) Source # | Since: base-4.21.0.0 | ||||
Ord1 (UFloat :: Type -> Type) Source # | Since: base-4.21.0.0 | ||||
Defined in Data.Functor.Classes | |||||
Show1 (UFloat :: Type -> Type) Source # | Since: base-4.21.0.0 | ||||
Foldable (UFloat :: Type -> Type) Source # | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => UFloat m -> m Source # foldMap :: Monoid m => (a -> m) -> UFloat a -> m Source # foldMap' :: Monoid m => (a -> m) -> UFloat a -> m Source # foldr :: (a -> b -> b) -> b -> UFloat a -> b Source # foldr' :: (a -> b -> b) -> b -> UFloat a -> b Source # foldl :: (b -> a -> b) -> b -> UFloat a -> b Source # foldl' :: (b -> a -> b) -> b -> UFloat a -> b Source # foldr1 :: (a -> a -> a) -> UFloat a -> a Source # foldl1 :: (a -> a -> a) -> UFloat a -> a Source # toList :: UFloat a -> [a] Source # null :: UFloat a -> Bool Source # length :: UFloat a -> Int Source # elem :: Eq a => a -> UFloat a -> Bool Source # maximum :: Ord a => UFloat a -> a Source # minimum :: Ord a => UFloat a -> a Source # | |||||
Traversable (UFloat :: Type -> Type) Source # | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Traversable | |||||
Functor (URec Float :: Type -> Type) Source # | Since: base-4.9.0.0 | ||||
Generic (URec Float p) Source # | |||||
Defined in GHC.Internal.Generics
| |||||
Show (URec Float p) Source # | |||||
Eq (URec Float p) Source # | |||||
Ord (URec Float p) Source # | |||||
Defined in GHC.Internal.Generics compare :: URec Float p -> URec Float p -> Ordering Source # (<) :: URec Float p -> URec Float p -> Bool Source # (<=) :: URec Float p -> URec Float p -> Bool Source # (>) :: URec Float p -> URec Float p -> Bool Source # (>=) :: URec Float p -> URec Float p -> Bool Source # max :: URec Float p -> URec Float p -> URec Float p Source # min :: URec Float p -> URec Float p -> URec Float p Source # | |||||
data URec Float (p :: k) Source # | Used for marking occurrences of Since: base-4.9.0.0 | ||||
type Rep1 (URec Float :: k -> Type) Source # | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Generics | |||||
type Rep (URec Float p) Source # | |||||
Defined in GHC.Internal.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
PrintfArg Double Source # | Since: base-2.1 | ||||
Defined in Text.Printf formatArg :: Double -> FieldFormatter Source # parseFormat :: Double -> ModifierParser Source # | |||||
Data Double Source # | Since: base-4.0.0.0 | ||||
Defined in GHC.Internal.Data.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Double -> c Double Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Double Source # toConstr :: Double -> Constr Source # dataTypeOf :: Double -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Double) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Double) Source # gmapT :: (forall b. Data b => b -> b) -> Double -> Double Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Double -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Double -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Double -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Double -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Double -> m Double Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Double -> m Double Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Double -> m Double Source # | |||||
Floating Double Source # | Since: base-2.1 | ||||
Defined in GHC.Internal.Float exp :: Double -> Double Source # log :: Double -> Double Source # sqrt :: Double -> Double Source # (**) :: Double -> Double -> Double Source # logBase :: Double -> Double -> Double Source # sin :: Double -> Double Source # cos :: Double -> Double Source # tan :: Double -> Double Source # asin :: Double -> Double Source # acos :: Double -> Double Source # atan :: Double -> Double Source # sinh :: Double -> Double Source # cosh :: Double -> Double Source # tanh :: Double -> Double Source # asinh :: Double -> Double Source # acosh :: Double -> Double Source # atanh :: Double -> Double Source # log1p :: Double -> Double Source # expm1 :: Double -> Double Source # | |||||
RealFloat Double Source # | Since: base-2.1 | ||||
Defined in GHC.Internal.Float floatRadix :: Double -> Integer Source # floatDigits :: Double -> Int Source # floatRange :: Double -> (Int, Int) Source # decodeFloat :: Double -> (Integer, Int) Source # encodeFloat :: Integer -> Int -> Double Source # exponent :: Double -> Int Source # significand :: Double -> Double Source # scaleFloat :: Int -> Double -> Double Source # isNaN :: Double -> Bool Source # isInfinite :: Double -> Bool Source # isDenormalized :: Double -> Bool Source # isNegativeZero :: Double -> Bool Source # | |||||
Storable Double Source # | Since: base-2.1 | ||||
Defined in GHC.Internal.Foreign.Storable sizeOf :: Double -> Int Source # alignment :: Double -> Int Source # peekElemOff :: Ptr Double -> Int -> IO Double Source # pokeElemOff :: Ptr Double -> Int -> Double -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Double Source # pokeByteOff :: Ptr b -> Int -> Double -> IO () Source # | |||||
Read Double Source # | Since: base-2.1 | ||||
Eq Double Source # | Note that due to the presence of
Also note that
| ||||
Ord Double Source # | IEEE 754 IEEE 754-2008, section 5.11 requires that if at least one of arguments of
IEEE 754-2008, section 5.10 defines Thus, users must be extremely cautious when using Moving further, the behaviour of IEEE 754-2008 compliant | ||||
Defined in GHC.Classes | |||||
Lift Double Source # | |||||
Generic1 (URec Double :: k -> Type) Source # | |||||
Defined in GHC.Internal.Generics
| |||||
Eq1 (UDouble :: Type -> Type) Source # | Since: base-4.21.0.0 | ||||
Ord1 (UDouble :: Type -> Type) Source # | Since: base-4.21.0.0 | ||||
Defined in Data.Functor.Classes | |||||
Show1 (UDouble :: Type -> Type) Source # | Since: base-4.21.0.0 | ||||
Foldable (UDouble :: Type -> Type) Source # | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => UDouble m -> m Source # foldMap :: Monoid m => (a -> m) -> UDouble a -> m Source # foldMap' :: Monoid m => (a -> m) -> UDouble a -> m Source # foldr :: (a -> b -> b) -> b -> UDouble a -> b Source # foldr' :: (a -> b -> b) -> b -> UDouble a -> b Source # foldl :: (b -> a -> b) -> b -> UDouble a -> b Source # foldl' :: (b -> a -> b) -> b -> UDouble a -> b Source # foldr1 :: (a -> a -> a) -> UDouble a -> a Source # foldl1 :: (a -> a -> a) -> UDouble a -> a Source # toList :: UDouble a -> [a] Source # null :: UDouble a -> Bool Source # length :: UDouble a -> Int Source # elem :: Eq a => a -> UDouble a -> Bool Source # maximum :: Ord a => UDouble a -> a Source # minimum :: Ord a => UDouble a -> a Source # | |||||
Traversable (UDouble :: Type -> Type) Source # | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Traversable | |||||
Functor (URec Double :: Type -> Type) Source # | Since: base-4.9.0.0 | ||||
Generic (URec Double p) Source # | |||||
Defined in GHC.Internal.Generics
| |||||
Show (URec Double p) Source # | Since: base-4.9.0.0 | ||||
Eq (URec Double p) Source # | Since: base-4.9.0.0 | ||||
Ord (URec Double p) Source # | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Generics compare :: URec Double p -> URec Double p -> Ordering Source # (<) :: URec Double p -> URec Double p -> Bool Source # (<=) :: URec Double p -> URec Double p -> Bool Source # (>) :: URec Double p -> URec Double p -> Bool Source # (>=) :: URec Double p -> URec Double p -> Bool Source # max :: URec Double p -> URec Double p -> URec Double p Source # min :: URec Double p -> URec Double p -> URec Double p Source # | |||||
data URec Double (p :: k) Source # | Used for marking occurrences of Since: base-4.9.0.0 | ||||
type Rep1 (URec Double :: k -> Type) Source # | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Generics | |||||
type Rep (URec Double p) Source # | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Generics |
Instances
PrintfArg Word Source # | Since: base-2.1 | ||||
Defined in Text.Printf formatArg :: Word -> FieldFormatter Source # parseFormat :: Word -> ModifierParser Source # | |||||
Bits Word Source # | Since: base-2.1 | ||||
Defined in GHC.Internal.Bits (.&.) :: Word -> Word -> Word Source # (.|.) :: Word -> Word -> Word Source # xor :: Word -> Word -> Word Source # complement :: Word -> Word Source # shift :: Word -> Int -> Word Source # rotate :: Word -> Int -> Word Source # setBit :: Word -> Int -> Word Source # clearBit :: Word -> Int -> Word Source # complementBit :: Word -> Int -> Word Source # testBit :: Word -> Int -> Bool Source # bitSizeMaybe :: Word -> Maybe Int Source # bitSize :: Word -> Int Source # isSigned :: Word -> Bool Source # shiftL :: Word -> Int -> Word Source # unsafeShiftL :: Word -> Int -> Word Source # shiftR :: Word -> Int -> Word Source # unsafeShiftR :: Word -> Int -> Word Source # rotateL :: Word -> Int -> Word Source # | |||||
FiniteBits Word Source # | Since: base-4.6.0.0 | ||||
Defined in GHC.Internal.Bits finiteBitSize :: Word -> Int Source # countLeadingZeros :: Word -> Int Source # countTrailingZeros :: Word -> Int Source # | |||||
Data Word Source # | Since: base-4.0.0.0 | ||||
Defined in GHC.Internal.Data.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Word -> c Word Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Word Source # toConstr :: Word -> Constr Source # dataTypeOf :: Word -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Word) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Word) Source # gmapT :: (forall b. Data b => b -> b) -> Word -> Word Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Word -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Word -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Word -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Word -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Word -> m Word Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Word -> m Word Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Word -> m Word Source # | |||||
Bounded Word Source # | Since: base-2.1 | ||||
Enum Word Source # | Since: base-2.1 | ||||
Storable Word Source # | Since: base-2.1 | ||||
Defined in GHC.Internal.Foreign.Storable sizeOf :: Word -> Int Source # alignment :: Word -> Int Source # peekElemOff :: Ptr Word -> Int -> IO Word Source # pokeElemOff :: Ptr Word -> Int -> Word -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Word Source # pokeByteOff :: Ptr b -> Int -> Word -> IO () Source # | |||||
Ix Word Source # | Since: base-4.6.0.0 | ||||
Num Word Source # | Since: base-2.1 | ||||
Read Word Source # | Since: base-4.5.0.0 | ||||
Integral Word Source # | Since: base-2.1 | ||||
Defined in GHC.Internal.Real | |||||
Real Word Source # | Since: base-2.1 | ||||
Defined in GHC.Internal.Real toRational :: Word -> Rational Source # | |||||
Show Word Source # | Since: base-2.1 | ||||
Eq Word Source # | |||||
Ord Word Source # | |||||
Lift Word Source # | |||||
Generic1 (URec Word :: k -> Type) Source # | |||||
Defined in GHC.Internal.Generics
| |||||
Eq1 (UWord :: Type -> Type) Source # | Since: base-4.21.0.0 | ||||
Ord1 (UWord :: Type -> Type) Source # | Since: base-4.21.0.0 | ||||
Defined in Data.Functor.Classes | |||||
Show1 (UWord :: Type -> Type) Source # | Since: base-4.21.0.0 | ||||
Foldable (UWord :: Type -> Type) Source # | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => UWord m -> m Source # foldMap :: Monoid m => (a -> m) -> UWord a -> m Source # foldMap' :: Monoid m => (a -> m) -> UWord a -> m Source # foldr :: (a -> b -> b) -> b -> UWord a -> b Source # foldr' :: (a -> b -> b) -> b -> UWord a -> b Source # foldl :: (b -> a -> b) -> b -> UWord a -> b Source # foldl' :: (b -> a -> b) -> b -> UWord a -> b Source # foldr1 :: (a -> a -> a) -> UWord a -> a Source # foldl1 :: (a -> a -> a) -> UWord a -> a Source # toList :: UWord a -> [a] Source # null :: UWord a -> Bool Source # length :: UWord a -> Int Source # elem :: Eq a => a -> UWord a -> Bool Source # maximum :: Ord a => UWord a -> a Source # minimum :: Ord a => UWord a -> a Source # | |||||
Traversable (UWord :: Type -> Type) Source # | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Traversable | |||||
Functor (URec Word :: Type -> Type) Source # | Since: base-4.9.0.0 | ||||
Generic (URec Word p) Source # | |||||
Defined in GHC.Internal.Generics
| |||||
Show (URec Word p) Source # | Since: base-4.9.0.0 | ||||
Eq (URec Word p) Source # | Since: base-4.9.0.0 | ||||
Ord (URec Word p) Source # | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Generics compare :: URec Word p -> URec Word p -> Ordering Source # (<) :: URec Word p -> URec Word p -> Bool Source # (<=) :: URec Word p -> URec Word p -> Bool Source # (>) :: URec Word p -> URec Word p -> Bool Source # (>=) :: URec Word p -> URec Word p -> Bool Source # | |||||
data URec Word (p :: k) Source # | Used for marking occurrences of Since: base-4.9.0.0 | ||||
type Rep1 (URec Word :: k -> Type) Source # | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Generics | |||||
type Rep (URec Word p) Source # | Since: base-4.9.0.0 | ||||
Defined in GHC.Internal.Generics |
GHC.Internal.Numeric type classes
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 + x
is the additive identityfromInteger
0x + fromInteger 0
=x
negate
gives the additive inversex + negate x
=fromInteger 0
- Associativity of
(
*
) (x * y) * z
=x * (y * z)
is the multiplicative identityfromInteger
1x * fromInteger 1
=x
andfromInteger 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
, thenfromInteger
is 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.
(+) :: a -> a -> a infixl 6 Source #
(-) :: a -> a -> a infixl 6 Source #
(*) :: a -> a -> a infixl 7 Source #
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 Source #
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 Unique Source # | Since: base-4.4.0.0 |
Defined in GHC.Internal.Event.Unique | |
Num CBool Source # | |
Num CChar Source # | |
Num CClock Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Num CDouble Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Num CFloat Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Num CInt Source # | |
Num CIntMax Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Num CIntPtr Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Num CLLong Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Num CLong Source # | |
Num CPtrdiff Source # | |
Defined in GHC.Internal.Foreign.C.Types (+) :: CPtrdiff -> CPtrdiff -> CPtrdiff Source # (-) :: CPtrdiff -> CPtrdiff -> CPtrdiff Source # (*) :: CPtrdiff -> CPtrdiff -> CPtrdiff Source # negate :: CPtrdiff -> CPtrdiff Source # abs :: CPtrdiff -> CPtrdiff Source # signum :: CPtrdiff -> CPtrdiff Source # fromInteger :: Integer -> CPtrdiff Source # | |
Num CSChar Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Num CSUSeconds Source # | |
Defined in GHC.Internal.Foreign.C.Types (+) :: CSUSeconds -> CSUSeconds -> CSUSeconds Source # (-) :: CSUSeconds -> CSUSeconds -> CSUSeconds Source # (*) :: CSUSeconds -> CSUSeconds -> CSUSeconds Source # negate :: CSUSeconds -> CSUSeconds Source # abs :: CSUSeconds -> CSUSeconds Source # signum :: CSUSeconds -> CSUSeconds Source # fromInteger :: Integer -> CSUSeconds Source # | |
Num CShort Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Num CSigAtomic Source # | |
Defined in GHC.Internal.Foreign.C.Types (+) :: CSigAtomic -> CSigAtomic -> CSigAtomic Source # (-) :: CSigAtomic -> CSigAtomic -> CSigAtomic Source # (*) :: CSigAtomic -> CSigAtomic -> CSigAtomic Source # negate :: CSigAtomic -> CSigAtomic Source # abs :: CSigAtomic -> CSigAtomic Source # signum :: CSigAtomic -> CSigAtomic Source # fromInteger :: Integer -> CSigAtomic Source # | |
Num CSize Source # | |
Num CTime Source # | |
Num CUChar Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Num CUInt Source # | |
Num CUIntMax Source # | |
Defined in GHC.Internal.Foreign.C.Types (+) :: CUIntMax -> CUIntMax -> CUIntMax Source # (-) :: CUIntMax -> CUIntMax -> CUIntMax Source # (*) :: CUIntMax -> CUIntMax -> CUIntMax Source # negate :: CUIntMax -> CUIntMax Source # abs :: CUIntMax -> CUIntMax Source # signum :: CUIntMax -> CUIntMax Source # fromInteger :: Integer -> CUIntMax Source # | |
Num CUIntPtr Source # | |
Defined in GHC.Internal.Foreign.C.Types (+) :: CUIntPtr -> CUIntPtr -> CUIntPtr Source # (-) :: CUIntPtr -> CUIntPtr -> CUIntPtr Source # (*) :: CUIntPtr -> CUIntPtr -> CUIntPtr Source # negate :: CUIntPtr -> CUIntPtr Source # abs :: CUIntPtr -> CUIntPtr Source # signum :: CUIntPtr -> CUIntPtr Source # fromInteger :: Integer -> CUIntPtr Source # | |
Num CULLong Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Num CULong Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Num CUSeconds Source # | |
Defined in GHC.Internal.Foreign.C.Types (+) :: CUSeconds -> CUSeconds -> CUSeconds Source # (-) :: CUSeconds -> CUSeconds -> CUSeconds Source # (*) :: CUSeconds -> CUSeconds -> CUSeconds Source # negate :: CUSeconds -> CUSeconds Source # abs :: CUSeconds -> CUSeconds Source # signum :: CUSeconds -> CUSeconds Source # fromInteger :: Integer -> CUSeconds Source # | |
Num CUShort Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Num CWchar Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Num IntPtr Source # | |
Defined in GHC.Internal.Foreign.Ptr | |
Num WordPtr Source # | |
Defined in GHC.Internal.Foreign.Ptr | |
Num Int16 Source # | Since: base-2.1 |
Num Int32 Source # | Since: base-2.1 |
Num Int64 Source # | Since: base-2.1 |
Num Int8 Source # | Since: base-2.1 |
Num CBlkCnt Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Num CBlkSize Source # | |
Defined in GHC.Internal.System.Posix.Types (+) :: CBlkSize -> CBlkSize -> CBlkSize Source # (-) :: CBlkSize -> CBlkSize -> CBlkSize Source # (*) :: CBlkSize -> CBlkSize -> CBlkSize Source # negate :: CBlkSize -> CBlkSize Source # abs :: CBlkSize -> CBlkSize Source # signum :: CBlkSize -> CBlkSize Source # fromInteger :: Integer -> CBlkSize Source # | |
Num CCc Source # | |
Num CClockId Source # | |
Defined in GHC.Internal.System.Posix.Types (+) :: CClockId -> CClockId -> CClockId Source # (-) :: CClockId -> CClockId -> CClockId Source # (*) :: CClockId -> CClockId -> CClockId Source # negate :: CClockId -> CClockId Source # abs :: CClockId -> CClockId Source # signum :: CClockId -> CClockId Source # fromInteger :: Integer -> CClockId Source # | |
Num CDev Source # | |
Num CFsBlkCnt Source # | |
Defined in GHC.Internal.System.Posix.Types (+) :: CFsBlkCnt -> CFsBlkCnt -> CFsBlkCnt Source # (-) :: CFsBlkCnt -> CFsBlkCnt -> CFsBlkCnt Source # (*) :: CFsBlkCnt -> CFsBlkCnt -> CFsBlkCnt Source # negate :: CFsBlkCnt -> CFsBlkCnt Source # abs :: CFsBlkCnt -> CFsBlkCnt Source # signum :: CFsBlkCnt -> CFsBlkCnt Source # fromInteger :: Integer -> CFsBlkCnt Source # | |
Num CFsFilCnt Source # | |
Defined in GHC.Internal.System.Posix.Types (+) :: CFsFilCnt -> CFsFilCnt -> CFsFilCnt Source # (-) :: CFsFilCnt -> CFsFilCnt -> CFsFilCnt Source # (*) :: CFsFilCnt -> CFsFilCnt -> CFsFilCnt Source # negate :: CFsFilCnt -> CFsFilCnt Source # abs :: CFsFilCnt -> CFsFilCnt Source # signum :: CFsFilCnt -> CFsFilCnt Source # fromInteger :: Integer -> CFsFilCnt Source # | |
Num CGid Source # | |
Num CId Source # | |
Num CIno Source # | |
Num CKey Source # | |
Num CMode Source # | |
Num CNfds Source # | |
Num CNlink Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Num COff Source # | |
Num CPid Source # | |
Num CRLim Source # | |
Num CSocklen Source # | |
Defined in GHC.Internal.System.Posix.Types (+) :: CSocklen -> CSocklen -> CSocklen Source # (-) :: CSocklen -> CSocklen -> CSocklen Source # (*) :: CSocklen -> CSocklen -> CSocklen Source # negate :: CSocklen -> CSocklen Source # abs :: CSocklen -> CSocklen Source # signum :: CSocklen -> CSocklen Source # fromInteger :: Integer -> CSocklen Source # | |
Num CSpeed Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Num CSsize Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Num CTcflag Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Num CUid Source # | |
Num Fd Source # | |
Num Word16 Source # | Since: base-2.1 |
Num Word32 Source # | Since: base-2.1 |
Num Word64 Source # | Since: base-2.1 |
Num Word8 Source # | Since: base-2.1 |
Num Integer Source # | Since: base-2.1 |
Defined in GHC.Internal.Num | |
Num Natural Source # | Note that Since: base-4.8.0.0 |
Defined in GHC.Internal.Num | |
Num Int Source # | Since: base-2.1 |
Num Word Source # | Since: base-2.1 |
RealFloat a => Num (Complex a) Source # | Since: base-2.1 |
Defined in Data.Complex (+) :: Complex a -> Complex a -> Complex a Source # (-) :: Complex a -> Complex a -> Complex a Source # (*) :: Complex a -> Complex a -> Complex a Source # negate :: Complex a -> Complex a Source # abs :: Complex a -> Complex a Source # signum :: Complex a -> Complex a Source # fromInteger :: Integer -> Complex a Source # | |
Num a => Num (Max a) Source # | Since: base-4.9.0.0 |
Num a => Num (Min a) Source # | Since: base-4.9.0.0 |
Num a => Num (Identity a) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Identity (+) :: Identity a -> Identity a -> Identity a Source # (-) :: Identity a -> Identity a -> Identity a Source # (*) :: Identity a -> Identity a -> Identity a Source # negate :: Identity a -> Identity a Source # abs :: Identity a -> Identity a Source # signum :: Identity a -> Identity a Source # fromInteger :: Integer -> Identity a Source # | |
Num a => Num (Down a) Source # | Since: base-4.11.0.0 |
Defined in GHC.Internal.Data.Ord | |
Num a => Num (Product a) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Data.Semigroup.Internal (+) :: Product a -> Product a -> Product a Source # (-) :: Product a -> Product a -> Product a Source # (*) :: Product a -> Product a -> Product a Source # negate :: Product a -> Product a Source # abs :: Product a -> Product a Source # signum :: Product a -> Product a Source # fromInteger :: Integer -> Product a Source # | |
Num a => Num (Sum a) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Data.Semigroup.Internal | |
Integral a => Num (Ratio a) Source # | Since: base-2.0.1 |
Defined in GHC.Internal.Real | |
HasResolution a => Num (Fixed a) Source # | Multiplication is not associative or distributive:
Since: base-2.1 |
Defined in Data.Fixed | |
Num a => Num (Op a b) Source # | |
Defined in Data.Functor.Contravariant | |
Num a => Num (Const a b) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Const (+) :: Const a b -> Const a b -> Const a b Source # (-) :: Const a b -> Const a b -> Const a b Source # (*) :: Const a b -> Const a b -> Const a b Source # negate :: Const a b -> Const a b Source # abs :: Const a b -> Const a b Source # signum :: Const a b -> Const a b Source # fromInteger :: Integer -> Const a b Source # | |
(Applicative f, Num a) => Num (Ap f a) Source # | Note that even if the underlying Commutativity:
Additive inverse:
Distributivity:
Since: base-4.12.0.0 |
Defined in GHC.Internal.Data.Monoid | |
Num (f a) => Num (Alt f a) Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.Data.Semigroup.Internal | |
Num (f (g a)) => Num (Compose f g a) Source # | Since: base-4.19.0.0 |
Defined in Data.Functor.Compose (+) :: Compose f g a -> Compose f g a -> Compose f g a Source # (-) :: Compose f g a -> Compose f g a -> Compose f g a Source # (*) :: Compose f g a -> Compose f g a -> Compose f g a Source # negate :: Compose f g a -> Compose f g a Source # abs :: Compose f g a -> Compose f g a Source # signum :: Compose f g a -> Compose f g a Source # fromInteger :: Integer -> Compose f g a Source # |
class (Num a, Ord a) => Real a where Source #
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
, thenfromRational
is a left inverse fortoRational
, i.e.fromRational (toRational i) = i
The law does not hold for Float
, Double
, CFloat
,
CDouble
, etc., because these types contain non-finite values,
which cannot be roundtripped through Rational
.
toRational :: a -> Rational Source #
Rational equivalent of its real argument with full precision.
Instances
Real CBool Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CBool -> Rational Source # | |
Real CChar Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CChar -> Rational Source # | |
Real CClock Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CClock -> Rational Source # | |
Real CDouble Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CDouble -> Rational Source # | |
Real CFloat Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CFloat -> Rational Source # | |
Real CInt Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CInt -> Rational Source # | |
Real CIntMax Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CIntMax -> Rational Source # | |
Real CIntPtr Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CIntPtr -> Rational Source # | |
Real CLLong Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CLLong -> Rational Source # | |
Real CLong Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CLong -> Rational Source # | |
Real CPtrdiff Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CPtrdiff -> Rational Source # | |
Real CSChar Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CSChar -> Rational Source # | |
Real CSUSeconds Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CSUSeconds -> Rational Source # | |
Real CShort Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CShort -> Rational Source # | |
Real CSigAtomic Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CSigAtomic -> Rational Source # | |
Real CSize Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CSize -> Rational Source # | |
Real CTime Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CTime -> Rational Source # | |
Real CUChar Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CUChar -> Rational Source # | |
Real CUInt Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CUInt -> Rational Source # | |
Real CUIntMax Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CUIntMax -> Rational Source # | |
Real CUIntPtr Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CUIntPtr -> Rational Source # | |
Real CULLong Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CULLong -> Rational Source # | |
Real CULong Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CULong -> Rational Source # | |
Real CUSeconds Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CUSeconds -> Rational Source # | |
Real CUShort Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CUShort -> Rational Source # | |
Real CWchar Source # | |
Defined in GHC.Internal.Foreign.C.Types toRational :: CWchar -> Rational Source # | |
Real IntPtr Source # | |
Defined in GHC.Internal.Foreign.Ptr toRational :: IntPtr -> Rational Source # | |
Real WordPtr Source # | |
Defined in GHC.Internal.Foreign.Ptr toRational :: WordPtr -> Rational Source # | |
Real Int16 Source # | Since: base-2.1 |
Defined in GHC.Internal.Int toRational :: Int16 -> Rational Source # | |
Real Int32 Source # | Since: base-2.1 |
Defined in GHC.Internal.Int toRational :: Int32 -> Rational Source # | |
Real Int64 Source # | Since: base-2.1 |
Defined in GHC.Internal.Int toRational :: Int64 -> Rational Source # | |
Real Int8 Source # | Since: base-2.1 |
Defined in GHC.Internal.Int toRational :: Int8 -> Rational Source # | |
Real CBlkCnt Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: CBlkCnt -> Rational Source # | |
Real CBlkSize Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: CBlkSize -> Rational Source # | |
Real CCc Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: CCc -> Rational Source # | |
Real CClockId Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: CClockId -> Rational Source # | |
Real CDev Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: CDev -> Rational Source # | |
Real CFsBlkCnt Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: CFsBlkCnt -> Rational Source # | |
Real CFsFilCnt Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: CFsFilCnt -> Rational Source # | |
Real CGid Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: CGid -> Rational Source # | |
Real CId Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: CId -> Rational Source # | |
Real CIno Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: CIno -> Rational Source # | |
Real CKey Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: CKey -> Rational Source # | |
Real CMode Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: CMode -> Rational Source # | |
Real CNfds Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: CNfds -> Rational Source # | |
Real CNlink Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: CNlink -> Rational Source # | |
Real COff Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: COff -> Rational Source # | |
Real CPid Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: CPid -> Rational Source # | |
Real CRLim Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: CRLim -> Rational Source # | |
Real CSocklen Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: CSocklen -> Rational Source # | |
Real CSpeed Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: CSpeed -> Rational Source # | |
Real CSsize Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: CSsize -> Rational Source # | |
Real CTcflag Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: CTcflag -> Rational Source # | |
Real CUid Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: CUid -> Rational Source # | |
Real Fd Source # | |
Defined in GHC.Internal.System.Posix.Types toRational :: Fd -> Rational Source # | |
Real Word16 Source # | Since: base-2.1 |
Defined in GHC.Internal.Word toRational :: Word16 -> Rational Source # | |
Real Word32 Source # | Since: base-2.1 |
Defined in GHC.Internal.Word toRational :: Word32 -> Rational Source # | |
Real Word64 Source # | Since: base-2.1 |
Defined in GHC.Internal.Word toRational :: Word64 -> Rational Source # | |
Real Word8 Source # | Since: base-2.1 |
Defined in GHC.Internal.Word toRational :: Word8 -> Rational Source # | |
Real Integer Source # | Since: base-2.0.1 |
Defined in GHC.Internal.Real toRational :: Integer -> Rational Source # | |
Real Natural Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.Real toRational :: Natural -> Rational Source # | |
Real Int Source # | Since: base-2.0.1 |
Defined in GHC.Internal.Real toRational :: Int -> Rational Source # | |
Real Word Source # | Since: base-2.1 |
Defined in GHC.Internal.Real toRational :: Word -> Rational Source # | |
Real a => Real (Identity a) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Identity toRational :: Identity a -> Rational Source # | |
Real a => Real (Down a) Source # | Since: base-4.14.0.0 |
Defined in GHC.Internal.Data.Ord toRational :: Down a -> Rational Source # | |
Integral a => Real (Ratio a) Source # | Since: base-2.0.1 |
Defined in GHC.Internal.Real toRational :: Ratio a -> Rational Source # | |
HasResolution a => Real (Fixed a) Source # | Since: base-2.1 |
Defined in Data.Fixed toRational :: Fixed a -> Rational Source # | |
Real a => Real (Const a b) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Const toRational :: Const a b -> Rational Source # | |
Real (f (g a)) => Real (Compose f g a) Source # | Since: base-4.19.0.0 |
Defined in Data.Functor.Compose toRational :: Compose f g a -> 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
withrem x y
=fromInteger 0
org (rem x y)
<g y
x
=y * div x y + mod x y
withmod x y
=fromInteger 0
orf (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
.
quot :: a -> a -> a infixl 7 Source #
Integer division truncated toward zero.
WARNING: This function is partial (because it throws when 0 is passed as
the divisor) for all the integer types in base
.
rem :: a -> a -> a infixl 7 Source #
Integer remainder, satisfying
(x `quot` y)*y + (x `rem` y) == x
WARNING: This function is partial (because it throws when 0 is passed as
the divisor) for all the integer types in base
.
div :: a -> a -> a infixl 7 Source #
Integer division truncated toward negative infinity.
WARNING: This function is partial (because it throws when 0 is passed as
the divisor) for all the integer types in base
.
mod :: a -> a -> a infixl 7 Source #
Integer modulus, satisfying
(x `div` y)*y + (x `mod` y) == x
WARNING: This function is partial (because it throws when 0 is passed as
the divisor) for all the integer types in base
.
quotRem :: a -> a -> (a, a) Source #
WARNING: This function is partial (because it throws when 0 is passed as
the divisor) for all the integer types in base
.
divMod :: a -> a -> (a, a) Source #
WARNING: This function is partial (because it throws when 0 is passed as
the divisor) for all the integer types in base
.
toInteger :: a -> Integer Source #
Conversion to Integer
.
Instances
Integral CBool Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Integral CChar Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Integral CInt Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Integral CIntMax Source # | |
Defined in GHC.Internal.Foreign.C.Types 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 # | |
Integral CIntPtr Source # | |
Defined in GHC.Internal.Foreign.C.Types 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 # | |
Integral CLLong Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Integral CLong Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Integral CPtrdiff Source # | |
Defined in GHC.Internal.Foreign.C.Types 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 # | |
Integral CSChar Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Integral CShort Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Integral CSigAtomic Source # | |
Defined in GHC.Internal.Foreign.C.Types 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 CSize Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Integral CUChar Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Integral CUInt Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Integral CUIntMax Source # | |
Defined in GHC.Internal.Foreign.C.Types 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 # | |
Integral CUIntPtr Source # | |
Defined in GHC.Internal.Foreign.C.Types 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 # | |
Integral CULLong Source # | |
Defined in GHC.Internal.Foreign.C.Types 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 # | |
Integral CULong Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Integral CUShort Source # | |
Defined in GHC.Internal.Foreign.C.Types 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 # | |
Integral CWchar Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Integral IntPtr Source # | |
Defined in GHC.Internal.Foreign.Ptr | |
Integral WordPtr Source # | |
Defined in GHC.Internal.Foreign.Ptr 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 # | |
Integral Int16 Source # | Since: base-2.1 |
Defined in GHC.Internal.Int | |
Integral Int32 Source # | Since: base-2.1 |
Defined in GHC.Internal.Int | |
Integral Int64 Source # | Since: base-2.1 |
Defined in GHC.Internal.Int | |
Integral Int8 Source # | Since: base-2.1 |
Defined in GHC.Internal.Int | |
Integral CBlkCnt Source # | |
Defined in GHC.Internal.System.Posix.Types 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 # | |
Integral CBlkSize Source # | |
Defined in GHC.Internal.System.Posix.Types 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 # | |
Integral CClockId Source # | |
Defined in GHC.Internal.System.Posix.Types 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 # | |
Integral CDev Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Integral CFsBlkCnt Source # | |
Defined in GHC.Internal.System.Posix.Types 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 # | |
Integral CFsFilCnt Source # | |
Defined in GHC.Internal.System.Posix.Types 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 # | |
Integral CGid Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Integral CId Source # | |
Integral CIno Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Integral CKey Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Integral CMode Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Integral CNfds Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Integral CNlink Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Integral COff Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Integral CPid Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Integral CRLim Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Integral CSocklen Source # | |
Defined in GHC.Internal.System.Posix.Types quot :: CSocklen -> CSocklen -> CSocklen Source # rem :: CSocklen -> CSocklen -> CSocklen Source # div :: CSocklen -> CSocklen -> CSocklen Source # mod :: CSocklen -> CSocklen -> CSocklen Source # quotRem :: CSocklen -> CSocklen -> (CSocklen, CSocklen) Source # divMod :: CSocklen -> CSocklen -> (CSocklen, CSocklen) Source # | |
Integral CSsize Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Integral CTcflag Source # | |
Defined in GHC.Internal.System.Posix.Types 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 # | |
Integral CUid Source # | |
Defined in GHC.Internal.System.Posix.Types | |
Integral Fd Source # | |
Integral Word16 Source # | Since: base-2.1 |
Defined in GHC.Internal.Word | |
Integral Word32 Source # | Since: base-2.1 |
Defined in GHC.Internal.Word | |
Integral Word64 Source # | Since: base-2.1 |
Defined in GHC.Internal.Word | |
Integral Word8 Source # | Since: base-2.1 |
Defined in GHC.Internal.Word | |
Integral Integer Source # | Since: base-2.0.1 |
Defined in GHC.Internal.Real 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 # | |
Integral Natural Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.Real 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 # | |
Integral Int Source # | Since: base-2.0.1 |
Integral Word Source # | Since: base-2.1 |
Defined in GHC.Internal.Real | |
Integral a => Integral (Identity a) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Identity 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 # | |
Integral a => Integral (Const a b) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Const 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 # | |
Integral (f (g a)) => Integral (Compose f g a) Source # | Since: base-4.19.0.0 |
Defined in Data.Functor.Compose quot :: Compose f g a -> Compose f g a -> Compose f g a Source # rem :: Compose f g a -> Compose f g a -> Compose f g a Source # div :: Compose f g a -> Compose f g a -> Compose f g a Source # mod :: Compose f g a -> Compose f g a -> Compose f g a Source # quotRem :: Compose f g a -> Compose f g a -> (Compose f g a, Compose f g a) Source # divMod :: Compose f g a -> Compose f g a -> (Compose f g a, Compose f g a) 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 inversex * recip x
=recip x * x
=fromInteger 1
- Totality of
toRational
toRational
is total- Coherence with
toRational
- if the type also implements
Real
, thenfromRational
is 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.
fromRational, (recip | (/))
(/) :: a -> a -> a infixl 7 Source #
Fractional division.
Reciprocal fraction.
fromRational :: Rational -> a Source #
Conversion from a Rational
(that is
).
A floating literal stands for an application of Ratio
Integer
fromRational
to a value of type Rational
, so such literals have type
(
.Fractional
a) => a
Instances
Fractional CDouble Source # | |
Fractional CFloat Source # | |
RealFloat a => Fractional (Complex a) Source # | Since: base-2.1 |
Fractional a => Fractional (Identity a) Source # | Since: base-4.9.0.0 |
Fractional a => Fractional (Down a) Source # | Since: base-4.14.0.0 |
Integral a => Fractional (Ratio a) Source # | Since: base-2.0.1 |
HasResolution a => Fractional (Fixed a) Source # | Since: base-2.1 |
Fractional a => Fractional (Op a b) Source # | |
Fractional a => Fractional (Const a b) Source # | Since: base-4.9.0.0 |
Fractional (f (g a)) => Fractional (Compose f g a) Source # | Since: base-4.20.0.0 |
class Fractional a => Floating a where Source #
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 b
exp (fromInteger 0)
=fromInteger 1
Instances
Floating CDouble Source # | |
Defined in GHC.Internal.Foreign.C.Types exp :: CDouble -> CDouble Source # log :: CDouble -> CDouble Source # sqrt :: CDouble -> CDouble Source # (**) :: CDouble -> CDouble -> CDouble Source # logBase :: CDouble -> CDouble -> CDouble Source # sin :: CDouble -> CDouble Source # cos :: CDouble -> CDouble Source # tan :: CDouble -> CDouble Source # asin :: CDouble -> CDouble Source # acos :: CDouble -> CDouble Source # atan :: CDouble -> CDouble Source # sinh :: CDouble -> CDouble Source # cosh :: CDouble -> CDouble Source # tanh :: CDouble -> CDouble Source # asinh :: CDouble -> CDouble Source # acosh :: CDouble -> CDouble Source # atanh :: CDouble -> CDouble Source # log1p :: CDouble -> CDouble Source # expm1 :: CDouble -> CDouble Source # | |
Floating CFloat Source # | |
Defined in GHC.Internal.Foreign.C.Types exp :: CFloat -> CFloat Source # log :: CFloat -> CFloat Source # sqrt :: CFloat -> CFloat Source # (**) :: CFloat -> CFloat -> CFloat Source # logBase :: CFloat -> CFloat -> CFloat Source # sin :: CFloat -> CFloat Source # cos :: CFloat -> CFloat Source # tan :: CFloat -> CFloat Source # asin :: CFloat -> CFloat Source # acos :: CFloat -> CFloat Source # atan :: CFloat -> CFloat Source # sinh :: CFloat -> CFloat Source # cosh :: CFloat -> CFloat Source # tanh :: CFloat -> CFloat Source # asinh :: CFloat -> CFloat Source # acosh :: CFloat -> CFloat Source # atanh :: CFloat -> CFloat Source # log1p :: CFloat -> CFloat Source # expm1 :: CFloat -> CFloat Source # | |
Floating Double Source # | Since: base-2.1 |
Defined in GHC.Internal.Float exp :: Double -> Double Source # log :: Double -> Double Source # sqrt :: Double -> Double Source # (**) :: Double -> Double -> Double Source # logBase :: Double -> Double -> Double Source # sin :: Double -> Double Source # cos :: Double -> Double Source # tan :: Double -> Double Source # asin :: Double -> Double Source # acos :: Double -> Double Source # atan :: Double -> Double Source # sinh :: Double -> Double Source # cosh :: Double -> Double Source # tanh :: Double -> Double Source # asinh :: Double -> Double Source # acosh :: Double -> Double Source # atanh :: Double -> Double Source # log1p :: Double -> Double Source # expm1 :: Double -> Double Source # | |
Floating Float Source # | Since: base-2.1 |
Defined in GHC.Internal.Float exp :: Float -> Float Source # log :: Float -> Float Source # sqrt :: Float -> Float Source # (**) :: Float -> Float -> Float Source # logBase :: Float -> Float -> Float Source # sin :: Float -> Float Source # cos :: Float -> Float Source # tan :: Float -> Float Source # asin :: Float -> Float Source # acos :: Float -> Float Source # atan :: Float -> Float Source # sinh :: Float -> Float Source # cosh :: Float -> Float Source # tanh :: Float -> Float Source # asinh :: Float -> Float Source # acosh :: Float -> Float Source # atanh :: Float -> Float Source # log1p :: Float -> Float Source # expm1 :: Float -> Float Source # | |
RealFloat a => Floating (Complex a) Source # | Since: base-2.1 |
Defined in Data.Complex exp :: Complex a -> Complex a Source # log :: Complex a -> Complex a Source # sqrt :: Complex a -> Complex a Source # (**) :: Complex a -> Complex a -> Complex a Source # logBase :: Complex a -> Complex a -> Complex a Source # sin :: Complex a -> Complex a Source # cos :: Complex a -> Complex a Source # tan :: Complex a -> Complex a Source # asin :: Complex a -> Complex a Source # acos :: Complex a -> Complex a Source # atan :: Complex a -> Complex a Source # sinh :: Complex a -> Complex a Source # cosh :: Complex a -> Complex a Source # tanh :: Complex a -> Complex a Source # asinh :: Complex a -> Complex a Source # acosh :: Complex a -> Complex a Source # atanh :: Complex a -> Complex a Source # log1p :: Complex a -> Complex a Source # expm1 :: Complex a -> Complex a Source # | |
Floating a => Floating (Identity a) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Identity exp :: Identity a -> Identity a Source # log :: Identity a -> Identity a Source # sqrt :: Identity a -> Identity a Source # (**) :: Identity a -> Identity a -> Identity a Source # logBase :: Identity a -> Identity a -> Identity a Source # sin :: Identity a -> Identity a Source # cos :: Identity a -> Identity a Source # tan :: Identity a -> Identity a Source # asin :: Identity a -> Identity a Source # acos :: Identity a -> Identity a Source # atan :: Identity a -> Identity a Source # sinh :: Identity a -> Identity a Source # cosh :: Identity a -> Identity a Source # tanh :: Identity a -> Identity a Source # asinh :: Identity a -> Identity a Source # acosh :: Identity a -> Identity a Source # atanh :: Identity a -> Identity a Source # log1p :: Identity a -> Identity a Source # expm1 :: Identity a -> Identity a Source # | |
Floating a => Floating (Down a) Source # | Since: base-4.14.0.0 |
Defined in GHC.Internal.Data.Ord exp :: Down a -> Down a Source # log :: Down a -> Down a Source # sqrt :: Down a -> Down a Source # (**) :: Down a -> Down a -> Down a Source # logBase :: Down a -> Down a -> Down a Source # sin :: Down a -> Down a Source # cos :: Down a -> Down a Source # tan :: Down a -> Down a Source # asin :: Down a -> Down a Source # acos :: Down a -> Down a Source # atan :: Down a -> Down a Source # sinh :: Down a -> Down a Source # cosh :: Down a -> Down a Source # tanh :: Down a -> Down a Source # asinh :: Down a -> Down a Source # acosh :: Down a -> Down a Source # atanh :: Down a -> Down a Source # log1p :: Down a -> Down a Source # expm1 :: Down a -> Down a Source # | |
Floating a => Floating (Op a b) Source # | |
Defined in Data.Functor.Contravariant exp :: Op a b -> Op a b Source # log :: Op a b -> Op a b Source # sqrt :: Op a b -> Op a b Source # (**) :: Op a b -> Op a b -> Op a b Source # logBase :: Op a b -> Op a b -> Op a b Source # sin :: Op a b -> Op a b Source # cos :: Op a b -> Op a b Source # tan :: Op a b -> Op a b Source # asin :: Op a b -> Op a b Source # acos :: Op a b -> Op a b Source # atan :: Op a b -> Op a b Source # sinh :: Op a b -> Op a b Source # cosh :: Op a b -> Op a b Source # tanh :: Op a b -> Op a b Source # asinh :: Op a b -> Op a b Source # acosh :: Op a b -> Op a b Source # atanh :: Op a b -> Op a b Source # log1p :: Op a b -> Op a b Source # expm1 :: Op a b -> Op a b Source # | |
Floating a => Floating (Const a b) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Const exp :: Const a b -> Const a b Source # log :: Const a b -> Const a b Source # sqrt :: Const a b -> Const a b Source # (**) :: Const a b -> Const a b -> Const a b Source # logBase :: Const a b -> Const a b -> Const a b Source # sin :: Const a b -> Const a b Source # cos :: Const a b -> Const a b Source # tan :: Const a b -> Const a b Source # asin :: Const a b -> Const a b Source # acos :: Const a b -> Const a b Source # atan :: Const a b -> Const a b Source # sinh :: Const a b -> Const a b Source # cosh :: Const a b -> Const a b Source # tanh :: Const a b -> Const a b Source # asinh :: Const a b -> Const a b Source # acosh :: Const a b -> Const a b Source # atanh :: Const a b -> Const a b Source # log1p :: Const a b -> Const a b Source # expm1 :: Const a b -> Const a b Source # | |
Floating (f (g a)) => Floating (Compose f g a) Source # | Since: base-4.20.0.0 |
Defined in Data.Functor.Compose exp :: Compose f g a -> Compose f g a Source # log :: Compose f g a -> Compose f g a Source # sqrt :: Compose f g a -> Compose f g a Source # (**) :: Compose f g a -> Compose f g a -> Compose f g a Source # logBase :: Compose f g a -> Compose f g a -> Compose f g a Source # sin :: Compose f g a -> Compose f g a Source # cos :: Compose f g a -> Compose f g a Source # tan :: Compose f g a -> Compose f g a Source # asin :: Compose f g a -> Compose f g a Source # acos :: Compose f g a -> Compose f g a Source # atan :: Compose f g a -> Compose f g a Source # sinh :: Compose f g a -> Compose f g a Source # cosh :: Compose f g a -> Compose f g a Source # tanh :: Compose f g a -> Compose f g a Source # asinh :: Compose f g a -> Compose f g a Source # acosh :: Compose f g a -> Compose f g a Source # atanh :: Compose f g a -> Compose f g a Source # log1p :: Compose f g a -> Compose f g a Source # expm1 :: Compose f g a -> Compose f g a Source # |
class (Real a, Fractional a) => RealFrac a where Source #
Extracting components of fractions.
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 asx
; andf
is 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 Source #
returns the integer nearest truncate
xx
between zero and x
round :: Integral b => a -> b Source #
returns the nearest integer to round
xx
;
the even integer if x
is equidistant between two integers
ceiling :: Integral b => a -> b Source #
returns the least integer not less than ceiling
xx
floor :: Integral b => a -> b Source #
returns the greatest integer not greater than floor
xx
Instances
RealFrac CDouble Source # | |
RealFrac CFloat Source # | |
RealFrac a => RealFrac (Identity a) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Identity | |
RealFrac a => RealFrac (Down a) Source # | Since: base-4.14.0.0 |
Integral a => RealFrac (Ratio a) Source # | Since: base-2.0.1 |
HasResolution a => RealFrac (Fixed a) Source # | Since: base-2.1 |
RealFrac a => RealFrac (Const a b) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Const | |
RealFrac (f (g a)) => RealFrac (Compose f g a) Source # | Since: base-4.20.0.0 |
Defined in Data.Functor.Compose |
class (RealFrac a, Floating a) => RealFloat a where Source #
Efficient, machine-independent access to the components of a floating-point number.
floatRadix, floatDigits, floatRange, decodeFloat, encodeFloat, isNaN, isInfinite, isDenormalized, isNegativeZero, isIEEE
floatRadix :: a -> Integer Source #
a constant function, returning the radix of the representation
(often 2
)
floatDigits :: a -> Int Source #
a constant function, returning the number of digits of
floatRadix
in the significand
floatRange :: a -> (Int, Int) Source #
a constant function, returning the lowest and highest values the exponent may assume
decodeFloat :: a -> (Integer, Int) Source #
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 Source #
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.
exponent
corresponds to the second component of decodeFloat
.
and for finite nonzero exponent
0 = 0x
,
.
If exponent
x = snd (decodeFloat
x) + floatDigits
xx
is a finite floating-point number, it is equal in value to
, where significand
x * b ^^ exponent
xb
is the
floating-point radix.
The behaviour is unspecified on infinite or NaN
values.
significand :: a -> a Source #
The first component of decodeFloat
, scaled to lie in the open
interval (-1
,1
), either 0.0
or of absolute value >= 1/b
,
where b
is the floating-point radix.
The behaviour is unspecified on infinite or NaN
values.
scaleFloat :: Int -> a -> a Source #
multiplies a floating-point number by an integer power of the radix
True
if the argument is an IEEE "not-a-number" (NaN) value
isInfinite :: a -> Bool Source #
True
if the argument is an IEEE infinity or negative infinity
isDenormalized :: a -> Bool Source #
True
if the argument is too small to be represented in
normalized format
isNegativeZero :: a -> Bool Source #
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
RealFloat CDouble Source # | |
Defined in GHC.Internal.Foreign.C.Types floatRadix :: CDouble -> Integer Source # floatDigits :: CDouble -> Int Source # floatRange :: CDouble -> (Int, Int) Source # decodeFloat :: CDouble -> (Integer, Int) Source # encodeFloat :: Integer -> Int -> CDouble Source # exponent :: CDouble -> Int Source # significand :: CDouble -> CDouble Source # scaleFloat :: Int -> CDouble -> CDouble Source # isNaN :: CDouble -> Bool Source # isInfinite :: CDouble -> Bool Source # isDenormalized :: CDouble -> Bool Source # isNegativeZero :: CDouble -> Bool Source # | |
RealFloat CFloat Source # | |
Defined in GHC.Internal.Foreign.C.Types floatRadix :: CFloat -> Integer Source # floatDigits :: CFloat -> Int Source # floatRange :: CFloat -> (Int, Int) Source # decodeFloat :: CFloat -> (Integer, Int) Source # encodeFloat :: Integer -> Int -> CFloat Source # exponent :: CFloat -> Int Source # significand :: CFloat -> CFloat Source # scaleFloat :: Int -> CFloat -> CFloat Source # isNaN :: CFloat -> Bool Source # isInfinite :: CFloat -> Bool Source # isDenormalized :: CFloat -> Bool Source # isNegativeZero :: CFloat -> Bool Source # | |
RealFloat Double Source # | Since: base-2.1 |
Defined in GHC.Internal.Float floatRadix :: Double -> Integer Source # floatDigits :: Double -> Int Source # floatRange :: Double -> (Int, Int) Source # decodeFloat :: Double -> (Integer, Int) Source # encodeFloat :: Integer -> Int -> Double Source # exponent :: Double -> Int Source # significand :: Double -> Double Source # scaleFloat :: Int -> Double -> Double Source # isNaN :: Double -> Bool Source # isInfinite :: Double -> Bool Source # isDenormalized :: Double -> Bool Source # isNegativeZero :: Double -> Bool Source # | |
RealFloat Float Source # | Since: base-2.1 |
Defined in GHC.Internal.Float floatRadix :: Float -> Integer Source # floatDigits :: Float -> Int Source # floatRange :: Float -> (Int, Int) Source # decodeFloat :: Float -> (Integer, Int) Source # encodeFloat :: Integer -> Int -> Float Source # exponent :: Float -> Int Source # significand :: Float -> Float Source # scaleFloat :: Int -> Float -> Float Source # isNaN :: Float -> Bool Source # isInfinite :: Float -> Bool Source # isDenormalized :: Float -> Bool Source # isNegativeZero :: Float -> Bool Source # | |
RealFloat a => RealFloat (Identity a) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Identity floatRadix :: Identity a -> Integer Source # floatDigits :: Identity a -> Int Source # floatRange :: Identity a -> (Int, Int) Source # decodeFloat :: Identity a -> (Integer, Int) Source # encodeFloat :: Integer -> Int -> Identity a Source # exponent :: Identity a -> Int Source # significand :: Identity a -> Identity a Source # scaleFloat :: Int -> Identity a -> Identity a Source # isNaN :: Identity a -> Bool Source # isInfinite :: Identity a -> Bool Source # isDenormalized :: Identity a -> Bool Source # isNegativeZero :: Identity a -> Bool Source # | |
RealFloat a => RealFloat (Down a) Source # | Since: base-4.14.0.0 |
Defined in GHC.Internal.Data.Ord floatRadix :: Down a -> Integer Source # floatDigits :: Down a -> Int Source # floatRange :: Down a -> (Int, Int) Source # decodeFloat :: Down a -> (Integer, Int) Source # encodeFloat :: Integer -> Int -> Down a Source # exponent :: Down a -> Int Source # significand :: Down a -> Down a Source # scaleFloat :: Int -> Down a -> Down a Source # isNaN :: Down a -> Bool Source # isInfinite :: Down a -> Bool Source # isDenormalized :: Down a -> Bool Source # isNegativeZero :: Down a -> Bool Source # | |
RealFloat a => RealFloat (Const a b) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Const floatRadix :: Const a b -> Integer Source # floatDigits :: Const a b -> Int Source # floatRange :: Const a b -> (Int, Int) Source # decodeFloat :: Const a b -> (Integer, Int) Source # encodeFloat :: Integer -> Int -> Const a b Source # exponent :: Const a b -> Int Source # significand :: Const a b -> Const a b Source # scaleFloat :: Int -> Const a b -> Const a b Source # isNaN :: Const a b -> Bool Source # isInfinite :: Const a b -> Bool Source # isDenormalized :: Const a b -> Bool Source # isNegativeZero :: Const a b -> Bool Source # | |
RealFloat (f (g a)) => RealFloat (Compose f g a) Source # | Since: base-4.20.0.0 |
Defined in Data.Functor.Compose floatRadix :: Compose f g a -> Integer Source # floatDigits :: Compose f g a -> Int Source # floatRange :: Compose f g a -> (Int, Int) Source # decodeFloat :: Compose f g a -> (Integer, Int) Source # encodeFloat :: Integer -> Int -> Compose f g a Source # exponent :: Compose f g a -> Int Source # significand :: Compose f g a -> Compose f g a Source # scaleFloat :: Int -> Compose f g a -> Compose f g a Source # isNaN :: Compose f g a -> Bool Source # isInfinite :: Compose f g a -> Bool Source # isDenormalized :: Compose f g a -> Bool Source # isNegativeZero :: Compose f g a -> Bool Source # isIEEE :: Compose f g a -> Bool Source # atan2 :: Compose f g a -> Compose f g a -> Compose f g a Source # |
GHC.Internal.Numeric functions
gcd :: Integral a => a -> a -> a Source #
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 minBound
0
or
) for such types.minBound
lcm :: Integral a => a -> a -> a Source #
is the smallest positive integer that both lcm
x yx
and y
divide.
(^) :: (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
fromIntegral :: (Integral a, Num b) => a -> b Source #
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 Source #
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
Semigroups and Monoids
class Semigroup a where Source #
The class of semigroups (types with an associative binary operation).
Instances should satisfy the following:
You can alternatively define sconcat
instead of (<>
), in which case the
laws are:
Since: base-4.9.0.0
(<>) :: a -> a -> a infixr 6 Source #
An associative operation.
Examples
>>>
[1,2,3] <> [4,5,6]
[1,2,3,4,5,6]
>>>
Just [1, 2, 3] <> Just [4, 5, 6]
Just [1,2,3,4,5,6]
>>>
putStr "Hello, " <> putStrLn "World!"
Hello, World!
Instances
Semigroup ByteArray Source # | Since: base-4.17.0.0 |
Semigroup Void Source # | Since: base-4.9.0.0 |
Semigroup All Source # | Since: base-4.9.0.0 |
Semigroup Any Source # | Since: base-4.9.0.0 |
Semigroup Event Source # | Since: base-4.10.0.0 |
Semigroup EventLifetime Source # | Since: base-4.11.0.0 |
Semigroup Lifetime Source # | Since: base-4.10.0.0 |
Semigroup ExceptionContext Source # | |
Defined in GHC.Internal.Exception.Context (<>) :: ExceptionContext -> ExceptionContext -> ExceptionContext Source # sconcat :: NonEmpty ExceptionContext -> ExceptionContext Source # stimes :: Integral b => b -> ExceptionContext -> ExceptionContext Source # | |
Semigroup Ordering Source # | Since: base-4.9.0.0 |
Semigroup () Source # | Since: base-4.9.0.0 |
Semigroup (Comparison a) Source # |
(<>) :: Comparison a -> Comparison a -> Comparison a Comparison cmp <> Comparison cmp' = Comparison a a' -> cmp a a' <> cmp a a' |
Defined in Data.Functor.Contravariant (<>) :: Comparison a -> Comparison a -> Comparison a Source # sconcat :: NonEmpty (Comparison a) -> Comparison a Source # stimes :: Integral b => b -> Comparison a -> Comparison a Source # | |
Semigroup (Equivalence a) Source # |
(<>) :: Equivalence a -> Equivalence a -> Equivalence a Equivalence equiv <> Equivalence equiv' = Equivalence a b -> equiv a b && equiv' a b |
Defined in Data.Functor.Contravariant (<>) :: Equivalence a -> Equivalence a -> Equivalence a Source # sconcat :: NonEmpty (Equivalence a) -> Equivalence a Source # stimes :: Integral b => b -> Equivalence a -> Equivalence a Source # | |
Semigroup (Predicate a) Source # |
(<>) :: Predicate a -> Predicate a -> Predicate a Predicate pred <> Predicate pred' = Predicate a -> pred a && pred' a |
Semigroup (First a) Source # | Since: base-4.9.0.0 |
Semigroup (Last a) Source # | Since: base-4.9.0.0 |
Ord a => Semigroup (Max a) Source # | Since: base-4.9.0.0 |
Ord a => Semigroup (Min a) Source # | Since: base-4.9.0.0 |
Monoid m => Semigroup (WrappedMonoid m) Source # | Since: base-4.9.0.0 |
Defined in Data.Semigroup (<>) :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m Source # sconcat :: NonEmpty (WrappedMonoid m) -> WrappedMonoid m Source # stimes :: Integral b => b -> WrappedMonoid m -> WrappedMonoid m Source # | |
Semigroup (NonEmpty a) Source # | Since: base-4.9.0.0 |
Semigroup a => Semigroup (STM a) Source # | Since: base-4.17.0.0 |
Bits a => Semigroup (And a) Source # | Since: base-4.16 |
FiniteBits a => Semigroup (Iff a) Source # | This constraint is arguably
too strong. However, as some types (such as Since: base-4.16 |
Bits a => Semigroup (Ior a) Source # | Since: base-4.16 |
Bits a => Semigroup (Xor a) Source # | Since: base-4.16 |
Semigroup a => Semigroup (Identity a) Source # | Since: base-4.9.0.0 |
Ord a => Semigroup (Max a) Source # | Since: base-4.11.0.0 |
Ord a => Semigroup (Min a) Source # | Since: base-4.11.0.0 |
Semigroup (First a) Source # | Since: base-4.9.0.0 |
Semigroup (Last a) Source # | Since: base-4.9.0.0 |
Semigroup a => Semigroup (Down a) Source # | Since: base-4.11.0.0 |
Semigroup a => Semigroup (Dual a) Source # | Since: base-4.9.0.0 |
Semigroup (Endo a) Source # | Since: base-4.9.0.0 |
Num a => Semigroup (Product a) Source # | Since: base-4.9.0.0 |
Num a => Semigroup (Sum a) Source # | Since: base-4.9.0.0 |
(Generic a, Semigroup (Rep a ())) => Semigroup (Generically a) Source # | Since: base-4.17.0.0 |
Defined in GHC.Internal.Generics (<>) :: Generically a -> Generically a -> Generically a Source # sconcat :: NonEmpty (Generically a) -> Generically a Source # stimes :: Integral b => b -> Generically a -> Generically a Source # | |
Semigroup p => Semigroup (Par1 p) Source # | Since: base-4.12.0.0 |
Semigroup a => Semigroup (Q a) Source # | Since: ghc-internal-2.17.0.0 |
Semigroup a => Semigroup (IO a) Source # | Since: base-4.10.0.0 |
Semigroup a => Semigroup (Maybe a) Source # | Since: base-4.9.0.0 |
Semigroup a => Semigroup (Solo a) Source # | Since: base-4.15 |
Semigroup [a] Source # | Since: base-4.9.0.0 |
Semigroup a => Semigroup (Op a b) Source # |
(<>) :: Op a b -> Op a b -> Op a b Op f <> Op g = Op a -> f a <> g a |
Semigroup (Either a b) Source # | Since: base-4.9.0.0 |
Semigroup (Proxy s) Source # | Since: base-4.9.0.0 |
Semigroup (U1 p) Source # | Since: base-4.12.0.0 |
Semigroup (V1 p) Source # | Since: base-4.12.0.0 |
Semigroup a => Semigroup (ST s a) Source # | Since: base-4.11.0.0 |
(Semigroup a, Semigroup b) => Semigroup (a, b) Source # | Since: base-4.9.0.0 |
Semigroup b => Semigroup (a -> b) Source # | Since: base-4.9.0.0 |
Semigroup a => Semigroup (Const a b) Source # | Since: base-4.9.0.0 |
(Applicative f, Semigroup a) => Semigroup (Ap f a) Source # | Since: base-4.12.0.0 |
Alternative f => Semigroup (Alt f a) Source # | Since: base-4.9.0.0 |
Semigroup (f p) => Semigroup (Rec1 f p) Source # | Since: base-4.12.0.0 |
(Semigroup a, Semigroup b, Semigroup c) => Semigroup (a, b, c) Source # | Since: base-4.9.0.0 |
(Semigroup (f a), Semigroup (g a)) => Semigroup (Product f g a) Source # | Since: base-4.16.0.0 |
(Semigroup (f p), Semigroup (g p)) => Semigroup ((f :*: g) p) Source # | Since: base-4.12.0.0 |
Semigroup c => Semigroup (K1 i c p) Source # | Since: base-4.12.0.0 |
(Semigroup a, Semigroup b, Semigroup c, Semigroup d) => Semigroup (a, b, c, d) Source # | Since: base-4.9.0.0 |
Semigroup (f (g a)) => Semigroup (Compose f g a) Source # | Since: base-4.16.0.0 |
Semigroup (f (g p)) => Semigroup ((f :.: g) p) Source # | Since: base-4.12.0.0 |
Semigroup (f p) => Semigroup (M1 i c f p) Source # | Since: base-4.12.0.0 |
(Semigroup a, Semigroup b, Semigroup c, Semigroup d, Semigroup e) => Semigroup (a, b, c, d, e) Source # | Since: base-4.9.0.0 |
class Semigroup a => Monoid a where Source #
The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following:
- Right identity
x
<>
mempty
= x- Left identity
mempty
<>
x = x- Associativity
x
(<>
(y<>
z) = (x<>
y)<>
zSemigroup
law)- Concatenation
mconcat
=foldr
(<>
)mempty
You can alternatively define mconcat
instead of mempty
, in which case the
laws are:
- Unit
mconcat
(pure
x) = x- Multiplication
mconcat
(join
xss) =mconcat
(fmap
mconcat
xss)- Subclass
mconcat
(toList
xs) =sconcat
xs
The method names refer to the monoid of lists under concatenation, but there are many other instances.
Some types can be viewed as a monoid in more than one way,
e.g. both addition and multiplication on numbers.
In such cases we often define newtype
s and make those instances
of Monoid
, e.g. Sum
and Product
.
NOTE: Semigroup
is a superclass of Monoid
since base-4.11.0.0.
Identity of mappend
Examples
>>>
"Hello world" <> mempty
"Hello world"
>>>
mempty <> [1, 2, 3]
[1,2,3]
mappend :: a -> a -> a Source #
An associative operation
NOTE: This method is redundant and has the default
implementation
since base-4.11.0.0.
Should it be implemented manually, since mappend
= (<>
)mappend
is a synonym for
(<>
), it is expected that the two functions are defined the same
way. In a future GHC release mappend
will be removed from Monoid
.
Fold a list using the monoid.
For most types, the default definition for mconcat
will be
used, but the function is included in the class definition so
that an optimized version can be provided for specific types.
>>>
mconcat ["Hello", " ", "Haskell", "!"]
"Hello Haskell!"
Instances
Monoid ByteArray Source # | Since: base-4.17.0.0 |
Monoid All Source # | Since: base-2.1 |
Monoid Any Source # | Since: base-2.1 |
Monoid Event Source # | Since: base-4.4.0.0 |
Monoid EventLifetime Source # | Since: base-4.8.0.0 |
Monoid Lifetime Source # |
Since: base-4.8.0.0 |
Monoid ExceptionContext Source # | |
Defined in GHC.Internal.Exception.Context | |
Monoid Ordering Source # | Since: base-2.1 |
Monoid () Source # | Since: base-2.1 |
Monoid (Comparison a) Source # |
mempty :: Comparison a mempty = Comparison _ _ -> EQ |
Defined in Data.Functor.Contravariant mempty :: Comparison a Source # mappend :: Comparison a -> Comparison a -> Comparison a Source # mconcat :: [Comparison a] -> Comparison a Source # | |
Monoid (Equivalence a) Source # |
mempty :: Equivalence a mempty = Equivalence _ _ -> True |
Defined in Data.Functor.Contravariant mempty :: Equivalence a Source # mappend :: Equivalence a -> Equivalence a -> Equivalence a Source # mconcat :: [Equivalence a] -> Equivalence a Source # | |
Monoid (Predicate a) Source # |
mempty :: Predicate a mempty = _ -> True |
(Ord a, Bounded a) => Monoid (Max a) Source # | Since: base-4.9.0.0 |
(Ord a, Bounded a) => Monoid (Min a) Source # | Since: base-4.9.0.0 |
Monoid m => Monoid (WrappedMonoid m) Source # | Since: base-4.9.0.0 |
Defined in Data.Semigroup mempty :: WrappedMonoid m Source # mappend :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m Source # mconcat :: [WrappedMonoid m] -> WrappedMonoid m Source # | |
Monoid a => Monoid (STM a) Source # | Since: base-4.17.0.0 |
FiniteBits a => Monoid (And a) Source # | This constraint is arguably too strong. However,
as some types (such as Since: base-4.16 |
FiniteBits a => Monoid (Iff a) Source # | This constraint is arguably
too strong. However, as some types (such as Since: base-4.16 |
Bits a => Monoid (Ior a) Source # | Since: base-4.16 |
Bits a => Monoid (Xor a) Source # | Since: base-4.16 |
Monoid a => Monoid (Identity a) Source # | Since: base-4.9.0.0 |
Ord a => Monoid (Max a) Source # | Since: base-4.8.0.0 |
Ord a => Monoid (Min a) Source # | Since: base-4.8.0.0 |
Monoid (First a) Source # | Since: base-2.1 |
Monoid (Last a) Source # | Since: base-2.1 |
Monoid a => Monoid (Down a) Source # | Since: base-4.11.0.0 |
Monoid a => Monoid (Dual a) Source # | Since: base-2.1 |
Monoid (Endo a) Source # | Since: base-2.1 |
Num a => Monoid (Product a) Source # | Since: base-2.1 |
Num a => Monoid (Sum a) Source # | Since: base-2.1 |
(Generic a, Monoid (Rep a ())) => Monoid (Generically a) Source # | Since: base-4.17.0.0 |
Defined in GHC.Internal.Generics mempty :: Generically a Source # mappend :: Generically a -> Generically a -> Generically a Source # mconcat :: [Generically a] -> Generically a Source # | |
Monoid p => Monoid (Par1 p) Source # | Since: base-4.12.0.0 |
Monoid a => Monoid (Q a) Source # | Since: ghc-internal-2.17.0.0 |
Monoid a => Monoid (IO a) Source # | Since: base-4.9.0.0 |
Semigroup a => Monoid (Maybe a) Source # | Lift a semigroup into Since 4.11.0: constraint on inner Since: base-2.1 |
Monoid a => Monoid (Solo a) Source # | Since: base-4.15 |
Monoid [a] Source # | Since: base-2.1 |
Monoid a => Monoid (Op a b) Source # |
mempty :: Op a b mempty = Op _ -> mempty |
Monoid (Proxy s) Source # | Since: base-4.7.0.0 |
Monoid (U1 p) Source # | Since: base-4.12.0.0 |
Monoid a => Monoid (ST s a) Source # | Since: base-4.11.0.0 |
(Monoid a, Monoid b) => Monoid (a, b) Source # | Since: base-2.1 |
Monoid b => Monoid (a -> b) Source # | Since: base-2.1 |
Monoid a => Monoid (Const a b) Source # | Since: base-4.9.0.0 |
(Applicative f, Monoid a) => Monoid (Ap f a) Source # | Since: base-4.12.0.0 |
Alternative f => Monoid (Alt f a) Source # | Since: base-4.8.0.0 |
Monoid (f p) => Monoid (Rec1 f p) Source # | Since: base-4.12.0.0 |
(Monoid a, Monoid b, Monoid c) => Monoid (a, b, c) Source # | Since: base-2.1 |
(Monoid (f a), Monoid (g a)) => Monoid (Product f g a) Source # | Since: base-4.16.0.0 |
(Monoid (f p), Monoid (g p)) => Monoid ((f :*: g) p) Source # | Since: base-4.12.0.0 |
Monoid c => Monoid (K1 i c p) Source # | Since: base-4.12.0.0 |
(Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d) Source # | Since: base-2.1 |
Monoid (f (g a)) => Monoid (Compose f g a) Source # | Since: base-4.16.0.0 |
Monoid (f (g p)) => Monoid ((f :.: g) p) Source # | Since: base-4.12.0.0 |
Monoid (f p) => Monoid (M1 i c f p) Source # | Since: base-4.12.0.0 |
(Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e) Source # | Since: base-2.1 |
Monads and functors
class Functor (f :: Type -> Type) where Source #
A type f
is a Functor if it provides a function fmap
which, given any types a
and b
lets you apply any function from (a -> b)
to turn an f a
into an f b
, preserving the
structure of f
. Furthermore f
needs to adhere to the following:
Note, that the second law follows from the free theorem of the type fmap
and
the first law, so you need only check that the former condition holds.
See these articles by School of Haskell or
David Luposchainsky
for an explanation.
fmap :: (a -> b) -> f a -> f b Source #
fmap
is used to apply a function of type (a -> b)
to a value of type f a
,
where f is a functor, to produce a value of type f b
.
Note that for any type constructor with more than one parameter (e.g., Either
),
only the last type parameter can be modified with fmap
(e.g., b
in `Either a b`).
Some type constructors with two parameters or more have a
instance that allows
both the last and the penultimate parameters to be mapped over.Bifunctor
Examples
Convert from a
to a Maybe
IntMaybe String
using show
:
>>>
fmap show Nothing
Nothing>>>
fmap show (Just 3)
Just "3"
Convert from an
to an
Either
Int IntEither Int String
using show
:
>>>
fmap show (Left 17)
Left 17>>>
fmap show (Right 17)
Right "17"
Double each element of a list:
>>>
fmap (*2) [1,2,3]
[2,4,6]
Apply even
to the second element of a pair:
>>>
fmap even (2,2)
(2,True)
It may seem surprising that the function is only applied to the last element of the tuple
compared to the list example above which applies it to every element in the list.
To understand, remember that tuples are type constructors with multiple type parameters:
a tuple of 3 elements (a,b,c)
can also be written (,,) a b c
and its Functor
instance
is defined for Functor ((,,) a b)
(i.e., only the third parameter is free to be mapped over
with fmap
).
It explains why fmap
can be used with tuples containing values of different types as in the
following example:
>>>
fmap even ("hello", 1.0, 4)
("hello",1.0,True)
Instances
Functor Complex Source # | Since: base-4.9.0.0 |
Functor First Source # | Since: base-4.9.0.0 |
Functor Last Source # | Since: base-4.9.0.0 |
Functor Max Source # | Since: base-4.9.0.0 |
Functor Min Source # | Since: base-4.9.0.0 |
Functor ArgDescr Source # | Since: base-4.7.0.0 |
Functor ArgOrder Source # | Since: base-4.7.0.0 |
Functor OptDescr Source # | Since: base-4.7.0.0 |
Functor NonEmpty Source # | Since: base-4.9.0.0 |
Functor STM Source # | Since: base-4.3.0.0 |
Functor Handler Source # | Since: base-4.6.0.0 |
Functor Identity Source # | Since: base-4.8.0.0 |
Functor First Source # | Since: base-4.8.0.0 |
Functor Last Source # | Since: base-4.8.0.0 |
Functor Down Source # | Since: base-4.11.0.0 |
Functor Dual Source # | Since: base-4.8.0.0 |
Functor Product Source # | Since: base-4.8.0.0 |
Functor Sum Source # | Since: base-4.8.0.0 |
Functor ZipList Source # | Since: base-2.1 |
Functor NoIO Source # | Since: base-4.8.0.0 |
Functor Par1 Source # | Since: base-4.9.0.0 |
Functor Q Source # | |
Functor TyVarBndr Source # | |
Functor P Source # | Since: base-4.8.0.0 |
Functor ReadP Source # | Since: base-2.1 |
Functor ReadPrec Source # | Since: base-2.1 |
Functor IO Source # | Since: base-2.1 |
Functor Maybe Source # | Since: base-2.1 |
Functor Solo Source # | Since: base-4.15 |
Functor [] Source # | Since: base-2.1 |
Monad m => Functor (WrappedMonad m) Source # | Since: base-2.1 |
Defined in Control.Applicative fmap :: (a -> b) -> WrappedMonad m a -> WrappedMonad m b Source # (<$) :: a -> WrappedMonad m b -> WrappedMonad m a Source # | |
Functor (Arg a) Source # | Since: base-4.9.0.0 |
Functor (Array i) Source # | Since: base-2.1 |
Arrow a => Functor (ArrowMonad a) Source # | Since: base-4.6.0.0 |
Defined in GHC.Internal.Control.Arrow fmap :: (a0 -> b) -> ArrowMonad a a0 -> ArrowMonad a b Source # (<$) :: a0 -> ArrowMonad a b -> ArrowMonad a a0 Source # | |
Functor (ST s) Source # | Since: base-2.1 |
Functor (Either a) Source # | Since: base-3.0 |
Functor (StateL s) Source # | Since: base-4.0 |
Functor (StateR s) Source # | Since: base-4.0 |
Functor (Proxy :: Type -> Type) Source # | Since: base-4.7.0.0 |
Functor (U1 :: Type -> Type) Source # | Since: base-4.9.0.0 |
Functor (V1 :: Type -> Type) Source # | Since: base-4.9.0.0 |
Functor (ST s) Source # | Since: base-2.1 |
Functor ((,) a) Source # | Since: base-2.1 |
Arrow a => Functor (WrappedArrow a b) Source # | Since: base-2.1 |
Defined in Control.Applicative fmap :: (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 Source # (<$) :: a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 Source # | |
Functor m => Functor (Kleisli m a) Source # | Since: base-4.14.0.0 |
Functor (Const m :: Type -> Type) Source # | Since: base-2.1 |
Monad m => Functor (StateT s m) Source # | Since: base-4.18.0.0 |
Functor f => Functor (Ap f) Source # | Since: base-4.12.0.0 |
Functor f => Functor (Alt f) Source # | Since: base-4.8.0.0 |
(Generic1 f, Functor (Rep1 f)) => Functor (Generically1 f) Source # | Since: base-4.17.0.0 |
Defined in GHC.Internal.Generics fmap :: (a -> b) -> Generically1 f a -> Generically1 f b Source # (<$) :: a -> Generically1 f b -> Generically1 f a Source # | |
Functor f => Functor (Rec1 f) Source # | Since: base-4.9.0.0 |
Functor (URec (Ptr ()) :: Type -> Type) Source # | Since: base-4.9.0.0 |
Functor (URec Char :: Type -> Type) Source # | Since: base-4.9.0.0 |
Functor (URec Double :: Type -> Type) Source # | Since: base-4.9.0.0 |
Functor (URec Float :: Type -> Type) Source # | Since: base-4.9.0.0 |
Functor (URec Int :: Type -> Type) Source # | Since: base-4.9.0.0 |
Functor (URec Word :: Type -> Type) Source # | Since: base-4.9.0.0 |
Functor ((,,) a b) Source # | Since: base-4.14.0.0 |
(Functor f, Functor g) => Functor (Product f g) Source # | Since: base-4.9.0.0 |
(Functor f, Functor g) => Functor (Sum f g) Source # | Since: base-4.9.0.0 |
(Functor f, Functor g) => Functor (f :*: g) Source # | Since: base-4.9.0.0 |
(Functor f, Functor g) => Functor (f :+: g) Source # | Since: base-4.9.0.0 |
Functor (K1 i c :: Type -> Type) Source # | Since: base-4.9.0.0 |
Functor ((,,,) a b c) Source # | Since: base-4.14.0.0 |
Functor ((->) r) Source # | Since: base-2.1 |
(Functor f, Functor g) => Functor (Compose f g) Source # | Since: base-4.9.0.0 |
(Functor f, Functor g) => Functor (f :.: g) Source # | Since: base-4.9.0.0 |
Functor f => Functor (M1 i c f) Source # | Since: base-4.9.0.0 |
Functor ((,,,,) a b c d) Source # | Since: base-4.18.0.0 |
Functor ((,,,,,) a b c d e) Source # | Since: base-4.18.0.0 |
Functor ((,,,,,,) a b c d e f) Source # | Since: base-4.18.0.0 |
(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 Source #
An infix synonym for fmap
.
The name of this operator is an allusion to $
.
Note the similarities between their types:
($) :: (a -> b) -> a -> b (<$>) :: Functor f => (a -> b) -> f a -> f b
Whereas $
is function application, <$>
is function
application lifted over a Functor
.
Examples
Convert from a
to a Maybe
Int
using Maybe
String
show
:
>>>
show <$> Nothing
Nothing
>>>
show <$> Just 3
Just "3"
Convert from an
to an
Either
Int
Int
Either
Int
String
using show
:
>>>
show <$> Left 17
Left 17
>>>
show <$> Right 17
Right "17"
Double each element of a list:
>>>
(*2) <$> [1,2,3]
[2,4,6]
Apply even
to the second element of a pair:
>>>
even <$> (2,2)
(2,True)
class Functor f => Applicative (f :: Type -> Type) where Source #
A functor with application, providing operations to
A minimal complete definition must include implementations of pure
and of either <*>
or liftA2
. If it defines both, then they must behave
the same as their default definitions:
(<*>
) =liftA2
id
liftA2
f x y = f<$>
x<*>
y
Further, any definition must satisfy the following:
- Identity
pure
id
<*>
v = v- Composition
pure
(.)<*>
u<*>
v<*>
w = u<*>
(v<*>
w)- Homomorphism
pure
f<*>
pure
x =pure
(f x)- Interchange
u
<*>
pure
y =pure
($
y)<*>
u
The other methods have the following default definitions, which may be overridden with equivalent specialized implementations:
As a consequence of these laws, the Functor
instance for f
will satisfy
It may be useful to note that supposing
forall x y. p (q x y) = f x . g y
it follows from the above that
liftA2
p (liftA2
q u v) =liftA2
f u .liftA2
g v
If f
is also a Monad
, it should satisfy
(which implies that pure
and <*>
satisfy the applicative functor laws).
Lift a value into the Structure.
Examples
>>>
pure 1 :: Maybe Int
Just 1
>>>
pure 'z' :: [Char]
"z"
>>>
pure (pure ":D") :: Maybe [String]
Just [":D"]
(<*>) :: f (a -> b) -> f a -> f b infixl 4 Source #
Sequential application.
A few functors support an implementation of <*>
that is more
efficient than the default one.
Example
Used in combination with
, (<$>)
can be used to build a record.(<*>)
>>>
data MyState = MyState {arg1 :: Foo, arg2 :: Bar, arg3 :: Baz}
>>>
produceFoo :: Applicative f => f Foo
>>>
produceBar :: Applicative f => f Bar
>>>
produceBaz :: Applicative f => f Baz
>>>
mkState :: Applicative f => f MyState
>>>
mkState = MyState <$> produceFoo <*> produceBar <*> produceBaz
liftA2 :: (a -> b -> c) -> f a -> f b -> f c Source #
Lift a binary function to actions.
Some functors support an implementation of liftA2
that is more
efficient than the default one. In particular, if fmap
is an
expensive operation, it is likely better to use liftA2
than to
fmap
over the structure and then use <*>
.
This became a typeclass method in 4.10.0.0. Prior to that, it was
a function defined in terms of <*>
and fmap
.
Example
>>>
liftA2 (,) (Just 3) (Just 5)
Just (3,5)
>>>
liftA2 (+) [1, 2, 3] [4, 5, 6]
[5,6,7,6,7,8,7,8,9]
(*>) :: f a -> f b -> f b infixl 4 Source #
Sequence actions, discarding the value of the first argument.
Examples
If used in conjunction with the Applicative instance for Maybe
,
you can chain Maybe computations, with a possible "early return"
in case of Nothing
.
>>>
Just 2 *> Just 3
Just 3
>>>
Nothing *> Just 3
Nothing
Of course a more interesting use case would be to have effectful computations instead of just returning pure values.
>>>
import Data.Char
>>>
import GHC.Internal.Text.ParserCombinators.ReadP
>>>
let p = string "my name is " *> munch1 isAlpha <* eof
>>>
readP_to_S p "my name is Simon"
[("Simon","")]
(<*) :: f a -> f b -> f a infixl 4 Source #
Sequence actions, discarding the value of the second argument.
Instances
Applicative Complex Source # | Since: base-4.9.0.0 |
Applicative First Source # | Since: base-4.9.0.0 |
Applicative Last Source # | Since: base-4.9.0.0 |
Applicative Max Source # | Since: base-4.9.0.0 |
Applicative Min Source # | Since: base-4.9.0.0 |
Applicative NonEmpty Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Base | |
Applicative STM Source # | Since: base-4.8.0.0 |
Applicative Identity Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.Data.Functor.Identity | |
Applicative First Source # | Since: base-4.8.0.0 |
Applicative Last Source # | Since: base-4.8.0.0 |
Applicative Down Source # | Since: base-4.11.0.0 |
Applicative Dual Source # | Since: base-4.8.0.0 |
Applicative Product Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.Data.Semigroup.Internal | |
Applicative Sum Source # | Since: base-4.8.0.0 |
Applicative ZipList Source # | f <$> ZipList xs1 <*> ... <*> ZipList xsN = ZipList (zipWithN f xs1 ... xsN) where (\a b c -> stimes c [a, b]) <$> ZipList "abcd" <*> ZipList "567" <*> ZipList [1..] = ZipList (zipWith3 (\a b c -> stimes c [a, b]) "abcd" "567" [1..]) = ZipList {getZipList = ["a5","b6b6","c7c7c7"]} Since: base-2.1 |
Defined in GHC.Internal.Functor.ZipList | |
Applicative NoIO Source # | Since: base-4.8.0.0 |
Applicative Par1 Source # | Since: base-4.9.0.0 |
Applicative Q Source # | |
Applicative P Source # | Since: base-4.5.0.0 |
Applicative ReadP Source # | Since: base-4.6.0.0 |
Applicative ReadPrec Source # | Since: base-4.6.0.0 |
Defined in GHC.Internal.Text.ParserCombinators.ReadPrec | |
Applicative IO Source # | Since: base-2.1 |
Applicative Maybe Source # | Since: base-2.1 |
Applicative Solo Source # | Since: base-4.15 |
Applicative [] Source # | Since: base-2.1 |
Monad m => Applicative (WrappedMonad m) Source # | Since: base-2.1 |
Defined in Control.Applicative pure :: a -> WrappedMonad m a Source # (<*>) :: WrappedMonad m (a -> b) -> WrappedMonad m a -> WrappedMonad m b Source # liftA2 :: (a -> b -> c) -> WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m c Source # (*>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b Source # (<*) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m a Source # | |
Arrow a => Applicative (ArrowMonad a) Source # | Since: base-4.6.0.0 |
Defined in GHC.Internal.Control.Arrow pure :: a0 -> ArrowMonad a a0 Source # (<*>) :: ArrowMonad a (a0 -> b) -> ArrowMonad a a0 -> ArrowMonad a b Source # liftA2 :: (a0 -> b -> c) -> ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a c Source # (*>) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a b Source # (<*) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a a0 Source # | |
Applicative (ST s) Source # | Since: base-2.1 |
Applicative (Either e) Source # | Since: base-3.0 |
Defined in GHC.Internal.Data.Either | |
Applicative (StateL s) Source # | Since: base-4.0 |
Defined in GHC.Internal.Data.Functor.Utils | |
Applicative (StateR s) Source # | Since: base-4.0 |
Defined in GHC.Internal.Data.Functor.Utils | |
Applicative (Proxy :: Type -> Type) Source # | Since: base-4.7.0.0 |
Applicative (U1 :: Type -> Type) Source # | Since: base-4.9.0.0 |
Applicative (ST s) Source # | Since: base-4.4.0.0 |
Monoid a => Applicative ((,) a) Source # | For tuples, the ("hello ", (+15)) <*> ("world!", 2002) ("hello world!",2017) Since: base-2.1 |
Arrow a => Applicative (WrappedArrow a b) Source # | Since: base-2.1 |
Defined in Control.Applicative pure :: a0 -> WrappedArrow a b a0 Source # (<*>) :: WrappedArrow a b (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 Source # liftA2 :: (a0 -> b0 -> c) -> WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b c Source # (*>) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b b0 Source # (<*) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 Source # | |
Applicative m => Applicative (Kleisli m a) Source # | Since: base-4.14.0.0 |
Defined in GHC.Internal.Control.Arrow pure :: a0 -> Kleisli m a a0 Source # (<*>) :: Kleisli m a (a0 -> b) -> Kleisli m a a0 -> Kleisli m a b Source # liftA2 :: (a0 -> b -> c) -> Kleisli m a a0 -> Kleisli m a b -> Kleisli m a c Source # (*>) :: Kleisli m a a0 -> Kleisli m a b -> Kleisli m a b Source # (<*) :: Kleisli m a a0 -> Kleisli m a b -> Kleisli m a a0 Source # | |
Monoid m => Applicative (Const m :: Type -> Type) Source # | Since: base-2.0.1 |
Defined in GHC.Internal.Data.Functor.Const | |
Monad m => Applicative (StateT s m) Source # | Since: base-4.18.0.0 |
Defined in GHC.Internal.Data.Functor.Utils pure :: a -> StateT s m a Source # (<*>) :: StateT s m (a -> b) -> StateT s m a -> StateT s m b Source # liftA2 :: (a -> b -> c) -> StateT s m a -> StateT s m b -> StateT s m c Source # (*>) :: StateT s m a -> StateT s m b -> StateT s m b Source # (<*) :: StateT s m a -> StateT s m b -> StateT s m a Source # | |
Applicative f => Applicative (Ap f) Source # | Since: base-4.12.0.0 |
Applicative f => Applicative (Alt f) Source # | Since: base-4.8.0.0 |
(Generic1 f, Applicative (Rep1 f)) => Applicative (Generically1 f) Source # | Since: base-4.17.0.0 |
Defined in GHC.Internal.Generics pure :: a -> Generically1 f a Source # (<*>) :: Generically1 f (a -> b) -> Generically1 f a -> Generically1 f b Source # liftA2 :: (a -> b -> c) -> Generically1 f a -> Generically1 f b -> Generically1 f c Source # (*>) :: Generically1 f a -> Generically1 f b -> Generically1 f b Source # (<*) :: Generically1 f a -> Generically1 f b -> Generically1 f a Source # | |
Applicative f => Applicative (Rec1 f) Source # | Since: base-4.9.0.0 |
(Monoid a, Monoid b) => Applicative ((,,) a b) Source # | Since: base-4.14.0.0 |
Defined in GHC.Internal.Base | |
(Applicative f, Applicative g) => Applicative (Product f g) Source # | Since: base-4.9.0.0 |
Defined in Data.Functor.Product pure :: a -> Product f g a Source # (<*>) :: Product f g (a -> b) -> Product f g a -> Product f g b Source # liftA2 :: (a -> b -> c) -> Product f g a -> Product f g b -> Product f g c Source # (*>) :: Product f g a -> Product f g b -> Product f g b Source # (<*) :: Product f g a -> Product f g b -> Product f g a Source # | |
(Applicative f, Applicative g) => Applicative (f :*: g) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics | |
Monoid c => Applicative (K1 i c :: Type -> Type) Source # | Since: base-4.12.0.0 |
(Monoid a, Monoid b, Monoid c) => Applicative ((,,,) a b c) Source # | Since: base-4.14.0.0 |
Defined in GHC.Internal.Base pure :: a0 -> (a, b, c, a0) Source # (<*>) :: (a, b, c, a0 -> b0) -> (a, b, c, a0) -> (a, b, c, b0) Source # liftA2 :: (a0 -> b0 -> c0) -> (a, b, c, a0) -> (a, b, c, b0) -> (a, b, c, c0) Source # (*>) :: (a, b, c, a0) -> (a, b, c, b0) -> (a, b, c, b0) Source # (<*) :: (a, b, c, a0) -> (a, b, c, b0) -> (a, b, c, a0) Source # | |
Applicative ((->) r) Source # | Since: base-2.1 |
(Applicative f, Applicative g) => Applicative (Compose f g) Source # | Since: base-4.9.0.0 |
Defined in Data.Functor.Compose pure :: a -> Compose f g a Source # (<*>) :: Compose f g (a -> b) -> Compose f g a -> Compose f g b Source # liftA2 :: (a -> b -> c) -> Compose f g a -> Compose f g b -> Compose f g c Source # (*>) :: Compose f g a -> Compose f g b -> Compose f g b Source # (<*) :: Compose f g a -> Compose f g b -> Compose f g a Source # | |
(Applicative f, Applicative g) => Applicative (f :.: g) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics | |
Applicative f => Applicative (M1 i c f) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics |
class Applicative m => Monad (m :: Type -> Type) where Source #
The Monad
class defines the basic operations over a monad,
a concept from a branch of mathematics known as category theory.
From the perspective of a Haskell programmer, however, it is best to
think of a monad as an abstract datatype of actions.
Haskell's do
expressions provide a convenient syntax for writing
monadic expressions.
Instances of Monad
should satisfy the following:
- Left identity
return
a>>=
k = k a- Right identity
m
>>=
return
= m- Associativity
m
>>=
(\x -> k x>>=
h) = (m>>=
k)>>=
h
Furthermore, the Monad
and Applicative
operations should relate as follows:
The above laws imply:
and that pure
and (<*>
) satisfy the applicative functor laws.
The instances of Monad
for List
, Maybe
and IO
defined in the Prelude satisfy these laws.
(>>=) :: m a -> (a -> m b) -> m b infixl 1 Source #
Sequentially compose two actions, passing any value produced by the first as an argument to the second.
'as
' can be understood as the >>=
bsdo
expression
do a <- as bs a
An alternative name for this function is 'bind', but some people may refer to it as 'flatMap', which results from it being equivalent to
\x f ->join
(fmap
f x) :: Monad m => m a -> (a -> m b) -> m b
which can be seen as mapping a value with
Monad m => m a -> m (m b)
and then 'flattening' m (m b)
to m b
using join
.
(>>) :: m a -> m b -> m b infixl 1 Source #
Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages.
'as
' can be understood as the >>
bsdo
expression
do as bs
or in terms of
as(>>=)
as >>= const bs
Inject a value into the monadic type.
This function should not be different from its default implementation
as pure
. The justification for the existence of this function is
merely historic.
Instances
Monad Complex Source # | Since: base-4.9.0.0 |
Monad First Source # | Since: base-4.9.0.0 |
Monad Last Source # | Since: base-4.9.0.0 |
Monad Max Source # | Since: base-4.9.0.0 |
Monad Min Source # | Since: base-4.9.0.0 |
Monad NonEmpty Source # | Since: base-4.9.0.0 |
Monad STM Source # | Since: base-4.3.0.0 |
Monad Identity Source # | Since: base-4.8.0.0 |
Monad First Source # | Since: base-4.8.0.0 |
Monad Last Source # | Since: base-4.8.0.0 |
Monad Down Source # | Since: base-4.11.0.0 |
Monad Dual Source # | Since: base-4.8.0.0 |
Monad Product Source # | Since: base-4.8.0.0 |
Monad Sum Source # | Since: base-4.8.0.0 |
Monad NoIO Source # | Since: base-4.4.0.0 |
Monad Par1 Source # | Since: base-4.9.0.0 |
Monad Q Source # | |
Monad P Source # | Since: base-2.1 |
Monad ReadP Source # | Since: base-2.1 |
Monad ReadPrec Source # | Since: base-2.1 |
Monad IO Source # | Since: base-2.1 |
Monad Maybe Source # | Since: base-2.1 |
Monad Solo Source # | Since: base-4.15 |
Monad [] Source # | Since: base-2.1 |
Monad m => Monad (WrappedMonad m) Source # | Since: base-4.7.0.0 |
Defined in Control.Applicative (>>=) :: WrappedMonad m a -> (a -> WrappedMonad m b) -> WrappedMonad m b Source # (>>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b Source # return :: a -> WrappedMonad m a Source # | |
ArrowApply a => Monad (ArrowMonad a) Source # | Since: base-2.1 |
Defined in GHC.Internal.Control.Arrow (>>=) :: ArrowMonad a a0 -> (a0 -> ArrowMonad a b) -> ArrowMonad a b Source # (>>) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a b Source # return :: a0 -> ArrowMonad a a0 Source # | |
Monad (ST s) Source # | Since: base-2.1 |
Monad (Either e) Source # | Since: base-4.4.0.0 |
Monad (Proxy :: Type -> Type) Source # | Since: base-4.7.0.0 |
Monad (U1 :: Type -> Type) Source # | Since: base-4.9.0.0 |
Monad (ST s) Source # | Since: base-2.1 |
Monoid a => Monad ((,) a) Source # | Since: base-4.9.0.0 |
Monad m => Monad (Kleisli m a) Source # | Since: base-4.14.0.0 |
Monad m => Monad (StateT s m) Source # | Since: base-4.18.0.0 |
Monad f => Monad (Ap f) Source # | Since: base-4.12.0.0 |
Monad f => Monad (Alt f) Source # | Since: base-4.8.0.0 |
Monad f => Monad (Rec1 f) Source # | Since: base-4.9.0.0 |
(Monoid a, Monoid b) => Monad ((,,) a b) Source # | Since: base-4.14.0.0 |
(Monad f, Monad g) => Monad (Product f g) Source # | Since: base-4.9.0.0 |
(Monad f, Monad g) => Monad (f :*: g) Source # | Since: base-4.9.0.0 |
(Monoid a, Monoid b, Monoid c) => Monad ((,,,) a b c) Source # | Since: base-4.14.0.0 |
Monad ((->) r) Source # | Since: base-2.1 |
Monad f => Monad (M1 i c f) Source # | Since: base-4.9.0.0 |
class Monad m => MonadFail (m :: Type -> Type) where Source #
When a value is bound in do
-notation, the pattern on the left
hand side of <-
might not match. In this case, this class
provides a function to recover.
A Monad
without a MonadFail
instance may only be used in conjunction
with pattern that always match, such as newtypes, tuples, data types with
only a single data constructor, and irrefutable patterns (~pat
).
Instances of MonadFail
should satisfy the following law: fail s
should
be a left zero for >>=
,
fail s >>= f = fail s
If your Monad
is also MonadPlus
, a popular definition is
fail _ = mzero
fail s
should be an action that runs in the monad itself, not an
exception (except in instances of MonadIO
). In particular,
fail
should not be implemented in terms of error
.
Since: base-4.9.0.0
Instances
MonadFail Q Source # | |
MonadFail P Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Text.ParserCombinators.ReadP | |
MonadFail ReadP Source # | Since: base-4.9.0.0 |
MonadFail ReadPrec Source # | Since: base-4.9.0.0 |
MonadFail IO Source # | Since: base-4.9.0.0 |
MonadFail Maybe Source # | Since: base-4.9.0.0 |
MonadFail [] Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Control.Monad.Fail | |
MonadFail f => MonadFail (Ap f) Source # | Since: base-4.12.0.0 |
sequence_ :: (Foldable t, Monad m) => t (m a) -> m () Source #
Evaluate each monadic action in the structure from left to right,
and ignore the results. For a version that doesn't ignore the
results see sequence
.
sequence_
is just like sequenceA_
, but specialised to monadic
actions.
(=<<) :: Monad m => (a -> m b) -> m a -> m b infixr 1 Source #
Same as >>=
, but with the arguments interchanged.
as >>= f == f =<< as
Folds and traversals
class Foldable (t :: Type -> Type) where Source #
The Foldable class represents data structures that can be reduced to a summary value one element at a time. Strict left-associative folds are a good fit for space-efficient reduction, while lazy right-associative folds are a good fit for corecursive iteration, or for folds that short-circuit after processing an initial subsequence of the structure's elements.
Instances can be derived automatically by enabling the DeriveFoldable
extension. For example, a derived instance for a binary tree might be:
{-# LANGUAGE DeriveFoldable #-} data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a) deriving Foldable
A more detailed description can be found in the Overview section of Data.Foldable.
For the class laws see the Laws section of Data.Foldable.
foldMap :: Monoid m => (a -> m) -> t a -> m Source #
Map each element of the structure into a monoid, and combine the
results with (
. This fold is right-associative and lazy in the
accumulator. For strict left-associative folds consider <>
)foldMap'
instead.
Examples
Basic usage:
>>>
foldMap Sum [1, 3, 5]
Sum {getSum = 9}
>>>
foldMap Product [1, 3, 5]
Product {getProduct = 15}
>>>
foldMap (replicate 3) [1, 2, 3]
[1,1,1,2,2,2,3,3,3]
When a Monoid's (
is lazy in its second argument, <>
)foldMap
can
return a result even from an unbounded structure. For example, lazy
accumulation enables Data.ByteString.Builder to efficiently serialise
large data structures and produce the output incrementally:
>>>
import qualified Data.ByteString.Lazy as L
>>>
import qualified Data.ByteString.Builder as B
>>>
let bld :: Int -> B.Builder; bld i = B.intDec i <> B.word8 0x20
>>>
let lbs = B.toLazyByteString $ foldMap bld [0..]
>>>
L.take 64 lbs
"0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24"
foldr :: (a -> b -> b) -> b -> t a -> b Source #
Right-associative fold of a structure, lazy in the accumulator.
In the case of lists, foldr
, when applied to a binary operator, a
starting value (typically the right-identity of the operator), and a
list, reduces the list using the binary operator, from right to left:
foldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)
Note that since the head of the resulting expression is produced by an
application of the operator to the first element of the list, given an
operator lazy in its right argument, foldr
can produce a terminating
expression from an unbounded list.
For a general Foldable
structure this should be semantically identical
to,
foldr f z =foldr
f z .toList
Examples
Basic usage:
>>>
foldr (||) False [False, True, False]
True
>>>
foldr (||) False []
False
>>>
foldr (\c acc -> acc ++ [c]) "foo" ['a', 'b', 'c', 'd']
"foodcba"
Infinite structures
⚠️ Applying foldr
to infinite structures usually doesn't terminate.
It may still terminate under one of the following conditions:
- the folding function is short-circuiting
- the folding function is lazy on its second argument
Short-circuiting
(
short-circuits on ||
)True
values, so the following terminates
because there is a True
value finitely far from the left side:
>>>
foldr (||) False (True : repeat False)
True
But the following doesn't terminate:
>>>
foldr (||) False (repeat False ++ [True])
* Hangs forever *
Laziness in the second argument
Applying foldr
to infinite structures terminates when the operator is
lazy in its second argument (the initial accumulator is never used in
this case, and so could be left undefined
, but []
is more clear):
>>>
take 5 $ foldr (\i acc -> i : fmap (+3) acc) [] (repeat 1)
[1,4,7,10,13]
foldl :: (b -> a -> b) -> b -> t a -> b Source #
Left-associative fold of a structure, lazy in the accumulator. This is rarely what you want, but can work well for structures with efficient right-to-left sequencing and an operator that is lazy in its left argument.
In the case of lists, foldl
, when applied to a binary operator, a
starting value (typically the left-identity of the operator), and a
list, reduces the list using the binary operator, from left to right:
foldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn
Note that to produce the outermost application of the operator the
entire input list must be traversed. Like all left-associative folds,
foldl
will diverge if given an infinite list.
If you want an efficient strict left-fold, you probably want to use
foldl'
instead of foldl
. The reason for this is that the latter
does not force the inner results (e.g. z `f` x1
in the above
example) before applying them to the operator (e.g. to (`f` x2)
).
This results in a thunk chain O(n) elements long, which then must be
evaluated from the outside-in.
For a general Foldable
structure this should be semantically identical
to:
foldl f z =foldl
f z .toList
Examples
The first example is a strict fold, which in practice is best performed
with foldl'
.
>>>
foldl (+) 42 [1,2,3,4]
52
Though the result below is lazy, the input is reversed before prepending it to the initial accumulator, so corecursion begins only after traversing the entire input string.
>>>
foldl (\acc c -> c : acc) "abcd" "efgh"
"hgfeabcd"
A left fold of a structure that is infinite on the right cannot terminate, even when for any finite input the fold just returns the initial accumulator:
>>>
foldl (\a _ -> a) 0 $ repeat 1
* Hangs forever *
WARNING: When it comes to lists, you always want to use either foldl'
or foldr
instead.
foldl' :: (b -> a -> b) -> b -> t a -> b Source #
Left-associative fold of a structure but with strict application of the operator.
This ensures that each step of the fold is forced to Weak Head Normal
Form before being applied, avoiding the collection of thunks that would
otherwise occur. This is often what you want to strictly reduce a
finite structure to a single strict result (e.g. sum
).
For a general Foldable
structure this should be semantically identical
to,
foldl' f z =foldl'
f z .toList
Since: base-4.6.0.0
foldr1 :: (a -> a -> a) -> t a -> a Source #
A variant of foldr
that has no base case,
and thus may only be applied to non-empty structures.
This function is non-total and will raise a runtime exception if the structure happens to be empty.
Examples
Basic usage:
>>>
foldr1 (+) [1..4]
10
>>>
foldr1 (+) []
Exception: Prelude.foldr1: empty list
>>>
foldr1 (+) Nothing
*** Exception: foldr1: empty structure
>>>
foldr1 (-) [1..4]
-2
>>>
foldr1 (&&) [True, False, True, True]
False
>>>
foldr1 (||) [False, False, True, True]
True
>>>
foldr1 (+) [1..]
* Hangs forever *
foldl1 :: (a -> a -> a) -> t a -> a Source #
A variant of foldl
that has no base case,
and thus may only be applied to non-empty structures.
This function is non-total and will raise a runtime exception if the structure happens to be empty.
foldl1
f =foldl1
f .toList
Examples
Basic usage:
>>>
foldl1 (+) [1..4]
10
>>>
foldl1 (+) []
*** Exception: Prelude.foldl1: empty list
>>>
foldl1 (+) Nothing
*** Exception: foldl1: empty structure
>>>
foldl1 (-) [1..4]
-8
>>>
foldl1 (&&) [True, False, True, True]
False
>>>
foldl1 (||) [False, False, True, True]
True
>>>
foldl1 (+) [1..]
* Hangs forever *
elem :: Eq a => a -> t a -> Bool infix 4 Source #
Does the element occur in the structure?
Note: elem
is often used in infix form.
Examples
Basic usage:
>>>
3 `elem` []
False
>>>
3 `elem` [1,2]
False
>>>
3 `elem` [1,2,3,4,5]
True
For infinite structures, the default implementation of elem
terminates if the sought-after value exists at a finite distance
from the left side of the structure:
>>>
3 `elem` [1..]
True
>>>
3 `elem` ([4..] ++ [3])
* Hangs forever *
Since: base-4.8.0.0
maximum :: Ord a => t a -> a Source #
The largest element of a non-empty structure. This function is
equivalent to
, and its behavior on structures with
multiple largest elements depends on the relevant implementation of
foldr1
max
max
. For the default implementation of max
(max x y = if x <= y
then y else x
), structure order is used as a tie-breaker: if there are
multiple largest elements, the rightmost of them is chosen (this is
equivalent to
).maximumBy
compare
This function is non-total and will raise a runtime exception if the structure happens to be empty. A structure that supports random access and maintains its elements in order should provide a specialised implementation to return the maximum in faster than linear time.
Examples
Basic usage:
>>>
maximum [1..10]
10
>>>
maximum []
*** Exception: Prelude.maximum: empty list
>>>
maximum Nothing
*** Exception: maximum: empty structure
WARNING: This function is partial for possibly-empty structures like lists.
Since: base-4.8.0.0
minimum :: Ord a => t a -> a Source #
The least element of a non-empty structure. This function is
equivalent to
, and its behavior on structures with
multiple largest elements depends on the relevant implementation of
foldr1
min
min
. For the default implementation of min
(min x y = if x <= y
then x else y
), structure order is used as a tie-breaker: if there are
multiple least elements, the leftmost of them is chosen (this is
equivalent to
).minimumBy
compare
This function is non-total and will raise a runtime exception if the structure happens to be empty. A structure that supports random access and maintains its elements in order should provide a specialised implementation to return the minimum in faster than linear time.
Examples
Basic usage:
>>>
minimum [1..10]
1
>>>
minimum []
*** Exception: Prelude.minimum: empty list
>>>
minimum Nothing
*** Exception: minimum: empty structure
WARNING: This function is partial for possibly-empty structures like lists.
Since: base-4.8.0.0
sum :: Num a => t a -> a Source #
The sum
function computes the sum of the numbers of a structure.
Examples
Basic usage:
>>>
sum []
0
>>>
sum [42]
42
>>>
sum [1..10]
55
>>>
sum [4.1, 2.0, 1.7]
7.8
>>>
sum [1..]
* Hangs forever *
Since: base-4.8.0.0
product :: Num a => t a -> a Source #
The product
function computes the product of the numbers of a
structure.
Examples
Basic usage:
>>>
product []
1
>>>
product [42]
42
>>>
product [1..10]
3628800
>>>
product [4.1, 2.0, 1.7]
13.939999999999998
>>>
product [1..]
* Hangs forever *
Since: base-4.8.0.0
Instances
Foldable Complex Source # | Since: base-4.9.0.0 |
Defined in Data.Complex fold :: Monoid m => Complex m -> m Source # foldMap :: Monoid m => (a -> m) -> Complex a -> m Source # foldMap' :: Monoid m => (a -> m) -> Complex a -> m Source # foldr :: (a -> b -> b) -> b -> Complex a -> b Source # foldr' :: (a -> b -> b) -> b -> Complex a -> b Source # foldl :: (b -> a -> b) -> b -> Complex a -> b Source # foldl' :: (b -> a -> b) -> b -> Complex a -> b Source # foldr1 :: (a -> a -> a) -> Complex a -> a Source # foldl1 :: (a -> a -> a) -> Complex a -> a Source # toList :: Complex a -> [a] Source # null :: Complex a -> Bool Source # length :: Complex a -> Int Source # elem :: Eq a => a -> Complex a -> Bool Source # maximum :: Ord a => Complex a -> a Source # minimum :: Ord a => Complex a -> a Source # | |
Foldable First Source # | Since: base-4.9.0.0 |
Defined in Data.Semigroup fold :: Monoid m => First m -> m Source # foldMap :: Monoid m => (a -> m) -> First a -> m Source # foldMap' :: Monoid m => (a -> m) -> First a -> m Source # foldr :: (a -> b -> b) -> b -> First a -> b Source # foldr' :: (a -> b -> b) -> b -> First a -> b Source # foldl :: (b -> a -> b) -> b -> First a -> b Source # foldl' :: (b -> a -> b) -> b -> First a -> b Source # foldr1 :: (a -> a -> a) -> First a -> a Source # foldl1 :: (a -> a -> a) -> First a -> a Source # toList :: First a -> [a] Source # null :: First a -> Bool Source # length :: First a -> Int Source # elem :: Eq a => a -> First a -> Bool Source # maximum :: Ord a => First a -> a Source # minimum :: Ord a => First a -> a Source # | |
Foldable Last Source # | Since: base-4.9.0.0 |
Defined in Data.Semigroup fold :: Monoid m => Last m -> m Source # foldMap :: Monoid m => (a -> m) -> Last a -> m Source # foldMap' :: Monoid m => (a -> m) -> Last a -> m Source # foldr :: (a -> b -> b) -> b -> Last a -> b Source # foldr' :: (a -> b -> b) -> b -> Last a -> b Source # foldl :: (b -> a -> b) -> b -> Last a -> b Source # foldl' :: (b -> a -> b) -> b -> Last a -> b Source # foldr1 :: (a -> a -> a) -> Last a -> a Source # foldl1 :: (a -> a -> a) -> Last a -> a Source # toList :: Last a -> [a] Source # null :: Last a -> Bool Source # length :: Last a -> Int Source # elem :: Eq a => a -> Last a -> Bool Source # maximum :: Ord a => Last a -> a Source # minimum :: Ord a => Last a -> a Source # | |
Foldable Max Source # | Since: base-4.9.0.0 |
Defined in Data.Semigroup fold :: Monoid m => Max m -> m Source # foldMap :: Monoid m => (a -> m) -> Max a -> m Source # foldMap' :: Monoid m => (a -> m) -> Max a -> m Source # foldr :: (a -> b -> b) -> b -> Max a -> b Source # foldr' :: (a -> b -> b) -> b -> Max a -> b Source # foldl :: (b -> a -> b) -> b -> Max a -> b Source # foldl' :: (b -> a -> b) -> b -> Max a -> b Source # foldr1 :: (a -> a -> a) -> Max a -> a Source # foldl1 :: (a -> a -> a) -> Max a -> a Source # toList :: Max a -> [a] Source # null :: Max a -> Bool Source # length :: Max a -> Int Source # elem :: Eq a => a -> Max a -> Bool Source # maximum :: Ord a => Max a -> a Source # minimum :: Ord a => Max a -> a Source # | |
Foldable Min Source # | Since: base-4.9.0.0 |
Defined in Data.Semigroup fold :: Monoid m => Min m -> m Source # foldMap :: Monoid m => (a -> m) -> Min a -> m Source # foldMap' :: Monoid m => (a -> m) -> Min a -> m Source # foldr :: (a -> b -> b) -> b -> Min a -> b Source # foldr' :: (a -> b -> b) -> b -> Min a -> b Source # foldl :: (b -> a -> b) -> b -> Min a -> b Source # foldl' :: (b -> a -> b) -> b -> Min a -> b Source # foldr1 :: (a -> a -> a) -> Min a -> a Source # foldl1 :: (a -> a -> a) -> Min a -> a Source # toList :: Min a -> [a] Source # null :: Min a -> Bool Source # length :: Min a -> Int Source # elem :: Eq a => a -> Min a -> Bool Source # maximum :: Ord a => Min a -> a Source # minimum :: Ord a => Min a -> a Source # | |
Foldable NonEmpty Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => NonEmpty m -> m Source # foldMap :: Monoid m => (a -> m) -> NonEmpty a -> m Source # foldMap' :: Monoid m => (a -> m) -> NonEmpty a -> m Source # foldr :: (a -> b -> b) -> b -> NonEmpty a -> b Source # foldr' :: (a -> b -> b) -> b -> NonEmpty a -> b Source # foldl :: (b -> a -> b) -> b -> NonEmpty a -> b Source # foldl' :: (b -> a -> b) -> b -> NonEmpty a -> b Source # foldr1 :: (a -> a -> a) -> NonEmpty a -> a Source # foldl1 :: (a -> a -> a) -> NonEmpty a -> a Source # toList :: NonEmpty a -> [a] Source # null :: NonEmpty a -> Bool Source # length :: NonEmpty a -> Int Source # elem :: Eq a => a -> NonEmpty a -> Bool Source # maximum :: Ord a => NonEmpty a -> a Source # minimum :: Ord a => NonEmpty a -> a Source # | |
Foldable Identity Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.Data.Functor.Identity fold :: Monoid m => Identity m -> m Source # foldMap :: Monoid m => (a -> m) -> Identity a -> m Source # foldMap' :: Monoid m => (a -> m) -> Identity a -> m Source # foldr :: (a -> b -> b) -> b -> Identity a -> b Source # foldr' :: (a -> b -> b) -> b -> Identity a -> b Source # foldl :: (b -> a -> b) -> b -> Identity a -> b Source # foldl' :: (b -> a -> b) -> b -> Identity a -> b Source # foldr1 :: (a -> a -> a) -> Identity a -> a Source # foldl1 :: (a -> a -> a) -> Identity a -> a Source # toList :: Identity a -> [a] Source # null :: Identity a -> Bool Source # length :: Identity a -> Int Source # elem :: Eq a => a -> Identity a -> Bool Source # maximum :: Ord a => Identity a -> a Source # minimum :: Ord a => Identity a -> a Source # | |
Foldable First Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => First m -> m Source # foldMap :: Monoid m => (a -> m) -> First a -> m Source # foldMap' :: Monoid m => (a -> m) -> First a -> m Source # foldr :: (a -> b -> b) -> b -> First a -> b Source # foldr' :: (a -> b -> b) -> b -> First a -> b Source # foldl :: (b -> a -> b) -> b -> First a -> b Source # foldl' :: (b -> a -> b) -> b -> First a -> b Source # foldr1 :: (a -> a -> a) -> First a -> a Source # foldl1 :: (a -> a -> a) -> First a -> a Source # toList :: First a -> [a] Source # null :: First a -> Bool Source # length :: First a -> Int Source # elem :: Eq a => a -> First a -> Bool Source # maximum :: Ord a => First a -> a Source # minimum :: Ord a => First a -> a Source # | |
Foldable Last Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => Last m -> m Source # foldMap :: Monoid m => (a -> m) -> Last a -> m Source # foldMap' :: Monoid m => (a -> m) -> Last a -> m Source # foldr :: (a -> b -> b) -> b -> Last a -> b Source # foldr' :: (a -> b -> b) -> b -> Last a -> b Source # foldl :: (b -> a -> b) -> b -> Last a -> b Source # foldl' :: (b -> a -> b) -> b -> Last a -> b Source # foldr1 :: (a -> a -> a) -> Last a -> a Source # foldl1 :: (a -> a -> a) -> Last a -> a Source # toList :: Last a -> [a] Source # null :: Last a -> Bool Source # length :: Last a -> Int Source # elem :: Eq a => a -> Last a -> Bool Source # maximum :: Ord a => Last a -> a Source # minimum :: Ord a => Last a -> a Source # | |
Foldable Down Source # | Since: base-4.12.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => Down m -> m Source # foldMap :: Monoid m => (a -> m) -> Down a -> m Source # foldMap' :: Monoid m => (a -> m) -> Down a -> m Source # foldr :: (a -> b -> b) -> b -> Down a -> b Source # foldr' :: (a -> b -> b) -> b -> Down a -> b Source # foldl :: (b -> a -> b) -> b -> Down a -> b Source # foldl' :: (b -> a -> b) -> b -> Down a -> b Source # foldr1 :: (a -> a -> a) -> Down a -> a Source # foldl1 :: (a -> a -> a) -> Down a -> a Source # toList :: Down a -> [a] Source # null :: Down a -> Bool Source # length :: Down a -> Int Source # elem :: Eq a => a -> Down a -> Bool Source # maximum :: Ord a => Down a -> a Source # minimum :: Ord a => Down a -> a Source # | |
Foldable Dual Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => Dual m -> m Source # foldMap :: Monoid m => (a -> m) -> Dual a -> m Source # foldMap' :: Monoid m => (a -> m) -> Dual a -> m Source # foldr :: (a -> b -> b) -> b -> Dual a -> b Source # foldr' :: (a -> b -> b) -> b -> Dual a -> b Source # foldl :: (b -> a -> b) -> b -> Dual a -> b Source # foldl' :: (b -> a -> b) -> b -> Dual a -> b Source # foldr1 :: (a -> a -> a) -> Dual a -> a Source # foldl1 :: (a -> a -> a) -> Dual a -> a Source # toList :: Dual a -> [a] Source # null :: Dual a -> Bool Source # length :: Dual a -> Int Source # elem :: Eq a => a -> Dual a -> Bool Source # maximum :: Ord a => Dual a -> a Source # minimum :: Ord a => Dual a -> a Source # | |
Foldable Product Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => Product m -> m Source # foldMap :: Monoid m => (a -> m) -> Product a -> m Source # foldMap' :: Monoid m => (a -> m) -> Product a -> m Source # foldr :: (a -> b -> b) -> b -> Product a -> b Source # foldr' :: (a -> b -> b) -> b -> Product a -> b Source # foldl :: (b -> a -> b) -> b -> Product a -> b Source # foldl' :: (b -> a -> b) -> b -> Product a -> b Source # foldr1 :: (a -> a -> a) -> Product a -> a Source # foldl1 :: (a -> a -> a) -> Product a -> a Source # toList :: Product a -> [a] Source # null :: Product a -> Bool Source # length :: Product a -> Int Source # elem :: Eq a => a -> Product a -> Bool Source # maximum :: Ord a => Product a -> a Source # minimum :: Ord a => Product a -> a Source # | |
Foldable Sum Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => Sum m -> m Source # foldMap :: Monoid m => (a -> m) -> Sum a -> m Source # foldMap' :: Monoid m => (a -> m) -> Sum a -> m Source # foldr :: (a -> b -> b) -> b -> Sum a -> b Source # foldr' :: (a -> b -> b) -> b -> Sum a -> b Source # foldl :: (b -> a -> b) -> b -> Sum a -> b Source # foldl' :: (b -> a -> b) -> b -> Sum a -> b Source # foldr1 :: (a -> a -> a) -> Sum a -> a Source # foldl1 :: (a -> a -> a) -> Sum a -> a Source # toList :: Sum a -> [a] Source # null :: Sum a -> Bool Source # length :: Sum a -> Int Source # elem :: Eq a => a -> Sum a -> Bool Source # maximum :: Ord a => Sum a -> a Source # minimum :: Ord a => Sum a -> a Source # | |
Foldable ZipList Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Functor.ZipList fold :: Monoid m => ZipList m -> m Source # foldMap :: Monoid m => (a -> m) -> ZipList a -> m Source # foldMap' :: Monoid m => (a -> m) -> ZipList a -> m Source # foldr :: (a -> b -> b) -> b -> ZipList a -> b Source # foldr' :: (a -> b -> b) -> b -> ZipList a -> b Source # foldl :: (b -> a -> b) -> b -> ZipList a -> b Source # foldl' :: (b -> a -> b) -> b -> ZipList a -> b Source # foldr1 :: (a -> a -> a) -> ZipList a -> a Source # foldl1 :: (a -> a -> a) -> ZipList a -> a Source # toList :: ZipList a -> [a] Source # null :: ZipList a -> Bool Source # length :: ZipList a -> Int Source # elem :: Eq a => a -> ZipList a -> Bool Source # maximum :: Ord a => ZipList a -> a Source # minimum :: Ord a => ZipList a -> a Source # | |
Foldable Par1 Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => Par1 m -> m Source # foldMap :: Monoid m => (a -> m) -> Par1 a -> m Source # foldMap' :: Monoid m => (a -> m) -> Par1 a -> m Source # foldr :: (a -> b -> b) -> b -> Par1 a -> b Source # foldr' :: (a -> b -> b) -> b -> Par1 a -> b Source # foldl :: (b -> a -> b) -> b -> Par1 a -> b Source # foldl' :: (b -> a -> b) -> b -> Par1 a -> b Source # foldr1 :: (a -> a -> a) -> Par1 a -> a Source # foldl1 :: (a -> a -> a) -> Par1 a -> a Source # toList :: Par1 a -> [a] Source # null :: Par1 a -> Bool Source # length :: Par1 a -> Int Source # elem :: Eq a => a -> Par1 a -> Bool Source # maximum :: Ord a => Par1 a -> a Source # minimum :: Ord a => Par1 a -> a Source # | |
Foldable TyVarBndr Source # | |
Defined in GHC.Internal.TH.Syntax fold :: Monoid m => TyVarBndr m -> m Source # foldMap :: Monoid m => (a -> m) -> TyVarBndr a -> m Source # foldMap' :: Monoid m => (a -> m) -> TyVarBndr a -> m Source # foldr :: (a -> b -> b) -> b -> TyVarBndr a -> b Source # foldr' :: (a -> b -> b) -> b -> TyVarBndr a -> b Source # foldl :: (b -> a -> b) -> b -> TyVarBndr a -> b Source # foldl' :: (b -> a -> b) -> b -> TyVarBndr a -> b Source # foldr1 :: (a -> a -> a) -> TyVarBndr a -> a Source # foldl1 :: (a -> a -> a) -> TyVarBndr a -> a Source # toList :: TyVarBndr a -> [a] Source # null :: TyVarBndr a -> Bool Source # length :: TyVarBndr a -> Int Source # elem :: Eq a => a -> TyVarBndr a -> Bool Source # maximum :: Ord a => TyVarBndr a -> a Source # minimum :: Ord a => TyVarBndr a -> a Source # | |
Foldable Maybe Source # | Since: base-2.1 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => Maybe m -> m Source # foldMap :: Monoid m => (a -> m) -> Maybe a -> m Source # foldMap' :: Monoid m => (a -> m) -> Maybe a -> m Source # foldr :: (a -> b -> b) -> b -> Maybe a -> b Source # foldr' :: (a -> b -> b) -> b -> Maybe a -> b Source # foldl :: (b -> a -> b) -> b -> Maybe a -> b Source # foldl' :: (b -> a -> b) -> b -> Maybe a -> b Source # foldr1 :: (a -> a -> a) -> Maybe a -> a Source # foldl1 :: (a -> a -> a) -> Maybe a -> a Source # toList :: Maybe a -> [a] Source # null :: Maybe a -> Bool Source # length :: Maybe a -> Int Source # elem :: Eq a => a -> Maybe a -> Bool Source # maximum :: Ord a => Maybe a -> a Source # minimum :: Ord a => Maybe a -> a Source # | |
Foldable Solo Source # | Since: base-4.15 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => Solo m -> m Source # foldMap :: Monoid m => (a -> m) -> Solo a -> m Source # foldMap' :: Monoid m => (a -> m) -> Solo a -> m Source # foldr :: (a -> b -> b) -> b -> Solo a -> b Source # foldr' :: (a -> b -> b) -> b -> Solo a -> b Source # foldl :: (b -> a -> b) -> b -> Solo a -> b Source # foldl' :: (b -> a -> b) -> b -> Solo a -> b Source # foldr1 :: (a -> a -> a) -> Solo a -> a Source # foldl1 :: (a -> a -> a) -> Solo a -> a Source # toList :: Solo a -> [a] Source # null :: Solo a -> Bool Source # length :: Solo a -> Int Source # elem :: Eq a => a -> Solo a -> Bool Source # maximum :: Ord a => Solo a -> a Source # minimum :: Ord a => Solo a -> a Source # | |
Foldable [] Source # | Since: base-2.1 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => [m] -> m Source # foldMap :: Monoid m => (a -> m) -> [a] -> m Source # foldMap' :: Monoid m => (a -> m) -> [a] -> m Source # foldr :: (a -> b -> b) -> b -> [a] -> b Source # foldr' :: (a -> b -> b) -> b -> [a] -> b Source # foldl :: (b -> a -> b) -> b -> [a] -> b Source # foldl' :: (b -> a -> b) -> b -> [a] -> b Source # foldr1 :: (a -> a -> a) -> [a] -> a Source # foldl1 :: (a -> a -> a) -> [a] -> a Source # elem :: Eq a => a -> [a] -> Bool Source # maximum :: Ord a => [a] -> a Source # minimum :: Ord a => [a] -> a Source # | |
Foldable (Arg a) Source # | Since: base-4.9.0.0 |
Defined in Data.Semigroup fold :: Monoid m => Arg a m -> m Source # foldMap :: Monoid m => (a0 -> m) -> Arg a a0 -> m Source # foldMap' :: Monoid m => (a0 -> m) -> Arg a a0 -> m Source # foldr :: (a0 -> b -> b) -> b -> Arg a a0 -> b Source # foldr' :: (a0 -> b -> b) -> b -> Arg a a0 -> b Source # foldl :: (b -> a0 -> b) -> b -> Arg a a0 -> b Source # foldl' :: (b -> a0 -> b) -> b -> Arg a a0 -> b Source # foldr1 :: (a0 -> a0 -> a0) -> Arg a a0 -> a0 Source # foldl1 :: (a0 -> a0 -> a0) -> Arg a a0 -> a0 Source # toList :: Arg a a0 -> [a0] Source # null :: Arg a a0 -> Bool Source # length :: Arg a a0 -> Int Source # elem :: Eq a0 => a0 -> Arg a a0 -> Bool Source # maximum :: Ord a0 => Arg a a0 -> a0 Source # minimum :: Ord a0 => Arg a a0 -> a0 Source # | |
Foldable (Array i) Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => Array i m -> m Source # foldMap :: Monoid m => (a -> m) -> Array i a -> m Source # foldMap' :: Monoid m => (a -> m) -> Array i a -> m Source # foldr :: (a -> b -> b) -> b -> Array i a -> b Source # foldr' :: (a -> b -> b) -> b -> Array i a -> b Source # foldl :: (b -> a -> b) -> b -> Array i a -> b Source # foldl' :: (b -> a -> b) -> b -> Array i a -> b Source # foldr1 :: (a -> a -> a) -> Array i a -> a Source # foldl1 :: (a -> a -> a) -> Array i a -> a Source # toList :: Array i a -> [a] Source # null :: Array i a -> Bool Source # length :: Array i a -> Int Source # elem :: Eq a => a -> Array i a -> Bool Source # maximum :: Ord a => Array i a -> a Source # minimum :: Ord a => Array i a -> a Source # | |
Foldable (Either a) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => Either a m -> m Source # foldMap :: Monoid m => (a0 -> m) -> Either a a0 -> m Source # foldMap' :: Monoid m => (a0 -> m) -> Either a a0 -> m Source # foldr :: (a0 -> b -> b) -> b -> Either a a0 -> b Source # foldr' :: (a0 -> b -> b) -> b -> Either a a0 -> b Source # foldl :: (b -> a0 -> b) -> b -> Either a a0 -> b Source # foldl' :: (b -> a0 -> b) -> b -> Either a a0 -> b Source # foldr1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 Source # foldl1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 Source # toList :: Either a a0 -> [a0] Source # null :: Either a a0 -> Bool Source # length :: Either a a0 -> Int Source # elem :: Eq a0 => a0 -> Either a a0 -> Bool Source # maximum :: Ord a0 => Either a a0 -> a0 Source # minimum :: Ord a0 => Either a a0 -> a0 Source # | |
Foldable (Proxy :: Type -> Type) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => Proxy m -> m Source # foldMap :: Monoid m => (a -> m) -> Proxy a -> m Source # foldMap' :: Monoid m => (a -> m) -> Proxy a -> m Source # foldr :: (a -> b -> b) -> b -> Proxy a -> b Source # foldr' :: (a -> b -> b) -> b -> Proxy a -> b Source # foldl :: (b -> a -> b) -> b -> Proxy a -> b Source # foldl' :: (b -> a -> b) -> b -> Proxy a -> b Source # foldr1 :: (a -> a -> a) -> Proxy a -> a Source # foldl1 :: (a -> a -> a) -> Proxy a -> a Source # toList :: Proxy a -> [a] Source # null :: Proxy a -> Bool Source # length :: Proxy a -> Int Source # elem :: Eq a => a -> Proxy a -> Bool Source # maximum :: Ord a => Proxy a -> a Source # minimum :: Ord a => Proxy a -> a Source # | |
Foldable (U1 :: Type -> Type) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => U1 m -> m Source # foldMap :: Monoid m => (a -> m) -> U1 a -> m Source # foldMap' :: Monoid m => (a -> m) -> U1 a -> m Source # foldr :: (a -> b -> b) -> b -> U1 a -> b Source # foldr' :: (a -> b -> b) -> b -> U1 a -> b Source # foldl :: (b -> a -> b) -> b -> U1 a -> b Source # foldl' :: (b -> a -> b) -> b -> U1 a -> b Source # foldr1 :: (a -> a -> a) -> U1 a -> a Source # foldl1 :: (a -> a -> a) -> U1 a -> a Source # toList :: U1 a -> [a] Source # length :: U1 a -> Int Source # elem :: Eq a => a -> U1 a -> Bool Source # maximum :: Ord a => U1 a -> a Source # minimum :: Ord a => U1 a -> a Source # | |
Foldable (UAddr :: Type -> Type) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => UAddr m -> m Source # foldMap :: Monoid m => (a -> m) -> UAddr a -> m Source # foldMap' :: Monoid m => (a -> m) -> UAddr a -> m Source # foldr :: (a -> b -> b) -> b -> UAddr a -> b Source # foldr' :: (a -> b -> b) -> b -> UAddr a -> b Source # foldl :: (b -> a -> b) -> b -> UAddr a -> b Source # foldl' :: (b -> a -> b) -> b -> UAddr a -> b Source # foldr1 :: (a -> a -> a) -> UAddr a -> a Source # foldl1 :: (a -> a -> a) -> UAddr a -> a Source # toList :: UAddr a -> [a] Source # null :: UAddr a -> Bool Source # length :: UAddr a -> Int Source # elem :: Eq a => a -> UAddr a -> Bool Source # maximum :: Ord a => UAddr a -> a Source # minimum :: Ord a => UAddr a -> a Source # | |
Foldable (UChar :: Type -> Type) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => UChar m -> m Source # foldMap :: Monoid m => (a -> m) -> UChar a -> m Source # foldMap' :: Monoid m => (a -> m) -> UChar a -> m Source # foldr :: (a -> b -> b) -> b -> UChar a -> b Source # foldr' :: (a -> b -> b) -> b -> UChar a -> b Source # foldl :: (b -> a -> b) -> b -> UChar a -> b Source # foldl' :: (b -> a -> b) -> b -> UChar a -> b Source # foldr1 :: (a -> a -> a) -> UChar a -> a Source # foldl1 :: (a -> a -> a) -> UChar a -> a Source # toList :: UChar a -> [a] Source # null :: UChar a -> Bool Source # length :: UChar a -> Int Source # elem :: Eq a => a -> UChar a -> Bool Source # maximum :: Ord a => UChar a -> a Source # minimum :: Ord a => UChar a -> a Source # | |
Foldable (UDouble :: Type -> Type) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => UDouble m -> m Source # foldMap :: Monoid m => (a -> m) -> UDouble a -> m Source # foldMap' :: Monoid m => (a -> m) -> UDouble a -> m Source # foldr :: (a -> b -> b) -> b -> UDouble a -> b Source # foldr' :: (a -> b -> b) -> b -> UDouble a -> b Source # foldl :: (b -> a -> b) -> b -> UDouble a -> b Source # foldl' :: (b -> a -> b) -> b -> UDouble a -> b Source # foldr1 :: (a -> a -> a) -> UDouble a -> a Source # foldl1 :: (a -> a -> a) -> UDouble a -> a Source # toList :: UDouble a -> [a] Source # null :: UDouble a -> Bool Source # length :: UDouble a -> Int Source # elem :: Eq a => a -> UDouble a -> Bool Source # maximum :: Ord a => UDouble a -> a Source # minimum :: Ord a => UDouble a -> a Source # | |
Foldable (UFloat :: Type -> Type) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => UFloat m -> m Source # foldMap :: Monoid m => (a -> m) -> UFloat a -> m Source # foldMap' :: Monoid m => (a -> m) -> UFloat a -> m Source # foldr :: (a -> b -> b) -> b -> UFloat a -> b Source # foldr' :: (a -> b -> b) -> b -> UFloat a -> b Source # foldl :: (b -> a -> b) -> b -> UFloat a -> b Source # foldl' :: (b -> a -> b) -> b -> UFloat a -> b Source # foldr1 :: (a -> a -> a) -> UFloat a -> a Source # foldl1 :: (a -> a -> a) -> UFloat a -> a Source # toList :: UFloat a -> [a] Source # null :: UFloat a -> Bool Source # length :: UFloat a -> Int Source # elem :: Eq a => a -> UFloat a -> Bool Source # maximum :: Ord a => UFloat a -> a Source # minimum :: Ord a => UFloat a -> a Source # | |
Foldable (UInt :: Type -> Type) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => UInt m -> m Source # foldMap :: Monoid m => (a -> m) -> UInt a -> m Source # foldMap' :: Monoid m => (a -> m) -> UInt a -> m Source # foldr :: (a -> b -> b) -> b -> UInt a -> b Source # foldr' :: (a -> b -> b) -> b -> UInt a -> b Source # foldl :: (b -> a -> b) -> b -> UInt a -> b Source # foldl' :: (b -> a -> b) -> b -> UInt a -> b Source # foldr1 :: (a -> a -> a) -> UInt a -> a Source # foldl1 :: (a -> a -> a) -> UInt a -> a Source # toList :: UInt a -> [a] Source # null :: UInt a -> Bool Source # length :: UInt a -> Int Source # elem :: Eq a => a -> UInt a -> Bool Source # maximum :: Ord a => UInt a -> a Source # minimum :: Ord a => UInt a -> a Source # | |
Foldable (UWord :: Type -> Type) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => UWord m -> m Source # foldMap :: Monoid m => (a -> m) -> UWord a -> m Source # foldMap' :: Monoid m => (a -> m) -> UWord a -> m Source # foldr :: (a -> b -> b) -> b -> UWord a -> b Source # foldr' :: (a -> b -> b) -> b -> UWord a -> b Source # foldl :: (b -> a -> b) -> b -> UWord a -> b Source # foldl' :: (b -> a -> b) -> b -> UWord a -> b Source # foldr1 :: (a -> a -> a) -> UWord a -> a Source # foldl1 :: (a -> a -> a) -> UWord a -> a Source # toList :: UWord a -> [a] Source # null :: UWord a -> Bool Source # length :: UWord a -> Int Source # elem :: Eq a => a -> UWord a -> Bool Source # maximum :: Ord a => UWord a -> a Source # minimum :: Ord a => UWord a -> a Source # | |
Foldable (V1 :: Type -> Type) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => V1 m -> m Source # foldMap :: Monoid m => (a -> m) -> V1 a -> m Source # foldMap' :: Monoid m => (a -> m) -> V1 a -> m Source # foldr :: (a -> b -> b) -> b -> V1 a -> b Source # foldr' :: (a -> b -> b) -> b -> V1 a -> b Source # foldl :: (b -> a -> b) -> b -> V1 a -> b Source # foldl' :: (b -> a -> b) -> b -> V1 a -> b Source # foldr1 :: (a -> a -> a) -> V1 a -> a Source # foldl1 :: (a -> a -> a) -> V1 a -> a Source # toList :: V1 a -> [a] Source # length :: V1 a -> Int Source # elem :: Eq a => a -> V1 a -> Bool Source # maximum :: Ord a => V1 a -> a Source # minimum :: Ord a => V1 a -> a Source # | |
Foldable ((,) a) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => (a, m) -> m Source # foldMap :: Monoid m => (a0 -> m) -> (a, a0) -> m Source # foldMap' :: Monoid m => (a0 -> m) -> (a, a0) -> m Source # foldr :: (a0 -> b -> b) -> b -> (a, a0) -> b Source # foldr' :: (a0 -> b -> b) -> b -> (a, a0) -> b Source # foldl :: (b -> a0 -> b) -> b -> (a, a0) -> b Source # foldl' :: (b -> a0 -> b) -> b -> (a, a0) -> b Source # foldr1 :: (a0 -> a0 -> a0) -> (a, a0) -> a0 Source # foldl1 :: (a0 -> a0 -> a0) -> (a, a0) -> a0 Source # toList :: (a, a0) -> [a0] Source # null :: (a, a0) -> Bool Source # length :: (a, a0) -> Int Source # elem :: Eq a0 => a0 -> (a, a0) -> Bool Source # maximum :: Ord a0 => (a, a0) -> a0 Source # minimum :: Ord a0 => (a, a0) -> a0 Source # | |
Foldable (Const m :: Type -> Type) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Data.Functor.Const fold :: Monoid m0 => Const m m0 -> m0 Source # foldMap :: Monoid m0 => (a -> m0) -> Const m a -> m0 Source # foldMap' :: Monoid m0 => (a -> m0) -> Const m a -> m0 Source # foldr :: (a -> b -> b) -> b -> Const m a -> b Source # foldr' :: (a -> b -> b) -> b -> Const m a -> b Source # foldl :: (b -> a -> b) -> b -> Const m a -> b Source # foldl' :: (b -> a -> b) -> b -> Const m a -> b Source # foldr1 :: (a -> a -> a) -> Const m a -> a Source # foldl1 :: (a -> a -> a) -> Const m a -> a Source # toList :: Const m a -> [a] Source # null :: Const m a -> Bool Source # length :: Const m a -> Int Source # elem :: Eq a => a -> Const m a -> Bool Source # maximum :: Ord a => Const m a -> a Source # minimum :: Ord a => Const m a -> a Source # | |
Foldable f => Foldable (Ap f) Source # | Since: base-4.12.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => Ap f m -> m Source # foldMap :: Monoid m => (a -> m) -> Ap f a -> m Source # foldMap' :: Monoid m => (a -> m) -> Ap f a -> m Source # foldr :: (a -> b -> b) -> b -> Ap f a -> b Source # foldr' :: (a -> b -> b) -> b -> Ap f a -> b Source # foldl :: (b -> a -> b) -> b -> Ap f a -> b Source # foldl' :: (b -> a -> b) -> b -> Ap f a -> b Source # foldr1 :: (a -> a -> a) -> Ap f a -> a Source # foldl1 :: (a -> a -> a) -> Ap f a -> a Source # toList :: Ap f a -> [a] Source # null :: Ap f a -> Bool Source # length :: Ap f a -> Int Source # elem :: Eq a => a -> Ap f a -> Bool Source # maximum :: Ord a => Ap f a -> a Source # minimum :: Ord a => Ap f a -> a Source # | |
Foldable f => Foldable (Alt f) Source # | Since: base-4.12.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => Alt f m -> m Source # foldMap :: Monoid m => (a -> m) -> Alt f a -> m Source # foldMap' :: Monoid m => (a -> m) -> Alt f a -> m Source # foldr :: (a -> b -> b) -> b -> Alt f a -> b Source # foldr' :: (a -> b -> b) -> b -> Alt f a -> b Source # foldl :: (b -> a -> b) -> b -> Alt f a -> b Source # foldl' :: (b -> a -> b) -> b -> Alt f a -> b Source # foldr1 :: (a -> a -> a) -> Alt f a -> a Source # foldl1 :: (a -> a -> a) -> Alt f a -> a Source # toList :: Alt f a -> [a] Source # null :: Alt f a -> Bool Source # length :: Alt f a -> Int Source # elem :: Eq a => a -> Alt f a -> Bool Source # maximum :: Ord a => Alt f a -> a Source # minimum :: Ord a => Alt f a -> a Source # | |
Foldable f => Foldable (Rec1 f) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => Rec1 f m -> m Source # foldMap :: Monoid m => (a -> m) -> Rec1 f a -> m Source # foldMap' :: Monoid m => (a -> m) -> Rec1 f a -> m Source # foldr :: (a -> b -> b) -> b -> Rec1 f a -> b Source # foldr' :: (a -> b -> b) -> b -> Rec1 f a -> b Source # foldl :: (b -> a -> b) -> b -> Rec1 f a -> b Source # foldl' :: (b -> a -> b) -> b -> Rec1 f a -> b Source # foldr1 :: (a -> a -> a) -> Rec1 f a -> a Source # foldl1 :: (a -> a -> a) -> Rec1 f a -> a Source # toList :: Rec1 f a -> [a] Source # null :: Rec1 f a -> Bool Source # length :: Rec1 f a -> Int Source # elem :: Eq a => a -> Rec1 f a -> Bool Source # maximum :: Ord a => Rec1 f a -> a Source # minimum :: Ord a => Rec1 f a -> a Source # | |
(Foldable f, Foldable g) => Foldable (Product f g) Source # | Since: base-4.9.0.0 |
Defined in Data.Functor.Product fold :: Monoid m => Product f g m -> m Source # foldMap :: Monoid m => (a -> m) -> Product f g a -> m Source # foldMap' :: Monoid m => (a -> m) -> Product f g a -> m Source # foldr :: (a -> b -> b) -> b -> Product f g a -> b Source # foldr' :: (a -> b -> b) -> b -> Product f g a -> b Source # foldl :: (b -> a -> b) -> b -> Product f g a -> b Source # foldl' :: (b -> a -> b) -> b -> Product f g a -> b Source # foldr1 :: (a -> a -> a) -> Product f g a -> a Source # foldl1 :: (a -> a -> a) -> Product f g a -> a Source # toList :: Product f g a -> [a] Source # null :: Product f g a -> Bool Source # length :: Product f g a -> Int Source # elem :: Eq a => a -> Product f g a -> Bool Source # maximum :: Ord a => Product f g a -> a Source # minimum :: Ord a => Product f g a -> a Source # | |
(Foldable f, Foldable g) => Foldable (Sum f g) Source # | Since: base-4.9.0.0 |
Defined in Data.Functor.Sum fold :: Monoid m => Sum f g m -> m Source # foldMap :: Monoid m => (a -> m) -> Sum f g a -> m Source # foldMap' :: Monoid m => (a -> m) -> Sum f g a -> m Source # foldr :: (a -> b -> b) -> b -> Sum f g a -> b Source # foldr' :: (a -> b -> b) -> b -> Sum f g a -> b Source # foldl :: (b -> a -> b) -> b -> Sum f g a -> b Source # foldl' :: (b -> a -> b) -> b -> Sum f g a -> b Source # foldr1 :: (a -> a -> a) -> Sum f g a -> a Source # foldl1 :: (a -> a -> a) -> Sum f g a -> a Source # toList :: Sum f g a -> [a] Source # null :: Sum f g a -> Bool Source # length :: Sum f g a -> Int Source # elem :: Eq a => a -> Sum f g a -> Bool Source # maximum :: Ord a => Sum f g a -> a Source # minimum :: Ord a => Sum f g a -> a Source # | |
(Foldable f, Foldable g) => Foldable (f :*: g) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => (f :*: g) m -> m Source # foldMap :: Monoid m => (a -> m) -> (f :*: g) a -> m Source # foldMap' :: Monoid m => (a -> m) -> (f :*: g) a -> m Source # foldr :: (a -> b -> b) -> b -> (f :*: g) a -> b Source # foldr' :: (a -> b -> b) -> b -> (f :*: g) a -> b Source # foldl :: (b -> a -> b) -> b -> (f :*: g) a -> b Source # foldl' :: (b -> a -> b) -> b -> (f :*: g) a -> b Source # foldr1 :: (a -> a -> a) -> (f :*: g) a -> a Source # foldl1 :: (a -> a -> a) -> (f :*: g) a -> a Source # toList :: (f :*: g) a -> [a] Source # null :: (f :*: g) a -> Bool Source # length :: (f :*: g) a -> Int Source # elem :: Eq a => a -> (f :*: g) a -> Bool Source # maximum :: Ord a => (f :*: g) a -> a Source # minimum :: Ord a => (f :*: g) a -> a Source # | |
(Foldable f, Foldable g) => Foldable (f :+: g) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => (f :+: g) m -> m Source # foldMap :: Monoid m => (a -> m) -> (f :+: g) a -> m Source # foldMap' :: Monoid m => (a -> m) -> (f :+: g) a -> m Source # foldr :: (a -> b -> b) -> b -> (f :+: g) a -> b Source # foldr' :: (a -> b -> b) -> b -> (f :+: g) a -> b Source # foldl :: (b -> a -> b) -> b -> (f :+: g) a -> b Source # foldl' :: (b -> a -> b) -> b -> (f :+: g) a -> b Source # foldr1 :: (a -> a -> a) -> (f :+: g) a -> a Source # foldl1 :: (a -> a -> a) -> (f :+: g) a -> a Source # toList :: (f :+: g) a -> [a] Source # null :: (f :+: g) a -> Bool Source # length :: (f :+: g) a -> Int Source # elem :: Eq a => a -> (f :+: g) a -> Bool Source # maximum :: Ord a => (f :+: g) a -> a Source # minimum :: Ord a => (f :+: g) a -> a Source # | |
Foldable (K1 i c :: Type -> Type) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => K1 i c m -> m Source # foldMap :: Monoid m => (a -> m) -> K1 i c a -> m Source # foldMap' :: Monoid m => (a -> m) -> K1 i c a -> m Source # foldr :: (a -> b -> b) -> b -> K1 i c a -> b Source # foldr' :: (a -> b -> b) -> b -> K1 i c a -> b Source # foldl :: (b -> a -> b) -> b -> K1 i c a -> b Source # foldl' :: (b -> a -> b) -> b -> K1 i c a -> b Source # foldr1 :: (a -> a -> a) -> K1 i c a -> a Source # foldl1 :: (a -> a -> a) -> K1 i c a -> a Source # toList :: K1 i c a -> [a] Source # null :: K1 i c a -> Bool Source # length :: K1 i c a -> Int Source # elem :: Eq a => a -> K1 i c a -> Bool Source # maximum :: Ord a => K1 i c a -> a Source # minimum :: Ord a => K1 i c a -> a Source # | |
(Foldable f, Foldable g) => Foldable (Compose f g) Source # | Since: base-4.9.0.0 |
Defined in Data.Functor.Compose fold :: Monoid m => Compose f g m -> m Source # foldMap :: Monoid m => (a -> m) -> Compose f g a -> m Source # foldMap' :: Monoid m => (a -> m) -> Compose f g a -> m Source # foldr :: (a -> b -> b) -> b -> Compose f g a -> b Source # foldr' :: (a -> b -> b) -> b -> Compose f g a -> b Source # foldl :: (b -> a -> b) -> b -> Compose f g a -> b Source # foldl' :: (b -> a -> b) -> b -> Compose f g a -> b Source # foldr1 :: (a -> a -> a) -> Compose f g a -> a Source # foldl1 :: (a -> a -> a) -> Compose f g a -> a Source # toList :: Compose f g a -> [a] Source # null :: Compose f g a -> Bool Source # length :: Compose f g a -> Int Source # elem :: Eq a => a -> Compose f g a -> Bool Source # maximum :: Ord a => Compose f g a -> a Source # minimum :: Ord a => Compose f g a -> a Source # | |
(Foldable f, Foldable g) => Foldable (f :.: g) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => (f :.: g) m -> m Source # foldMap :: Monoid m => (a -> m) -> (f :.: g) a -> m Source # foldMap' :: Monoid m => (a -> m) -> (f :.: g) a -> m Source # foldr :: (a -> b -> b) -> b -> (f :.: g) a -> b Source # foldr' :: (a -> b -> b) -> b -> (f :.: g) a -> b Source # foldl :: (b -> a -> b) -> b -> (f :.: g) a -> b Source # foldl' :: (b -> a -> b) -> b -> (f :.: g) a -> b Source # foldr1 :: (a -> a -> a) -> (f :.: g) a -> a Source # foldl1 :: (a -> a -> a) -> (f :.: g) a -> a Source # toList :: (f :.: g) a -> [a] Source # null :: (f :.: g) a -> Bool Source # length :: (f :.: g) a -> Int Source # elem :: Eq a => a -> (f :.: g) a -> Bool Source # maximum :: Ord a => (f :.: g) a -> a Source # minimum :: Ord a => (f :.: g) a -> a Source # | |
Foldable f => Foldable (M1 i c f) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => M1 i c f m -> m Source # foldMap :: Monoid m => (a -> m) -> M1 i c f a -> m Source # foldMap' :: Monoid m => (a -> m) -> M1 i c f a -> m Source # foldr :: (a -> b -> b) -> b -> M1 i c f a -> b Source # foldr' :: (a -> b -> b) -> b -> M1 i c f a -> b Source # foldl :: (b -> a -> b) -> b -> M1 i c f a -> b Source # foldl' :: (b -> a -> b) -> b -> M1 i c f a -> b Source # foldr1 :: (a -> a -> a) -> M1 i c f a -> a Source # foldl1 :: (a -> a -> a) -> M1 i c f a -> a Source # toList :: M1 i c f a -> [a] Source # null :: M1 i c f a -> Bool Source # length :: M1 i c f a -> Int Source # elem :: Eq a => a -> M1 i c f a -> Bool Source # maximum :: Ord a => M1 i c f a -> a Source # minimum :: Ord a => M1 i c f a -> a Source # |
class (Functor t, Foldable t) => Traversable (t :: Type -> Type) where Source #
Functors representing data structures that can be transformed to
structures of the same shape by performing an Applicative
(or,
therefore, Monad
) action on each element from left to right.
A more detailed description of what same shape means, the various methods, how traversals are constructed, and example advanced use-cases can be found in the Overview section of Data.Traversable.
For the class laws see the Laws section of Data.Traversable.
traverse :: Applicative f => (a -> f b) -> t a -> f (t b) Source #
Map each element of a structure to an action, evaluate these actions
from left to right, and collect the results. For a version that ignores
the results see traverse_
.
Examples
Basic usage:
In the first two examples we show each evaluated action mapping to the output structure.
>>>
traverse Just [1,2,3,4]
Just [1,2,3,4]
>>>
traverse id [Right 1, Right 2, Right 3, Right 4]
Right [1,2,3,4]
In the next examples, we show that Nothing
and Left
values short
circuit the created structure.
>>>
traverse (const Nothing) [1,2,3,4]
Nothing
>>>
traverse (\x -> if odd x then Just x else Nothing) [1,2,3,4]
Nothing
>>>
traverse id [Right 1, Right 2, Right 3, Right 4, Left 0]
Left 0
sequenceA :: Applicative f => t (f a) -> f (t a) Source #
Evaluate each action in the structure from left to right, and
collect the results. For a version that ignores the results
see sequenceA_
.
Examples
Basic usage:
For the first two examples we show sequenceA fully evaluating a a structure and collecting the results.
>>>
sequenceA [Just 1, Just 2, Just 3]
Just [1,2,3]
>>>
sequenceA [Right 1, Right 2, Right 3]
Right [1,2,3]
The next two example show Nothing
and Just
will short circuit
the resulting structure if present in the input. For more context,
check the Traversable
instances for Either
and Maybe
.
>>>
sequenceA [Just 1, Just 2, Just 3, Nothing]
Nothing
>>>
sequenceA [Right 1, Right 2, Right 3, Left 4]
Left 4
mapM :: Monad m => (a -> m b) -> t a -> m (t b) Source #
Map each element of a structure to a monadic action, evaluate
these actions from left to right, and collect the results. For
a version that ignores the results see mapM_
.
Examples
sequence :: Monad m => t (m a) -> m (t a) Source #
Evaluate each monadic action in the structure from left to
right, and collect the results. For a version that ignores the
results see sequence_
.
Examples
Basic usage:
The first two examples are instances where the input and
and output of sequence
are isomorphic.
>>>
sequence $ Right [1,2,3,4]
[Right 1,Right 2,Right 3,Right 4]
>>>
sequence $ [Right 1,Right 2,Right 3,Right 4]
Right [1,2,3,4]
The following examples demonstrate short circuit behavior
for sequence
.
>>>
sequence $ Left [1,2,3,4]
Left [1,2,3,4]
>>>
sequence $ [Left 0, Right 1,Right 2,Right 3,Right 4]
Left 0
Instances
Traversable Complex Source # | Since: base-4.9.0.0 |
Defined in Data.Complex | |
Traversable First Source # | Since: base-4.9.0.0 |
Traversable Last Source # | Since: base-4.9.0.0 |
Traversable Max Source # | Since: base-4.9.0.0 |
Traversable Min Source # | Since: base-4.9.0.0 |
Traversable NonEmpty Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Traversable | |
Traversable Identity Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Traversable | |
Traversable First Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.Data.Traversable | |
Traversable Last Source # | Since: base-4.8.0.0 |
Traversable Down Source # | Since: base-4.12.0.0 |
Traversable Dual Source # | Since: base-4.8.0.0 |
Traversable Product Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.Data.Traversable | |
Traversable Sum Source # | Since: base-4.8.0.0 |
Traversable ZipList Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Functor.ZipList | |
Traversable Par1 Source # | Since: base-4.9.0.0 |
Traversable TyVarBndr Source # | |
Defined in GHC.Internal.TH.Syntax | |
Traversable Maybe Source # | Since: base-2.1 |
Defined in GHC.Internal.Data.Traversable | |
Traversable Solo Source # | Since: base-4.15 |
Traversable [] Source # | Since: base-2.1 |
Traversable (Arg a) Source # | Since: base-4.9.0.0 |
Ix i => Traversable (Array i) Source # | Since: base-2.1 |
Defined in GHC.Internal.Data.Traversable | |
Traversable (Either a) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Data.Traversable | |
Traversable (Proxy :: Type -> Type) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Data.Traversable | |
Traversable (U1 :: Type -> Type) Source # | Since: base-4.9.0.0 |
Traversable (UAddr :: Type -> Type) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Traversable | |
Traversable (UChar :: Type -> Type) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Traversable | |
Traversable (UDouble :: Type -> Type) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Traversable | |
Traversable (UFloat :: Type -> Type) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Traversable | |
Traversable (UInt :: Type -> Type) Source # | Since: base-4.9.0.0 |
Traversable (UWord :: Type -> Type) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Traversable | |
Traversable (V1 :: Type -> Type) Source # | Since: base-4.9.0.0 |
Traversable ((,) a) Source # | Since: base-4.7.0.0 |
Traversable (Const m :: Type -> Type) Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Data.Traversable | |
Traversable f => Traversable (Ap f) Source # | Since: base-4.12.0.0 |
Defined in GHC.Internal.Data.Traversable | |
Traversable f => Traversable (Alt f) Source # | Since: base-4.12.0.0 |
Defined in GHC.Internal.Data.Traversable | |
Traversable f => Traversable (Rec1 f) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Traversable | |
(Traversable f, Traversable g) => Traversable (Product f g) Source # | Since: base-4.9.0.0 |
Defined in Data.Functor.Product traverse :: Applicative f0 => (a -> f0 b) -> Product f g a -> f0 (Product f g b) Source # sequenceA :: Applicative f0 => Product f g (f0 a) -> f0 (Product f g a) Source # mapM :: Monad m => (a -> m b) -> Product f g a -> m (Product f g b) Source # sequence :: Monad m => Product f g (m a) -> m (Product f g a) Source # | |
(Traversable f, Traversable g) => Traversable (Sum f g) Source # | Since: base-4.9.0.0 |
Defined in Data.Functor.Sum | |
(Traversable f, Traversable g) => Traversable (f :*: g) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Traversable | |
(Traversable f, Traversable g) => Traversable (f :+: g) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Traversable | |
Traversable (K1 i c :: Type -> Type) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Traversable | |
(Traversable f, Traversable g) => Traversable (Compose f g) Source # | Since: base-4.9.0.0 |
Defined in Data.Functor.Compose traverse :: Applicative f0 => (a -> f0 b) -> Compose f g a -> f0 (Compose f g b) Source # sequenceA :: Applicative f0 => Compose f g (f0 a) -> f0 (Compose f g a) Source # mapM :: Monad m => (a -> m b) -> Compose f g a -> m (Compose f g b) Source # sequence :: Monad m => Compose f g (m a) -> m (Compose f g a) Source # | |
(Traversable f, Traversable g) => Traversable (f :.: g) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Traversable | |
Traversable f => Traversable (M1 i c f) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Traversable |
Miscellaneous functions
Identity function.
id x = x
This function might seem useless at first glance, but it can be very useful in a higher order context.
Examples
>>>
length $ filter id [True, True, False, True]
3
>>>
Just (Just 3) >>= id
Just 3
>>>
foldr id 0 [(^3), (*5), (+2)]
1000
const x y
always evaluates to x
, ignoring its second argument.
const x = \_ -> x
This function might seem useless at first glance, but it can be very useful in a higher order context.
Examples
>>>
const 42 "hello"
42
>>>
map (const 42) [0..3]
[42,42,42,42]
(.) :: (b -> c) -> (a -> b) -> a -> c infixr 9 Source #
Right to left function composition.
(f . g) x = f (g x)
f . id = f = id . f
Examples
>>>
map ((*2) . length) [[], [0, 1, 2], [0]]
[0,6,2]
>>>
foldr (.) id [(+1), (*3), (^3)] 2
25
>>>
let (...) = (.).(.) in ((*2)...(+)) 5 10
30
flip :: (a -> b -> c) -> b -> a -> c Source #
takes its (first) two arguments in the reverse order of flip
ff
.
flip f x y = f y x
flip . flip = id
Examples
>>>
flip (++) "hello" "world"
"worldhello"
>>>
let (.>) = flip (.) in (+1) .> show $ 5
"6"
($) :: (a -> b) -> a -> b infixr 0 Source #
is the function application operator.($)
Applying
to a function ($)
f
and an argument x
gives the same result as applying f
to x
directly. The definition is akin to this:
($) :: (a -> b) -> a -> b ($) f x = f x
This is
specialized from id
a -> a
to (a -> b) -> (a -> b)
which by the associativity of (->)
is the same as (a -> b) -> a -> b
.
On the face of it, this may appear pointless! But it's actually one of the most useful and important operators in Haskell.
The order of operations is very different between ($)
and normal function application. Normal function application has precedence 10 - higher than any operator - and associates to the left. So these two definitions are equivalent:
expr = min 5 1 + 5 expr = ((min 5) 1) + 5
($)
has precedence 0 (the lowest) and associates to the right, so these are equivalent:
expr = min 5 $ 1 + 5 expr = (min 5) (1 + 5)
Examples
A common use cases of ($)
is to avoid parentheses in complex expressions.
For example, instead of using nested parentheses in the following Haskell function:
-- | Sum numbers in a string: strSum "100 5 -7" == 98 strSum ::String
->Int
strSum s =sum
(mapMaybe
readMaybe
(words
s))
we can deploy the function application operator:
-- | Sum numbers in a string: strSum "100 5 -7" == 98 strSum ::String
->Int
strSum s =sum
$
mapMaybe
readMaybe
$
words
s
($)
is also used as a section (a partially applied operator), in order to indicate that we wish to apply some yet-unspecified function to a given value. For example, to apply the argument 5
to a list of functions:
applyFive :: [Int] applyFive = map ($ 5) [(+1), (2^)] >>> [6, 32]
Technical Remark (Representation Polymorphism)
($)
is fully representation-polymorphic. This allows it to also be used with arguments of unlifted and even unboxed kinds, such as unboxed integers:
fastMod :: Int -> Int -> Int fastMod (I# x) (I# m) = I# $ remInt# x m
until :: (a -> Bool) -> (a -> a) -> a -> a Source #
yields the result of applying until
p ff
until p
holds.
errorWithoutStackTrace :: [Char] -> a Source #
A variant of error
that does not produce a stack trace.
Since: base-4.9.0.0
undefined :: HasCallStack => a Source #
seq :: a -> b -> b infixr 0 Source #
The value of
is bottom if seq
a ba
is bottom, and
otherwise equal to b
. In other words, it evaluates the first
argument a
to weak head normal form (WHNF). seq
is usually
introduced to improve performance by avoiding unneeded laziness.
A note on evaluation order: the expression
does
not guarantee that seq
a ba
will be evaluated before b
.
The only guarantee given by seq
is that the both a
and b
will be evaluated before seq
returns a value.
In particular, this means that b
may be evaluated before
a
. If you need to guarantee a specific order of evaluation,
you must use the function pseq
from the "parallel" package.
($!) :: (a -> b) -> a -> b infixr 0 Source #
Strict (call-by-value) application operator. It takes a function and an argument, evaluates the argument to weak head normal form (WHNF), then calls the function with that value.
List operations
map :: (a -> b) -> [a] -> [b] Source #
\(\mathcal{O}(n)\). map
f xs
is the list obtained by applying f
to
each element of xs
, i.e.,
map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn] map f [x1, x2, ...] == [f x1, f x2, ...]
this means that map id == id
Examples
>>>
map (+1) [1, 2, 3]
[2,3,4]
>>>
map id [1, 2, 3]
[1,2,3]
>>>
map (\n -> 3 * n + 1) [1, 2, 3]
[4,7,10]
(++) :: [a] -> [a] -> [a] infixr 5 Source #
(++)
appends two lists, i.e.,
[x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn] [x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]
If the first list is not finite, the result is the first list.
Performance considerations
This function takes linear time in the number of elements of the
first list. Thus it is better to associate repeated
applications of (++)
to the right (which is the default behaviour):
xs ++ (ys ++ zs)
or simply xs ++ ys ++ zs
, but not (xs ++ ys) ++ zs
.
For the same reason concat
=
foldr
(++)
[]
has linear performance, while foldl
(++)
[]
is prone
to quadratic slowdown
Examples
>>>
[1, 2, 3] ++ [4, 5, 6]
[1,2,3,4,5,6]
>>>
[] ++ [1, 2, 3]
[1,2,3]
>>>
[3, 2, 1] ++ []
[3,2,1]
filter :: (a -> Bool) -> [a] -> [a] Source #
\(\mathcal{O}(n)\). filter
, applied to a predicate and a list, returns
the list of those elements that satisfy the predicate; i.e.,
filter p xs = [ x | x <- xs, p x]
Examples
>>>
filter odd [1, 2, 3]
[1,3]
>>>
filter (\l -> length l > 3) ["Hello", ", ", "World", "!"]
["Hello","World"]
>>>
filter (/= 3) [1, 2, 3, 4, 3, 2, 1]
[1,2,4,2,1]
head :: HasCallStack => [a] -> a Source #
Warning: This is a partial function, it throws an error on empty lists. Use pattern matching, uncons
or listToMaybe
instead. Consider refactoring to use Data.List.NonEmpty.
\(\mathcal{O}(1)\). Extract the first element of a list, which must be non-empty.
To disable the warning about partiality put {-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}
at the top of the file. To disable it throughout a package put the same
options into ghc-options
section of Cabal file. To disable it in GHCi
put :set -Wno-x-partial -Wno-unrecognised-warning-flags
into ~/.ghci
config file.
See also the migration guide.
Examples
>>>
head [1, 2, 3]
1
>>>
head [1..]
1
>>>
head []
*** Exception: Prelude.head: empty list
last :: HasCallStack => [a] -> a Source #
\(\mathcal{O}(n)\). Extract the last element of a list, which must be finite and non-empty.
WARNING: This function is partial. Consider using unsnoc
instead.
Examples
>>>
last [1, 2, 3]
3
>>>
last [1..]
* Hangs forever *
>>>
last []
*** Exception: Prelude.last: empty list
tail :: HasCallStack => [a] -> [a] Source #
Warning: This is a partial function, it throws an error on empty lists. Replace it with drop
1, or use pattern matching or uncons
instead. Consider refactoring to use Data.List.NonEmpty.
\(\mathcal{O}(1)\). Extract the elements after the head of a list, which must be non-empty.
To disable the warning about partiality put {-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}
at the top of the file. To disable it throughout a package put the same
options into ghc-options
section of Cabal file. To disable it in GHCi
put :set -Wno-x-partial -Wno-unrecognised-warning-flags
into ~/.ghci
config file.
See also the migration guide.
Examples
>>>
tail [1, 2, 3]
[2,3]
>>>
tail [1]
[]
>>>
tail []
*** Exception: Prelude.tail: empty list
init :: HasCallStack => [a] -> [a] Source #
\(\mathcal{O}(n)\). Return all the elements of a list except the last one. The list must be non-empty.
WARNING: This function is partial. Consider using unsnoc
instead.
Examples
>>>
init [1, 2, 3]
[1,2]
>>>
init [1]
[]
>>>
init []
*** Exception: Prelude.init: empty list
(!!) :: HasCallStack => [a] -> Int -> a infixl 9 Source #
List index (subscript) operator, starting from 0.
It is an instance of the more general genericIndex
,
which takes an index of any integral type.
WARNING: This function is partial, and should only be used if you are
sure that the indexing will not fail. Otherwise, use !?
.
WARNING: This function takes linear time in the index.
Examples
>>>
['a', 'b', 'c'] !! 0
'a'
>>>
['a', 'b', 'c'] !! 2
'c'
>>>
['a', 'b', 'c'] !! 3
*** Exception: Prelude.!!: index too large
>>>
['a', 'b', 'c'] !! (-1)
*** Exception: Prelude.!!: negative index
null :: Foldable t => t a -> Bool Source #
Test whether the structure is empty. The default implementation is Left-associative and lazy in both the initial element and the accumulator. Thus optimised for structures where the first element can be accessed in constant time. Structures where this is not the case should have a non-default implementation.
Examples
Basic usage:
>>>
null []
True
>>>
null [1]
False
null
is expected to terminate even for infinite structures.
The default implementation terminates provided the structure
is bounded on the left (there is a leftmost element).
>>>
null [1..]
False
Since: base-4.8.0.0
length :: Foldable t => t a -> Int Source #
Returns the size/length of a finite structure as an Int
. The
default implementation just counts elements starting with the leftmost.
Instances for structures that can compute the element count faster
than via element-by-element counting, should provide a specialised
implementation.
Examples
Basic usage:
>>>
length []
0
>>>
length ['a', 'b', 'c']
3>>>
length [1..]
* Hangs forever *
Since: base-4.8.0.0
reverse :: [a] -> [a] Source #
\(\mathcal{O}(n)\). reverse
xs
returns the elements of xs
in reverse order.
xs
must be finite.
Laziness
reverse
is lazy in its elements.
>>>
head (reverse [undefined, 1])
1
>>>
reverse (1 : 2 : undefined)
*** Exception: Prelude.undefined
Examples
>>>
reverse []
[]
>>>
reverse [42]
[42]
>>>
reverse [2,5,7]
[7,5,2]
>>>
reverse [1..]
* Hangs forever *
Special folds
and :: Foldable t => t Bool -> Bool Source #
and
returns the conjunction of a container of Bools. For the
result to be True
, the container must be finite; False
, however,
results from a False
value finitely far from the left end.
Examples
Basic usage:
>>>
and []
True
>>>
and [True]
True
>>>
and [False]
False
>>>
and [True, True, False]
False
>>>
and (False : repeat True) -- Infinite list [False,True,True,True,...
False
>>>
and (repeat True)
* Hangs forever *
or :: Foldable t => t Bool -> Bool Source #
or
returns the disjunction of a container of Bools. For the
result to be False
, the container must be finite; True
, however,
results from a True
value finitely far from the left end.
Examples
Basic usage:
>>>
or []
False
>>>
or [True]
True
>>>
or [False]
False
>>>
or [True, True, False]
True
>>>
or (True : repeat False) -- Infinite list [True,False,False,False,...
True
>>>
or (repeat False)
* Hangs forever *
any :: Foldable t => (a -> Bool) -> t a -> Bool Source #
Determines whether any element of the structure satisfies the predicate.
Examples
Basic usage:
>>>
any (> 3) []
False
>>>
any (> 3) [1,2]
False
>>>
any (> 3) [1,2,3,4,5]
True
>>>
any (> 3) [1..]
True
>>>
any (> 3) [0, -1..]
* Hangs forever *
all :: Foldable t => (a -> Bool) -> t a -> Bool Source #
Determines whether all elements of the structure satisfy the predicate.
Examples
Basic usage:
>>>
all (> 3) []
True
>>>
all (> 3) [1,2]
False
>>>
all (> 3) [1,2,3,4,5]
False
>>>
all (> 3) [1..]
False
>>>
all (> 3) [4..]
* Hangs forever *
concat :: Foldable t => t [a] -> [a] Source #
The concatenation of all the elements of a container of lists.
Examples
Basic usage:
>>>
concat (Just [1, 2, 3])
[1,2,3]
>>>
concat (Left 42)
[]
>>>
concat [[1, 2, 3], [4, 5], [6], []]
[1,2,3,4,5,6]
concatMap :: Foldable t => (a -> [b]) -> t a -> [b] Source #
Map a function over all the elements of a container and concatenate the resulting lists.
Examples
Basic usage:
>>>
concatMap (take 3) [[1..], [10..], [100..], [1000..]]
[1,2,3,10,11,12,100,101,102,1000,1001,1002]
>>>
concatMap (take 3) (Just [1..])
[1,2,3]
Building lists
Scans
scanl :: (b -> a -> b) -> b -> [a] -> [b] Source #
\(\mathcal{O}(n)\). scanl
is similar to foldl
, but returns a list of
successive reduced values from the left:
scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
Note that
last (scanl f z xs) == foldl f z xs
Examples
>>>
scanl (+) 0 [1..4]
[0,1,3,6,10]
>>>
scanl (+) 42 []
[42]
>>>
scanl (-) 100 [1..4]
[100,99,97,94,90]
>>>
scanl (\reversedString nextChar -> nextChar : reversedString) "foo" ['a', 'b', 'c', 'd']
["foo","afoo","bafoo","cbafoo","dcbafoo"]
>>>
take 10 (scanl (+) 0 [1..])
[0,1,3,6,10,15,21,28,36,45]
>>>
take 1 (scanl undefined 'a' undefined)
"a"
scanl1 :: (a -> a -> a) -> [a] -> [a] Source #
\(\mathcal{O}(n)\). scanl1
is a variant of scanl
that has no starting
value argument:
scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
Examples
>>>
scanl1 (+) [1..4]
[1,3,6,10]
>>>
scanl1 (+) []
[]
>>>
scanl1 (-) [1..4]
[1,-1,-4,-8]
>>>
scanl1 (&&) [True, False, True, True]
[True,False,False,False]
>>>
scanl1 (||) [False, False, True, True]
[False,False,True,True]
>>>
take 10 (scanl1 (+) [1..])
[1,3,6,10,15,21,28,36,45,55]
>>>
take 1 (scanl1 undefined ('a' : undefined))
"a"
scanr :: (a -> b -> b) -> b -> [a] -> [b] Source #
\(\mathcal{O}(n)\). scanr
is the right-to-left dual of scanl
. Note that the order of parameters on the accumulating function are reversed compared to scanl
.
Also note that
head (scanr f z xs) == foldr f z xs.
Examples
>>>
scanr (+) 0 [1..4]
[10,9,7,4,0]
>>>
scanr (+) 42 []
[42]
>>>
scanr (-) 100 [1..4]
[98,-97,99,-96,100]
>>>
scanr (\nextChar reversedString -> nextChar : reversedString) "foo" ['a', 'b', 'c', 'd']
["abcdfoo","bcdfoo","cdfoo","dfoo","foo"]
>>>
force $ scanr (+) 0 [1..]
*** Exception: stack overflow
scanr1 :: (a -> a -> a) -> [a] -> [a] Source #
\(\mathcal{O}(n)\). scanr1
is a variant of scanr
that has no starting
value argument.
Examples
>>>
scanr1 (+) [1..4]
[10,9,7,4]
>>>
scanr1 (+) []
[]
>>>
scanr1 (-) [1..4]
[-2,3,-1,4]
>>>
scanr1 (&&) [True, False, True, True]
[False,False,True,True]
>>>
scanr1 (||) [True, True, False, False]
[True,True,False,False]
>>>
force $ scanr1 (+) [1..]
*** Exception: stack overflow
Infinite lists
iterate :: (a -> a) -> a -> [a] Source #
iterate
f x
returns an infinite list of repeated applications
of f
to x
:
iterate f x == [x, f x, f (f x), ...]
Laziness
Note that iterate
is lazy, potentially leading to thunk build-up if
the consumer doesn't force each iterate. See iterate'
for a strict
variant of this function.
>>>
take 1 $ iterate undefined 42
[42]
Examples
>>>
take 10 $ iterate not True
[True,False,True,False,True,False,True,False,True,False]
>>>
take 10 $ iterate (+3) 42
[42,45,48,51,54,57,60,63,66,69]
iterate id ==
:repeat
>>>
take 10 $ iterate id 1
[1,1,1,1,1,1,1,1,1,1]
repeat
x
is an infinite list, with x
the value of every element.
Examples
>>>
take 10 $ repeat 17
[17,17,17,17,17,17,17,17,17, 17]
>>>
repeat undefined
[*** Exception: Prelude.undefined
replicate :: Int -> a -> [a] Source #
replicate
n x
is a list of length n
with x
the value of
every element.
It is an instance of the more general genericReplicate
,
in which n
may be of any integral type.
Examples
>>>
replicate 0 True
[]
>>>
replicate (-1) True
[]
>>>
replicate 4 True
[True,True,True,True]
cycle :: HasCallStack => [a] -> [a] Source #
cycle
ties a finite list into a circular one, or equivalently,
the infinite repetition of the original list. It is the identity
on infinite lists.
Examples
>>>
cycle []
*** Exception: Prelude.cycle: empty list
>>>
take 10 (cycle [42])
[42,42,42,42,42,42,42,42,42,42]
>>>
take 10 (cycle [2, 5, 7])
[2,5,7,2,5,7,2,5,7,2]
>>>
take 1 (cycle (42 : undefined))
[42]
Sublists
take :: Int -> [a] -> [a] Source #
take
n
, applied to a list xs
, returns the prefix of xs
of length n
, or xs
itself if n >=
.length
xs
It is an instance of the more general genericTake
,
in which n
may be of any integral type.
Laziness
>>>
take 0 undefined
[]>>>
take 2 (1 : 2 : undefined)
[1,2]
Examples
>>>
take 5 "Hello World!"
"Hello"
>>>
take 3 [1,2,3,4,5]
[1,2,3]
>>>
take 3 [1,2]
[1,2]
>>>
take 3 []
[]
>>>
take (-1) [1,2]
[]
>>>
take 0 [1,2]
[]
drop :: Int -> [a] -> [a] Source #
drop
n xs
returns the suffix of xs
after the first n
elements, or []
if n >=
.length
xs
It is an instance of the more general genericDrop
,
in which n
may be of any integral type.
Examples
>>>
drop 6 "Hello World!"
"World!"
>>>
drop 3 [1,2,3,4,5]
[4,5]
>>>
drop 3 [1,2]
[]
>>>
drop 3 []
[]
>>>
drop (-1) [1,2]
[1,2]
>>>
drop 0 [1,2]
[1,2]
takeWhile :: (a -> Bool) -> [a] -> [a] Source #
takeWhile
, applied to a predicate p
and a list xs
, returns the
longest prefix (possibly empty) of xs
of elements that satisfy p
.
Laziness
>>>
takeWhile (const False) undefined
*** Exception: Prelude.undefined
>>>
takeWhile (const False) (undefined : undefined)
[]
>>>
take 1 (takeWhile (const True) (1 : undefined))
[1]
Examples
>>>
takeWhile (< 3) [1,2,3,4,1,2,3,4]
[1,2]
>>>
takeWhile (< 9) [1,2,3]
[1,2,3]
>>>
takeWhile (< 0) [1,2,3]
[]
span :: (a -> Bool) -> [a] -> ([a], [a]) Source #
span
, applied to a predicate p
and a list xs
, returns a tuple where
first element is the longest prefix (possibly empty) of xs
of elements that
satisfy p
and second element is the remainder of the list:
span
p xs
is equivalent to (
, even if takeWhile
p xs, dropWhile
p xs)p
is _|_
.
Laziness
>>>
span undefined []
([],[])>>>
fst (span (const False) undefined)
*** Exception: Prelude.undefined>>>
fst (span (const False) (undefined : undefined))
[]>>>
take 1 (fst (span (const True) (1 : undefined)))
[1]
span
produces the first component of the tuple lazily:
>>>
take 10 (fst (span (const True) [1..]))
[1,2,3,4,5,6,7,8,9,10]
Examples
>>>
span (< 3) [1,2,3,4,1,2,3,4]
([1,2],[3,4,1,2,3,4])
>>>
span (< 9) [1,2,3]
([1,2,3],[])
>>>
span (< 0) [1,2,3]
([],[1,2,3])
break :: (a -> Bool) -> [a] -> ([a], [a]) Source #
break
, applied to a predicate p
and a list xs
, returns a tuple where
first element is longest prefix (possibly empty) of xs
of elements that
do not satisfy p
and second element is the remainder of the list:
break
p
is equivalent to
and consequently to span
(not
. p)(
,
even if takeWhile
(not
. p) xs, dropWhile
(not
. p) xs)p
is _|_
.
Laziness
>>>
break undefined []
([],[])
>>>
fst (break (const True) undefined)
*** Exception: Prelude.undefined
>>>
fst (break (const True) (undefined : undefined))
[]
>>>
take 1 (fst (break (const False) (1 : undefined)))
[1]
break
produces the first component of the tuple lazily:
>>>
take 10 (fst (break (const False) [1..]))
[1,2,3,4,5,6,7,8,9,10]
Examples
>>>
break (> 3) [1,2,3,4,1,2,3,4]
([1,2,3],[4,1,2,3,4])
>>>
break (< 9) [1,2,3]
([],[1,2,3])
>>>
break (> 9) [1,2,3]
([1,2,3],[])
splitAt :: Int -> [a] -> ([a], [a]) Source #
splitAt
n xs
returns a tuple where first element is xs
prefix of
length n
and second element is the remainder of the list:
splitAt
is an instance of the more general genericSplitAt
,
in which n
may be of any integral type.
Laziness
It is equivalent to (
unless take
n xs, drop
n xs)n
is _|_
:
splitAt _|_ xs = _|_
, not (_|_, _|_)
).
The first component of the tuple is produced lazily:
>>>
fst (splitAt 0 undefined)
[]
>>>
take 1 (fst (splitAt 10 (1 : undefined)))
[1]
Examples
>>>
splitAt 6 "Hello World!"
("Hello ","World!")
>>>
splitAt 3 [1,2,3,4,5]
([1,2,3],[4,5])
>>>
splitAt 1 [1,2,3]
([1],[2,3])
>>>
splitAt 3 [1,2,3]
([1,2,3],[])
>>>
splitAt 4 [1,2,3]
([1,2,3],[])
>>>
splitAt 0 [1,2,3]
([],[1,2,3])
>>>
splitAt (-1) [1,2,3]
([],[1,2,3])
Searching lists
notElem :: (Foldable t, Eq a) => a -> t a -> Bool infix 4 Source #
notElem
is the negation of elem
.
Examples
Basic usage:
>>>
3 `notElem` []
True
>>>
3 `notElem` [1,2]
True
>>>
3 `notElem` [1,2,3,4,5]
False
For infinite structures, notElem
terminates if the value exists at a
finite distance from the left side of the structure:
>>>
3 `notElem` [1..]
False
>>>
3 `notElem` ([4..] ++ [3])
* Hangs forever *
Zipping and unzipping lists
zip :: [a] -> [b] -> [(a, b)] Source #
\(\mathcal{O}(\min(m,n))\). zip
takes two lists and returns a list of
corresponding pairs.
zip
is right-lazy:
>>>
zip [] undefined
[]>>>
zip undefined []
*** Exception: Prelude.undefined ...
zip
is capable of list fusion, but it is restricted to its
first list argument and its resulting list.
Examples
>>>
zip [1, 2, 3] ['a', 'b', 'c']
[(1,'a'),(2,'b'),(3,'c')]
If one input list is shorter than the other, excess elements of the longer list are discarded, even if one of the lists is infinite:
>>>
zip [1] ['a', 'b']
[(1,'a')]
>>>
zip [1, 2] ['a']
[(1,'a')]
>>>
zip [] [1..]
[]
>>>
zip [1..] []
[]
zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] Source #
\(\mathcal{O}(\min(m,n))\). zipWith
generalises zip
by zipping with the
function given as the first argument, instead of a tupling function.
zipWith (,) xs ys == zip xs ys zipWith f [x1,x2,x3..] [y1,y2,y3..] == [f x1 y1, f x2 y2, f x3 y3..]
zipWith
is right-lazy:
>>>
let f = undefined
>>>
zipWith f [] undefined
[]
zipWith
is capable of list fusion, but it is restricted to its
first list argument and its resulting list.
Examples
zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d] Source #
\(\mathcal{O}(\min(l,m,n))\). The zipWith3
function takes a function which combines three
elements, as well as three lists and returns a list of the function applied
to corresponding elements, analogous to zipWith
.
It is capable of list fusion, but it is restricted to its
first list argument and its resulting list.
zipWith3 (,,) xs ys zs == zip3 xs ys zs zipWith3 f [x1,x2,x3..] [y1,y2,y3..] [z1,z2,z3..] == [f x1 y1 z1, f x2 y2 z2, f x3 y3 z3..]
Examples
>>>
zipWith3 (\x y z -> [x, y, z]) "123" "abc" "xyz"
["1ax","2by","3cz"]
>>>
zipWith3 (\x y z -> (x * y) + z) [1, 2, 3] [4, 5, 6] [7, 8, 9]
[11,18,27]
unzip :: [(a, b)] -> ([a], [b]) Source #
unzip
transforms a list of pairs into a list of first components
and a list of second components.
Examples
>>>
unzip []
([],[])
>>>
unzip [(1, 'a'), (2, 'b')]
([1,2],"ab")
Functions on strings
lines :: String -> [String] Source #
Splits the argument into a list of lines stripped of their terminating
\n
characters. The \n
terminator is optional in a final non-empty
line of the argument string.
When the argument string is empty, or ends in a \n
character, it can be
recovered by passing the result of lines
to the unlines
function.
Otherwise, unlines
appends the missing terminating \n
. This makes
unlines . lines
idempotent:
(unlines . lines) . (unlines . lines) = (unlines . lines)
Examples
>>>
lines "" -- empty input contains no lines
[]
>>>
lines "\n" -- single empty line
[""]
>>>
lines "one" -- single unterminated line
["one"]
>>>
lines "one\n" -- single non-empty line
["one"]
>>>
lines "one\n\n" -- second line is empty
["one",""]
>>>
lines "one\ntwo" -- second line is unterminated
["one","two"]
>>>
lines "one\ntwo\n" -- two non-empty lines
["one","two"]
Converting to and from String
Converting to String
Conversion of values to readable String
s.
Derived instances of Show
have the following properties, which
are compatible with derived instances of Read
:
- The result of
show
is a syntactically correct Haskell expression containing only constants, given the fixity declarations in force at the point where the type is declared. It contains only the constructor names defined in the data type, parentheses, and spaces. When labelled constructor fields are used, braces, commas, field names, and equal signs are also used. - If the constructor is defined to be an infix operator, then
showsPrec
will produce infix applications of the constructor. - the representation will be enclosed in parentheses if the
precedence of the top-level constructor in
x
is less thand
(associativity is ignored). Thus, ifd
is0
then the result is never surrounded in parentheses; ifd
is11
it is always surrounded in parentheses, unless it is an atomic expression. - If the constructor is defined using record syntax, then
show
will produce the record-syntax form, with the fields given in the same order as the original declaration.
For example, given the declarations
infixr 5 :^: data Tree a = Leaf a | Tree a :^: Tree a
the derived instance of Show
is equivalent to
instance (Show a) => Show (Tree a) where showsPrec d (Leaf m) = showParen (d > app_prec) $ showString "Leaf " . showsPrec (app_prec+1) m where app_prec = 10 showsPrec d (u :^: v) = showParen (d > up_prec) $ showsPrec (up_prec+1) u . showString " :^: " . showsPrec (up_prec+1) v where up_prec = 5
Note that right-associativity of :^:
is ignored. For example,
produces the stringshow
(Leaf 1 :^: Leaf 2 :^: Leaf 3)"Leaf 1 :^: (Leaf 2 :^: Leaf 3)"
.
:: Int | the operator precedence of the enclosing
context (a number from |
-> a | the value to be converted to a |
-> ShowS |
Convert a value to a readable String
.
showsPrec
should satisfy the law
showsPrec d x r ++ s == showsPrec d x (r ++ s)
Derived instances of Read
and Show
satisfy the following:
That is, readsPrec
parses the string produced by
showsPrec
, and delivers the value that showsPrec
started with.
Instances
Show ByteArray Source # | Since: base-4.17.0.0 |
Show Timeout Source # | Since: base-4.0 |
Show Void Source # | Since: base-4.8.0.0 |
Show ByteOrder Source # | Since: base-4.11.0.0 |
Show ClosureType Source # | |
Defined in GHC.Internal.ClosureTypes | |
Show BlockReason Source # | Since: base-4.3.0.0 |
Defined in GHC.Internal.Conc.Sync | |
Show ThreadId Source # | Since: base-4.2.0.0 |
Show ThreadStatus Source # | Since: base-4.3.0.0 |
Defined in GHC.Internal.Conc.Sync | |
Show NestedAtomically Source # | Since: base-4.0 |
Defined in GHC.Internal.Control.Exception.Base | |
Show NoMatchingContinuationPrompt Source # | Since: base-4.18 |
Defined in GHC.Internal.Control.Exception.Base | |
Show NoMethodError Source # | Since: base-4.0 |
Defined in GHC.Internal.Control.Exception.Base | |
Show NonTermination Source # | Since: base-4.0 |
Defined in GHC.Internal.Control.Exception.Base | |
Show PatternMatchFail Source # | Since: base-4.0 |
Defined in GHC.Internal.Control.Exception.Base | |
Show RecConError Source # | Since: base-4.0 |
Defined in GHC.Internal.Control.Exception.Base | |
Show RecSelError Source # | Since: base-4.0 |
Defined in GHC.Internal.Control.Exception.Base | |
Show RecUpdError Source # | Since: base-4.0 |
Defined in GHC.Internal.Control.Exception.Base | |
Show TypeError Source # | Since: base-4.9.0.0 |
Show Constr Source # | Since: base-4.0.0.0 |
Show ConstrRep Source # | Since: base-4.0.0.0 |
Show DataRep Source # | Since: base-4.0.0.0 |
Show DataType Source # | Since: base-4.0.0.0 |
Show Fixity Source # | Since: base-4.0.0.0 |
Show Dynamic Source # | Since: base-2.1 |
Show All Source # | Since: base-2.1 |
Show Any Source # | Since: base-2.1 |
Show SomeTypeRep Source # | Since: base-4.10.0.0 |
Defined in GHC.Internal.Data.Typeable.Internal | |
Show Version Source # | Since: base-2.1 |
Show ControlMessage Source # | Since: base-4.4.0.0 |
Show Event Source # | Since: base-4.4.0.0 |
Show EventLifetime Source # | Since: base-4.8.0.0 |
Show Lifetime Source # | Since: base-4.8.1.0 |
Show Timeout Source # | Since: base-4.4.0.0 |
Show FdKey Source # | Since: base-4.4.0.0 |
Show State Source # | Since: base-4.4.0.0 |
Show State Source # | Since: base-4.7.0.0 |
Show Unique Source # | Since: base-4.3.1.0 |
Show ErrorCall Source # | Since: base-4.0.0.0 |
Show ArithException Source # | Since: base-4.0.0.0 |
Defined in GHC.Internal.Exception.Type | |
Show SomeException Source # | Since: ghc-internal-3.0 |
Defined in GHC.Internal.Exception.Type | |
Show WhileHandling Source # | |
Defined in GHC.Internal.Exception.Type | |
Show Fingerprint Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.Fingerprint.Type | |
Show CBool Source # | |
Show CChar Source # | |
Show CClock Source # | |
Show CDouble Source # | |
Show CFloat Source # | |
Show CInt Source # | |
Show CIntMax Source # | |
Show CIntPtr Source # | |
Show CLLong Source # | |
Show CLong Source # | |
Show CPtrdiff Source # | |
Show CSChar Source # | |
Show CSUSeconds Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Show CShort Source # | |
Show CSigAtomic Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Show CSize Source # | |
Show CTime Source # | |
Show CUChar Source # | |
Show CUInt Source # | |
Show CUIntMax Source # | |
Show CUIntPtr Source # | |
Show CULLong Source # | |
Show CULong Source # | |
Show CUSeconds Source # | |
Show CUShort Source # | |
Show CWchar Source # | |
Show IntPtr Source # | |
Show WordPtr Source # | |
Show ForeignSrcLang Source # | |
Defined in GHC.Internal.ForeignSrcLang | |
Show Associativity Source # | Since: base-4.6.0.0 |
Defined in GHC.Internal.Generics | |
Show DecidedStrictness Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics | |
Show Fixity Source # | Since: base-4.6.0.0 |
Show SourceStrictness Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics | |
Show SourceUnpackedness Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics | |
Show MaskingState Source # | Since: base-4.3.0.0 |
Defined in GHC.Internal.IO | |
Show SeekMode Source # | Since: base-4.2.0.0 |
Show CodingFailureMode Source # | Since: base-4.4.0.0 |
Defined in GHC.Internal.IO.Encoding.Failure | |
Show CodingProgress Source # | Since: base-4.4.0.0 |
Defined in GHC.Internal.IO.Encoding.Types | |
Show TextEncoding Source # | Since: base-4.3.0.0 |
Defined in GHC.Internal.IO.Encoding.Types | |
Show AllocationLimitExceeded Source # | Since: base-4.7.1.0 |
Defined in GHC.Internal.IO.Exception | |
Show ArrayException Source # | Since: base-4.1.0.0 |
Defined in GHC.Internal.IO.Exception | |
Show AssertionFailed Source # | Since: base-4.1.0.0 |
Defined in GHC.Internal.IO.Exception | |
Show AsyncException Source # | Since: base-4.1.0.0 |
Defined in GHC.Internal.IO.Exception | |
Show BlockedIndefinitelyOnMVar Source # | Since: base-4.1.0.0 |
Defined in GHC.Internal.IO.Exception | |
Show BlockedIndefinitelyOnSTM Source # | Since: base-4.1.0.0 |
Defined in GHC.Internal.IO.Exception | |
Show CompactionFailed Source # | Since: base-4.10.0.0 |
Defined in GHC.Internal.IO.Exception | |
Show Deadlock Source # | Since: base-4.1.0.0 |
Show ExitCode Source # | |
Show FixIOException Source # | Since: base-4.11.0.0 |
Defined in GHC.Internal.IO.Exception | |
Show IOErrorType Source # | Since: base-4.1.0.0 |
Defined in GHC.Internal.IO.Exception | |
Show IOException Source # | Since: base-4.1.0.0 |
Defined in GHC.Internal.IO.Exception | |
Show SomeAsyncException Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.IO.Exception | |
Show FD Source # | Since: base-4.1.0.0 |
Show HandlePosn Source # | Since: base-4.1.0.0 |
Defined in GHC.Internal.IO.Handle | |
Show FileLockingNotSupported Source # | Since: base-4.10.0.0 |
Defined in GHC.Internal.IO.Handle.Lock.Common | |
Show BufferMode Source # | Since: base-4.2.0.0 |
Defined in GHC.Internal.IO.Handle.Types | |
Show Handle Source # | Since: base-4.1.0.0 |
Show HandleType Source # | Since: base-4.1.0.0 |
Defined in GHC.Internal.IO.Handle.Types | |
Show Newline Source # | Since: base-4.3.0.0 |
Show NewlineMode Source # | Since: base-4.3.0.0 |
Defined in GHC.Internal.IO.Handle.Types | |
Show IOMode Source # | Since: base-4.2.0.0 |
Show IOPortException Source # | |
Show InfoProv Source # | |
Show Int16 Source # | Since: base-2.1 |
Show Int32 Source # | Since: base-2.1 |
Show Int64 Source # | Since: base-2.1 |
Show Int8 Source # | Since: base-2.1 |
Show Extension Source # | |
Show CCFlags Source # | Since: base-4.8.0.0 |
Show ConcFlags Source # | Since: base-4.8.0.0 |
Show DebugFlags Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.RTS.Flags | |
Show DoCostCentres Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.RTS.Flags | |
Show DoHeapProfile Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.RTS.Flags | |
Show DoTrace Source # | Since: base-4.8.0.0 |
Show GCFlags Source # | Since: base-4.8.0.0 |
Show GiveGCStats Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.RTS.Flags | |
Show HpcFlags Source # | Since: base-4.20.0.0 |
Show IoManagerFlag Source # | |
Defined in GHC.Internal.RTS.Flags | |
Show MiscFlags Source # | Since: base-4.8.0.0 |
Show ParFlags Source # | Since: base-4.8.0.0 |
Show ProfFlags Source # | Since: base-4.8.0.0 |
Show RTSFlags Source # | Since: base-4.8.0.0 |
Show TickyFlags Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.RTS.Flags | |
Show TraceFlags Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.RTS.Flags | |
Show FractionalExponentBase Source # | |
Defined in GHC.Internal.Real | |
Show StackEntry Source # | |
Defined in GHC.Internal.Stack.CloneStack | |
Show CallStack Source # | Since: base-4.9.0.0 |
Show SrcLoc Source # | Since: base-4.9.0.0 |
Show StaticPtrInfo Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.StaticPtr | |
Show GCDetails Source # | Since: base-4.10.0.0 |
Show RTSStats Source # | Since: base-4.10.0.0 |
Show CBlkCnt Source # | |
Show CBlkSize Source # | |
Show CCc Source # | |
Show CClockId Source # | |
Show CDev Source # | |
Show CFsBlkCnt Source # | |
Show CFsFilCnt Source # | |
Show CGid Source # | |
Show CId Source # | |
Show CIno Source # | |
Show CKey Source # | |
Show CMode Source # | |
Show CNfds Source # | |
Show CNlink Source # | |
Show COff Source # | |
Show CPid Source # | |
Show CRLim Source # | |
Show CSocklen Source # | |
Show CSpeed Source # | |
Show CSsize Source # | |
Show CTcflag Source # | |
Show CTimer Source # | |
Show CUid Source # | |
Show Fd Source # | |
Show AnnLookup Source # | |
Show AnnTarget Source # | |
Show Bang Source # | |
Show BndrVis Source # | |
Show Body Source # | |
Show Bytes Source # | |
Show Callconv Source # | |
Show Clause Source # | |
Show Con Source # | |
Show Dec Source # | |
Show DecidedStrictness Source # | |
Defined in GHC.Internal.TH.Syntax | |
Show DerivClause Source # | |
Defined in GHC.Internal.TH.Syntax | |
Show DerivStrategy Source # | |
Defined in GHC.Internal.TH.Syntax | |
Show DocLoc Source # | |
Show Exp Source # | |
Show FamilyResultSig Source # | |
Defined in GHC.Internal.TH.Syntax | |
Show Fixity Source # | |
Show FixityDirection Source # | |
Defined in GHC.Internal.TH.Syntax | |
Show Foreign Source # | |
Show FunDep Source # | |
Show Guard Source # | |
Show Info Source # | |
Show InjectivityAnn Source # | |
Defined in GHC.Internal.TH.Syntax | |
Show Inline Source # | |
Show Lit Source # | |
Show Loc Source # | |
Show Match Source # | |
Show ModName Source # | |
Show Module Source # | |
Show ModuleInfo Source # | |
Defined in GHC.Internal.TH.Syntax | |
Show Name Source # | |
Show NameFlavour Source # | |
Defined in GHC.Internal.TH.Syntax | |
Show NameSpace Source # | |
Show NamespaceSpecifier Source # | |
Defined in GHC.Internal.TH.Syntax | |
Show OccName Source # | |
Show Overlap Source # | |
Show Pat Source # | |
Show PatSynArgs Source # | |
Defined in GHC.Internal.TH.Syntax | |
Show PatSynDir Source # | |
Show Phases Source # | |
Show PkgName Source # | |
Show Pragma Source # | |
Show Range Source # | |
Show Role Source # | |
Show RuleBndr Source # | |
Show RuleMatch Source # | |
Show Safety Source # | |
Show SourceStrictness Source # | |
Defined in GHC.Internal.TH.Syntax | |
Show SourceUnpackedness Source # | |
Defined in GHC.Internal.TH.Syntax | |
Show Specificity Source # | |
Defined in GHC.Internal.TH.Syntax | |
Show Stmt Source # | |
Show TyLit Source # | |
Show TySynEqn Source # | |
Show Type Source # | |
Show TypeFamilyHead Source # | |
Defined in GHC.Internal.TH.Syntax | |
Show Lexeme Source # | Since: base-2.1 |
Show Number Source # | Since: base-4.6.0.0 |
Show SomeChar Source # | |
Show SomeSymbol Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.TypeLits | |
Show SomeNat Source # | Since: base-4.7.0.0 |
Show GeneralCategory Source # | Since: base-2.1 |
Defined in GHC.Internal.Unicode | |
Show Word16 Source # | Since: base-2.1 |
Show Word32 Source # | Since: base-2.1 |
Show Word64 Source # | Since: base-2.1 |
Show Word8 Source # | Since: base-2.1 |
Show KindRep Source # | |
Show Module Source # | Since: base-4.9.0.0 |
Show Ordering Source # | Since: base-2.1 |
Show TrName Source # | Since: base-4.9.0.0 |
Show TyCon Source # | Since: base-2.1 |
Show TypeLitSort Source # | Since: base-4.11.0.0 |
Defined in GHC.Internal.Show | |
Show Integer Source # | Since: base-2.1 |
Show Natural Source # | Since: base-4.8.0.0 |
Show () Source # | Since: base-2.1 |
Show Bool Source # | Since: base-2.1 |
Show Char Source # | Since: base-2.1 |
Show Int Source # | Since: base-2.1 |
Show Levity Source # | Since: base-4.15.0.0 |
Show RuntimeRep Source # | Since: base-4.11.0.0 |
Defined in GHC.Internal.Show | |
Show VecCount Source # | Since: base-4.11.0.0 |
Show VecElem Source # | Since: base-4.11.0.0 |
Show Word Source # | Since: base-2.1 |
Show a => Show (Complex a) Source # | Since: base-2.1 |
Show a => Show (First a) Source # | Since: base-4.9.0.0 |
Show a => Show (Last a) Source # | Since: base-4.9.0.0 |
Show a => Show (Max a) Source # | Since: base-4.9.0.0 |
Show a => Show (Min a) Source # | Since: base-4.9.0.0 |
Show m => Show (WrappedMonoid m) Source # | Since: base-4.9.0.0 |
Defined in Data.Semigroup | |
Show a => Show (NonEmpty a) Source # | Since: base-4.11.0.0 |
Show a => Show (And a) Source # | Since: base-4.16 |
Show a => Show (Iff a) Source # | Since: base-4.16 |
Show a => Show (Ior a) Source # | Since: base-4.16 |
Show a => Show (Xor a) Source # | Since: base-4.16 |
Show a => Show (Identity a) Source # | This instance would be equivalent to the derived instances of the
Since: base-4.8.0.0 |
Show a => Show (First a) Source # | Since: base-2.1 |
Show a => Show (Last a) Source # | Since: base-2.1 |
Show a => Show (Down a) Source # | This instance would be equivalent to the derived instances of the
Since: base-4.7.0.0 |
Show a => Show (Dual a) Source # | Since: base-2.1 |
Show a => Show (Product a) Source # | Since: base-2.1 |
Show a => Show (Sum a) Source # | Since: base-2.1 |
Show a => Show (ExceptionWithContext a) Source # | |
Defined in GHC.Internal.Exception.Type | |
Show e => Show (NoBacktrace e) Source # | |
Defined in GHC.Internal.Exception.Type | |
Show (ConstPtr a) Source # | |
Show (ForeignPtr a) Source # | Since: base-2.1 |
Defined in GHC.Internal.ForeignPtr | |
Show a => Show (ZipList a) Source # | Since: base-4.7.0.0 |
Show p => Show (Par1 p) Source # | Since: base-4.7.0.0 |
Show (FunPtr a) Source # | Since: base-2.1 |
Show (Ptr a) Source # | Since: base-2.1 |
Show a => Show (Ratio a) Source # | Since: base-2.0.1 |
Show flag => Show (TyVarBndr flag) Source # | |
Show (SChar c) Source # | Since: base-4.18.0.0 |
Show (SSymbol s) Source # | Since: base-4.18.0.0 |
Show (SNat n) Source # | Since: base-4.18.0.0 |
Show a => Show (Maybe a) Source # | Since: base-2.1 |
Show a => Show (Solo a) Source # | Since: base-4.15 |
Show a => Show [a] Source # | Since: base-2.1 |
HasResolution a => Show (Fixed a) Source # | Since: base-2.1 |
(Show a, Show b) => Show (Arg a b) Source # | Since: base-4.9.0.0 |
(Ix a, Show a, Show b) => Show (Array a b) Source # | Since: base-2.1 |
(Show a, Show b) => Show (Either a b) Source # | Since: base-3.0 |
Show (Proxy s) Source # | Since: base-4.7.0.0 |
Show (TypeRep a) Source # | |
Show (U1 p) Source # | Since: base-4.9.0.0 |
Show (UAddr p) Source # | Since: base-4.21.0.0 |
Show (V1 p) Source # | Since: base-4.9.0.0 |
Show (ST s a) Source # | Since: base-2.1 |
(Show a, Show b) => Show (a, b) Source # | Since: base-2.1 |
Show (a -> b) Source # | Since: base-2.1 |
Show a => Show (Const a b) Source # | This instance would be equivalent to the derived instances of the
Since: base-4.8.0.0 |
Show (f a) => Show (Ap f a) Source # | Since: base-4.12.0.0 |
Show (f a) => Show (Alt f a) Source # | Since: base-4.8.0.0 |
Show (Coercion a b) Source # | Since: base-4.7.0.0 |
Show (a :~: b) Source # | Since: base-4.7.0.0 |
Show (OrderingI a b) Source # | |
Show (f p) => Show (Rec1 f p) Source # | Since: base-4.7.0.0 |
Show (URec Char p) Source # | Since: base-4.9.0.0 |
Show (URec Double p) Source # | Since: base-4.9.0.0 |
Show (URec Float p) Source # | |
Show (URec Int p) Source # | Since: base-4.9.0.0 |
Show (URec Word p) Source # | Since: base-4.9.0.0 |
(Show a, Show b, Show c) => Show (a, b, c) Source # | Since: base-2.1 |
(Show (f a), Show (g a)) => Show (Product f g a) Source # | Since: base-4.18.0.0 |
(Show (f a), Show (g a)) => Show (Sum f g a) Source # | Since: base-4.18.0.0 |
Show (a :~~: b) Source # | Since: base-4.10.0.0 |
(Show (f p), Show (g p)) => Show ((f :*: g) p) Source # | Since: base-4.7.0.0 |
(Show (f p), Show (g p)) => Show ((f :+: g) p) Source # | Since: base-4.7.0.0 |
Show c => Show (K1 i c p) Source # | Since: base-4.7.0.0 |
(Show a, Show b, Show c, Show d) => Show (a, b, c, d) Source # | Since: base-2.1 |
Show (f (g a)) => Show (Compose f g a) Source # | Since: base-4.18.0.0 |
Show (f (g p)) => Show ((f :.: g) p) Source # | Since: base-4.7.0.0 |
Show (f p) => Show (M1 i c f p) Source # | Since: base-4.7.0.0 |
(Show a, Show b, Show c, Show d, Show e) => Show (a, b, c, d, e) Source # | Since: base-2.1 |
(Show a, Show b, Show c, Show d, Show e, Show f) => Show (a, b, c, d, e, f) Source # | Since: base-2.1 |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g) => Show (a, b, c, d, e, f, g) Source # | Since: base-2.1 |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h) => Show (a, b, c, d, e, f, g, h) Source # | Since: base-2.1 |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i) => Show (a, b, c, d, e, f, g, h, i) Source # | Since: base-2.1 |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j) => Show (a, b, c, d, e, f, g, h, i, j) Source # | Since: base-2.1 |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k) => Show (a, b, c, d, e, f, g, h, i, j, k) Source # | Since: base-2.1 |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l) => Show (a, b, c, d, e, f, g, h, i, j, k, l) Source # | Since: base-2.1 |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m) Source # | Since: base-2.1 |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m, Show n) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source # | Since: base-2.1 |
(Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m, Show n, Show o) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source # | Since: base-2.1 |
showChar :: Char -> ShowS Source #
utility function converting a Char
to a show function that
simply prepends the character unchanged.
showString :: String -> ShowS Source #
utility function converting a String
to a show function that
simply prepends the string unchanged.
Converting from String
Parsing of String
s, producing values.
Derived instances of Read
make the following assumptions, which
derived instances of Show
obey:
- If the constructor is defined to be an infix operator, then the
derived
Read
instance will parse only infix applications of the constructor (not the prefix form). - Associativity is not used to reduce the occurrence of parentheses, although precedence may be.
- If the constructor is defined using record syntax, the derived
Read
will parse only the record-syntax form, and furthermore, the fields must be given in the same order as the original declaration. - The derived
Read
instance allows arbitrary Haskell whitespace between tokens of the input string. Extra parentheses are also allowed.
For example, given the declarations
infixr 5 :^: data Tree a = Leaf a | Tree a :^: Tree a
the derived instance of Read
in Haskell 2010 is equivalent to
instance (Read a) => Read (Tree a) where readsPrec d r = readParen (d > app_prec) (\r -> [(Leaf m,t) | ("Leaf",s) <- lex r, (m,t) <- readsPrec (app_prec+1) s]) r ++ readParen (d > up_prec) (\r -> [(u:^:v,w) | (u,s) <- readsPrec (up_prec+1) r, (":^:",t) <- lex s, (v,w) <- readsPrec (up_prec+1) t]) r where app_prec = 10 up_prec = 5
Note that right-associativity of :^:
is unused.
The derived instance in GHC is equivalent to
instance (Read a) => Read (Tree a) where readPrec = parens $ (prec app_prec $ do Ident "Leaf" <- lexP m <- step readPrec return (Leaf m)) +++ (prec up_prec $ do u <- step readPrec Symbol ":^:" <- lexP v <- step readPrec return (u :^: v)) where app_prec = 10 up_prec = 5 readListPrec = readListPrecDefault
Why do both readsPrec
and readPrec
exist, and why does GHC opt to
implement readPrec
in derived Read
instances instead of readsPrec
?
The reason is that readsPrec
is based on the ReadS
type, and although
ReadS
is mentioned in the Haskell 2010 Report, it is not a very efficient
parser data structure.
readPrec
, on the other hand, is based on a much more efficient ReadPrec
datatype (a.k.a "new-style parsers"), but its definition relies on the use
of the RankNTypes
language extension. Therefore, readPrec
(and its
cousin, readListPrec
) are marked as GHC-only. Nevertheless, it is
recommended to use readPrec
instead of readsPrec
whenever possible
for the efficiency improvements it brings.
As mentioned above, derived Read
instances in GHC will implement
readPrec
instead of readsPrec
. The default implementations of
readsPrec
(and its cousin, readList
) will simply use readPrec
under
the hood. If you are writing a Read
instance by hand, it is recommended
to write it like so:
instanceRead
T wherereadPrec
= ...readListPrec
=readListPrecDefault
:: Int | the operator precedence of the enclosing
context (a number from |
-> ReadS a |
attempts to parse a value from the front of the string, returning a list of (parsed value, remaining string) pairs. If there is no successful parse, the returned list is empty.
Derived instances of Read
and Show
satisfy the following:
That is, readsPrec
parses the string produced by
showsPrec
, and delivers the value that
showsPrec
started with.
Instances
Read Void Source # | Reading a Since: base-4.8.0.0 |
Read ByteOrder Source # | Since: base-4.11.0.0 |
Read All Source # | Since: base-2.1 |
Read Any Source # | Since: base-2.1 |
Read Version Source # | Since: base-2.1 |
Read CBool Source # | |
Read CChar Source # | |
Read CClock Source # | |
Read CDouble Source # | |
Read CFloat Source # | |
Read CInt Source # | |
Read CIntMax Source # | |
Read CIntPtr Source # | |
Read CLLong Source # | |
Read CLong Source # | |
Read CPtrdiff Source # | |
Read CSChar Source # | |
Read CSUSeconds Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Read CShort Source # | |
Read CSigAtomic Source # | |
Defined in GHC.Internal.Foreign.C.Types | |
Read CSize Source # | |
Read CTime Source # | |
Read CUChar Source # | |
Read CUInt Source # | |
Read CUIntMax Source # | |
Read CUIntPtr Source # | |
Read CULLong Source # | |
Read CULong Source # | |
Read CUSeconds Source # | |
Read CUShort Source # | |
Read CWchar Source # | |
Read IntPtr Source # | |
Read WordPtr Source # | |
Read Associativity Source # | Since: base-4.6.0.0 |
Defined in GHC.Internal.Generics | |
Read DecidedStrictness Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics | |
Read Fixity Source # | Since: base-4.6.0.0 |
Read SourceStrictness Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics | |
Read SourceUnpackedness Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Generics | |
Read SeekMode Source # | Since: base-4.2.0.0 |
Read ExitCode Source # | |
Read BufferMode Source # | Since: base-4.2.0.0 |
Defined in GHC.Internal.IO.Handle.Types | |
Read Newline Source # | Since: base-4.3.0.0 |
Read NewlineMode Source # | Since: base-4.3.0.0 |
Defined in GHC.Internal.IO.Handle.Types | |
Read IOMode Source # | Since: base-4.2.0.0 |
Read Int16 Source # | Since: base-2.1 |
Read Int32 Source # | Since: base-2.1 |
Read Int64 Source # | Since: base-2.1 |
Read Int8 Source # | Since: base-2.1 |
Read GCDetails Source # | Since: base-4.10.0.0 |
Read RTSStats Source # | Since: base-4.10.0.0 |
Read CBlkCnt Source # | |
Read CBlkSize Source # | |
Read CCc Source # | |
Read CClockId Source # | |
Read CDev Source # | |
Read CFsBlkCnt Source # | |
Read CFsFilCnt Source # | |
Read CGid Source # | |
Read CId Source # | |
Read CIno Source # | |
Read CKey Source # | |
Read CMode Source # | |
Read CNfds Source # | |
Read CNlink Source # | |
Read COff Source # | |
Read CPid Source # | |
Read CRLim Source # | |
Read CSocklen Source # | |
Read CSpeed Source # | |
Read CSsize Source # | |
Read CTcflag Source # | |
Read CUid Source # | |
Read Fd Source # | |
Read Lexeme Source # | Since: base-2.1 |
Read SomeChar Source # | |
Read SomeSymbol Source # | Since: base-4.7.0.0 |
Defined in GHC.Internal.TypeLits | |
Read SomeNat Source # | Since: base-4.7.0.0 |
Read GeneralCategory Source # | Since: base-2.1 |
Defined in GHC.Internal.Read | |
Read Word16 Source # | Since: base-2.1 |
Read Word32 Source # | Since: base-2.1 |
Read Word64 Source # | Since: base-2.1 |
Read Word8 Source # | Since: base-2.1 |
Read Ordering Source # | Since: base-2.1 |
Read Integer Source # | Since: base-2.1 |
Read Natural Source # | Since: base-4.8.0.0 |
Read () Source # | Since: base-2.1 |
Read Bool Source # | Since: base-2.1 |
Read Char Source # | Since: base-2.1 |
Read Double Source # | Since: base-2.1 |
Read Float Source # | Since: base-2.1 |
Read Int Source # | Since: base-2.1 |
Read Word Source # | Since: base-4.5.0.0 |
Read a => Read (Complex a) Source # | Since: base-2.1 |
Read a => Read (First a) Source # | Since: base-4.9.0.0 |
Read a => Read (Last a) Source # | Since: base-4.9.0.0 |
Read a => Read (Max a) Source # | Since: base-4.9.0.0 |
Read a => Read (Min a) Source # | Since: base-4.9.0.0 |
Read m => Read (WrappedMonoid m) Source # | Since: base-4.9.0.0 |
Defined in Data.Semigroup readsPrec :: Int -> ReadS (WrappedMonoid m) Source # readList :: ReadS [WrappedMonoid m] Source # readPrec :: ReadPrec (WrappedMonoid m) Source # readListPrec :: ReadPrec [WrappedMonoid m] Source # | |
Read a => Read (NonEmpty a) Source # | Since: base-4.11.0.0 |
Read a => Read (And a) Source # | Since: base-4.16 |
Read a => Read (Iff a) Source # | Since: base-4.16 |
Read a => Read (Ior a) Source # | Since: base-4.16 |
Read a => Read (Xor a) Source # | Since: base-4.16 |
Read a => Read (Identity a) Source # | This instance would be equivalent to the derived instances of the
Since: base-4.8.0.0 |
Read a => Read (First a) Source # | Since: base-2.1 |
Read a => Read (Last a) Source # | Since: base-2.1 |
Read a => Read (Down a) Source # | This instance would be equivalent to the derived instances of the
Since: base-4.7.0.0 |
Read a => Read (Dual a) Source # | Since: base-2.1 |
Read a => Read (Product a) Source # | Since: base-2.1 |
Read a => Read (Sum a) Source # | Since: base-2.1 |
Read a => Read (ZipList a) Source # | Since: base-4.7.0.0 |
Read p => Read (Par1 p) Source # | Since: base-4.7.0.0 |
(Integral a, Read a) => Read (Ratio a) Source # | Since: base-2.1 |
Read a => Read (Maybe a) Source # | Since: base-2.1 |
Read a => Read (Solo a) Source # | Since: base-4.15 |
Read a => Read [a] Source # | Since: base-2.1 |
HasResolution a => Read (Fixed a) Source # | Since: base-4.3.0.0 |
(Read a, Read b) => Read (Arg a b) Source # | Since: base-4.9.0.0 |
(Ix a, Read a, Read b) => Read (Array a b) Source # | Since: base-2.1 |
(Read a, Read b) => Read (Either a b) Source # | Since: base-3.0 |
Read (Proxy t) Source # | Since: base-4.7.0.0 |
Read (U1 p) Source # | Since: base-4.9.0.0 |
Read (V1 p) Source # | Since: base-4.9.0.0 |
(Read a, Read b) => Read (a, b) Source # | Since: base-2.1 |
Read a => Read (Const a b) Source # | This instance would be equivalent to the derived instances of the
Since: base-4.8.0.0 |
Read (f a) => Read (Ap f a) Source # | Since: base-4.12.0.0 |
Read (f a) => Read (Alt f a) Source # | Since: base-4.8.0.0 |
Coercible a b => Read (Coercion a b) Source # | Since: base-4.7.0.0 |
a ~ b => Read (a :~: b) Source # | Since: base-4.7.0.0 |
Read (f p) => Read (Rec1 f p) Source # | Since: base-4.7.0.0 |
(Read a, Read b, Read c) => Read (a, b, c) Source # | Since: base-2.1 |
(Read (f a), Read (g a)) => Read (Product f g a) Source # | Since: base-4.18.0.0 |
(Read (f a), Read (g a)) => Read (Sum f g a) Source # | Since: base-4.18.0.0 |
a ~~ b => Read (a :~~: b) Source # | Since: base-4.10.0.0 |
(Read (f p), Read (g p)) => Read ((f :*: g) p) Source # | Since: base-4.7.0.0 |
(Read (f p), Read (g p)) => Read ((f :+: g) p) Source # | Since: base-4.7.0.0 |
Read c => Read (K1 i c p) Source # | Since: base-4.7.0.0 |
(Read a, Read b, Read c, Read d) => Read (a, b, c, d) Source # | Since: base-2.1 |
Read (f (g a)) => Read (Compose f g a) Source # | Since: base-4.18.0.0 |
Read (f (g p)) => Read ((f :.: g) p) Source # | Since: base-4.7.0.0 |
Read (f p) => Read (M1 i c f p) Source # | Since: base-4.7.0.0 |
(Read a, Read b, Read c, Read d, Read e) => Read (a, b, c, d, e) Source # | Since: base-2.1 |
(Read a, Read b, Read c, Read d, Read e, Read f) => Read (a, b, c, d, e, f) Source # | Since: base-2.1 |
(Read a, Read b, Read c, Read d, Read e, Read f, Read g) => Read (a, b, c, d, e, f, g) Source # | Since: base-2.1 |
(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h) => Read (a, b, c, d, e, f, g, h) Source # | Since: base-2.1 |
(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i) => Read (a, b, c, d, e, f, g, h, i) Source # | Since: base-2.1 |
(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j) => Read (a, b, c, d, e, f, g, h, i, j) Source # | Since: base-2.1 |
(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k) => Read (a, b, c, d, e, f, g, h, i, j, k) Source # | Since: base-2.1 |
(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l) => Read (a, b, c, d, e, f, g, h, i, j, k, l) Source # | Since: base-2.1 |
Defined in GHC.Internal.Read | |
(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m) Source # | Since: base-2.1 |
Defined in GHC.Internal.Read | |
(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m, Read n) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source # | Since: base-2.1 |
Defined in GHC.Internal.Read | |
(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m, Read n, Read o) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source # | Since: base-2.1 |
Defined in GHC.Internal.Read readsPrec :: Int -> ReadS (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source # readList :: ReadS [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] Source # readPrec :: ReadPrec (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source # readListPrec :: ReadPrec [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)] Source # |
read :: Read a => String -> a Source #
The read
function reads input from a string, which must be
completely consumed by the input process. read
fails with an error
if the
parse is unsuccessful, and it is therefore discouraged from being used in
real applications. Use readMaybe
or readEither
for safe alternatives.
>>>
read "123" :: Int
123
>>>
read "hello" :: Int
*** Exception: Prelude.read: no parse
The lex
function reads a single lexeme from the input, discarding
initial white space, and returning the characters that constitute the
lexeme. If the input string contains only white space, lex
returns a
single successful `lexeme' consisting of the empty string. (Thus
.) If there is no legal lexeme at the
beginning of the input string, lex
"" = [("","")]lex
fails (i.e. returns []
).
This lexer is not completely faithful to the Haskell lexical syntax in the following respects:
- Qualified names are not handled properly
- Octal and hexadecimal numerics are not recognized as a single token
- Comments are not treated properly
Basic Input and output
A value of type
is a computation which, when performed,
does some I/O before returning a value of type IO
aa
.
There is really only one way to "perform" an I/O action: bind it to
Main.main
in your program. When your program is run, the I/O will
be performed. It isn't possible to perform I/O from an arbitrary
function, unless that function is itself in the IO
monad and called
at some point, directly or indirectly, from Main.main
.
IO
is a monad, so IO
actions can be combined using either the do-notation
or the >>
and >>=
operations from the Monad
class.
Instances
Alternative IO Source # | Takes the first non-throwing Since: base-4.9.0.0 |
Applicative IO Source # | Since: base-2.1 |
Functor IO Source # | Since: base-2.1 |
Monad IO Source # | Since: base-2.1 |
MonadPlus IO Source # | Takes the first non-throwing Since: base-4.9.0.0 |
MonadFail IO Source # | Since: base-4.9.0.0 |
MonadFix IO Source # | Since: base-2.1 |
MonadIO IO Source # | Since: base-4.9.0.0 |
GHCiSandboxIO IO Source # | Since: base-4.4.0.0 |
Defined in GHC.Internal.GHCi ghciStepIO :: IO a -> IO a Source # | |
Quasi IO Source # | |
Defined in GHC.Internal.TH.Syntax qNewName :: String -> IO Name Source # qReport :: Bool -> String -> IO () Source # qRecover :: IO a -> IO a -> IO a Source # qLookupName :: Bool -> String -> IO (Maybe Name) Source # qReify :: Name -> IO Info Source # qReifyFixity :: Name -> IO (Maybe Fixity) Source # qReifyType :: Name -> IO Type Source # qReifyInstances :: Name -> [Type] -> IO [Dec] Source # qReifyRoles :: Name -> IO [Role] Source # qReifyAnnotations :: Data a => AnnLookup -> IO [a] Source # qReifyModule :: Module -> IO ModuleInfo Source # qReifyConStrictness :: Name -> IO [DecidedStrictness] Source # qRunIO :: IO a -> IO a Source # qGetPackageRoot :: IO FilePath Source # qAddDependentFile :: FilePath -> IO () Source # qAddTempFile :: String -> IO FilePath Source # qAddTopDecls :: [Dec] -> IO () Source # qAddForeignFilePath :: ForeignSrcLang -> String -> IO () Source # qAddModFinalizer :: Q () -> IO () Source # qAddCorePlugin :: String -> IO () Source # qGetQ :: Typeable a => IO (Maybe a) Source # qPutQ :: Typeable a => a -> IO () Source # qIsExtEnabled :: Extension -> IO Bool Source # qExtsEnabled :: IO [Extension] Source # | |
Quote IO Source # | |
a ~ () => HPrintfType (IO a) Source # | Since: base-4.7.0.0 |
Defined in Text.Printf | |
a ~ () => PrintfType (IO a) Source # | Since: base-4.7.0.0 |
Defined in Text.Printf | |
Monoid a => Monoid (IO a) Source # | Since: base-4.9.0.0 |
Semigroup a => Semigroup (IO a) Source # | Since: base-4.10.0.0 |
Simple I/O operations
Output functions
putStr :: String -> IO () Source #
Write a string to the standard output device
putStr
is implemented as
.hPutStr
stdout
This operation may fail with the same errors, and has the same issues with concurrency, as hPutStr
!
Examples
Note that the following do not put a newline.
>>>
putStr "Hello, World!"
Hello, World!
>>>
putStr "\0052\0042\0050"
4*2
print :: Show a => a -> IO () Source #
The print
function outputs a value of any printable type to the
standard output device.
Printable types are those that are instances of class Show
; print
converts values to strings for output using the show
operation and
adds a newline.
print
is implemented as putStrLn
.
show
This operation may fail with the same errors, and has the same issues with concurrency, as hPutStr
!
Examples
>>>
print [1, 2, 3]
[1,2,3]
Be careful when using print
for outputting strings,
as this will invoke show
and cause strings to be printed
with quotation marks and non-ascii symbols escaped.
>>>
print "λ :D"
"\995 :D"
A program to print the first 8 integers and their powers of 2 could be written as:
>>>
print [(n, 2^n) | n <- [0..8]]
[(0,1),(1,2),(2,4),(3,8),(4,16),(5,32),(6,64),(7,128),(8,256)]
Input functions
getContents :: IO String Source #
The getContents
operation returns all user input as a single string,
which is read lazily as it is needed.
getContents
is implemented as
.hGetContents
stdin
This operation may fail with the same errors as hGetContents
.
Examples
>>>
getContents >>= putStr
> aaabbbccc :D aaabbbccc :D > I hope you have a great day I hope you have a great day > ^D
>>>
getContents >>= print . length
> abc > <3 > def ^D 11
interact :: (String -> String) -> IO () Source #
takes the entire input from interact
fstdin
and applies f
to it.
The resulting string is written to the stdout
device.
Note that this operation is lazy, which allows to produce output even before all input has been consumed.
This operation may fail with the same errors as getContents
and putStr
.
Examples
>>>
interact (\str -> str ++ str)
> hi :) hi :) > ^D hi :)
>>>
interact (const ":D")
:D
>>>
interact (show . words)
> hello world! > I hope you have a great day > ^D ["hello","world!","I","hope","you","have","a","great","day"]
Files
type FilePath = String Source #
File and directory names are values of type String
, whose precise
meaning is operating system dependent. Files can be opened, yielding a
handle which can then be used to operate on the contents of that file.
readFile :: FilePath -> IO String Source #
The readFile
function reads a file and
returns the contents of the file as a string.
The file is read lazily, on demand, as with getContents
.
This operation may fail with the same errors as hGetContents
and openFile
.
Examples
>>>
readFile "~/hello_world"
"Greetings!"
>>>
take 5 <$> readFile "/dev/zero"
"\NUL\NUL\NUL\NUL\NUL"
writeFile :: FilePath -> String -> IO () Source #
The computation
function writes the string writeFile
file strstr
,
to the file file
.
This operation may fail with the same errors as hPutStr
and withFile
.
Examples
>>>
writeFile "hello" "world" >> readFile "hello"
"world"
>>>
writeFile "~/" "D:"
*** Exception: ~/: withFile: inappropriate type (Is a directory)
appendFile :: FilePath -> String -> IO () Source #
The computation
function appends the string appendFile
file strstr
,
to the file file
.
Note that writeFile
and appendFile
write a literal string
to a file. To write a value of any printable type, as with print
,
use the show
function to convert the value to a string first.
This operation may fail with the same errors as hPutStr
and withFile
.
Examples
The following example could be more efficently written by acquiring a handle
instead with openFile
and using the computations capable of writing to handles
such as hPutStr
.
>>>
let fn = "hello_world"
>>>
in writeFile fn "hello" >> appendFile fn " world!" >> (readFile fn >>= putStrLn)
"hello world!"
>>>
let fn = "foo"; output = readFile' fn >>= putStrLn
>>>
in output >> appendFile fn (show [1,2,3]) >> output
this is what's in the file this is what's in the file[1,2,3]
readIO :: Read a => String -> IO a Source #
The readIO
function is similar to read
except that it signals
parse failure to the IO
monad instead of terminating the program.
This operation may fail with:
isUserError
if there is no unambiguous parse.
Examples
>>>
fmap (+ 1) (readIO "1")
2
>>>
readIO "not quite ()" :: IO ()
*** Exception: user error (Prelude.readIO: no parse)
Exception handling in the I/O monad
type IOError = IOException Source #