base-prelude-1.6.1: Featureful preludes formed solely from the "base" package

BasePrelude

Description

Reexports of most of the definitions from the "base" package, which it is a common practice to import unqualified.

For details check out the source.

Synopsis

# Documentation

(++) :: [a] -> [a] -> [a] infixr 5 #

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

seq :: forall (r :: RuntimeRep) a (b :: TYPE r). a -> b -> b infixr 0 #

The value of seq a b is bottom if a 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 seq a b does not guarantee that a 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.

filter :: (a -> Bool) -> [a] -> [a] #

$$\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]
>>> filter odd [1, 2, 3]
[1,3]


zip :: [a] -> [b] -> [(a, b)] #

$$\mathcal{O}(\min(m,n))$$. zip takes two lists and returns a list of corresponding pairs.

zip [1, 2] ['a', 'b'] = [(1, 'a'), (2, 'b')]

If one input list is short, excess elements of the longer list are discarded:

zip [1] ['a', 'b'] = [(1, 'a')]
zip [1, 2] ['a'] = [(1, 'a')]

zip is right-lazy:

zip [] _|_ = []
zip _|_ [] = _|_

zip is capable of list fusion, but it is restricted to its first list argument and its resulting list.

newStablePtr :: a -> IO (StablePtr a) #

Create a stable pointer referring to the given Haskell value.

print :: Show a => a -> IO () #

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.

For example, a program to print the first 20 integers and their powers of 2 could be written as:

main = print ([(n, 2^n) | n <- [0..19]])

fst :: (a, b) -> a #

Extract the first component of a pair.

snd :: (a, b) -> b #

Extract the second component of a pair.

otherwise is defined as the value True. It helps to make guards more readable. eg.

 f x | x < 0     = ...
| otherwise = ...

assert :: Bool -> a -> a #

If the first argument evaluates to True, then the result is the second argument. Otherwise an AssertionFailed exception is raised, containing a String with the source file and line number of the call to assert.

Assertions can normally be turned on or off with a compiler flag (for GHC, assertions are normally on unless optimisation is turned on with -O or the -fignore-asserts option is given). When assertions are turned off, the first argument to assert is ignored, and the second argument is returned as the result.

lazy :: a -> a #

The lazy function restrains strictness analysis a little. The call lazy e means the same as e, but lazy has a magical property so far as strictness analysis is concerned: it is lazy in its first argument, even though its semantics is strict. After strictness analysis has run, calls to lazy are inlined to be the identity function.

This behaviour is occasionally useful when controlling evaluation order. Notably, lazy is used in the library definition of par:

par :: a -> b -> b
par x y = case (par# x) of _ -> lazy y

If lazy were not lazy, par would look strict in y which would defeat the whole purpose of par.

Like seq, the argument of lazy can have an unboxed type.

assertError :: (?callStack :: CallStack) => Bool -> a -> a #

trace :: String -> a -> a #

The trace function outputs the trace message given as its first argument, before returning the second argument as its result.

For example, this returns the value of f x but first outputs the message.

>>> let x = 123; f = show
>>> trace ("calling f with x = " ++ show x) (f x)
"calling f with x = 123
123"


The trace function should only be used for debugging, or for monitoring execution. The function is not referentially transparent: its type indicates that it is a pure function but it has the side effect of outputting the trace message.

inline :: a -> a #

The call inline f arranges that f is inlined, regardless of its size. More precisely, the call inline f rewrites to the right-hand side of f's definition. This allows the programmer to control inlining from a particular call site rather than the definition site of the function (c.f. INLINE pragmas).

This inlining occurs regardless of the argument to the call or the size of f's definition; it is unconditional. The main caveat is that f's definition must be visible to the compiler; it is therefore recommended to mark the function with an INLINABLE pragma at its definition so that GHC guarantees to record its unfolding regardless of size.

If no inlining takes place, the inline function expands to the identity function in Phase zero, so its use imposes no overhead.

map :: (a -> b) -> [a] -> [b] #

$$\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, ...]
>>> map (+1) [1, 2, 3]


groupWith :: Ord b => (a -> b) -> [a] -> [[a]] #

The groupWith function uses the user supplied function which projects an element out of every list element in order to first sort the input list and then to form groups by equality on these projected elements

($) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b infixr 0 # Application operator. This operator is redundant, since ordinary application (f x) means the same as (f$ x). However, $ has low, right-associative binding precedence, so it sometimes allows parentheses to be omitted; for example: f$ g $h x = f (g (h x)) It is also useful in higher-order situations, such as map ($ 0) xs, or zipWith ($) fs xs. Note that ($) is levity-polymorphic in its result type, so that foo \$ True where foo :: Bool -> Int# is well-typed.

coerce :: forall (k :: RuntimeRep) (a :: TYPE k) (b :: TYPE k). Coercible a b => a -> b #

The function coerce allows you to safely convert between values of types that have the same representation with no run-time overhead. In the simplest case you can use it instead of a newtype constructor, to go from the newtype's concrete type to the abstract type. But it also works in more complicated settings, e.g. converting a list of newtypes to a list of concrete types.

This function is runtime-representation polymorphic, but the RuntimeRep type argument is marked as Inferred, meaning that it is not available for visible type application. This means the typechecker will accept coerce @Int @Age 42.

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

general coercion from integral types

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

general coercion to fractional types

guard :: Alternative f => Bool -> f () #

Conditional failure of Alternative computations. Defined by

guard True  = pure ()
guard False = empty


#### Examples

Expand

Common uses of guard include conditionally signaling an error in an error monad and conditionally rejecting the current choice in an Alternative-based parser.

As an example of signaling an error in the error monad Maybe, consider a safe division function safeDiv x y that returns Nothing when the denominator y is zero and Just (x div y) otherwise. For example:

>>> safeDiv 4 0
Nothing
>>> safeDiv 4 2
Just 2


A definition of safeDiv using guards, but not guard:

safeDiv :: Int -> Int -> Maybe Int
safeDiv x y | y /= 0    = Just (x div y)
| otherwise = Nothing


A definition of safeDiv using guard and Monad do-notation:

safeDiv :: Int -> Int -> Maybe Int
safeDiv x y = do
guard (y /= 0)
return (x div y)


class IsList l where #

The IsList class and its methods are intended to be used in conjunction with the OverloadedLists extension.

Since: base-4.7.0.0

Minimal complete definition

Associated Types

type Item l #

The Item type function returns the type of items of the structure l.

Methods

fromList :: [Item l] -> l #

The fromList function constructs the structure l from the given list of Item l

fromListN :: Int -> [Item l] -> l #

The fromListN function takes the input list's length as a hint. Its behaviour should be equivalent to fromList. The hint can be used to construct the structure l more efficiently compared to fromList. If the given hint does not equal to the input list's length the behaviour of fromListN is not specified.

