cardano-prelude-0.1.0.0: A Prelude replacement for the Cardano project
Safe Haskell None
Language Haskell2010

Cardano.Prelude

Synopsis

Documentation

forceElemsToWHNF :: Foldable t => t a -> t a Source #

Force all of the elements of a Foldable to weak head normal form.

In order to ensure that all of the elements of a Foldable are strict, we can simply foldMap over it and seq each value with () . However, () 's mappend implementation is actually completely lazy: _ <> _ = () So, in order to work around this, we instead utilize this newly defined StrictUnit whose mappend implementation is specifically strict.

parseJSString :: forall a m e. ( Typeable a, ReportSchemaErrors m, Buildable e) => ( Text -> Either e a) -> JSValue -> m a Source #

Attempt to parse a value of type a from the body of a JSString using parser

class HeapWords a where Source #

Size in the heap of values, in words (to get the size in bytes multiply by 4 on a 32-bit machine or 8 on a 64-bit machine)

Instances

Instances details
HeapWords Bool Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords Char Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords Float Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords Int Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords Integer Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords Natural Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords Word Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords Word8 Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords Word32 Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords Word64 Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords ByteString Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords UTCTime Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords Text Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords ShortByteString Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords IntSet Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords BigNat Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords LByteString Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords Day Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords a => HeapWords [a] Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords a => HeapWords ( Maybe a) Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords a => HeapWords ( IntMap a) Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords a => HeapWords ( Seq a) Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords a => HeapWords ( Set a) Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords e => HeapWords ( Vector e) Source #
Instance details

Defined in Cardano.Prelude.HeapWords

HeapWords (a -> b) Source #
Instance details

Defined in Cardano.Prelude.HeapWords

Methods

heapWords :: (a -> b) -> Int Source #

( HeapWords a, HeapWords b) => HeapWords ( Either a b) Source #
Instance details

Defined in Cardano.Prelude.HeapWords

( HeapWords a, HeapWords b) => HeapWords (a, b) Source #
Instance details

Defined in Cardano.Prelude.HeapWords

Methods

heapWords :: (a, b) -> Int Source #

( HeapWords a, HeapWords b) => HeapWords ( Map a b) Source #
Instance details

Defined in Cardano.Prelude.HeapWords

( HeapWords a, HeapWords b, HeapWords c) => HeapWords (a, b, c) Source #
Instance details

Defined in Cardano.Prelude.HeapWords

Methods

heapWords :: (a, b, c) -> Int Source #

( HeapWords a, HeapWords b, HeapWords c, HeapWords d) => HeapWords (a, b, c, d) Source #
Instance details

Defined in Cardano.Prelude.HeapWords

Methods

heapWords :: (a, b, c, d) -> Int Source #

heapSizeMb :: Int -> Int Source #

These functions assume a 64-bit architecture

heapSizeKb :: Int -> Int Source #

These functions assume a 64-bit architecture

heapWords10 :: ( HeapWords a9, HeapWords a8, HeapWords a7, HeapWords a6, HeapWords a5, HeapWords a4, HeapWords a3, HeapWords a2, HeapWords a1, HeapWords a) => a -> a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> Int Source #

heapWords11 :: ( HeapWords a10, HeapWords a9, HeapWords a8, HeapWords a7, HeapWords a6, HeapWords a5, HeapWords a4, HeapWords a3, HeapWords a2, HeapWords a1, HeapWords a) => a -> a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> a10 -> Int Source #

heapWords12 :: ( HeapWords a11, HeapWords a10, HeapWords a9, HeapWords a8, HeapWords a7, HeapWords a6, HeapWords a5, HeapWords a4, HeapWords a3, HeapWords a2, HeapWords a1, HeapWords a) => a -> a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> a10 -> a11 -> Int Source #

heapWords13 :: ( HeapWords a12, HeapWords a11, HeapWords a10, HeapWords a9, HeapWords a8, HeapWords a7, HeapWords a6, HeapWords a5, HeapWords a4, HeapWords a3, HeapWords a2, HeapWords a1, HeapWords a) => a -> a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> a10 -> a11 -> a12 -> Int Source #

heapWordsUnpacked :: HeapWords a => a -> Int Source #

Calculate the number of heap words used by a field unpacked within another constructor.

