Safe Haskell | Unsafe |
---|---|
Language | Haskell2010 |
Synopsis
- (++) :: [a] -> [a] -> [a]
- seq :: a -> b -> b
- print :: Show a => a -> IO ()
- fromIntegral :: (Integral a, Num b) => a -> b
- realToFrac :: (Real a, Fractional b) => a -> b
- class Bounded 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 Fractional a => Floating a where
- pi :: a
- exp :: a -> a
- log :: a -> a
- sqrt :: a -> a
- (**) :: a -> a -> a
- 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
- expm1 :: a -> a
- log1pexp :: a -> a
- log1mexp :: a -> a
- class Num a => Fractional a where
- (/) :: a -> a -> a
- recip :: a -> a
- fromRational :: Rational -> a
- class (Real a, Enum a) => Integral a where
- class Num a where
- class (Num a, Ord a) => Real a where
- toRational :: a -> Rational
- 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
- class (Real a, Fractional a) => RealFrac a where
- class Show a where
- class KnownNat (n :: Nat)
- class KnownSymbol (n :: Symbol)
- class IsLabel (x :: Symbol) a where
- fromLabel :: a
- class HasField (x :: k) r a | x r -> a where
- getField :: r -> a
- data Bool
- data Char
- data Double = D# Double#
- data Float = F# Float#
- data Int
- data Integer
- data Ordering
- data Ratio a = !a :% !a
- type Rational = Ratio Integer
- data IO a
- data Word
- data Ptr a
- data FunPtr a
- type Type = Type
- data Constraint
- data Nat
- data Symbol
- type family CmpNat (a :: Nat) (b :: Nat) :: Ordering where ...
- class a ~R# b => Coercible (a :: k0) (b :: k0)
- data StaticPtr a
- data CallStack
- showSignedFloat :: RealFloat a => (a -> ShowS) -> Int -> a -> ShowS
- integralEnumFromThenTo :: Integral a => a -> a -> a -> [a]
- integralEnumFromTo :: Integral a => a -> a -> [a]
- integralEnumFromThen :: (Integral a, Bounded a) => a -> a -> [a]
- integralEnumFrom :: (Integral a, Bounded a) => a -> [a]
- gcdWord' :: Word -> Word -> Word
- gcdInt' :: Int -> Int -> Int
- (^^%^^) :: Integral a => Rational -> a -> Rational
- (^%^) :: Integral a => Rational -> a -> Rational
- numericEnumFromThenTo :: (Ord a, Fractional a) => a -> a -> a -> [a]
- numericEnumFromTo :: (Ord a, Fractional a) => a -> a -> [a]
- numericEnumFromThen :: Fractional a => a -> a -> [a]
- numericEnumFrom :: Fractional a => a -> [a]
- notANumber :: Rational
- infinity :: Rational
- ratioPrec1 :: Int
- ratioPrec :: Int
- underflowError :: a
- overflowError :: a
- ratioZeroDenominatorError :: a
- divZeroError :: a
- reduce :: Integral a => a -> a -> Ratio a
- boundedEnumFromThen :: (Enum a, Bounded a) => a -> a -> [a]
- boundedEnumFrom :: (Enum a, Bounded a) => a -> [a]
- maxInt :: Int
- minInt :: Int
- showStackTrace :: IO (Maybe String)
- getStackTrace :: IO (Maybe [Location])
- data SrcLoc = SrcLoc {
- sourceFile :: String
- sourceLine :: Int
- sourceColumn :: Int
- data Location = Location {
- objectName :: String
- functionName :: String
- srcLoc :: Maybe SrcLoc
- putStrLn :: String -> IO ()
- putStr :: String -> IO ()
- withFrozenCallStack :: HasCallStack => (HasCallStack -> a) -> a
- callStack :: HasCallStack -> CallStack
- prettyCallStack :: CallStack -> String
- prettySrcLoc :: SrcLoc -> String
- someSymbolVal :: String -> SomeSymbol
- someNatVal :: Integer -> Maybe SomeNat
- symbolVal :: KnownSymbol n => proxy n -> String
- natVal :: KnownNat n => proxy n -> Integer
- data SomeSymbol where
- SomeSymbol :: forall (n :: Symbol). KnownSymbol n => Proxy n -> SomeSymbol
- data SomeNat where
- showFloat :: RealFloat a => a -> ShowS
- lcm :: Integral a => a -> a -> a
- gcd :: Integral a => a -> a -> a
- (^^) :: (Fractional a, Integral b) => a -> b -> a
- (^) :: (Num a, Integral b) => a -> b -> a
- odd :: Integral a => a -> Bool
- even :: Integral a => a -> Bool
- showSigned :: Real a => (a -> ShowS) -> Int -> a -> ShowS
- denominator :: Ratio a -> a
- numerator :: Ratio a -> a
- (%) :: Integral a => a -> a -> Ratio a
- subtract :: Num a => a -> a -> a
- currentCallStack :: IO [String]
- asTypeOf :: a -> a -> a
- until :: (a -> Bool) -> (a -> a) -> a -> a
- ord :: Char -> Int
- getCallStack :: CallStack -> [([Char], SrcLoc)]
- type HasCallStack = ?callStack :: CallStack
- ($!) :: (a -> b) -> a -> b
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.
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.
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]])
fromIntegral :: (Integral a, Num b) => a -> b #
general coercion from integral types
realToFrac :: (Real a, Fractional b) => a -> b #
general coercion to fractional types
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
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
the successor of a value. For numeric types, succ
adds 1.
the 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)
.
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
class Fractional a => Floating a where #
Trigonometric and hyperbolic functions and related functions.
The Haskell Report defines no laws for Floating
. However, '(+)', '(*)'
and exp
are customarily expected to define an exponential field and have
the following properties:
exp (a + b)
= @exp a * exp bexp (fromInteger 0)
=fromInteger 1
(**) :: a -> a -> a infixr 8 #
computes log1p
x
, but provides more precise
results for small (absolute) values of log
(1 + x)x
if possible.
Since: base-4.9.0.0
computes expm1
x
, but provides more precise
results for small (absolute) values of exp
x - 1x
if possible.
Since: base-4.9.0.0
Instances
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 inversex * 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.
fromRational, (recip | (/))
fractional division
reciprocal fraction
fromRational :: Rational -> a #
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 CFloat | |
Fractional CDouble | |
Integral a => Fractional (Ratio a) | Since: base-2.0.1 |
RealFloat a => Fractional (Complex a) | Since: base-2.1 |
Fractional a => Fractional (Identity a) | Since: base-4.9.0.0 |
Fractional a => Fractional (Const a b) | Since: base-4.9.0.0 |
class (Real a, Enum a) => Integral a where #
Integral numbers, supporting integer division.
The Haskell Report defines no laws for Integral
. However, Integral
instances are customarily expected to define a Euclidean domain and have the
following properties for the 'div'/'mod' and 'quot'/'rem' pairs, given
suitable Euclidean functions f
and g
:
x
=y * quot x y + rem x 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
.
quot :: a -> a -> a infixl 7 #
integer division truncated toward zero
integer remainder, satisfying
(x `quot` y)*y + (x `rem` y) == x
integer division truncated toward negative infinity
integer modulus, satisfying
(x `div` y)*y + (x `mod` y) == x
conversion to Integer
Instances
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
fromInteger 0
is the additive identityx + fromInteger 0
=x
negate
gives the additive inversex + negate x
=fromInteger 0
- Associativity of (*)
(x * y) * z
=x * (y * z)
fromInteger 1
is the multiplicative identityx * 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)
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.
Unary negation.
Absolute value.
Sign of a number.
The functions abs
and signum
should satisfy the law:
abs x * signum x == x
For real numbers, the signum
is either -1
(negative), 0
(zero)
or 1
(positive).
fromInteger :: Integer -> a #
Conversion from an Integer
.
An integer literal represents the application of the function
fromInteger
to the appropriate value of type Integer
,
so such literals have type (
.Num
a) => a
Instances
Num Int | Since: base-2.1 |
Num Int8 | Since: base-2.1 |
Num Int16 | Since: base-2.1 |
Num Int32 | Since: base-2.1 |
Num Int64 | Since: base-2.1 |
Num Integer | Since: base-2.1 |
Num Natural | Note that Since: base-4.8.0.0 |
Num Word | Since: base-2.1 |
Num Word8 | Since: base-2.1 |
Num Word16 | Since: base-2.1 |
Num Word32 | Since: base-2.1 |
Num Word64 | Since: base-2.1 |
Num CDev | |
Num CIno | |
Num CMode | |
Num COff | |
Num CPid | |
Num CSsize | |
Num CGid | |
Num CNlink | |
Num CUid | |
Num CCc | |
Num CSpeed | |
Num CTcflag | |
Num CRLim | |
Num CBlkSize | |
Num CBlkCnt | |
Num CClockId | |
Num CFsBlkCnt | |
Num CFsFilCnt | |
Num CId | |
Num CKey | |
Num Fd | |
Num CChar | |
Num CSChar | |
Num CUChar | |
Num CShort | |
Num CUShort | |
Num CInt | |
Num CUInt | |
Num CLong | |
Num CULong | |
Num CLLong | |
Num CULLong | |
Num CBool | |
Num CFloat | |
Num CDouble | |
Num CPtrdiff | |
Num CSize | |
Num CWchar | |
Num CSigAtomic | |
Defined in Foreign.C.Types (+) :: CSigAtomic -> CSigAtomic -> CSigAtomic # (-) :: CSigAtomic -> CSigAtomic -> CSigAtomic # (*) :: CSigAtomic -> CSigAtomic -> CSigAtomic # negate :: CSigAtomic -> CSigAtomic # abs :: CSigAtomic -> CSigAtomic # signum :: CSigAtomic -> CSigAtomic # fromInteger :: Integer -> CSigAtomic # | |
Num CClock | |
Num CTime | |
Num CUSeconds | |
Num CSUSeconds | |
Defined in Foreign.C.Types (+) :: CSUSeconds -> CSUSeconds -> CSUSeconds # (-) :: CSUSeconds -> CSUSeconds -> CSUSeconds # (*) :: CSUSeconds -> CSUSeconds -> CSUSeconds # negate :: CSUSeconds -> CSUSeconds # abs :: CSUSeconds -> CSUSeconds # signum :: CSUSeconds -> CSUSeconds # fromInteger :: Integer -> CSUSeconds # | |
Num CIntPtr | |
Num CUIntPtr | |
Num CIntMax | |
Num CUIntMax | |
Num WordPtr | |
Num IntPtr | |
Num CodePoint | |
Num DecoderState | |
Defined in Data.Text.Encoding (+) :: DecoderState -> DecoderState -> DecoderState # (-) :: DecoderState -> DecoderState -> DecoderState # (*) :: DecoderState -> DecoderState -> DecoderState # negate :: DecoderState -> DecoderState # abs :: DecoderState -> DecoderState # signum :: DecoderState -> DecoderState # fromInteger :: Integer -> DecoderState # | |
Integral a => Num (Ratio a) | Since: base-2.0.1 |
RealFloat a => Num (Complex a) | Since: base-2.1 |
Num a => Num (Min a) | Since: base-4.9.0.0 |
Num a => Num (Max a) | Since: base-4.9.0.0 |
Num a => Num (Identity a) | Since: base-4.9.0.0 |
Defined in Data.Functor.Identity | |
Num a => Num (Sum a) | Since: base-4.7.0.0 |
Num a => Num (Product a) | Since: base-4.7.0.0 |
Defined in Data.Semigroup.Internal | |
Num a => Num (Down a) | Since: base-4.11.0.0 |
Num a => Num (Const a b) | Since: base-4.9.0.0 |
(Applicative f, Num a) => Num (Ap f a) | Since: base-4.12.0.0 |
Num (f a) => Num (Alt f a) | Since: base-4.8.0.0 |
class (Num a, Ord a) => Real a where #
toRational :: a -> Rational #
the rational equivalent of its real argument with full precision
Instances
class (RealFrac a, Floating a) => RealFloat a where #
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 #
a constant function, returning the radix of the representation
(often 2
)
floatDigits :: a -> Int #
a constant function, returning the number of digits of
floatRadix
in the significand
floatRange :: a -> (Int, Int) #
a constant function, returning the lowest and highest values the exponent may assume
decodeFloat :: a -> (Integer, Int) #
The function decodeFloat
applied to a real floating-point
number returns the significand expressed as an Integer
and an
appropriately scaled exponent (an Int
). If
yields decodeFloat
x(m,n)
, then x
is equal in value to m*b^^n
, where b
is the floating-point radix, and furthermore, either m
and n
are both zero or else b^(d-1) <=
, where abs
m < b^dd
is
the value of
.
In particular, floatDigits
x
. If the type
contains a negative zero, also decodeFloat
0 = (0,0)
.
The result of decodeFloat
(-0.0) = (0,0)
is unspecified if either of
decodeFloat
x
or isNaN
x
is isInfinite
xTrue
.
encodeFloat :: Integer -> Int -> a #
encodeFloat
performs the inverse of decodeFloat
in the
sense that for finite x
with the exception of -0.0
,
.
uncurry
encodeFloat
(decodeFloat
x) = x
is one of the two closest representable
floating-point numbers to encodeFloat
m nm*b^^n
(or ±Infinity
if overflow
occurs); usually the closer, but if m
contains too many bits,
the result may be rounded in the wrong direction.
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 #
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 #
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 #
True
if the argument is an IEEE infinity or negative infinity
isDenormalized :: a -> Bool #
True
if the argument is too small to be represented in
normalized format
isNegativeZero :: a -> Bool #
True
if the argument is an IEEE negative zero
True
if the argument is an IEEE floating point number
a version of arctangent taking two real floating-point arguments.
For real floating x
and y
,
computes the angle
(from the positive x-axis) of the vector from the origin to the
point atan2
y x(x,y)
.
returns a value in the range [atan2
y x-pi
,
pi
]. It follows the Common Lisp semantics for the origin when
signed zeroes are supported.
, with atan2
y 1y
in a type
that is RealFloat
, should return the same value as
.
A default definition of atan
yatan2
is provided, but implementors
can provide a more accurate implementation.
Instances
class (Real a, Fractional a) => RealFrac a where #
Extracting components of fractions.
properFraction :: Integral b => a -> (b, a) #
The function properFraction
takes a real fractional number x
and returns a pair (n,f)
such that x = n+f
, and:
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 #
returns the integer nearest truncate
xx
between zero and x
round :: Integral b => a -> b #
returns the nearest integer to round
xx
;
the even integer if x
is equidistant between two integers
ceiling :: Integral b => a -> b #
returns the least integer not less than ceiling
xx
floor :: Integral b => a -> b #
returns the greatest integer not greater than floor
xx
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
This class gives the integer associated with a type-level natural. There are instances of the class for every concrete literal: 0, 1, 2, etc.
Since: base-4.7.0.0
natSing
class KnownSymbol (n :: Symbol) #
This class gives the string associated with a type-level symbol. There are instances of the class for every concrete literal: "hello", etc.
Since: base-4.7.0.0
symbolSing
class HasField (x :: k) r a | x r -> a where #
Constraint representing the fact that the field x
belongs to
the record type r
and has field type a
. This will be solved
automatically, but manual instances may be provided as well.
Instances
Bounded Bool | Since: base-2.1 |
Enum Bool | Since: base-2.1 |
Eq Bool | |
Ord Bool | |
Read Bool | Since: base-2.1 |
Show Bool | Since: base-2.1 |
Ix Bool | Since: base-2.1 |
Generic Bool | |
SingKind Bool | Since: base-4.9.0.0 |
Storable Bool | Since: base-2.1 |
Defined in Foreign.Storable | |
Bits Bool | Interpret Since: base-4.7.0.0 |
Defined in Data.Bits (.&.) :: Bool -> Bool -> Bool # (.|.) :: Bool -> Bool -> Bool # complement :: Bool -> Bool # shift :: Bool -> Int -> Bool # rotate :: Bool -> Int -> Bool # setBit :: Bool -> Int -> Bool # clearBit :: Bool -> Int -> Bool # complementBit :: Bool -> Int -> Bool # testBit :: Bool -> Int -> Bool # bitSizeMaybe :: Bool -> Maybe Int # shiftL :: Bool -> Int -> Bool # unsafeShiftL :: Bool -> Int -> Bool # shiftR :: Bool -> Int -> Bool # unsafeShiftR :: Bool -> Int -> Bool # rotateL :: Bool -> Int -> Bool # | |
FiniteBits Bool | Since: base-4.7.0.0 |
Defined in Data.Bits | |
NFData Bool | |
Defined in Control.DeepSeq | |
Hashable Bool | |
Defined in Data.Hashable.Class | |
SingI False | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
SingI True | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
type Rep Bool | Since: base-4.6.0.0 |
data Sing (a :: Bool) | |
type DemoteRep Bool | |
Defined in GHC.Generics |
The character type Char
is an enumeration whose values represent
Unicode (or equivalently ISO/IEC 10646) code points (i.e. characters, see
http://www.unicode.org/ for details). This set extends the ISO 8859-1
(Latin-1) character set (the first 256 characters), which is itself an extension
of the ASCII character set (the first 128 characters). A character literal in
Haskell has type Char
.
To convert a Char
to or from the corresponding Int
value defined
by Unicode, use toEnum
and fromEnum
from the
Enum
class respectively (or equivalently ord
and chr
).
Instances
Bounded Char | Since: base-2.1 |
Enum Char | Since: base-2.1 |
Eq Char | |
Ord Char | |
Read Char | Since: base-2.1 |
Show Char | Since: base-2.1 |
Ix Char | Since: base-2.1 |
Storable Char | Since: base-2.1 |
Defined in Foreign.Storable | |
NFData Char | |
Defined in Control.DeepSeq | |
ErrorList Char | |
Defined in Control.Monad.Trans.Error | |
Hashable Char | |
Defined in Data.Hashable.Class | |
StringConv String String Source # | |
StringConv String ByteString Source # | |
Defined in Protolude.Conv | |
StringConv String ByteString Source # | |
Defined in Protolude.Conv | |
StringConv String Text Source # | |
StringConv String Text Source # | |
StringConv ByteString String Source # | |
Defined in Protolude.Conv | |
StringConv ByteString String Source # | |
Defined in Protolude.Conv | |
StringConv Text String Source # | |
StringConv Text String Source # | |
Generic1 (URec Char :: k -> Type) | |
Print [Char] Source # | |
Functor (URec Char :: Type -> Type) | Since: base-4.9.0.0 |
Foldable (URec Char :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => URec Char m -> m # foldMap :: Monoid m => (a -> m) -> URec Char a -> m # foldr :: (a -> b -> b) -> b -> URec Char a -> b # foldr' :: (a -> b -> b) -> b -> URec Char a -> b # foldl :: (b -> a -> b) -> b -> URec Char a -> b # foldl' :: (b -> a -> b) -> b -> URec Char a -> b # foldr1 :: (a -> a -> a) -> URec Char a -> a # foldl1 :: (a -> a -> a) -> URec Char a -> a # toList :: URec Char a -> [a] # length :: URec Char a -> Int # elem :: Eq a => a -> URec Char a -> Bool # maximum :: Ord a => URec Char a -> a # minimum :: Ord a => URec Char a -> a # | |
Traversable (URec Char :: Type -> Type) | Since: base-4.9.0.0 |
Eq (URec Char p) | Since: base-4.9.0.0 |
Ord (URec Char p) | Since: base-4.9.0.0 |
Show (URec Char p) | Since: base-4.9.0.0 |
Generic (URec Char p) | |
data URec Char (p :: k) | Used for marking occurrences of Since: base-4.9.0.0 |
type Rep1 (URec Char :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
type Rep (URec Char p) | Since: base-4.9.0.0 |
Defined in GHC.Generics |
Double-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE double-precision type.
Instances
Eq Double | Note that due to the presence of
Also note that
|
Floating Double | Since: base-2.1 |
Ord Double | Note that due to the presence of
Also note that, due to the same,
|
Read Double | Since: base-2.1 |
RealFloat Double | Since: base-2.1 |
Defined in GHC.Float floatRadix :: Double -> Integer # floatDigits :: Double -> Int # floatRange :: Double -> (Int, Int) # decodeFloat :: Double -> (Integer, Int) # encodeFloat :: Integer -> Int -> Double # significand :: Double -> Double # scaleFloat :: Int -> Double -> Double # isInfinite :: Double -> Bool # isDenormalized :: Double -> Bool # isNegativeZero :: Double -> Bool # | |
Storable Double | Since: base-2.1 |
NFData Double | |
Defined in Control.DeepSeq | |
Hashable Double | |
Defined in Data.Hashable.Class | |
Generic1 (URec Double :: k -> Type) | |
Functor (URec Double :: Type -> Type) | Since: base-4.9.0.0 |
Foldable (URec Double :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => URec Double m -> m # foldMap :: Monoid m => (a -> m) -> URec Double a -> m # foldr :: (a -> b -> b) -> b -> URec Double a -> b # foldr' :: (a -> b -> b) -> b -> URec Double a -> b # foldl :: (b -> a -> b) -> b -> URec Double a -> b # foldl' :: (b -> a -> b) -> b -> URec Double a -> b # foldr1 :: (a -> a -> a) -> URec Double a -> a # foldl1 :: (a -> a -> a) -> URec Double a -> a # toList :: URec Double a -> [a] # null :: URec Double a -> Bool # length :: URec Double a -> Int # elem :: Eq a => a -> URec Double a -> Bool # maximum :: Ord a => URec Double a -> a # minimum :: Ord a => URec Double a -> a # | |
Traversable (URec Double :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Traversable | |
Eq (URec Double p) | Since: base-4.9.0.0 |
Ord (URec Double p) | Since: base-4.9.0.0 |
Defined in GHC.Generics compare :: URec Double p -> URec Double p -> Ordering # (<) :: URec Double p -> URec Double p -> Bool # (<=) :: URec Double p -> URec Double p -> Bool # (>) :: URec Double p -> URec Double p -> Bool # (>=) :: URec Double p -> URec Double p -> Bool # | |
Show (URec Double p) | Since: base-4.9.0.0 |
Generic (URec Double p) | |
data URec Double (p :: k) | Used for marking occurrences of Since: base-4.9.0.0 |
type Rep1 (URec Double :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
type Rep (URec Double p) | Since: base-4.9.0.0 |
Defined in GHC.Generics |
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
Eq Float | Note that due to the presence of
Also note that
|
Floating Float | Since: base-2.1 |
Ord Float | Note that due to the presence of
Also note that, due to the same,
|
Read Float | Since: base-2.1 |
RealFloat Float | Since: base-2.1 |
Defined in GHC.Float floatRadix :: Float -> Integer # floatDigits :: Float -> Int # floatRange :: Float -> (Int, Int) # decodeFloat :: Float -> (Integer, Int) # encodeFloat :: Integer -> Int -> Float # significand :: Float -> Float # scaleFloat :: Int -> Float -> Float # isInfinite :: Float -> Bool # isDenormalized :: Float -> Bool # isNegativeZero :: Float -> Bool # | |
Storable Float | Since: base-2.1 |
NFData Float | |
Defined in Control.DeepSeq | |
Hashable Float | |
Defined in Data.Hashable.Class | |
Generic1 (URec Float :: k -> Type) | |
Functor (URec Float :: Type -> Type) | Since: base-4.9.0.0 |
Foldable (URec Float :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => URec Float m -> m # foldMap :: Monoid m => (a -> m) -> URec Float a -> m # foldr :: (a -> b -> b) -> b -> URec Float a -> b # foldr' :: (a -> b -> b) -> b -> URec Float a -> b # foldl :: (b -> a -> b) -> b -> URec Float a -> b # foldl' :: (b -> a -> b) -> b -> URec Float a -> b # foldr1 :: (a -> a -> a) -> URec Float a -> a # foldl1 :: (a -> a -> a) -> URec Float a -> a # toList :: URec Float a -> [a] # null :: URec Float a -> Bool # length :: URec Float a -> Int # elem :: Eq a => a -> URec Float a -> Bool # maximum :: Ord a => URec Float a -> a # minimum :: Ord a => URec Float a -> a # | |
Traversable (URec Float :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Traversable | |
Eq (URec Float p) | |
Ord (URec Float p) | |
Defined in GHC.Generics | |
Show (URec Float p) | |
Generic (URec Float p) | |
data URec Float (p :: k) | Used for marking occurrences of Since: base-4.9.0.0 |
type Rep1 (URec Float :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
type Rep (URec Float p) | |
Defined in GHC.Generics |
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
Bounded Int | Since: base-2.1 |
Enum Int | Since: base-2.1 |
Eq Int | |
Integral Int | Since: base-2.0.1 |
Num Int | Since: base-2.1 |
Ord Int | |
Read Int | Since: base-2.1 |
Real Int | Since: base-2.0.1 |
Defined in GHC.Real toRational :: Int -> Rational # | |
Show Int | Since: base-2.1 |
Ix Int | Since: base-2.1 |
Storable Int | Since: base-2.1 |
Defined in Foreign.Storable | |
Bits Int | Since: base-2.1 |
Defined in Data.Bits | |
FiniteBits Int | Since: base-4.6.0.0 |
Defined in Data.Bits | |
NFData Int | |
Defined in Control.DeepSeq | |
Hashable Int | |
Defined in Data.Hashable.Class | |
Generic1 (URec Int :: k -> Type) | |
Functor (URec Int :: Type -> Type) | Since: base-4.9.0.0 |
Foldable (URec Int :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => URec Int m -> m # foldMap :: Monoid m => (a -> m) -> URec Int a -> m # foldr :: (a -> b -> b) -> b -> URec Int a -> b # foldr' :: (a -> b -> b) -> b -> URec Int a -> b # foldl :: (b -> a -> b) -> b -> URec Int a -> b # foldl' :: (b -> a -> b) -> b -> URec Int a -> b # foldr1 :: (a -> a -> a) -> URec Int a -> a # foldl1 :: (a -> a -> a) -> URec Int a -> a # elem :: Eq a => a -> URec Int a -> Bool # maximum :: Ord a => URec Int a -> a # minimum :: Ord a => URec Int a -> a # | |
Traversable (URec Int :: Type -> Type) | Since: base-4.9.0.0 |
Eq (URec Int p) | Since: base-4.9.0.0 |
Ord (URec Int p) | Since: base-4.9.0.0 |
Show (URec Int p) | Since: base-4.9.0.0 |
Generic (URec Int p) | |
data URec Int (p :: k) | Used for marking occurrences of Since: base-4.9.0.0 |
type Rep1 (URec Int :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
type Rep (URec Int p) | Since: base-4.9.0.0 |
Defined in GHC.Generics |
Invariant: Jn#
and Jp#
are used iff value doesn't fit in S#
Useful properties resulting from the invariants:
Instances
Instances
Bounded Ordering | Since: base-2.1 |
Enum Ordering | Since: base-2.1 |
Eq Ordering | |
Ord Ordering | |
Defined in GHC.Classes | |
Read Ordering | Since: base-2.1 |
Show Ordering | Since: base-2.1 |
Ix Ordering | Since: base-2.1 |
Defined in GHC.Arr | |
Generic Ordering | |
Semigroup Ordering | Since: base-4.9.0.0 |
Monoid Ordering | Since: base-2.1 |
NFData Ordering | |
Defined in Control.DeepSeq | |
Hashable Ordering | |
Defined in Data.Hashable.Class | |
type Rep Ordering | Since: base-4.6.0.0 |
Rational numbers, with numerator and denominator of some Integral
type.
Note that Ratio
's instances inherit the deficiencies from the type
parameter's. For example, Ratio Natural
's Num
instance has similar
problems to Natural
's.
!a :% !a |
Instances
NFData1 Ratio | Available on Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
Integral a => Enum (Ratio a) | Since: base-2.0.1 |
Eq a => Eq (Ratio a) | Since: base-2.1 |
Integral a => Fractional (Ratio a) | Since: base-2.0.1 |
Integral a => Num (Ratio a) | Since: base-2.0.1 |
Integral a => Ord (Ratio a) | Since: base-2.0.1 |
(Integral a, Read a) => Read (Ratio a) | Since: base-2.1 |
Integral a => Real (Ratio a) | Since: base-2.0.1 |
Defined in GHC.Real toRational :: Ratio a -> Rational # | |
Integral a => RealFrac (Ratio a) | Since: base-2.0.1 |
Show a => Show (Ratio a) | Since: base-2.0.1 |
(Storable a, Integral a) => Storable (Ratio a) | Since: base-4.8.0.0 |
NFData a => NFData (Ratio a) | |
Defined in Control.DeepSeq | |
Hashable a => Hashable (Ratio a) | |
Defined in Data.Hashable.Class |
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
Monad IO | Since: base-2.1 |
Functor IO | Since: base-2.1 |
Applicative IO | Since: base-2.1 |
MonadIO IO | Since: base-4.9.0.0 |
Defined in Control.Monad.IO.Class | |
Alternative IO | Since: base-4.9.0.0 |
MonadPlus IO | Since: base-4.9.0.0 |
MonadError IOException IO | |
Defined in Control.Monad.Error.Class throwError :: IOException -> IO a # catchError :: IO a -> (IOException -> IO a) -> IO a # | |
Semigroup a => Semigroup (IO a) | Since: base-4.10.0.0 |
Monoid a => Monoid (IO a) | Since: base-4.9.0.0 |
Instances
Bounded Word | Since: base-2.1 |
Enum Word | Since: base-2.1 |
Eq Word | |
Integral Word | Since: base-2.1 |
Num Word | Since: base-2.1 |
Ord Word | |
Read Word | Since: base-4.5.0.0 |
Real Word | Since: base-2.1 |
Defined in GHC.Real toRational :: Word -> Rational # | |
Show Word | Since: base-2.1 |
Ix Word | Since: base-4.6.0.0 |
Storable Word | Since: base-2.1 |
Defined in Foreign.Storable | |
Bits Word | Since: base-2.1 |
Defined in Data.Bits (.&.) :: Word -> Word -> Word # (.|.) :: Word -> Word -> Word # complement :: Word -> Word # shift :: Word -> Int -> Word # rotate :: Word -> Int -> Word # setBit :: Word -> Int -> Word # clearBit :: Word -> Int -> Word # complementBit :: Word -> Int -> Word # testBit :: Word -> Int -> Bool # bitSizeMaybe :: Word -> Maybe Int # shiftL :: Word -> Int -> Word # unsafeShiftL :: Word -> Int -> Word # shiftR :: Word -> Int -> Word # unsafeShiftR :: Word -> Int -> Word # rotateL :: Word -> Int -> Word # | |
FiniteBits Word | Since: base-4.6.0.0 |
Defined in Data.Bits | |
NFData Word | |
Defined in Control.DeepSeq | |
Hashable Word | |
Defined in Data.Hashable.Class | |
Generic1 (URec Word :: k -> Type) | |
Functor (URec Word :: Type -> Type) | Since: base-4.9.0.0 |
Foldable (URec Word :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => URec Word m -> m # foldMap :: Monoid m => (a -> m) -> URec Word a -> m # foldr :: (a -> b -> b) -> b -> URec Word a -> b # foldr' :: (a -> b -> b) -> b -> URec Word a -> b # foldl :: (b -> a -> b) -> b -> URec Word a -> b # foldl' :: (b -> a -> b) -> b -> URec Word a -> b # foldr1 :: (a -> a -> a) -> URec Word a -> a # foldl1 :: (a -> a -> a) -> URec Word a -> a # toList :: URec Word a -> [a] # length :: URec Word a -> Int # elem :: Eq a => a -> URec Word a -> Bool # maximum :: Ord a => URec Word a -> a # minimum :: Ord a => URec Word a -> a # | |
Traversable (URec Word :: Type -> Type) | Since: base-4.9.0.0 |
Eq (URec Word p) | Since: base-4.9.0.0 |
Ord (URec Word p) | Since: base-4.9.0.0 |
Show (URec Word p) | Since: base-4.9.0.0 |
Generic (URec Word p) | |
data URec Word (p :: k) | Used for marking occurrences of Since: base-4.9.0.0 |
type Rep1 (URec Word :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
type Rep (URec Word p) | Since: base-4.9.0.0 |
Defined in GHC.Generics |
A value of type
represents a pointer to an object, or an
array of objects, which may be marshalled to or from Haskell values
of type Ptr
aa
.
The type a
will often be an instance of class
Storable
which provides the marshalling operations.
However this is not essential, and you can provide your own operations
to access the pointer. For example you might write small foreign
functions to get or set the fields of a C struct
.
Instances
NFData1 Ptr | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
Generic1 (URec (Ptr ()) :: k -> Type) | |
Eq (Ptr a) | Since: base-2.1 |
Ord (Ptr a) | Since: base-2.1 |
Show (Ptr a) | Since: base-2.1 |
Storable (Ptr a) | Since: base-2.1 |
NFData (Ptr a) | Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
Hashable (Ptr a) | |
Defined in Data.Hashable.Class | |
Functor (URec (Ptr ()) :: Type -> Type) | Since: base-4.9.0.0 |
Foldable (URec (Ptr ()) :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => URec (Ptr ()) m -> m # foldMap :: Monoid m => (a -> m) -> URec (Ptr ()) a -> m # foldr :: (a -> b -> b) -> b -> URec (Ptr ()) a -> b # foldr' :: (a -> b -> b) -> b -> URec (Ptr ()) a -> b # foldl :: (b -> a -> b) -> b -> URec (Ptr ()) a -> b # foldl' :: (b -> a -> b) -> b -> URec (Ptr ()) a -> b # foldr1 :: (a -> a -> a) -> URec (Ptr ()) a -> a # foldl1 :: (a -> a -> a) -> URec (Ptr ()) a -> a # toList :: URec (Ptr ()) a -> [a] # null :: URec (Ptr ()) a -> Bool # length :: URec (Ptr ()) a -> Int # elem :: Eq a => a -> URec (Ptr ()) a -> Bool # maximum :: Ord a => URec (Ptr ()) a -> a # minimum :: Ord a => URec (Ptr ()) a -> a # | |
Traversable (URec (Ptr ()) :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Traversable | |
Eq (URec (Ptr ()) p) | Since: base-4.9.0.0 |
Ord (URec (Ptr ()) p) | Since: base-4.9.0.0 |
Defined in GHC.Generics compare :: URec (Ptr ()) p -> URec (Ptr ()) p -> Ordering # (<) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool # (<=) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool # (>) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool # (>=) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool # max :: URec (Ptr ()) p -> URec (Ptr ()) p -> URec (Ptr ()) p # min :: URec (Ptr ()) p -> URec (Ptr ()) p -> URec (Ptr ()) p # | |
Generic (URec (Ptr ()) p) | |
data URec (Ptr ()) (p :: k) | Used for marking occurrences of Since: base-4.9.0.0 |
type Rep1 (URec (Ptr ()) :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
type Rep (URec (Ptr ()) p) | Since: base-4.9.0.0 |
Defined in GHC.Generics |
A value of type
is a pointer to a function callable
from foreign code. The type FunPtr
aa
will normally be a foreign type,
a function type with zero or more arguments where
- the argument types are marshallable foreign types,
i.e.
Char
,Int
,Double
,Float
,Bool
,Int8
,Int16
,Int32
,Int64
,Word8
,Word16
,Word32
,Word64
,
,Ptr
a
,FunPtr
a
or a renaming of any of these usingStablePtr
anewtype
. - the return type is either a marshallable foreign type or has the form
whereIO
tt
is a marshallable foreign type or()
.
A value of type
may be a pointer to a foreign function,
either returned by another foreign function or imported with a
a static address import likeFunPtr
a
foreign import ccall "stdlib.h &free" p_free :: FunPtr (Ptr a -> IO ())
or a pointer to a Haskell function created using a wrapper stub
declared to produce a FunPtr
of the correct type. For example:
type Compare = Int -> Int -> Bool foreign import ccall "wrapper" mkCompare :: Compare -> IO (FunPtr Compare)
Calls to wrapper stubs like mkCompare
allocate storage, which
should be released with freeHaskellFunPtr
when no
longer required.
To convert FunPtr
values to corresponding Haskell functions, one
can define a dynamic stub for the specific foreign type, e.g.
type IntFunction = CInt -> IO () foreign import ccall "dynamic" mkFun :: FunPtr IntFunction -> IntFunction
Instances
NFData1 FunPtr | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
Eq (FunPtr a) | |
Ord (FunPtr a) | |
Show (FunPtr a) | Since: base-2.1 |
Storable (FunPtr a) | Since: base-2.1 |
Defined in Foreign.Storable | |
NFData (FunPtr a) | Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
Hashable (FunPtr a) | |
Defined in Data.Hashable.Class |
data Constraint #
The kind of constraints, like Show a
(Kind) This is the kind of type-level symbols. Declared here because class IP needs it
Instances
SingKind Symbol | Since: base-4.9.0.0 |
KnownSymbol a => SingI (a :: Symbol) | Since: base-4.9.0.0 |
Defined in GHC.Generics sing :: Sing a | |
data Sing (s :: Symbol) | |
Defined in GHC.Generics | |
type DemoteRep Symbol | |
Defined in GHC.Generics |
type family CmpNat (a :: Nat) (b :: Nat) :: Ordering where ... #
Comparison of type-level naturals, as a function.
Since: base-4.7.0.0
class a ~R# b => Coercible (a :: k0) (b :: k0) #
Coercible
is a two-parameter class that has instances for types a
and b
if
the compiler can infer that they have the same representation. This class
does not have regular instances; instead they are created on-the-fly during
type-checking. Trying to manually declare an instance of Coercible
is an error.
Nevertheless one can pretend that the following three kinds of instances exist. First, as a trivial base-case:
instance Coercible a a
Furthermore, for every type constructor there is
an instance that allows to coerce under the type constructor. For
example, let D
be a prototypical type constructor (data
or
newtype
) with three type arguments, which have roles nominal
,
representational
resp. phantom
. Then there is an instance of
the form
instance Coercible b b' => Coercible (D a b c) (D a b' c')
Note that the nominal
type arguments are equal, the
representational
type arguments can differ, but need to have a
Coercible
instance themself, and the phantom
type arguments can be
changed arbitrarily.
The third kind of instance exists for every newtype NT = MkNT T
and
comes in two variants, namely
instance Coercible a T => Coercible a NT
instance Coercible T b => Coercible NT b
This instance is only usable if the constructor MkNT
is in scope.
If, as a library author of a type constructor like Set a
, you
want to prevent a user of your module to write
coerce :: Set T -> Set NT
,
you need to set the role of Set
's type parameter to nominal
,
by writing
type role Set nominal
For more details about this feature, please refer to Safe Coercions by Joachim Breitner, Richard A. Eisenberg, Simon Peyton Jones and Stephanie Weirich.
Since: ghc-prim-4.7.0.0
A reference to a value of type a
.
Instances
IsStatic StaticPtr | Since: base-4.9.0.0 |
Defined in GHC.StaticPtr fromStaticPtr :: StaticPtr a -> StaticPtr a # |
CallStack
s are a lightweight method of obtaining a
partial call-stack at any point in the program.
A function can request its call-site with the HasCallStack
constraint.
For example, we can define
putStrLnWithCallStack :: HasCallStack => String -> IO ()
as a variant of putStrLn
that will get its call-site and print it,
along with the string given as argument. We can access the
call-stack inside putStrLnWithCallStack
with callStack
.
putStrLnWithCallStack :: HasCallStack => String -> IO () putStrLnWithCallStack msg = do putStrLn msg putStrLn (prettyCallStack callStack)
Thus, if we call putStrLnWithCallStack
we will get a formatted call-stack
alongside our string.
>>>
putStrLnWithCallStack "hello"
hello CallStack (from HasCallStack): putStrLnWithCallStack, called at <interactive>:2:1 in interactive:Ghci1
GHC solves HasCallStack
constraints in three steps:
- If there is a
CallStack
in scope -- i.e. the enclosing function has aHasCallStack
constraint -- GHC will append the new call-site to the existingCallStack
. - If there is no
CallStack
in scope -- e.g. in the GHCi session above -- and the enclosing definition does not have an explicit type signature, GHC will infer aHasCallStack
constraint for the enclosing definition (subject to the monomorphism restriction). - If there is no
CallStack
in scope and the enclosing definition has an explicit type signature, GHC will solve theHasCallStack
constraint for the singletonCallStack
containing just the current call-site.
CallStack
s do not interact with the RTS and do not require compilation
with -prof
. On the other hand, as they are built up explicitly via the
HasCallStack
constraints, they will generally not contain as much
information as the simulated call-stacks maintained by the RTS.
A CallStack
is a [(String, SrcLoc)]
. The String
is the name of
function that was called, the SrcLoc
is the call-site. The list is
ordered with the most recently called function at the head.
NOTE: The intrepid user may notice that HasCallStack
is just an
alias for an implicit parameter ?callStack :: CallStack
. This is an
implementation detail and should not be considered part of the
CallStack
API, we may decide to change the implementation in the
future.
Since: base-4.8.1.0
integralEnumFromThenTo :: Integral a => a -> a -> a -> [a] #
integralEnumFromTo :: Integral a => a -> a -> [a] #
integralEnumFromThen :: (Integral a, Bounded a) => a -> a -> [a] #
integralEnumFrom :: (Integral a, Bounded a) => a -> [a] #
numericEnumFromThenTo :: (Ord a, Fractional a) => a -> a -> a -> [a] #
numericEnumFromTo :: (Ord a, Fractional a) => a -> a -> [a] #
numericEnumFromThen :: Fractional a => a -> a -> [a] #
numericEnumFrom :: Fractional a => a -> [a] #
notANumber :: Rational #
ratioPrec1 :: Int #
underflowError :: a #
overflowError :: a #
divZeroError :: a #
reduce :: Integral a => a -> a -> Ratio a #
reduce
is a subsidiary function used only in this module.
It normalises a ratio by dividing both numerator and denominator by
their greatest common divisor.
boundedEnumFromThen :: (Enum a, Bounded a) => a -> a -> [a] #
boundedEnumFrom :: (Enum a, Bounded a) => a -> [a] #
showStackTrace :: IO (Maybe String) #
Get a string representation of the current execution stack state.
getStackTrace :: IO (Maybe [Location]) #
Get a trace of the current execution stack state.
Returns Nothing
if stack trace support isn't available on host machine.
A location in the original program source.
SrcLoc | |
|
Location information about an address from a backtrace.
Location | |
|
withFrozenCallStack :: HasCallStack => (HasCallStack -> a) -> a #
Perform some computation without adding new entries to the CallStack
.
Since: base-4.9.0.0
callStack :: HasCallStack -> CallStack #
prettyCallStack :: CallStack -> String #
Pretty print a CallStack
.
Since: base-4.9.0.0
prettySrcLoc :: SrcLoc -> String #
Pretty print a SrcLoc
.
Since: base-4.9.0.0
someSymbolVal :: String -> SomeSymbol #
Convert a string into an unknown type-level symbol.
Since: base-4.7.0.0
someNatVal :: Integer -> Maybe SomeNat #
Convert an integer into an unknown type-level natural.
Since: base-4.7.0.0
symbolVal :: KnownSymbol n => proxy n -> String #
Since: base-4.7.0.0
data SomeSymbol where #
This type represents unknown type-level symbols.
SomeSymbol :: forall (n :: Symbol). KnownSymbol n => Proxy n -> SomeSymbol | Since: base-4.7.0.0 |
Instances
Eq SomeSymbol | Since: base-4.7.0.0 |
Defined in GHC.TypeLits (==) :: SomeSymbol -> SomeSymbol -> Bool # (/=) :: SomeSymbol -> SomeSymbol -> Bool # | |
Ord SomeSymbol | Since: base-4.7.0.0 |
Defined in GHC.TypeLits compare :: SomeSymbol -> SomeSymbol -> Ordering # (<) :: SomeSymbol -> SomeSymbol -> Bool # (<=) :: SomeSymbol -> SomeSymbol -> Bool # (>) :: SomeSymbol -> SomeSymbol -> Bool # (>=) :: SomeSymbol -> SomeSymbol -> Bool # max :: SomeSymbol -> SomeSymbol -> SomeSymbol # min :: SomeSymbol -> SomeSymbol -> SomeSymbol # | |
Read SomeSymbol | Since: base-4.7.0.0 |
Defined in GHC.TypeLits readsPrec :: Int -> ReadS SomeSymbol # readList :: ReadS [SomeSymbol] # readPrec :: ReadPrec SomeSymbol # readListPrec :: ReadPrec [SomeSymbol] # | |
Show SomeSymbol | Since: base-4.7.0.0 |
Defined in GHC.TypeLits showsPrec :: Int -> SomeSymbol -> ShowS # show :: SomeSymbol -> String # showList :: [SomeSymbol] -> ShowS # |
This type represents unknown type-level natural numbers.
Since: base-4.10.0.0
showFloat :: RealFloat a => a -> ShowS #
Show a signed RealFloat
value to full precision
using standard decimal notation for arguments whose absolute value lies
between 0.1
and 9,999,999
, and scientific notation otherwise.
lcm :: Integral a => a -> a -> a #
is the smallest positive integer that both lcm
x yx
and y
divide.
gcd :: Integral a => a -> a -> a #
is the non-negative factor of both gcd
x yx
and y
of which
every common factor of x
and y
is also a factor; for example
, gcd
4 2 = 2
, gcd
(-4) 6 = 2
= gcd
0 44
.
= gcd
0 00
.
(That is, the common divisor that is "greatest" in the divisibility
preordering.)
Note: Since for signed fixed-width integer types,
,
the result may be negative if one of the arguments is abs
minBound
< 0
(and
necessarily is if the other is minBound
0
or
) for such types.minBound
(^^) :: (Fractional a, Integral b) => a -> b -> a infixr 8 #
raise a number to an integral power
:: Real a | |
=> (a -> ShowS) | a function that can show unsigned values |
-> Int | the precedence of the enclosing context |
-> a | the value to show |
-> ShowS |
Converts a possibly-negative Real
value to a string.
denominator :: Ratio a -> a #
Extract the denominator of the ratio in reduced form: the numerator and denominator have no common factor and the denominator is positive.
Extract the numerator of the ratio in reduced form: the numerator and denominator have no common factor and the denominator is positive.
currentCallStack :: IO [String] #
Returns a [String]
representing the current call stack. This
can be useful for debugging.
The implementation uses the call-stack simulation maintained by the
profiler, so it only works if the program was compiled with -prof
and contains suitable SCC annotations (e.g. by using -fprof-auto
).
Otherwise, the list returned is likely to be empty or
uninformative.
Since: base-4.5.0.0
until :: (a -> Bool) -> (a -> a) -> a -> a #
yields the result of applying until
p ff
until p
holds.
getCallStack :: CallStack -> [([Char], SrcLoc)] #
Extract a list of call-sites from the CallStack
.
The list is ordered by most recent call.
Since: base-4.8.1.0
type HasCallStack = ?callStack :: CallStack #
Request a CallStack.
NOTE: The implicit parameter ?callStack :: CallStack
is an
implementation detail and should not be considered part of the
CallStack
API, we may decide to change the implementation in the
future.
Since: base-4.9.0.0