toList :: l -> [Item l] #

The toList function extracts a list of Item l from the structure l. It should satisfy fromList . toList = id.

#### Instances

Instances details
 Be aware that 'fromList . toList = id' only for unfrozen CallStacks, since toList removes frozenness information.Since: base-4.9.0.0 Instance detailsDefined in GHC.Exts Associated Typestype Item CallStack # MethodsfromList :: [Item CallStack] -> CallStack #fromListN :: Int -> [Item CallStack] -> CallStack # Since: base-4.8.0.0 Instance detailsDefined in GHC.Exts Associated Typestype Item Version # MethodsfromList :: [Item Version] -> Version #fromListN :: Int -> [Item Version] -> Version #toList :: Version -> [Item Version] # IsList [a] Since: base-4.7.0.0 Instance detailsDefined in GHC.Exts Associated Typestype Item [a] # MethodsfromList :: [Item [a]] -> [a] #fromListN :: Int -> [Item [a]] -> [a] #toList :: [a] -> [Item [a]] # Since: base-4.15.0.0 Instance detailsDefined in GHC.Exts Associated Typestype Item (ZipList a) # MethodsfromList :: [Item (ZipList a)] -> ZipList a #fromListN :: Int -> [Item (ZipList a)] -> ZipList a #toList :: ZipList a -> [Item (ZipList a)] # Since: base-4.9.0.0 Instance detailsDefined in GHC.Exts Associated Typestype Item (NonEmpty a) # MethodsfromList :: [Item (NonEmpty a)] -> NonEmpty a #fromListN :: Int -> [Item (NonEmpty a)] -> NonEmpty a #toList :: NonEmpty a -> [Item (NonEmpty a)] #

toDyn :: Typeable a => a -> Dynamic #

Converts an arbitrary value into an object of type Dynamic.

The type of the object must be an instance of Typeable, which ensures that only monomorphically-typed objects may be converted to Dynamic. To convert a polymorphic object into Dynamic, give it a monomorphic type signature. For example:

   toDyn (id :: Int -> Int)

join :: Monad m => m (m a) -> m a #

The join function is the conventional monad join operator. It is used to remove one level of monadic structure, projecting its bound argument into the outer level.

'join bss' can be understood as the do expression

do bs <- bss
bs


#### Examples

Expand

A common use of join is to run an IO computation returned from an STM transaction, since STM transactions can't perform IO directly. Recall that

atomically :: STM a -> IO a


is used to run STM transactions atomically. So, by specializing the types of atomically and join to

atomically :: STM (IO b) -> IO (IO b)
join       :: IO (IO b)  -> IO b


we can compose them as

join . atomically :: STM (IO b) -> IO b


to run an STM transaction and the IO action it returns.

class Bounded a where #

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.

Methods

minBound :: a #

maxBound :: a #

#### Instances

Instances details
 Since: base-2.1 Instance detailsDefined in GHC.Enum Methods Since: base-2.1 Instance detailsDefined in GHC.Enum Methods Since: base-2.1 Instance detailsDefined in GHC.Enum Methods Since: base-2.1 Instance detailsDefined in GHC.Int Methods Since: base-2.1 Instance detailsDefined in GHC.Int Methods Since: base-2.1 Instance detailsDefined in GHC.Int Methods Since: base-2.1 Instance detailsDefined in GHC.Int Methods Since: base-2.1 Instance detailsDefined in GHC.Enum Methods Since: base-2.1 Instance detailsDefined in GHC.Enum Methods Since: base-2.1 Instance detailsDefined in GHC.Word Methods Since: base-2.1 Instance detailsDefined in GHC.Word Methods Since: base-2.1 Instance detailsDefined in GHC.Word Methods Since: base-2.1 Instance detailsDefined in GHC.Word Methods Since: base-4.10.0.0 Instance detailsDefined in GHC.Enum Methods Since: base-4.10.0.0 Instance detailsDefined in GHC.Enum Methods Bounded () Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: () #maxBound :: () # Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Since: base-2.1 Instance detailsDefined in Data.Semigroup.Internal Methods Since: base-2.1 Instance detailsDefined in Data.Semigroup.Internal Methods Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.Ptr Methods Instance detailsDefined in Foreign.Ptr Methods Since: base-2.1 Instance detailsDefined in GHC.Unicode Methods Bounded a => Bounded (Min a) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup MethodsminBound :: Min a #maxBound :: Min a # Bounded a => Bounded (Max a) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup MethodsminBound :: Max a #maxBound :: Max a # Bounded a => Bounded (First a) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods Bounded a => Bounded (Last a) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods Bounded m => Bounded (WrappedMonoid m) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods Bounded a => Bounded (Identity a) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Identity Methods Bounded a => Bounded (Dual a) Since: base-2.1 Instance detailsDefined in Data.Semigroup.Internal Methods Bounded a => Bounded (Sum a) Since: base-2.1 Instance detailsDefined in Data.Semigroup.Internal MethodsminBound :: Sum a #maxBound :: Sum a # Bounded a => Bounded (Product a) Since: base-2.1 Instance detailsDefined in Data.Semigroup.Internal Methods Bounded a => Bounded (Down a) Since: base-4.14.0.0 Instance detailsDefined in Data.Ord Methods (Bounded a, Bounded b) => Bounded (a, b) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b) #maxBound :: (a, b) # Bounded (Proxy t) Since: base-4.7.0.0 Instance detailsDefined in Data.Proxy Methods (Bounded a, Bounded b, Bounded c) => Bounded (a, b, c) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c) #maxBound :: (a, b, c) # Bounded a => Bounded (Const a b) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Const MethodsminBound :: Const a b #maxBound :: Const a b # (Applicative f, Bounded a) => Bounded (Ap f a) Since: base-4.12.0.0 Instance detailsDefined in Data.Monoid MethodsminBound :: Ap f a #maxBound :: Ap f a # a ~ b => Bounded (a :~: b) Since: base-4.7.0.0 Instance detailsDefined in Data.Type.Equality MethodsminBound :: a :~: b #maxBound :: a :~: b # (Bounded a, Bounded b, Bounded c, Bounded d) => Bounded (a, b, c, d) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d) #maxBound :: (a, b, c, d) # a ~~ b => Bounded (a :~~: b) Since: base-4.10.0.0 Instance detailsDefined in Data.Type.Equality MethodsminBound :: a :~~: b #maxBound :: a :~~: b # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e) => Bounded (a, b, c, d, e) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e) #maxBound :: (a, b, c, d, e) # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f) => Bounded (a, b, c, d, e, f) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f) #maxBound :: (a, b, c, d, e, f) # (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g) => Bounded (a, b, c, d, e, f, g) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g) #maxBound :: (a, b, c, d, e, f, g) # (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) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h) #maxBound :: (a, b, c, d, e, f, g, h) # (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) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h, i) #maxBound :: (a, b, c, d, e, f, g, h, i) # (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) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h, i, j) #maxBound :: (a, b, c, d, e, f, g, h, i, j) # (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) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h, i, j, k) #maxBound :: (a, b, c, d, e, f, g, h, i, j, k) # (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) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h, i, j, k, l) #maxBound :: (a, b, c, d, e, f, g, h, i, j, k, l) # (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) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m) #maxBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m) # (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) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) #maxBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) # (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) Since: base-2.1 Instance detailsDefined in GHC.Enum MethodsminBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) #maxBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) #