This function simply subtracts 2 from the heapWords result of its parameter, since in the case of an unpacked field we _do not_ have to use:

  • a word for the pointer to the inner structure.
  • a word for the constructor that is being unpacked.

data ClosureTreeOptions Source #

Options which detail how a Closure Tree should be constructed.

Constructors

ClosureTreeOptions

Fields

buildClosureTree :: ClosureTreeOptions -> a -> IO ( Maybe ( Tree Closure )) Source #

Given a Haskell expression, build a Tree which reflects its heap object representation.

buildAndRenderClosureTree :: ClosureTreeOptions -> a -> IO Text Source #

Given a Haskell expression, build a Tree which reflects its heap object representation and render it as Text .

data PerformGC Source #

Should we perform a GC call before counting the size?

Constructors

FirstPerformGC

Yes, first perform GC before counting

This should be used for most accurate results. Without calling GC first, the computed size might be larger than expected due to leftover indirections (black holes, selector thunks, etc.)

DontPerformGC

No, do not perform GC before counting

If pinpoint accuracy is not requried, then GC can be skipped, making the call much less expensive.

computeHeapSize :: a -> IO ( Either CountFailure Word64 ) Source #

Compute the size of the given closure

This is a wrapper around computeHeapSize' which sets some defaults for the capacity of worklist and the visited set: it uses a worklist capacity of 10k (which, assuming balanced data structures, should be more than enough), an initial visited set capacity of 250k, and a maximum visited set capacity of 16M. This means that this will use between 2 MB and 128 MB of heaps space.

It also does NOT perform GC before counting, for improved performance. Client code can call performMajorGC manually or use computeHeapSize' .

Should these limits not be sufficient, or conversely, the memory requirements be too large, use computeHeapSize' directly.

computeHeapSize' Source #

Arguments

:: PerformGC

Should we call GC before counting?

-> Word

Capacity of the worklist

-> Word

Initial capacity of the visited set

-> Word

Maximum capacity of the visited set

-> a
-> IO ( Either CountFailure Word64 )

Compute the size of the given closure

The size of the worklist should be set to the maximum expected depth of the closure; the size of the visited set should be set to the maximum /number of nodes/ in the closure.

computeHeapSizeWorkList can be used to estimate the size of the worklist required.

computeHeapSizeWorkList :: a -> Word64 Source #

Upper bound on the required work list size to compute closure size

NOTE: This ignores sharing, and so provides an upper bound only.

The size of a closure with no nested pointers can be computed without any stack space.

When we have a closure with (N + 1) nested pointers

p0 p1 .. pN

We will

  • Push pN, .., p1, p0 onto the stack
  • Pop off p0 and count its children
  • Pop off p1 and count its children
  • ..

until we have processed all children. This means that the stack space required will be the maximum of

[ N + 1 -- For the initial list
, requiredWorkList p0 + (N + 1) - 1
, requiredWorkList p1 + (N + 1) - 2
, ..
, requiredWorkList pN + (N + 1) - (N + 1)
]

For example, for a list, we would get that

requiredWorkList []     == 0
requiredWorkList (x:xs) == max [ 2
                               , requiredWorkList x + 1
                               , requiredWorkList xs
                               ]

which, for a list of Int (which requires only a stack of size 1), equals 2 (unless the list is empty).

Similarly, for binary trees, we get

requiredWorkList Leaf           == 0
requiredWorkList (Branch l x r) == max [ 3
                                       , requiredWorkList l + 2
                                       , requiredWorkList x + 1
                                       , requiredWorkList r
                                       ]

which, for a tree of Int , is bound by (height * 2) + 1 .

isNormalForm :: a -> IO Bool Source #

The function isNormalForm checks whether its argument is fully evaluated and deeply evaluated.

NOTE: The normal form check can be quite brittle, especially with -O0 . For example, writing something like

let !(Value x) = ... in ....

might translate to

let !.. = ... in ... (case ... of Value x -> x)

which would trivially be False . In general, isNormalForm should probably only be used with -O1 , but even then the answer may still depend on internal decisions made by ghc during compilation.

base16Builder :: ByteString -> Builder Source #

A Builder for a ByteString that performs base 16 encoding

base16F :: Format r ( ByteString -> r) Source #

A Format for a ByteString that performs base 16 encoding

pairF :: ( Buildable a, Buildable b) => Format r ((a, b) -> r) Source #

