| Safe Haskell | Unsafe |
|---|---|
| Language | Haskell2010 |
Protolude.Base
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
- class Fractional a => Floating a where
- class Num a => Fractional a where
- class (Real a, Enum a) => Integral a where
- class Num a where
- class (Num a, Ord a) => Real a where
- class (RealFrac a, Floating a) => RealFloat a where
- 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
- class HasField (x :: k) r a | x r -> a where
- 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 = *
- data Constraint
- type * = *
- 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
- 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
- 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
andsuccmaxBoundshould result in a runtime error.predminBound fromEnumandtoEnumshould give a runtime error if the result value is not representable in the result type. For example,is an error.toEnum7 ::BoolenumFromandenumFromThenshould 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 = minBoundMethods
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..].
enumFromThen :: a -> a -> [a] #
Used in Haskell's translation of [n,n'..].
enumFromTo :: a -> a -> [a] #
Used in Haskell's translation of [n..m].
enumFromThenTo :: a -> a -> a -> [a] #
Used in Haskell's translation of [n,n'..m].
Instances
class Fractional a => Floating a where #
Trigonometric and hyperbolic functions and related functions.
Minimal complete definition
pi, exp, log, sin, cos, asin, acos, atan, sinh, cosh, asinh, acosh, atanh
Methods
(**) :: 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.
Minimal complete definition
fromRational, (recip | (/))
Methods
fractional division
reciprocal fraction
fromRational :: Rational -> a #
Conversion from a Rational (that is ).
A floating literal stands for an application of Ratio IntegerfromRational
to a value of type Rational, so such literals have type
(.Fractional a) => a
Instances
| 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) | |
| Fractional a => Fractional (Const a b) | |
class (Real a, Enum a) => Integral a where #
Integral numbers, supporting integer division.
Methods
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.
Methods
Unary negation.
Absolute value.
Sign of a number.
The functions abs and signum should satisfy the law:
abs x * signum x == x
For real numbers, the signum is either -1 (negative), 0 (zero)
or 1 (positive).
fromInteger :: Integer -> a #
Conversion from an Integer.
An integer literal represents the application of the function
fromInteger to the appropriate value of type Integer,
so such literals have type (.Num a) => a
Instances
class (Num a, Ord a) => Real a where #
Minimal complete definition
Methods
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.
Minimal complete definition
floatRadix, floatDigits, floatRange, decodeFloat, encodeFloat, isNaN, isInfinite, isDenormalized, isNegativeZero, isIEEE
Methods
floatRadix :: a -> Integer #
a constant function, returning the radix of the representation
(often 2)
floatDigits :: a -> Int #
a constant function, returning the number of digits of
floatRadix in the significand
floatRange :: a -> (Int, Int) #
a constant function, returning the lowest and highest values the exponent may assume
decodeFloat :: a -> (Integer, Int) #
The function decodeFloat applied to a real floating-point
number returns the significand expressed as an Integer and an
appropriately scaled exponent (an Int). If
yields decodeFloat x(m,n), then x is equal in value to m*b^^n, where b
is the floating-point radix, and furthermore, either m and n
are both zero or else b^(d-1) <= , where abs m < b^dd is
the value of .
In particular, floatDigits x. If the type
contains a negative zero, also decodeFloat 0 = (0,0).
The result of decodeFloat (-0.0) = (0,0) is unspecified if either of
decodeFloat x or isNaN x is isInfinite xTrue.
encodeFloat :: Integer -> Int -> a #
encodeFloat performs the inverse of decodeFloat in the
sense that for finite x with the exception of -0.0,
.
uncurry encodeFloat (decodeFloat x) = x is one of the two closest representable
floating-point numbers to encodeFloat m nm*b^^n (or ±Infinity if overflow
occurs); usually the closer, but if m contains too many bits,
the result may be rounded in the wrong direction.
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.
Minimal complete definition
Methods
properFraction :: Integral b => a -> (b, a) #
The function properFraction takes a real fractional number x
and returns a pair (n,f) such that x = n+f, and:
nis an integral number with the same sign asx; andfis a fraction with the same type and sign asx, and with absolute value less than1.
The default definitions of the ceiling, floor, truncate
and round functions are in terms of properFraction.
truncate :: Integral b => a -> b #
returns the integer nearest truncate xx between zero and x
round :: Integral b => a -> b #
returns the nearest integer to round xx;
the even integer if x is equidistant between two integers
ceiling :: Integral b => a -> b #
returns the least integer not less than ceiling xx
floor :: Integral b => a -> b #
returns the greatest integer not greater than floor xx
Conversion of values to readable Strings.
Derived instances of Show have the following properties, which
are compatible with derived instances of Read:
- The result of
showis 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
showsPrecwill produce infix applications of the constructor. - the representation will be enclosed in parentheses if the
precedence of the top-level constructor in
xis less thand(associativity is ignored). Thus, ifdis0then the result is never surrounded in parentheses; ifdis11it is always surrounded in parentheses, unless it is an atomic expression. - If the constructor is defined using record syntax, then
showwill 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 = 5Note that right-associativity of :^: is ignored. For example,
produces the stringshow(Leaf 1 :^: Leaf 2 :^: Leaf 3)"Leaf 1 :^: (Leaf 2 :^: Leaf 3)".
Methods
Arguments
| :: 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
Minimal complete definition
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
Minimal complete definition
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.
Minimal complete definition
Instances
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
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
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
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 Methods 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 Methods finiteBitSize :: Int -> Int # countLeadingZeros :: Int -> Int # countTrailingZeros :: Int -> Int # | |
| NFData Int | |
Defined in Control.DeepSeq | |
| Hashable Int | |
Defined in Data.Hashable.Class | |
| Generic1 (URec Int :: k -> *) | |
| Functor (URec Int :: * -> *) | |
| Foldable (URec Int :: * -> *) | |
Defined in Data.Foldable Methods 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 :: * -> *) | |
| Eq (URec Int p) | |
| Ord (URec Int p) | |
| Show (URec Int p) | |
| 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 -> *) | |
Defined in GHC.Generics | |
| type Rep (URec Int p) | |
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 | |
| 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 | |
Rational numbers, with numerator and denominator of some Integral type.
Constructors
| !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) | |
| 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 Methods toRational :: Ratio a -> Rational # | |
| Integral a => RealFrac (Ratio a) | Since: base-2.0.1 |
| Show a => Show (Ratio a) | Since: base-2.0.1 |
| (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 | |
| 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 Methods 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 Methods (.&.) :: Word -> Word -> Word # (.|.) :: Word -> Word -> Word # complement :: Word -> Word # shift :: Word -> Int -> Word # rotate :: Word -> Int -> Word # setBit :: Word -> Int -> Word # clearBit :: Word -> Int -> Word # complementBit :: Word -> Int -> Word # testBit :: Word -> Int -> Bool # bitSizeMaybe :: Word -> Maybe Int # shiftL :: Word -> Int -> Word # unsafeShiftL :: Word -> Int -> Word # shiftR :: Word -> Int -> Word # unsafeShiftR :: Word -> Int -> Word # rotateL :: Word -> Int -> Word # | |
| FiniteBits Word | Since: base-4.6.0.0 |
Defined in Data.Bits Methods finiteBitSize :: Word -> Int # countLeadingZeros :: Word -> Int # countTrailingZeros :: Word -> Int # | |
| NFData Word | |
Defined in Control.DeepSeq | |
| Hashable Word | |
Defined in Data.Hashable.Class | |
| Generic1 (URec Word :: k -> *) | |
| Functor (URec Word :: * -> *) | |
| Foldable (URec Word :: * -> *) | |
Defined in Data.Foldable Methods 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 :: * -> *) | |
Defined in Data.Traversable | |
| Eq (URec Word p) | |
| Ord (URec Word p) | |
Defined in GHC.Generics | |
| Show (URec Word p) | |
| 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 -> *) | |
Defined in GHC.Generics | |
| type Rep (URec Word p) | |
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 -> *) | |
| Eq (Ptr a) | |
| Ord (Ptr a) | |
| 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 ()) :: * -> *) | |
| Foldable (URec (Ptr ()) :: * -> *) | |
Defined in Data.Foldable Methods 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 ()) :: * -> *) | |
Defined in Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> URec (Ptr ()) a -> f (URec (Ptr ()) b) # sequenceA :: Applicative f => URec (Ptr ()) (f a) -> f (URec (Ptr ()) a) # mapM :: Monad m => (a -> m b) -> URec (Ptr ()) a -> m (URec (Ptr ()) b) # sequence :: Monad m => URec (Ptr ()) (m a) -> m (URec (Ptr ()) a) # | |
| Eq (URec (Ptr ()) p) | |
| Ord (URec (Ptr ()) p) | |
Defined in GHC.Generics Methods 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 -> *) | |
Defined in GHC.Generics | |
| type Rep (URec (Ptr ()) p) | |
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,,Ptra,FunPtraor a renaming of any of these usingStablePtranewtype. - the return type is either a marshallable foreign type or has the form
whereIOttis 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) | |
Defined in GHC.Ptr | |
| 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 |
Defined in GHC.Generics | |
| KnownSymbol a => SingI (a :: Symbol) | Since: base-4.9.0.0 |
Defined in GHC.Generics Methods 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 Methods fromStaticPtr :: StaticPtr a -> StaticPtr a # | |
CallStacks 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
CallStackin scope -- i.e. the enclosing function has aHasCallStackconstraint -- GHC will append the new call-site to the existingCallStack. - If there is no
CallStackin scope -- e.g. in the GHCi session above -- and the enclosing definition does not have an explicit type signature, GHC will infer aHasCallStackconstraint for the enclosing definition (subject to the monomorphism restriction). - If there is no
CallStackin scope and the enclosing definition has an explicit type signature, GHC will solve theHasCallStackconstraint for the singletonCallStackcontaining just the current call-site.
CallStacks 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 #
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.
Constructors
| SrcLoc | |
Fields
| |
Location information about an address from a backtrace.
Constructors
| Location | |
Fields
| |
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.
Constructors
| SomeSymbol :: SomeSymbol | Since: base-4.7.0.0 |
Instances
| Eq SomeSymbol | Since: base-4.7.0.0 |
Defined in GHC.TypeLits | |
| Ord SomeSymbol | Since: base-4.7.0.0 |
Defined in GHC.TypeLits Methods 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 Methods 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 Methods 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 minBound0 or ) for such types.minBound
(^^) :: (Fractional a, Integral b) => a -> b -> a infixr 8 #
raise a number to an integral power
Arguments
| :: 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