class Enum a where #

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 succ maxBound and pred minBound should result in a runtime error.
• fromEnum and toEnum should give a runtime error if the result value is not representable in the result type. For example, toEnum 7 :: Bool is an error.
• enumFrom and enumFromThen should be defined with an implicit bound, thus:
   enumFrom     x   = enumFromTo     x maxBound
enumFromThen x y = enumFromThenTo x y bound
where
| otherwise                = minBound

Minimal complete definition

Methods

succ :: a -> a #

the successor of a value. For numeric types, succ adds 1.

pred :: a -> a #

the predecessor of a value. For numeric types, pred subtracts 1.

toEnum :: Int -> a #

Convert from an Int.

fromEnum :: a -> 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.

enumFrom :: a -> [a] #

Used in Haskell's translation of [n..] with [n..] = enumFrom n, a possible implementation being enumFrom n = n : enumFrom (succ n). For example:

• enumFrom 4 :: [Integer] = [4,5,6,7,...]
• enumFrom 6 :: [Int] = [6,7,8,9,...,maxBound :: Int]

enumFromThen :: a -> a -> [a] #

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 For example:

• enumFromThen 4 6 :: [Integer] = [4,6,8,10...]
• enumFromThen 6 2 :: [Int] = [6,2,-2,-6,...,minBound :: Int]

enumFromTo :: a -> a -> [a] #

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 = []. For example:

• enumFromTo 6 10 :: [Int] = [6,7,8,9,10]
• enumFromTo 42 1 :: [Integer] = []

enumFromThenTo :: a -> a -> a -> [a] #

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 = [] For example:

• enumFromThenTo 4 2 -6 :: [Integer] = [4,2,0,-2,-4,-6]
• enumFromThenTo 6 8 2 :: [Int] = []

#### Instances

Instances details

class Eq a where #

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, == is customarily expected to implement an equivalence relationship where two values comparing equal are indistinguishable by "public" functions, with a "public" function being one not allowing to see implementation details. For example, for a type representing non-normalised natural numbers modulo 100, a "public" function doesn't make the difference between 1 and 201. It is expected to have the following properties:

Reflexivity
x == x = True
Symmetry
x == y = y == x
Transitivity
if x == y && y == z = True, then x == z = True
Substitutivity
if x == y = True and f is a "public" function whose return type is an instance of Eq, then f x == f y = True
Negation
x /= y = not (x == y)

Minimal complete definition: either == or /=.

Minimal complete definition

Methods

(==) :: a -> a -> Bool infix 4 #

(/=) :: a -> a -> Bool infix 4 #

#### Instances