A Format for a pair of Buildable values (a, b)

pairBuilder :: ( Buildable a, Buildable b) => (a, b) -> Builder Source #

A Builder for a pair of Buildable values (a, b)

listJson :: ( Foldable t, Buildable a) => Format r (t a -> r) Source #

A Format for Foldable containers that outputs a JSON-style list

listJsonIndent :: ( Foldable t, Buildable a) => Word -> Format r (t a -> r) Source #

A Format similar to listJson that prints each value on a new line with indent spaces of indentation

mapJson :: ( IsList t, Item t ~ (k, v), Buildable k, Buildable v) => Format r (t -> r) Source #

A Format for Exts.IsList containers of Buildable key-value pairs that outputs a JSON-style colon-separated map

toAesonError :: Buildable e => Either e a -> Parser a Source #

Convert an Either -encoded error to an aeson parser error

aesonError :: Buildable e => e -> Parser a Source #

Convert a Buildable error into an aeson parser error

toCborError :: Buildable e => Either e a -> Decoder s a Source #

Convert an Either -encoded failure to a cborg decoder failure

cborError :: Buildable e => e -> Decoder s a Source #

Convert a Buildable error into a cborg decoder error

wrapError :: MonadError e' m => Either e a -> (e -> e') -> m a infix 1 Source #

A helper for lifting an Either to a MonadError

By using this function infix we can move the error handling to the end of an expression, hopefully improving readability.

orThrowError :: MonadError e m => Bool -> e -> m () infix 1 Source #

A helper for lifting unless to MonadError

By using this function infix we can move error handling to the end of a Bool expression, hopefully improving readability.

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

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 Source #

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] Source #

\(\mathcal{O}(n)\) . filter , applied to a predicate and a list, returns the list of those elements that satisfy the predicate; i.e.,

filter p xs = [ x | x <- xs, p x]
>>> filter odd [1, 2, 3]
[1,3]

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

\(\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.

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

Extract the first component of a pair.

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

Extract the second component of a pair.

otherwise :: Bool Source #

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

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

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

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.

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

general coercion from integral types

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

general coercion to fractional types

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

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)

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

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 Source #

The Bounded class is used to name the upper and lower limits of a type. Ord is not a superclass of Bounded since types that are not totally ordered may also have upper and lower bounds.

The Bounded class may be derived for any enumeration type; minBound is the first constructor listed in the data declaration and maxBound is the last. Bounded may also be derived for single-constructor datatypes whose constituent types are in Bounded .

Instances

Instances details
Bounded Bool

Since: base-2.1

Instance details

Defined in GHC.Enum

Bounded Char

Since: base-2.1

Instance details

Defined in GHC.Enum

Bounded Int

Since: base-2.1

Instance details

Defined in GHC.Enum

Bounded Int8

Since: base-2.1

Instance details

Defined in GHC.Int

Bounded Int16

Since: base-2.1

Instance details

Defined in GHC.Int

Bounded Int32

Since: base-2.1

Instance details

Defined in GHC.Int

Bounded Int64

Since: base-2.1

Instance details

Defined in GHC.Int

Bounded Ordering

Since: base-2.1

Instance details

Defined in GHC.Enum

Bounded Word

Since: base-2.1

Instance details

Defined in GHC.Enum

Bounded Word8

Since: base-2.1

Instance details

Defined in GHC.Word

Bounded Word16

Since: base-2.1

Instance details

Defined in GHC.Word

Bounded Word32

Since: base-2.1

Instance details

Defined in GHC.Word

Bounded Word64

Since: base-2.1

Instance details

Defined in GHC.Word

Bounded VecCount

Since: base-4.10.0.0

Instance details

Defined in GHC.Enum

Bounded VecElem

Since: base-4.10.0.0

Instance details

Defined in GHC.Enum

Bounded ()

Since: base-2.1

Instance details

Defined in GHC.Enum

Bounded CDev
Instance details

Defined in System.Posix.Types

Bounded CIno
Instance details

Defined in System.Posix.Types

Bounded CMode
Instance details

Defined in System.Posix.Types

Bounded COff
Instance details

Defined in System.Posix.Types

Bounded CPid
Instance details

Defined in System.Posix.Types

Bounded CSsize
Instance details

Defined in System.Posix.Types

Bounded CGid
Instance details

Defined in System.Posix.Types