Instances details
 Instance detailsDefined in GHC.Classes Methods(==) :: Bool -> Bool -> Bool #(/=) :: Bool -> Bool -> Bool # Instance detailsDefined in GHC.Classes Methods(==) :: Char -> Char -> Bool #(/=) :: Char -> Char -> Bool # Note that due to the presence of NaN, Double's Eq instance does not satisfy reflexivity.>>> 0/0 == (0/0 :: Double) False Also note that Double's Eq instance does not satisfy substitutivity:>>> 0 == (-0 :: Double) True >>> recip 0 == recip (-0 :: Double) False  Instance detailsDefined in GHC.Classes Methods(==) :: Double -> Double -> Bool #(/=) :: Double -> Double -> Bool # Note that due to the presence of NaN, Float's Eq instance does not satisfy reflexivity.>>> 0/0 == (0/0 :: Float) False Also note that Float's Eq instance does not satisfy substitutivity:>>> 0 == (-0 :: Float) True >>> recip 0 == recip (-0 :: Float) False  Instance detailsDefined in GHC.Classes Methods(==) :: Float -> Float -> Bool #(/=) :: Float -> Float -> Bool # Instance detailsDefined in GHC.Classes Methods(==) :: Int -> Int -> Bool #(/=) :: Int -> Int -> Bool # Since: base-2.1 Instance detailsDefined in GHC.Int Methods(==) :: Int8 -> Int8 -> Bool #(/=) :: Int8 -> Int8 -> Bool # Since: base-2.1 Instance detailsDefined in GHC.Int Methods(==) :: Int16 -> Int16 -> Bool #(/=) :: Int16 -> Int16 -> Bool # Since: base-2.1 Instance detailsDefined in GHC.Int Methods(==) :: Int32 -> Int32 -> Bool #(/=) :: Int32 -> Int32 -> Bool # Since: base-2.1 Instance detailsDefined in GHC.Int Methods(==) :: Int64 -> Int64 -> Bool #(/=) :: Int64 -> Int64 -> Bool # Instance detailsDefined in GHC.Integer.Type Methods(==) :: Integer -> Integer -> Bool #(/=) :: Integer -> Integer -> Bool # Since: base-4.8.0.0 Instance detailsDefined in GHC.Natural Methods(==) :: Natural -> Natural -> Bool #(/=) :: Natural -> Natural -> Bool # Instance detailsDefined in GHC.Classes Methods Instance detailsDefined in GHC.Classes Methods(==) :: Word -> Word -> Bool #(/=) :: Word -> Word -> Bool # Since: base-2.1 Instance detailsDefined in GHC.Word Methods(==) :: Word8 -> Word8 -> Bool #(/=) :: Word8 -> Word8 -> Bool # Since: base-2.1 Instance detailsDefined in GHC.Word Methods(==) :: Word16 -> Word16 -> Bool #(/=) :: Word16 -> Word16 -> Bool # Since: base-2.1 Instance detailsDefined in GHC.Word Methods(==) :: Word32 -> Word32 -> Bool #(/=) :: Word32 -> Word32 -> Bool # Since: base-2.1 Instance detailsDefined in GHC.Word Methods(==) :: Word64 -> Word64 -> Bool #(/=) :: Word64 -> Word64 -> Bool # Instance detailsDefined in Data.Typeable.Internal Methods Eq () Instance detailsDefined in GHC.Classes Methods(==) :: () -> () -> Bool #(/=) :: () -> () -> Bool # Instance detailsDefined in GHC.Classes Methods(==) :: TyCon -> TyCon -> Bool #(/=) :: TyCon -> TyCon -> Bool # Instance detailsDefined in GHC.Classes Methods(==) :: Module -> Module -> Bool #(/=) :: Module -> Module -> Bool # Instance detailsDefined in GHC.Classes Methods(==) :: TrName -> TrName -> Bool #(/=) :: TrName -> TrName -> Bool # Since: base-4.8.0.0 Instance detailsDefined in Data.Void Methods(==) :: Void -> Void -> Bool #(/=) :: Void -> Void -> Bool # Since: base-4.3.0.0 Instance detailsDefined in GHC.Exts Methods Equality of constructorsSince: base-4.0.0.0 Instance detailsDefined in Data.Data Methods(==) :: Constr -> Constr -> Bool #(/=) :: Constr -> Constr -> Bool # Since: base-4.0.0.0 Instance detailsDefined in Data.Data Methods(==) :: DataRep -> DataRep -> Bool #(/=) :: DataRep -> DataRep -> Bool # Since: base-4.0.0.0 Instance detailsDefined in Data.Data Methods Since: base-4.0.0.0 Instance detailsDefined in Data.Data Methods(==) :: Fixity -> Fixity -> Bool #(/=) :: Fixity -> Fixity -> Bool # Instance detailsDefined in System.Timeout Methods(==) :: Timeout -> Timeout -> Bool #(/=) :: Timeout -> Timeout -> Bool # Instance detailsDefined in Data.Unique Methods(==) :: Unique -> Unique -> Bool #(/=) :: Unique -> Unique -> Bool # Since: base-2.1 Instance detailsDefined in Data.Version Methods(==) :: Version -> Version -> Bool #(/=) :: Version -> Version -> Bool # Since: base-4.1.0.0 Instance detailsDefined in GHC.IO.Handle Methods Since: base-4.2.0.0 Instance detailsDefined in GHC.Conc.Sync Methods Since: base-4.3.0.0 Instance detailsDefined in GHC.Conc.Sync Methods Since: base-4.3.0.0 Instance detailsDefined in GHC.Conc.Sync Methods Instance detailsDefined in System.Posix.Types Methods(==) :: CDev -> CDev -> Bool #(/=) :: CDev -> CDev -> Bool # Instance detailsDefined in System.Posix.Types Methods(==) :: CIno -> CIno -> Bool #(/=) :: CIno -> CIno -> Bool # Instance detailsDefined in System.Posix.Types Methods(==) :: CMode -> CMode -> Bool #(/=) :: CMode -> CMode -> Bool # Instance detailsDefined in System.Posix.Types Methods(==) :: COff -> COff -> Bool #(/=) :: COff -> COff -> Bool # Instance detailsDefined in System.Posix.Types Methods(==) :: CPid -> CPid -> Bool #(/=) :: CPid -> CPid -> Bool # Instance detailsDefined in System.Posix.Types Methods(==) :: CSsize -> CSsize -> Bool #(/=) :: CSsize -> CSsize -> Bool # Instance detailsDefined in System.Posix.Types Methods(==) :: CGid -> CGid -> Bool #(/=) :: CGid -> CGid -> Bool # Instance detailsDefined in System.Posix.Types Methods(==) :: CNlink -> CNlink -> Bool #(/=) :: CNlink -> CNlink -> Bool # Instance detailsDefined in System.Posix.Types Methods(==) :: CUid -> CUid -> Bool #(/=) :: CUid -> CUid -> Bool # Instance detailsDefined in System.Posix.Types Methods(==) :: CCc -> CCc -> Bool #(/=) :: CCc -> CCc -> Bool # Instance detailsDefined in System.Posix.Types Methods(==) :: CSpeed -> CSpeed -> Bool #(/=) :: CSpeed -> CSpeed -> Bool # Instance detailsDefined in System.Posix.Types Methods(==) :: CTcflag -> CTcflag -> Bool #(/=) :: CTcflag -> CTcflag -> Bool # Instance detailsDefined in System.Posix.Types Methods(==) :: CRLim -> CRLim -> Bool #(/=) :: CRLim -> CRLim -> Bool # Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods(==) :: CBlkCnt -> CBlkCnt -> Bool #(/=) :: CBlkCnt -> CBlkCnt -> Bool # Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods(==) :: CId -> CId -> Bool #(/=) :: CId -> CId -> Bool # Instance detailsDefined in System.Posix.Types Methods(==) :: CKey -> CKey -> Bool #(/=) :: CKey -> CKey -> Bool # Instance detailsDefined in System.Posix.Types Methods(==) :: CTimer -> CTimer -> Bool #(/=) :: CTimer -> CTimer -> Bool # Instance detailsDefined in System.Posix.Types Methods Instance detailsDefined in System.Posix.Types Methods(==) :: CNfds -> CNfds -> Bool #(/=) :: CNfds -> CNfds -> Bool # Instance detailsDefined in System.Posix.Types Methods(==) :: Fd -> Fd -> Bool #(/=) :: Fd -> Fd -> Bool # Since: base-4.2.0.0 Instance detailsDefined in GHC.IO.Exception Methods Since: base-4.2.0.0 Instance detailsDefined in GHC.IO.Exception Methods Instance detailsDefined in GHC.IO.Exception Methods Since: base-4.1.0.0 Instance detailsDefined in GHC.IO.Exception Methods Since: base-4.1.0.0 Instance detailsDefined in GHC.IO.Handle.Types Methods(==) :: Handle -> Handle -> Bool #(/=) :: Handle -> Handle -> Bool # Since: base-4.2.0.0 Instance detailsDefined in GHC.IO.Handle.Types Methods Since: base-4.2.0.0 Instance detailsDefined in GHC.IO.Handle.Types Methods(==) :: Newline -> Newline -> Bool #(/=) :: Newline -> Newline -> Bool # Since: base-4.2.0.0 Instance detailsDefined in GHC.IO.Handle.Types Methods Since: base-4.2.0.0 Instance detailsDefined in GHC.IO.Device Methods Since: base-4.2.0.0 Instance detailsDefined in GHC.IO.Device Methods Since: base-4.4.0.0 Instance detailsDefined in GHC.IO.Encoding.Types Methods Since: base-4.3.0.0 Instance detailsDefined in GHC.IO Methods Since: base-4.1.0.0 Instance detailsDefined in GHC.IO.Exception Methods Since: base-4.7.0.0 Instance detailsDefined in GHC.Exception Methods Since: base-3.0 Instance detailsDefined in GHC.Exception.Type Methods Since: base-2.1 Instance detailsDefined in Data.Semigroup.Internal Methods(==) :: All -> All -> Bool #(/=) :: All -> All -> Bool # Since: base-2.1 Instance detailsDefined in Data.Semigroup.Internal Methods(==) :: Any -> Any -> Bool #(/=) :: Any -> Any -> Bool # Since: base-4.6.0.0 Instance detailsDefined in GHC.Generics Methods(==) :: Fixity -> Fixity -> Bool #(/=) :: Fixity -> Fixity -> Bool # Since: base-4.6.0.0 Instance detailsDefined in GHC.Generics Methods Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods Instance detailsDefined in Foreign.C.Types Methods(==) :: CChar -> CChar -> Bool #(/=) :: CChar -> CChar -> Bool # Instance detailsDefined in Foreign.C.Types Methods(==) :: CSChar -> CSChar -> Bool #(/=) :: CSChar -> CSChar -> Bool # Instance detailsDefined in Foreign.C.Types Methods(==) :: CUChar -> CUChar -> Bool #(/=) :: CUChar -> CUChar -> Bool # Instance detailsDefined in Foreign.C.Types Methods(==) :: CShort -> CShort -> Bool #(/=) :: CShort -> CShort -> Bool # Instance detailsDefined in Foreign.C.Types Methods(==) :: CUShort -> CUShort -> Bool #(/=) :: CUShort -> CUShort -> Bool # Instance detailsDefined in Foreign.C.Types Methods(==) :: CInt -> CInt -> Bool #(/=) :: CInt -> CInt -> Bool # Instance detailsDefined in Foreign.C.Types Methods(==) :: CUInt -> CUInt -> Bool #(/=) :: CUInt -> CUInt -> Bool # Instance detailsDefined in Foreign.C.Types Methods(==) :: CLong -> CLong -> Bool #(/=) :: CLong -> CLong -> Bool # Instance detailsDefined in Foreign.C.Types Methods(==) :: CULong -> CULong -> Bool #(/=) :: CULong -> CULong -> Bool # Instance detailsDefined in Foreign.C.Types Methods(==) :: CLLong -> CLLong -> Bool #(/=) :: CLLong -> CLLong -> Bool # Instance detailsDefined in Foreign.C.Types Methods(==) :: CULLong -> CULLong -> Bool #(/=) :: CULLong -> CULLong -> Bool # Instance detailsDefined in Foreign.C.Types Methods(==) :: CBool -> CBool -> Bool #(/=) :: CBool -> CBool -> Bool # Instance detailsDefined in Foreign.C.Types Methods(==) :: CFloat -> CFloat -> Bool #(/=) :: CFloat -> CFloat -> Bool # Instance detailsDefined in Foreign.C.Types Methods(==) :: CDouble -> CDouble -> Bool #(/=) :: CDouble -> CDouble -> Bool # Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods(==) :: CSize -> CSize -> Bool #(/=) :: CSize -> CSize -> Bool # Instance detailsDefined in Foreign.C.Types Methods(==) :: CWchar -> CWchar -> Bool #(/=) :: CWchar -> CWchar -> Bool # Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods(==) :: CClock -> CClock -> Bool #(/=) :: CClock -> CClock -> Bool # Instance detailsDefined in Foreign.C.Types Methods(==) :: CTime -> CTime -> Bool #(/=) :: CTime -> CTime -> Bool # Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods(==) :: CIntPtr -> CIntPtr -> Bool #(/=) :: CIntPtr -> CIntPtr -> Bool # Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.C.Types Methods(==) :: CIntMax -> CIntMax -> Bool #(/=) :: CIntMax -> CIntMax -> Bool # Instance detailsDefined in Foreign.C.Types Methods Instance detailsDefined in Foreign.Ptr Methods(==) :: WordPtr -> WordPtr -> Bool #(/=) :: WordPtr -> WordPtr -> Bool # Instance detailsDefined in Foreign.Ptr Methods(==) :: IntPtr -> IntPtr -> Bool #(/=) :: IntPtr -> IntPtr -> Bool # Since: base-4.2.0.0 Instance detailsDefined in GHC.IO.IOMode Methods(==) :: IOMode -> IOMode -> Bool #(/=) :: IOMode -> IOMode -> Bool # Since: base-4.4.0.0 Instance detailsDefined in GHC.Fingerprint.Type Methods Since: base-2.1 Instance detailsDefined in GHC.Unicode Methods Since: base-4.9.0.0 Instance detailsDefined in GHC.Stack.Types Methods(==) :: SrcLoc -> SrcLoc -> Bool #(/=) :: SrcLoc -> SrcLoc -> Bool # Instance detailsDefined in GHC.Integer.Type Methods(==) :: BigNat -> BigNat -> Bool #(/=) :: BigNat -> BigNat -> Bool # Eq a => Eq [a] Instance detailsDefined in GHC.Classes Methods(==) :: [a] -> [a] -> Bool #(/=) :: [a] -> [a] -> Bool # Eq a => Eq (Maybe a) Since: base-2.1 Instance detailsDefined in GHC.Maybe Methods(==) :: Maybe a -> Maybe a -> Bool #(/=) :: Maybe a -> Maybe a -> Bool # Eq a => Eq (Ratio a) Since: base-2.1 Instance detailsDefined in GHC.Real Methods(==) :: Ratio a -> Ratio a -> Bool #(/=) :: Ratio a -> Ratio a -> Bool # Eq (StablePtr a) Since: base-2.1 Instance detailsDefined in GHC.Stable Methods(==) :: StablePtr a -> StablePtr a -> Bool #(/=) :: StablePtr a -> StablePtr a -> Bool # Eq (Ptr a) Since: base-2.1 Instance detailsDefined in GHC.Ptr Methods(==) :: Ptr a -> Ptr a -> Bool #(/=) :: Ptr a -> Ptr a -> Bool # Eq (FunPtr a) Instance detailsDefined in GHC.Ptr Methods(==) :: FunPtr a -> FunPtr a -> Bool #(/=) :: FunPtr a -> FunPtr a -> Bool # Eq p => Eq (Par1 p) Since: base-4.7.0.0 Instance detailsDefined in GHC.Generics Methods(==) :: Par1 p -> Par1 p -> Bool #(/=) :: Par1 p -> Par1 p -> Bool # Eq a => Eq (Complex a) Since: base-2.1 Instance detailsDefined in Data.Complex Methods(==) :: Complex a -> Complex a -> Bool #(/=) :: Complex a -> Complex a -> Bool # Eq a => Eq (Min a) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods(==) :: Min a -> Min a -> Bool #(/=) :: Min a -> Min a -> Bool # Eq a => Eq (Max a) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods(==) :: Max a -> Max a -> Bool #(/=) :: Max a -> Max a -> Bool # Eq a => Eq (First a) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods(==) :: First a -> First a -> Bool #(/=) :: First a -> First a -> Bool # Eq a => Eq (Last a) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods(==) :: Last a -> Last a -> Bool #(/=) :: Last a -> Last a -> Bool # Eq m => Eq (WrappedMonoid m) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods(==) :: WrappedMonoid m -> WrappedMonoid m -> Bool #(/=) :: WrappedMonoid m -> WrappedMonoid m -> Bool # Eq a => Eq (Option a) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods(==) :: Option a -> Option a -> Bool #(/=) :: Option a -> Option a -> Bool # Eq (Chan a) Since: base-4.4.0.0 Instance detailsDefined in Control.Concurrent.Chan Methods(==) :: Chan a -> Chan a -> Bool #(/=) :: Chan a -> Chan a -> Bool # Eq (StableName a) Since: base-2.1 Instance detailsDefined in GHC.StableName Methods(==) :: StableName a -> StableName a -> Bool #(/=) :: StableName a -> StableName a -> Bool # Eq a => Eq (ZipList a) Since: base-4.7.0.0 Instance detailsDefined in Control.Applicative Methods(==) :: ZipList a -> ZipList a -> Bool #(/=) :: ZipList a -> ZipList a -> Bool # Eq a => Eq (Identity a) Since: base-4.8.0.0 Instance detailsDefined in Data.Functor.Identity Methods(==) :: Identity a -> Identity a -> Bool #(/=) :: Identity a -> Identity a -> Bool # Eq (TVar a) Since: base-4.8.0.0 Instance detailsDefined in GHC.Conc.Sync Methods(==) :: TVar a -> TVar a -> Bool #(/=) :: TVar a -> TVar a -> Bool # Eq (ForeignPtr a) Since: base-2.1 Instance detailsDefined in GHC.ForeignPtr Methods(==) :: ForeignPtr a -> ForeignPtr a -> Bool #(/=) :: ForeignPtr a -> ForeignPtr a -> Bool # Eq (IORef a) Pointer equality.Since: base-4.0.0.0 Instance detailsDefined in GHC.IORef Methods(==) :: IORef a -> IORef a -> Bool #(/=) :: IORef a -> IORef a -> Bool # Eq a => Eq (First a) Since: base-2.1 Instance detailsDefined in Data.Monoid Methods(==) :: First a -> First a -> Bool #(/=) :: First a -> First a -> Bool # Eq a => Eq (Last a) Since: base-2.1 Instance detailsDefined in Data.Monoid Methods(==) :: Last a -> Last a -> Bool #(/=) :: Last a -> Last a -> Bool # Eq a => Eq (Dual a) Since: base-2.1 Instance detailsDefined in Data.Semigroup.Internal Methods(==) :: Dual a -> Dual a -> Bool #(/=) :: Dual a -> Dual a -> Bool # Eq a => Eq (Sum a) Since: base-2.1 Instance detailsDefined in Data.Semigroup.Internal Methods(==) :: Sum a -> Sum a -> Bool #(/=) :: Sum a -> Sum a -> Bool # Eq a => Eq (Product a) Since: base-2.1 Instance detailsDefined in Data.Semigroup.Internal Methods(==) :: Product a -> Product a -> Bool #(/=) :: Product a -> Product a -> Bool # Eq a => Eq (Down a) Since: base-4.6.0.0 Instance detailsDefined in Data.Ord Methods(==) :: Down a -> Down a -> Bool #(/=) :: Down a -> Down a -> Bool # Eq (MVar a) Since: base-4.1.0.0 Instance detailsDefined in GHC.MVar Methods(==) :: MVar a -> MVar a -> Bool #(/=) :: MVar a -> MVar a -> Bool # Eq a => Eq (NonEmpty a) Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methods(==) :: NonEmpty a -> NonEmpty a -> Bool #(/=) :: NonEmpty a -> NonEmpty a -> Bool # (Eq a, Eq b) => Eq (Either a b) Since: base-2.1 Instance detailsDefined in Data.Either Methods(==) :: Either a b -> Either a b -> Bool #(/=) :: Either a b -> Either a b -> Bool # Eq (V1 p) Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods(==) :: V1 p -> V1 p -> Bool #(/=) :: V1 p -> V1 p -> Bool # Eq (U1 p) Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods(==) :: U1 p -> U1 p -> Bool #(/=) :: U1 p -> U1 p -> Bool # Eq (TypeRep a) Since: base-2.1 Instance detailsDefined in Data.Typeable.Internal Methods(==) :: TypeRep a -> TypeRep a -> Bool #(/=) :: TypeRep a -> TypeRep a -> Bool # (Eq a, Eq b) => Eq (a, b) Instance detailsDefined in GHC.Classes Methods(==) :: (a, b) -> (a, b) -> Bool #(/=) :: (a, b) -> (a, b) -> Bool # Eq (Fixed a) Since: base-2.1 Instance detailsDefined in Data.Fixed Methods(==) :: Fixed a -> Fixed a -> Bool #(/=) :: Fixed a -> Fixed a -> Bool # Eq a => Eq (Arg a b) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods(==) :: Arg a b -> Arg a b -> Bool #(/=) :: Arg a b -> Arg a b -> Bool # Eq (Proxy s) Since: base-4.7.0.0 Instance detailsDefined in Data.Proxy Methods(==) :: Proxy s -> Proxy s -> Bool #(/=) :: Proxy s -> Proxy s -> Bool # Eq (STRef s a) Pointer equality.Since: base-2.1 Instance detailsDefined in GHC.STRef Methods(==) :: STRef s a -> STRef s a -> Bool #(/=) :: STRef s a -> STRef s a -> Bool # Eq (f p) => Eq (Rec1 f p) Since: base-4.7.0.0 Instance detailsDefined in GHC.Generics Methods(==) :: Rec1 f p -> Rec1 f p -> Bool #(/=) :: Rec1 f p -> Rec1 f p -> Bool # Eq (URec (Ptr ()) p) Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods(==) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool #(/=) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool # Eq (URec Char p) Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods(==) :: URec Char p -> URec Char p -> Bool #(/=) :: URec Char p -> URec Char p -> Bool # Eq (URec Double p) Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods(==) :: URec Double p -> URec Double p -> Bool #(/=) :: URec Double p -> URec Double p -> Bool # Eq (URec Float p) Instance detailsDefined in GHC.Generics Methods(==) :: URec Float p -> URec Float p -> Bool #(/=) :: URec Float p -> URec Float p -> Bool # Eq (URec Int p) Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods(==) :: URec Int p -> URec Int p -> Bool #(/=) :: URec Int p -> URec Int p -> Bool # Eq (URec Word p) Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methods(==) :: URec Word p -> URec Word p -> Bool #(/=) :: URec Word p -> URec Word p -> Bool # (Eq a, Eq b, Eq c) => Eq (a, b, c) Instance detailsDefined in GHC.Classes Methods(==) :: (a, b, c) -> (a, b, c) -> Bool #(/=) :: (a, b, c) -> (a, b, c) -> Bool # Eq a => Eq (Const a b) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Const Methods(==) :: Const a b -> Const a b -> Bool #(/=) :: Const a b -> Const a b -> Bool # Eq (f a) => Eq (Ap f a) Since: base-4.12.0.0 Instance detailsDefined in Data.Monoid Methods(==) :: Ap f a -> Ap f a -> Bool #(/=) :: Ap f a -> Ap f a -> Bool # Eq (f a) => Eq (Alt f a) Since: base-4.8.0.0 Instance detailsDefined in Data.Semigroup.Internal Methods(==) :: Alt f a -> Alt f a -> Bool #(/=) :: Alt f a -> Alt f a -> Bool # Eq (a :~: b) Since: base-4.7.0.0 Instance detailsDefined in Data.Type.Equality Methods(==) :: (a :~: b) -> (a :~: b) -> Bool #(/=) :: (a :~: b) -> (a :~: b) -> Bool # Eq c => Eq (K1 i c p) Since: base-4.7.0.0 Instance detailsDefined in GHC.Generics Methods(==) :: K1 i c p -> K1 i c p -> Bool #(/=) :: K1 i c p -> K1 i c p -> Bool # (Eq (f p), Eq (g p)) => Eq ((f :+: g) p) Since: base-4.7.0.0 Instance detailsDefined in GHC.Generics Methods(==) :: (f :+: g) p -> (f :+: g) p -> Bool #(/=) :: (f :+: g) p -> (f :+: g) p -> Bool # (Eq (f p), Eq (g p)) => Eq ((f :*: g) p) Since: base-4.7.0.0 Instance detailsDefined in GHC.Generics Methods(==) :: (f :*: g) p -> (f :*: g) p -> Bool #(/=) :: (f :*: g) p -> (f :*: g) p -> Bool # (Eq a, Eq b, Eq c, Eq d) => Eq (a, b, c, d) Instance detailsDefined in GHC.Classes Methods(==) :: (a, b, c, d) -> (a, b, c, d) -> Bool #(/=) :: (a, b, c, d) -> (a, b, c, d) -> Bool # (Eq1 f, Eq1 g, Eq a) => Eq (Product f g a) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Product Methods(==) :: Product f g a -> Product f g a -> Bool #(/=) :: Product f g a -> Product f g a -> Bool # (Eq1 f, Eq1 g, Eq a) => Eq (Sum f g a) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Sum Methods(==) :: Sum f g a -> Sum f g a -> Bool #(/=) :: Sum f g a -> Sum f g a -> Bool # Eq (a :~~: b) Since: base-4.10.0.0 Instance detailsDefined in Data.Type.Equality Methods(==) :: (a :~~: b) -> (a :~~: b) -> Bool #(/=) :: (a :~~: b) -> (a :~~: b) -> Bool # Eq (f p) => Eq (M1 i c f p) Since: base-4.7.0.0 Instance detailsDefined in GHC.Generics Methods(==) :: M1 i c f p -> M1 i c f p -> Bool #(/=) :: M1 i c f p -> M1 i c f p -> Bool # Eq (f (g p)) => Eq ((f :.: g) p) Since: base-4.7.0.0 Instance detailsDefined in GHC.Generics Methods(==) :: (f :.: g) p -> (f :.: g) p -> Bool #(/=) :: (f :.: g) p -> (f :.: g) p -> Bool # (Eq a, Eq b, Eq c, Eq d, Eq e) => Eq (a, b, c, d, e) Instance detailsDefined in GHC.Classes Methods(==) :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool #(/=) :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool # (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Compose Methods(==) :: Compose f g a -> Compose f g a -> Bool #(/=) :: Compose f g a -> Compose f g a -> Bool # (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f) => Eq (a, b, c, d, e, f) Instance detailsDefined in GHC.Classes Methods(==) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> Bool #(/=) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> Bool # (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g) => Eq (a, b, c, d, e, f, g) Instance detailsDefined in GHC.Classes Methods(==) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> Bool #(/=) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> Bool # (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) Instance detailsDefined in GHC.Classes Methods(==) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> Bool #(/=) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> Bool # (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) Instance detailsDefined in GHC.Classes Methods(==) :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> Bool #(/=) :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> Bool # (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) Instance detailsDefined in GHC.Classes Methods(==) :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> Bool #(/=) :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> Bool # (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) Instance detailsDefined in GHC.Classes Methods(==) :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> Bool #(/=) :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> Bool # (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) Instance detailsDefined in GHC.Classes Methods(==) :: (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 #(/=) :: (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 # (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) Instance detailsDefined in GHC.Classes Methods(==) :: (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 #(/=) :: (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 # (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) Instance detailsDefined in GHC.Classes Methods(==) :: (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 #(/=) :: (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 # (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) Instance detailsDefined in GHC.Classes Methods(==) :: (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 #(/=) :: (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 #