Bounded CNlink
Instance details

Defined in System.Posix.Types

Bounded CUid
Instance details

Defined in System.Posix.Types

Bounded CTcflag
Instance details

Defined in System.Posix.Types

Bounded CRLim
Instance details

Defined in System.Posix.Types

Bounded CBlkSize
Instance details

Defined in System.Posix.Types

Bounded CBlkCnt
Instance details

Defined in System.Posix.Types

Bounded CClockId
Instance details

Defined in System.Posix.Types

Bounded CFsBlkCnt
Instance details

Defined in System.Posix.Types

Bounded CFsFilCnt
Instance details

Defined in System.Posix.Types

Bounded CId
Instance details

Defined in System.Posix.Types

Bounded CKey
Instance details

Defined in System.Posix.Types

Bounded CSocklen
Instance details

Defined in System.Posix.Types

Bounded CNfds
Instance details

Defined in System.Posix.Types

Bounded Fd
Instance details

Defined in System.Posix.Types

Bounded All

Since: base-2.1

Instance details

Defined in Data.Semigroup.Internal

Bounded Any

Since: base-2.1

Instance details

Defined in Data.Semigroup.Internal

Bounded Associativity

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Bounded SourceUnpackedness

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Bounded SourceStrictness

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Bounded DecidedStrictness

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Bounded CChar
Instance details

Defined in Foreign.C.Types

Bounded CSChar
Instance details

Defined in Foreign.C.Types

Bounded CUChar
Instance details

Defined in Foreign.C.Types

Bounded CShort
Instance details

Defined in Foreign.C.Types

Bounded CUShort
Instance details

Defined in Foreign.C.Types

Bounded CInt
Instance details

Defined in Foreign.C.Types

Bounded CUInt
Instance details

Defined in Foreign.C.Types

Bounded CLong
Instance details

Defined in Foreign.C.Types

Bounded CULong
Instance details

Defined in Foreign.C.Types

Bounded CLLong
Instance details

Defined in Foreign.C.Types

Bounded CULLong
Instance details

Defined in Foreign.C.Types

Bounded CBool
Instance details

Defined in Foreign.C.Types

Bounded CPtrdiff
Instance details

Defined in Foreign.C.Types

Bounded CSize
Instance details

Defined in Foreign.C.Types

Bounded CWchar
Instance details

Defined in Foreign.C.Types

Bounded CSigAtomic
Instance details

Defined in Foreign.C.Types

Bounded CIntPtr
Instance details

Defined in Foreign.C.Types

Bounded CUIntPtr
Instance details

Defined in Foreign.C.Types

Bounded CIntMax
Instance details

Defined in Foreign.C.Types

Bounded CUIntMax
Instance details

Defined in Foreign.C.Types

Bounded WordPtr
Instance details

Defined in Foreign.Ptr

Bounded IntPtr
Instance details

Defined in Foreign.Ptr

Bounded GeneralCategory

Since: base-2.1

Instance details

Defined in GHC.Unicode

Bounded Int54
Instance details

Defined in Text.JSON.Canonical.Types

Bounded TokenType
Instance details

Defined in Codec.CBOR.Decoding

Bounded Extension
Instance details

Defined in GHC.LanguageExtensions.Type

Bounded a => Bounded ( Solo a)
Instance details

Defined in Data.Tuple.Solo

Bounded a => Bounded ( Min a)

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Bounded a => Bounded ( Max a)

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Bounded a => Bounded ( First a)

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Bounded a => Bounded ( Last a)

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Bounded m => Bounded ( WrappedMonoid m)

Since: base-4.9.0.0

Instance details

Defined in Data.Semigroup

Bounded a => Bounded ( Identity a)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Identity

Bounded a => Bounded ( Dual a)

Since: base-2.1

Instance details

Defined in Data.Semigroup.Internal

Bounded a => Bounded ( Sum a)

Since: base-2.1

Instance details

Defined in Data.Semigroup.Internal

Bounded a => Bounded ( Product a)

Since: base-2.1

Instance details

Defined in Data.Semigroup.Internal

Bounded a => Bounded ( Down a)

Since: base-4.14.0.0

Instance details

Defined in Data.Ord

Bounded a => Bounded ( Shown a)
Instance details

Defined in Data.Text.Format.Types

( Bounded a, Bounded b) => Bounded (a, b)

Since: base-2.1

Instance details

Defined in GHC.Enum

Bounded ( Proxy t)

Since: base-4.7.0.0

Instance details

Defined in Data.Proxy

( Bounded a, Bounded b) => Bounded ( Pair a b)
Instance details

Defined in Data.Strict.Tuple

( Bounded a, Bounded b, Bounded c) => Bounded (a, b, c)

Since: base-2.1

Instance details

Defined in GHC.Enum

Methods

minBound :: (a, b, c) Source #

maxBound :: (a, b, c) Source #

Bounded a => Bounded ( Const a b)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Const

( Applicative f, Bounded a) => Bounded ( Ap f a)

Since: base-4.12.0.0

Instance details

Defined in Data.Monoid

Coercible a b => Bounded ( Coercion a b)

Since: base-4.7.0.0

Instance details

Defined in Data.Type.Coercion

a ~ b => Bounded (a :~: b)

Since: base-4.7.0.0

Instance details

Defined in Data.Type.Equality

Bounded b => Bounded ( Tagged s b)
Instance details

Defined in Data.Tagged

( Bounded a, Bounded b, Bounded c, Bounded d) => Bounded (a, b, c, d)

Since: base-2.1

Instance details

Defined in GHC.Enum

Methods

minBound :: (a, b, c, d) Source #

maxBound :: (a, b, c, d) Source #

a ~~ b => Bounded (a :~~: b)

Since: base-4.10.0.0

Instance details

Defined in Data.Type.Equality

( Bounded a, Bounded b, Bounded c, Bounded d, Bounded e) => Bounded (a, b, c, d, e)

Since: base-2.1

Instance details

Defined in GHC.Enum

Methods

minBound :: (a, b, c, d, e) Source #

maxBound :: (a, b, c, d, e) Source #

( Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f) => Bounded (a, b, c, d, e, f)

Since: base-2.1

Instance details

Defined in GHC.Enum

Methods

minBound :: (a, b, c, d, e, f) Source #

maxBound :: (a, b, c, d, e, f) Source #