class Fractional a => Floating a where #

Trigonometric and hyperbolic functions and related functions.

The Haskell Report defines no laws for Floating. However, (+), (*) and exp are customarily expected to define an exponential field and have the following properties:

• exp (a + b) = exp a * exp b
• exp (fromInteger 0) = fromInteger 1

Minimal complete definition

Methods

pi :: a #

exp :: a -> a #

log :: a -> a #

sqrt :: a -> a #

(**) :: a -> a -> a infixr 8 #

logBase :: a -> a -> a #

sin :: a -> a #

cos :: a -> a #

tan :: a -> a #

asin :: a -> a #

acos :: a -> a #

atan :: a -> a #

sinh :: a -> a #

cosh :: a -> a #

tanh :: a -> a #

asinh :: a -> a #

acosh :: a -> a #

atanh :: a -> a #

log1p :: a -> a #

log1p x computes log (1 + x), but provides more precise results for small (absolute) values of x if possible.

Since: base-4.9.0.0

expm1 :: a -> a #

expm1 x computes exp x - 1, but provides more precise results for small (absolute) values of x if possible.

Since: base-4.9.0.0

log1pexp :: a -> a #

log1pexp x computes log (1 + exp x), but provides more precise results if possible.

Examples:

• if x is a large negative number, log (1 + exp x) will be imprecise for the reasons given in log1p.
• if exp x is close to -1, log (1 + exp x) will be imprecise for the reasons given in expm1.