( 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 details

Defined in GHC.Enum

Methods

minBound :: (a, b, c, d, e, f, g) Source #

maxBound :: (a, b, c, d, e, f, g) Source #

( 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 details

Defined in GHC.Enum

Methods

minBound :: (a, b, c, d, e, f, g, h) Source #

maxBound :: (a, b, c, d, e, f, g, h) Source #

( 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 details

Defined in GHC.Enum

Methods

minBound :: (a, b, c, d, e, f, g, h, i) Source #

maxBound :: (a, b, c, d, e, f, g, h, i) Source #

( 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 details

Defined in GHC.Enum

Methods

minBound :: (a, b, c, d, e, f, g, h, i, j) Source #

maxBound :: (a, b, c, d, e, f, g, h, i, j) Source #

( 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 details

Defined in GHC.Enum

Methods

minBound :: (a, b, c, d, e, f, g, h, i, j, k) Source #

maxBound :: (a, b, c, d, e, f, g, h, i, j, k) Source #

( 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 details

Defined in GHC.Enum

Methods

minBound :: (a, b, c, d, e, f, g, h, i, j, k, l) Source #

maxBound :: (a, b, c, d, e, f, g, h, i, j, k, l) Source #

( 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 details

Defined in GHC.Enum

Methods

minBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m) Source #

maxBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m) Source #

( 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 details

Defined in GHC.Enum

Methods

minBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source #

maxBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source #

( 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 details

Defined in GHC.Enum

Methods

minBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source #

maxBound :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source #

class Enum a where Source #

Class Enum defines operations on sequentially ordered types.

The enumFrom ... methods are used in Haskell's translation of arithmetic sequences.

Instances of Enum may be derived for any enumeration type (types whose constructors have no fields). The nullary constructors are assumed to be numbered left-to-right by fromEnum from 0 through n-1 . See Chapter 10 of the Haskell Report for more details.

For any type that is an instance of class Bounded as well as Enum , the following should hold:

   enumFrom     x   = enumFromTo     x maxBound
   enumFromThen x y = enumFromThenTo x y bound
     where
       bound | fromEnum y >= fromEnum x = maxBound
             | otherwise                = minBound

Minimal complete definition

toEnum , fromEnum

Methods

succ :: a -> a Source #

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

pred :: a -> a Source #

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

toEnum :: Int -> a Source #

Convert from an Int .

fromEnum :: a -> Int Source #

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] Source #

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] Source #

Used in Haskell's translation of [n,n'..] with [n,n'..] = enumFromThen n n' , a possible implementation being enumFromThen n n' = n : n' : worker (f x) (f x n') , worker s v = v : worker s (s v) , x = fromEnum n' - fromEnum n and f n y | n > 0 = f (n - 1) (succ y) | n < 0 = f (n + 1) (pred y) | otherwise = y For example:

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

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

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

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

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

Used in Haskell's translation of [n,n'..m] with [n,n'..m] = enumFromThenTo n n' m , a possible implementation being enumFromThenTo n n' m = worker (f x) (c x) n m , x = fromEnum n' - fromEnum n , c x = bool (>=) ( (x 0) f n y | n > 0 = f (n - 1) (succ y) | n < 0 = f (n + 1) (pred y) | otherwise = y and worker s c v m | c v m = v : worker s c (s v) m | otherwise = [] For example:

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

Instances

Instances details
Enum Bool

Since: base-2.1

Instance details

Defined in GHC.Enum

Enum Char

Since: base-2.1

Instance details

Defined in GHC.Enum

Enum Int

Since: base-2.1

Instance details

Defined in GHC.Enum

Enum Int8

Since: base-2.1

Instance details

Defined in GHC.Int

Enum Int16

Since: base-2.1

Instance details

Defined in GHC.Int

Enum Int32

Since: base-2.1

Instance details

Defined in GHC.Int

Enum Int64

Since: base-2.1

Instance details

Defined in GHC.Int

Enum Integer

Since: base-2.1

Instance details

Defined in GHC.Enum

Enum Natural

Since: base-4.8.0.0

Instance details

Defined in GHC.Enum

Enum Ordering

Since: base-2.1

Instance details

Defined in GHC.Enum

Enum Word

Since: base-2.1

Instance details

Defined in GHC.Enum

Enum Word8

Since: base-2.1

Instance details

Defined in GHC.Word

Enum Word16

Since: base-2.1

Instance details

Defined in GHC.Word

Enum Word32

Since: base-2.1

Instance details

Defined in GHC.Word

Enum Word64

Since: base-2.1

Instance details

Defined in GHC.Word

Enum VecCount

Since: base-4.10.0.0

Instance details

Defined in GHC.Enum

Enum VecElem

Since: base-4.10.0.0

Instance details

Defined in GHC.Enum

Enum ()

Since: base-2.1

Instance details

Defined in GHC.Enum

Enum CDev
Instance details

Defined in System.Posix.Types

Enum CIno
Instance details

Defined in System.Posix.Types

Enum CMode
Instance details

Defined in System.Posix.Types

Enum COff
Instance details

Defined in System.Posix.Types

Enum CPid
Instance details

Defined in System.Posix.Types

Enum CSsize
Instance details

Defined in System.Posix.Types

Enum CGid
Instance details

Defined in System.Posix.Types

Enum CNlink
Instance details

Defined in System.Posix.Types

Enum CUid
Instance details

Defined in System.Posix.Types

Enum CCc
Instance details

Defined in System.Posix.Types

Enum CSpeed
Instance details

Defined in System.Posix.Types

Enum CTcflag
Instance details

Defined in System.Posix.Types

Enum CRLim
Instance details

Defined in System.Posix.Types

Enum CBlkSize
Instance details

Defined in System.Posix.Types

Enum CBlkCnt
Instance details

Defined in System.Posix.Types

Enum CClockId
Instance details

Defined in System.Posix.Types

Enum CFsBlkCnt
Instance details

Defined in System.Posix.Types

Enum CFsFilCnt
Instance details

Defined in System.Posix.Types

Enum CId
Instance details

Defined in System.Posix.Types

Enum CKey
Instance details

Defined in System.Posix.Types

Enum CSocklen
Instance details

Defined in System.Posix.Types

Enum CNfds
Instance details

Defined in System.Posix.Types

Enum Fd
Instance details

Defined in System.Posix.Types

Enum Associativity

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Enum SourceUnpackedness

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Enum SourceStrictness

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Enum DecidedStrictness

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Enum CChar
Instance details

Defined in Foreign.C.Types

Enum CSChar
Instance details

Defined in Foreign.C.Types