Since: base-4.9.0.0

log1mexp :: a -> a #

log1mexp x computes log (1 - exp x), but provides more precise results if possible.

Examples:

• if x is a large negative number, log (1 - exp x) will be imprecise for the reasons given in log1p.
• if exp x is close to 1, log (1 - exp x) will be imprecise for the reasons given in expm1.

Since: base-4.9.0.0

#### Instances

Instances details
 Since: base-2.1 Instance detailsDefined in GHC.Float Methodsexp :: Double -> Double #log :: Double -> Double #(**) :: Double -> Double -> Double #sin :: Double -> Double #cos :: Double -> Double #tan :: Double -> Double # Since: base-2.1 Instance detailsDefined in GHC.Float Methodspi :: Float #exp :: Float -> Float #log :: Float -> Float #sqrt :: Float -> Float #(**) :: Float -> Float -> Float #logBase :: Float -> Float -> Float #sin :: Float -> Float #cos :: Float -> Float #tan :: Float -> Float #asin :: Float -> Float #acos :: Float -> Float #atan :: Float -> Float #sinh :: Float -> Float #cosh :: Float -> Float #tanh :: Float -> Float #asinh :: Float -> Float #acosh :: Float -> Float #atanh :: Float -> Float #log1p :: Float -> Float #expm1 :: Float -> Float # Instance detailsDefined in Foreign.C.Types Methodsexp :: CFloat -> CFloat #log :: CFloat -> CFloat #(**) :: CFloat -> CFloat -> CFloat #sin :: CFloat -> CFloat #cos :: CFloat -> CFloat #tan :: CFloat -> CFloat # Instance detailsDefined in Foreign.C.Types Methods RealFloat a => Floating (Complex a) Since: base-2.1 Instance detailsDefined in Data.Complex Methodspi :: Complex a #exp :: Complex a -> Complex a #log :: Complex a -> Complex a #sqrt :: Complex a -> Complex a #(**) :: Complex a -> Complex a -> Complex a #logBase :: Complex a -> Complex a -> Complex a #sin :: Complex a -> Complex a #cos :: Complex a -> Complex a #tan :: Complex a -> Complex a #asin :: Complex a -> Complex a #acos :: Complex a -> Complex a #atan :: Complex a -> Complex a #sinh :: Complex a -> Complex a #cosh :: Complex a -> Complex a #tanh :: Complex a -> Complex a #asinh :: Complex a -> Complex a #acosh :: Complex a -> Complex a #atanh :: Complex a -> Complex a #log1p :: Complex a -> Complex a #expm1 :: Complex a -> Complex a #log1pexp :: Complex a -> Complex a #log1mexp :: Complex a -> Complex a # Floating a => Floating (Identity a) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Identity Methodspi :: Identity a #exp :: Identity a -> Identity a #log :: Identity a -> Identity a #sqrt :: Identity a -> Identity a #(**) :: Identity a -> Identity a -> Identity a #logBase :: Identity a -> Identity a -> Identity a #sin :: Identity a -> Identity a #cos :: Identity a -> Identity a #tan :: Identity a -> Identity a #asin :: Identity a -> Identity a #acos :: Identity a -> Identity a #atan :: Identity a -> Identity a #sinh :: Identity a -> Identity a #cosh :: Identity a -> Identity a #tanh :: Identity a -> Identity a #asinh :: Identity a -> Identity a #acosh :: Identity a -> Identity a #atanh :: Identity a -> Identity a #log1p :: Identity a -> Identity a #expm1 :: Identity a -> Identity a #log1pexp :: Identity a -> Identity a #log1mexp :: Identity a -> Identity a # Floating a => Floating (Down a) Since: base-4.14.0.0 Instance detailsDefined in Data.Ord Methodspi :: Down a #exp :: Down a -> Down a #log :: Down a -> Down a #sqrt :: Down a -> Down a #(**) :: Down a -> Down a -> Down a #logBase :: Down a -> Down a -> Down a #sin :: Down a -> Down a #cos :: Down a -> Down a #tan :: Down a -> Down a #asin :: Down a -> Down a #acos :: Down a -> Down a #atan :: Down a -> Down a #sinh :: Down a -> Down a #cosh :: Down a -> Down a #tanh :: Down a -> Down a #asinh :: Down a -> Down a #acosh :: Down a -> Down a #atanh :: Down a -> Down a #log1p :: Down a -> Down a #expm1 :: Down a -> Down a #log1pexp :: Down a -> Down a #log1mexp :: Down a -> Down a # Floating a => Floating (Op a b) Instance detailsDefined in Data.Functor.Contravariant Methodspi :: Op a b #exp :: Op a b -> Op a b #log :: Op a b -> Op a b #sqrt :: Op a b -> Op a b #(**) :: Op a b -> Op a b -> Op a b #logBase :: Op a b -> Op a b -> Op a b #sin :: Op a b -> Op a b #cos :: Op a b -> Op a b #tan :: Op a b -> Op a b #asin :: Op a b -> Op a b #acos :: Op a b -> Op a b #atan :: Op a b -> Op a b #sinh :: Op a b -> Op a b #cosh :: Op a b -> Op a b #tanh :: Op a b -> Op a b #asinh :: Op a b -> Op a b #acosh :: Op a b -> Op a b #atanh :: Op a b -> Op a b #log1p :: Op a b -> Op a b #expm1 :: Op a b -> Op a b #log1pexp :: Op a b -> Op a b #log1mexp :: Op a b -> Op a b # Floating a => Floating (Const a b) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Const Methodspi :: Const a b #exp :: Const a b -> Const a b #log :: Const a b -> Const a b #sqrt :: Const a b -> Const a b #(**) :: Const a b -> Const a b -> Const a b #logBase :: Const a b -> Const a b -> Const a b #sin :: Const a b -> Const a b #cos :: Const a b -> Const a b #tan :: Const a b -> Const a b #asin :: Const a b -> Const a b #acos :: Const a b -> Const a b #atan :: Const a b -> Const a b #sinh :: Const a b -> Const a b #cosh :: Const a b -> Const a b #tanh :: Const a b -> Const a b #asinh :: Const a b -> Const a b #acosh :: Const a b -> Const a b #atanh :: Const a b -> Const a b #log1p :: Const a b -> Const a b #expm1 :: Const a b -> Const a b #log1pexp :: Const a b -> Const a b #log1mexp :: Const a b -> Const a b #

class Num a => Fractional a where #

Fractional numbers, supporting real division.

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

recip gives the multiplicative inverse
x * recip x = recip x * x = fromInteger 1

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

Minimal complete definition

fromRational, (recip | (/))

Methods

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

Fractional division.

recip :: a -> a #

Reciprocal fraction.

fromRational :: Rational -> a #

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

#### Instances

Instances details
 Instance detailsDefined in Foreign.C.Types Methods(/) :: CFloat -> CFloat -> CFloat # Instance detailsDefined in Foreign.C.Types Methods Integral a => Fractional (Ratio a) Since: base-2.0.1 Instance detailsDefined in GHC.Real Methods(/) :: Ratio a -> Ratio a -> Ratio a #recip :: Ratio a -> Ratio a # RealFloat a =>