HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulelinear-base-0.4.0Haskell2010

Prelude.Linear

This module provides a replacement for Prelude with support for linear programming via linear versions of standard data types, functions and type classes.

A simple example:

Example4 expressions
:set -XLinearTypes:set -XNoImplicitPreludeimport Prelude.Linear:{  boolToInt :: Bool %1-> Int  boolToInt False = 0  boolToInt True = 1:}
Example1 expression
:{  makeInt :: Either Int Bool %1-> Int  makeInt = either id boolToInt:}

This module is designed to be imported unqualifed.

  • 13 types
  • 14 classes
  • 56 values

Standard Types, Classes and Related Functions

0 declarations

Basic data types

datadata Char
#

The character type Char represents Unicode codespace and its elements are code points as in definitions D9 and D10 of the Unicode Standard.

Character literals in Haskell are single-quoted: 'Q', 'Я' or 'Ω'. To represent a single quote itself use '\'', and to represent a backslash use '\\'. The full grammar can be found in the section 2.6 of the Haskell 2010 Language Report.

To specify a character by its code point one can use decimal, hexadecimal or octal notation: '\65', '\x41' and '\o101' are all alternative forms of 'A'. The largest code point is '\x10ffff'.

There is a special escape syntax for ASCII control characters:

Escape

Alternatives

Meaning

'\NUL'

'\0'

null character

'\SOH'

'\1'

start of heading

'\STX'

'\2'

start of text

'\ETX'

'\3'

end of text

'\EOT'

'\4'

end of transmission

'\ENQ'

'\5'

enquiry

'\ACK'

'\6'

acknowledge

'\BEL'

'\7'

,

'\a'

bell (alert)

'\BS'

'\8'

,

'\b'

backspace

'\HT'

'\9'

,

'\t'

horizontal tab

'\LF'

'\10'

,

'\n'

line feed (new line)

'\VT'

'\11'

,

'\v'

vertical tab

'\FF'

'\12'

,

'\f'

form feed

'\CR'

'\13'

,

'\r'

carriage return

'\SO'

'\14'

shift out

'\SI'

'\15'

shift in

'\DLE'

'\16'

data link escape

'\DC1'

'\17'

device control 1

'\DC2'

'\18'

device control 2

'\DC3'

'\19'

device control 3

'\DC4'

'\20'

device control 4

'\NAK'

'\21'

negative acknowledge

'\SYN'

'\22'

synchronous idle

'\ETB'

'\23'

end of transmission block

'\CAN'

'\24'

cancel

'\EM'

'\25'

end of medium

'\SUB'

'\26'

substitute

'\ESC'

'\27'

escape

'\FS'

'\28'

file separator

'\GS'

'\29'

group separator

'\RS'

'\30'

record separator

'\US'

'\31'

unit separator

'\SP'

'\32'

,

' '

space

'\DEL'

'\127'

delete

Data.Char provides utilities to work with Char.

Instances58Bounded, Enum, Data, Read, Ix, Storable, …

Tuples

4 declarations
valuefst :: (a, b) -> a
#

Extract the first component of a pair.

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

Extract the second component of a pair.

valuecurry :: ((a, b) %p -> c) %q -> a %p -> b %p -> c
#
valueuncurry :: (a %p -> b %p -> c) %q -> (a, b) %p -> c
#

Basic type classes

classclass Enum a where
#

Class Enum defines operations on sequentially ordered types.

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

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

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

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

Methods

  • succ :: a -> a

    Successor of a value. For numeric types, succ adds 1.

  • pred :: a -> a

    Predecessor of a value. For numeric types, pred subtracts 1.

  • toEnum :: Int -> a

    Convert from an Int.

  • fromEnum :: a -> Int

    Convert to an Int. It is implementation-dependent what fromEnum returns when applied to a value that is too large to fit in an Int.

  • enumFrom :: a -> [a]

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

    Examples
    • 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
      
    Examples
    • 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 = []
      
    Examples
    • 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 = []
      
    Examples
    • enumFromThenTo 4 2 -6 :: [Integer] = [4,2,0,-2,-4,-6]
    • enumFromThenTo 6 8 2 :: [Int] = []
Instances123Enum, …
  • Enum IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum ExtensionDefined in ghc-boot-th-9.10.3 · GHC.LanguageExtensions.Type
  • Enum ByteOrderDefined in ghc-internal-9.1003.0 · GHC.Internal.ByteOrder
  • Enum ClosureTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.ClosureTypes
  • Enum CBoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CClockDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CLLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CPtrdiffDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CSCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CSUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CSigAtomicDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CTimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CUCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CUIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CUIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CUIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CULLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CULongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CUShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum CWcharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Enum IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Enum WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Enum AssociativityDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Enum DecidedStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Enum SourceStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Enum SourceUnpackednessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Enum SeekModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Device
  • Enum IOModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.IOMode
  • Enum Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Enum Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Enum Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Enum Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Enum DoCostCentresDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Enum DoHeapProfileDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Enum DoTraceDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Enum GiveGCStatsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Enum IoSubSystemDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Enum CBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CBlkSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CCcDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CClockIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CDevDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CFsBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CFsFilCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CGidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CInoDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CModeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CNfdsDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CNlinkDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum COffDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CPidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CRLimDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CSocklenDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CSpeedDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CSsizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CTcflagDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum CUidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum FdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Enum GeneralCategoryDefined in ghc-internal-9.1003.0 · GHC.Internal.Unicode
  • Enum Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Enum Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Enum Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Enum Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Enum BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum CharDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    fromEnum just truncates its argument, beware of all sorts of overflows.

    List generators have extremely peculiar behavior, mandated by Haskell Report 2010:

    Example1 expression
    [0..1.5][0.0,1.0,2.0]
  • Enum FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    fromEnum just truncates its argument, beware of all sorts of overflows.

    List generators have extremely peculiar behavior, mandated by Haskell Report 2010:

    Example1 expression
    [0..1.5 :: Float][0.0,1.0,2.0]
  • Enum IntDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum LevityDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum OrderingDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum VecCountDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum VecElemDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum WordDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum GenericClassDefined in linear-generics-0.2.3 · Generics.Linear.TH.Internal
  • Enum CardinalityDefined in random-1.2.1.3 · System.Random.GFinite

    This is needed only as a superclass of Integral.

  • Enum I8Defined in text-2.1.3 · Data.Text.Foreign
  • Enum FPFormatDefined in text-2.1.3 · Data.Text.Lazy.Builder.RealFloat
  • Enum ()Defined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Enum a => Enum (Blind a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Enum a => Enum (Fixed a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Enum a => Enum (Large a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Enum a => Enum (Negative a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Enum a => Enum (NonNegative a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Enum a => Enum (NonPositive a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Enum a => Enum (NonZero a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Enum a => Enum (Positive a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Enum a => Enum (Shrink2 a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Enum a => Enum (Small a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Enum a => Enum (First a)Defined in base-4.20.2.0 · Data.Semigroup
  • Enum a => Enum (Last a)Defined in base-4.20.2.0 · Data.Semigroup
  • Enum a => Enum (Max a)Defined in base-4.20.2.0 · Data.Semigroup
  • Enum a => Enum (Min a)Defined in base-4.20.2.0 · Data.Semigroup
  • Enum a => Enum (WrappedMonoid a)Defined in base-4.20.2.0 · Data.Semigroup
  • Enum a => Enum (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Enum a => Enum (Iff a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Enum a => Enum (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Enum a => Enum (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Enum a => Enum (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Enum a => Enum (a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Integral a => Enum (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • (Enum a, Bounded a, Eq a) => Enum (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord

    Swaps succ and pred of the underlying type.

  • Enum (Fixed a)Defined in base-4.20.2.0 · Data.Fixed

    Recall that, for numeric types, succ and pred typically add and subtract 1, respectively. This is not true in the case of Fixed, whose successor and predecessor functions intuitively return the "next" and "previous" values in the enumeration. The results of these functions thus depend on the resolution of the Fixed value. For example, when enumerating values of resolution 10^-3 of type Milli = Fixed E3,

    Example1 expression
    succ (0.000 :: Milli)0.001

    and likewise

    Example1 expression
    pred (0.000 :: Milli)-0.001

    In other words, succ and pred increment and decrement a fixed-precision value by the least amount such that the value's resolution is unchanged. For example, 10^-12 is the smallest (positive) amount that can be added to a value of type Pico = Fixed E12 without changing its resolution, and so

    Example1 expression
    succ (0.000000000000 :: Pico)0.000000000001

    and similarly

    Example1 expression
    pred (0.000000000000 :: Pico)-0.000000000001

    This is worth bearing in mind when defining Fixed arithmetic sequences. In particular, you may be forgiven for thinking the sequence

      [1..10] :: [Pico]
    

    evaluates to [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] :: [Pico].

    However, this is not true. On the contrary, similarly to the above implementations of succ and pred, enumFromTo :: Pico -> Pico -> [Pico] has a "step size" of 10^-12. Hence, the list [1..10] :: [Pico] has the form

      [1.000000000000, 1.00000000001, 1.00000000002, ..., 10.000000000000]
    

    and contains 9 * 10^12 + 1 values.

  • Enum (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Enum (f a) => Enum (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Enum (f a) => Enum (Alt f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Enum a => Enum (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Coercible a b => Enum (Coercion a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Coercion
  • a ~ b => Enum (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • a ~~ b => Enum (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Enum (f (g a)) => Enum (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
classclass Bounded a where
#

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

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

Methods

Instances107Bounded, …

Numbers

datadata Int
#

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 Prelude.minBound and Prelude.maxBound from the Prelude.Bounded class.

Instances71Bounded, Enum, Integral, Data, Read, Real, …
datadata Integer
#

Arbitrary precision integers. In contrast with fixed-size integral types such as Int, the Integer type represents the entire infinite range of integers.

Integers are stored in a kind of sign-magnitude form, hence do not expect two's complement form when using bit operations.

If the value is small (i.e., fits into an Int), the IS constructor is used. Otherwise IP and IN constructors are used to store a BigNat representing the positive or the negative value magnitude, respectively.

Invariant: IP and IN are used iff the value does not fit in IS.

Instances23Enum, Eq, Integral, Data, Num, Ord, …
  • Enum IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Enum
  • Eq IntegerDefined in ghc-bignum-1.3 · GHC.Num.Integer
  • Integral IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Data IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Num IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Num
  • Ord IntegerDefined in ghc-bignum-1.3 · GHC.Num.Integer
  • Read IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Real IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Show IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Ix IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Ix
  • Bits IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Bits
  • PrintfArg IntegerDefined in base-4.20.2.0 · Text.Printf
  • NFData IntegerDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • Pretty IntegerDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJClass
  • Pretty IntegerDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJClass
  • Random IntegerDefined in random-1.2.1.3 · System.Random

    Note - random generates values in the Int range

  • UniformRange IntegerDefined in random-1.2.1.3 · System.Random.Internal
  • Arbitrary IntegerDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Arbitrary
  • CoArbitrary IntegerDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Arbitrary
  • Function IntegerDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Function
  • Binary IntegerDefined in binary-0.8.9.3 · Data.Binary.Class
  • Hashable IntegerDefined in hashable-1.4.7.0 · Data.Hashable.Class
  • Lift IntegerDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
datadata Float
#

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.

Instances54Enum, Floating, Fractional, Data, Num, Read, …
  • Enum FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    fromEnum just truncates its argument, beware of all sorts of overflows.

    List generators have extremely peculiar behavior, mandated by Haskell Report 2010:

    Example1 expression
    [0..1.5 :: Float][0.0,1.0,2.0]
  • Eq FloatDefined in ghc-prim-0.12.0 · GHC.Classes

    Note that due to the presence of NaN, Float's Eq instance does not satisfy reflexivity.

    Example1 expression
    0/0 == (0/0 :: Float)False

    Also note that Float's Eq instance does not satisfy extensionality:

    Example2 expressions
    0 == (-0 :: Float)Truerecip 0 == recip (-0 :: Float)False
  • Floating FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float
  • Fractional FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    This instance implements IEEE 754 standard with all its usual pitfalls about NaN, infinities and negative zero.

    Example4 expressions
    0 == (-0 :: Float)Truerecip 0 == recip (-0 :: Float)Falsemap (/ 0) [-1, 0, 1 :: Float][-Infinity,NaN,Infinity]map (* 0) $ map (/ 0) [-1, 0, 1 :: Float][NaN,NaN,NaN]
  • Data FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Num FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    This instance implements IEEE 754 standard with all its usual pitfalls about NaN, infinities and negative zero. Neither addition nor multiplication are associative or distributive:

    Example3 expressions
    (0.1 + 0.1 :: Float) + 0.5 == 0.1 + (0.1 + 0.5)False(0.1 + 0.2 :: Float) * 0.9 == 0.1 * 0.9 + 0.2 * 0.9False(0.1 * 0.1 :: Float) * 0.9 == 0.1 * (0.1 * 0.9)False
  • Ord FloatDefined in ghc-prim-0.12.0 · GHC.Classes

    See instance Ord Double for discussion of deviations from IEEE 754 standard.

  • Read FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Real FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    Beware that toRational generates garbage for non-finite arguments:

    Example2 expressions
    toRational (1/0 :: Float)340282366920938463463374607431768211456 % 1toRational (0/0 :: Float)510423550381407695195061911147652317184 % 1
  • RealFloat FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float
  • RealFrac FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    Beware that results for non-finite arguments are garbage:

    Example2 expressions
    [ f x | f <- [round, floor, ceiling], x <- [-1/0, 0/0, 1/0 :: Float] ] :: [Int][0,0,0,0,0,0,0,0,0]map properFraction [-1/0, 0/0, 1/0] :: [(Int, Float)][(0,0.0),(0,0.0),(0,0.0)]

    and get even more non-sensical if you ask for Integer instead of Int.

  • Show FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan
  • Storable FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • PrintfArg FloatDefined in base-4.20.2.0 · Text.Printf
  • NFData FloatDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • Pretty FloatDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJClass
  • Pretty FloatDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJClass
  • Random FloatDefined in random-1.2.1.3 · System.Random

    Note - random produces values in the closed range [0,1].

  • UniformRange FloatDefined in random-1.2.1.3 · System.Random.Internal
  • Arbitrary FloatDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Arbitrary
  • CoArbitrary FloatDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Arbitrary
  • Function FloatDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Function
  • Binary FloatDefined in binary-0.8.9.3 · Data.Binary.Class

    Uses non-IEEE754 encoding. Does not round-trip NaN.

  • Hashable FloatDefined in hashable-1.4.7.0 · Data.Hashable.Class

    Note: prior to hashable-1.3.0.0, hash 0.0 /= hash (-0.0)

    The hash of NaN is not well defined.

  • Prim FloatDefined in primitive-0.9.1.0 · Data.Primitive.Types
  • Unbox FloatDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • Generic FloatDefined in linear-generics-0.2.3 · Generics.Linear.Instances.Base · orphan
  • Consumable FloatDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Dupable FloatDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • Movable FloatDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • Lift FloatDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • IArray UArray FloatDefined in array-0.5.8.0 · Data.Array.Base
  • Vector Vector FloatDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MVector MVector FloatDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MArray IOUArray Float IODefined in array-0.5.8.0 · Data.Array.IO.Internals
  • Generic1 (URec Float)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic1 (URec Float)Defined in linear-generics-0.2.3 · Generics.Linear.Instances.Base · orphan
  • Foldable UFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Foldable
  • Traversable UFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Traversable
  • MArray (STUArray s) Float (ST s)Defined in array-0.5.8.0 · Data.Array.Base
  • Functor (URec Float)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (URec Float p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord (URec Float p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (URec Float p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (URec Float p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (URec Float p)Defined in linear-generics-0.2.3 · Generics.Linear.Instances.Base · orphan
  • type Rep (URec Float p) = D1 ('MetaData "URec" "GHC.Internal.Generics" "ghc-internal" 'False) (C1 ('MetaCons "UFloat" 'PrefixI 'True) (S1 ('MetaSel ('Just "uFloat#") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) UFloat))Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • type Rep1 (URec Float) = D1 ('MetaData "URec" "GHC.Internal.Generics" "ghc-internal" 'False) (C1 ('MetaCons "UFloat" 'PrefixI 'True) (S1 ('MetaSel ('Just "uFloat#") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) UFloat))Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • data URec FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics

    Used for marking occurrences of Float#

  • data MVector s FloatDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • data Vector FloatDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • type Rep Float = D1 ('MetaData "Float" "GHC.Types" "ghc-prim" 'False) (C1 ('MetaCons "F#" 'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) UFloat))Defined in linear-generics-0.2.3 · Generics.Linear.Instances.Base · orphan
  • type Rep (URec Float p) = D1 ('MetaData "URec" "GHC.Internal.Generics" "ghc-internal" 'False) (C1 ('MetaCons "UFloat" 'PrefixI 'True) (S1 ('MetaSel ('Just "uFloat#") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) UFloat))Defined in linear-generics-0.2.3 · Generics.Linear.Instances.Base · orphan
  • type Rep1 (URec Float) = D1 ('MetaData "URec" "GHC.Internal.Generics" "ghc-internal" 'False) (C1 ('MetaCons "UFloat" 'PrefixI 'True) (S1 ('MetaSel ('Just "uFloat#") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) UFloat))Defined in linear-generics-0.2.3 · Generics.Linear.Instances.Base · orphan
datadata Double
#

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.

Instances65Enum, Floating, Fractional, Data, Read, Real, …
  • Enum DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    fromEnum just truncates its argument, beware of all sorts of overflows.

    List generators have extremely peculiar behavior, mandated by Haskell Report 2010:

    Example1 expression
    [0..1.5][0.0,1.0,2.0]
  • Eq DoubleDefined in ghc-prim-0.12.0 · GHC.Classes

    Note that due to the presence of NaN, Double's Eq instance does not satisfy reflexivity.

    Example1 expression
    0/0 == (0/0 :: Double)False

    Also note that Double's Eq instance does not satisfy substitutivity:

    Example2 expressions
    0 == (-0 :: Double)Truerecip 0 == recip (-0 :: Double)False
  • Floating DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float
  • Fractional DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    This instance implements IEEE 754 standard with all its usual pitfalls about NaN, infinities and negative zero.

    Example4 expressions
    0 == (-0 :: Double)Truerecip 0 == recip (-0 :: Double)Falsemap (/ 0) [-1, 0, 1][-Infinity,NaN,Infinity]map (* 0) $ map (/ 0) [-1, 0, 1][NaN,NaN,NaN]
  • Data DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Num DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    This instance implements IEEE 754 standard with all its usual pitfalls about NaN, infinities and negative zero. Neither addition nor multiplication are associative or distributive:

    Example3 expressions
    (0.1 + 0.1) + 0.4 == 0.1 + (0.1 + 0.4)False(0.1 + 0.2) * 0.3 == 0.1 * 0.3 + 0.2 * 0.3False(0.1 * 0.1) * 0.3 == 0.1 * (0.1 * 0.3)False
  • Ord DoubleDefined in ghc-prim-0.12.0 · GHC.Classes

    IEEE 754 Double-precision type includes not only numbers, but also positive and negative infinities and a special element called NaN (which can be quiet or signal).

    IEEE 754-2008, section 5.11 requires that if at least one of arguments of <=, <, >, >= is NaN then the result of the comparison is False, and instance Ord Double complies with this requirement. This violates the reflexivity: both NaN <= NaN and NaN >= NaN are False.

    IEEE 754-2008, section 5.10 defines totalOrder predicate. Unfortunately, compare on Doubles violates the IEEE standard and does not define a total order. More specifically, both compare NaN x and compare x NaN always return GT.

    Thus, users must be extremely cautious when using instance Ord Double. For instance, one should avoid ordered containers with keys represented by Double, because data loss and corruption may happen. An IEEE-compliant compare is available in fp-ieee package as TotallyOrdered newtype.

    Moving further, the behaviour of min and max with regards to NaN is also non-compliant. IEEE 754-2008, section 5.3.1 defines that quiet NaN should be treated as a missing data by minNum and maxNum functions, for example, minNum(NaN, 1) = minNum(1, NaN) = 1. Some languages such as Java deviate from the standard implementing minNum(NaN, 1) = minNum(1, NaN) = NaN. However, min / max in base are even worse: min NaN 1 is 1, but min 1 NaN is NaN.

    IEEE 754-2008 compliant min / max can be found in ieee754 package under minNum / maxNum names. Implementations compliant with minimumNumber / maximumNumber from a newer IEEE 754-2019, section 9.6 are available from fp-ieee package.

  • Read DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Real DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    Beware that toRational generates garbage for non-finite arguments:

    Example2 expressions
    toRational (1/0)179769313 (and 300 more digits...) % 1toRational (0/0)269653970 (and 300 more digits...) % 1
  • RealFloat DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float
  • RealFrac DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    Beware that results for non-finite arguments are garbage:

    Example2 expressions
    [ f x | f <- [round, floor, ceiling], x <- [-1/0, 0/0, 1/0] ] :: [Int][0,0,0,0,0,0,0,0,0]map properFraction [-1/0, 0/0, 1/0] :: [(Int, Double)][(0,0.0),(0,0.0),(0,0.0)]

    and get even more non-sensical if you ask for Integer instead of Int.

  • Show DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan
  • Storable DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Storable
  • PrintfArg DoubleDefined in base-4.20.2.0 · Text.Printf
  • NFData DoubleDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • Pretty DoubleDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJClass
  • Pretty DoubleDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJClass
  • Random DoubleDefined in random-1.2.1.3 · System.Random

    Note - random produces values in the closed range [0,1].

  • UniformRange DoubleDefined in random-1.2.1.3 · System.Random.Internal
  • Arbitrary DoubleDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Arbitrary
  • CoArbitrary DoubleDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Arbitrary
  • Function DoubleDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Function
  • Binary DoubleDefined in binary-0.8.9.3 · Data.Binary.Class

    Uses non-IEEE754 encoding. Does not round-trip NaN.

  • Hashable DoubleDefined in hashable-1.4.7.0 · Data.Hashable.Class

    Note: prior to hashable-1.3.0.0, hash 0.0 /= hash (-0.0)

    The hash of NaN is not well defined.

  • Prim DoubleDefined in primitive-0.9.1.0 · Data.Primitive.Types
  • Unbox DoubleDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • Generic DoubleDefined in linear-generics-0.2.3 · Generics.Linear.Instances.Base · orphan
  • Consumable DoubleDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Dupable DoubleDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • MultIdentity DoubleDefined in linear-base-0.4.0 · Data.Num.Linear
  • Multiplicative DoubleDefined in linear-base-0.4.0 · Data.Num.Linear
  • AddIdentity DoubleDefined in linear-base-0.4.0 · Data.Num.Linear
  • Additive DoubleDefined in linear-base-0.4.0 · Data.Num.Linear
  • AdditiveGroup DoubleDefined in linear-base-0.4.0 · Data.Num.Linear
  • FromInteger DoubleDefined in linear-base-0.4.0 · Data.Num.Linear
  • Num DoubleDefined in linear-base-0.4.0 · Data.Num.Linear
  • Ring DoubleDefined in linear-base-0.4.0 · Data.Num.Linear
  • Semiring DoubleDefined in linear-base-0.4.0 · Data.Num.Linear
  • Movable DoubleDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • Eq DoubleDefined in linear-base-0.4.0 · Data.Ord.Linear.Internal.Eq
  • Ord DoubleDefined in linear-base-0.4.0 · Data.Ord.Linear.Internal.Ord
  • Lift DoubleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • IArray UArray DoubleDefined in array-0.5.8.0 · Data.Array.Base
  • Vector Vector DoubleDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MVector MVector DoubleDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • MArray IOUArray Double IODefined in array-0.5.8.0 · Data.Array.IO.Internals
  • Generic1 (URec Double)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic1 (URec Double)Defined in linear-generics-0.2.3 · Generics.Linear.Instances.Base · orphan
  • Foldable UDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Foldable
  • Traversable UDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Traversable
  • MArray (STUArray s) Double (ST s)Defined in array-0.5.8.0 · Data.Array.Base
  • Functor (URec Double)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Eq (URec Double p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Ord (URec Double p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (URec Double p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (URec Double p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Generic (URec Double p)Defined in linear-generics-0.2.3 · Generics.Linear.Instances.Base · orphan
  • type Rep (URec Double p) = D1 ('MetaData "URec" "GHC.Internal.Generics" "ghc-internal" 'False) (C1 ('MetaCons "UDouble" 'PrefixI 'True) (S1 ('MetaSel ('Just "uDouble#") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) UDouble))Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • type Rep1 (URec Double) = D1 ('MetaData "URec" "GHC.Internal.Generics" "ghc-internal" 'False) (C1 ('MetaCons "UDouble" 'PrefixI 'True) (S1 ('MetaSel ('Just "uDouble#") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) UDouble))Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • data URec DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics

    Used for marking occurrences of Double#

  • data MVector s DoubleDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • data Vector DoubleDefined in vector-0.13.2.0 · Data.Vector.Unboxed.Base
  • type Rep Double = D1 ('MetaData "Double" "GHC.Types" "ghc-prim" 'False) (C1 ('MetaCons "D#" 'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) UDouble))Defined in linear-generics-0.2.3 · Generics.Linear.Instances.Base · orphan
  • type Rep (URec Double p) = D1 ('MetaData "URec" "GHC.Internal.Generics" "ghc-internal" 'False) (C1 ('MetaCons "UDouble" 'PrefixI 'True) (S1 ('MetaSel ('Just "uDouble#") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) UDouble))Defined in linear-generics-0.2.3 · Generics.Linear.Instances.Base · orphan
  • type Rep1 (URec Double) = D1 ('MetaData "URec" "GHC.Internal.Generics" "ghc-internal" 'False) (C1 ('MetaCons "UDouble" 'PrefixI 'True) (S1 ('MetaSel ('Just "uDouble#") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) UDouble))Defined in linear-generics-0.2.3 · Generics.Linear.Instances.Base · orphan
typetype Rational = Ratio Integer
#

Arbitrary-precision rational numbers, represented as a ratio of two Integer values. A rational number may be constructed using the % operator.

datadata Word
#

A Word is an unsigned integral type, with the same size as Int.

Instances58Bounded, Enum, Integral, Data, Num, Read, …
classclass (Num a, Ord a) => Real a where
#

Real numbers.

The Haskell report defines no laws for Real, however Real instances are customarily expected to adhere to the following law:

Coherence with fromRational

if the type also implements

Fractional

, then

fromRational

is a left inverse for

toRational

, i.e.

fromRational (toRational i) = i

The law does not hold for Float, Double, CFloat, CDouble, etc., because these types contain non-finite values, which cannot be roundtripped through Rational.

Methods

Instances78Real, …
  • Real IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Real NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Real CBoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CClockDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CLLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CPtrdiffDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CSCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CSUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CSigAtomicDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CTimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CUCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CUIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CUIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CUIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CULLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CULongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CUShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real CWcharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Real IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Real WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Real Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Real Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Real Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Real Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Real CBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CBlkSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CCcDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CClockIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CDevDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CFsBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CFsFilCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CGidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CInoDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CModeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CNfdsDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CNlinkDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real COffDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CPidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CRLimDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CSocklenDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CSpeedDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CSsizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CTcflagDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real CUidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real FdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Real Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Real Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Real Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Real Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Real DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    Beware that toRational generates garbage for non-finite arguments:

    Example2 expressions
    toRational (1/0)179769313 (and 300 more digits...) % 1toRational (0/0)269653970 (and 300 more digits...) % 1
  • Real FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    Beware that toRational generates garbage for non-finite arguments:

    Example2 expressions
    toRational (1/0 :: Float)340282366920938463463374607431768211456 % 1toRational (0/0 :: Float)510423550381407695195061911147652317184 % 1
  • Real IntDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Real WordDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Real CardinalityDefined in random-1.2.1.3 · System.Random.GFinite

    This is needed only as a superclass of Integral.

  • Real I8Defined in text-2.1.3 · Data.Text.Foreign
  • Integral a => Real (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Real a => Real (Blind a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Real a => Real (Fixed a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Real a => Real (Large a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Real a => Real (Shrink2 a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Real a => Real (Small a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Real a => Real (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Real a => Real (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • HasResolution a => Real (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • Real a => Real (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Real (f (g a)) => Real (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
classclass (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 with rem x y = fromInteger 0 or g (rem x y) < g y

  • x = y * div x y + mod x y with mod x y = fromInteger 0 or f (mod x y) < f y

An example of a suitable Euclidean function, for Integer's instance, is abs.

In addition, toInteger should be total, and fromInteger should be a left inverse for it, i.e. fromInteger (toInteger i) = i.

Methods

  • quot :: a -> a -> ainfixl 7

    Integer division truncated toward zero.

    WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.

  • rem :: a -> a -> ainfixl 7

    Integer remainder, satisfying

    (x `quot` y)*y + (x `rem` y) == x

    WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.

  • div :: a -> a -> ainfixl 7

    Integer division truncated toward negative infinity.

    WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.

  • mod :: a -> a -> ainfixl 7

    Integer modulus, satisfying

    (x `div` y)*y + (x `mod` y) == x

    WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.

  • quotRem :: a -> a -> (a, a)

    Simultaneous quot and rem.

    WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.

  • divMod :: a -> a -> (a, a)

    simultaneous div and mod.

    WARNING: This function is partial (because it throws when 0 is passed as the divisor) for all the integer types in base.

  • toInteger :: a -> Integer

    Conversion to Integer.

Instances65Integral, …
  • Integral IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Integral NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Integral CBoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CLLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CPtrdiffDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CSCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CSigAtomicDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CUCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CUIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CUIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CUIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CULLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CULongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CUShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral CWcharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Integral IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Integral WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Integral Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Integral Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Integral Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Integral Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Integral CBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CBlkSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CClockIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CDevDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CFsBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CFsFilCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CGidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CInoDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CModeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CNfdsDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CNlinkDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral COffDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CPidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CRLimDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CSocklenDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CSsizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CTcflagDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral CUidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral FdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Integral Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Integral Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Integral Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Integral Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Integral IntDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Integral WordDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Integral CardinalityDefined in random-1.2.1.3 · System.Random.GFinite
  • Integral I8Defined in text-2.1.3 · Data.Text.Foreign
  • Integral a => Integral (Blind a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Integral a => Integral (Fixed a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Integral a => Integral (Large a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Integral a => Integral (Shrink2 a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Integral a => Integral (Small a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Integral a => Integral (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Integral a => Integral (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Integral (f (g a)) => Integral (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
classclass Fractional a => Floating a where
#

Trigonometric and hyperbolic functions and related functions.

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

  • exp (a + b) = exp a * exp b

  • exp (fromInteger 0) = fromInteger 1

Methods

Instances10Floating, …
classclass Num a => Fractional a where
#

Fractional numbers, supporting real division.

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

recip gives the multiplicative inverse

x * recip x

=

recip x * x

=

fromInteger 1

Totality of toRational

toRational

is total

Coherence with toRational

if the type also implements

Real

, then

fromRational

is a left inverse for

toRational

, i.e.

fromRational (toRational i) = i

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

Methods

Instances12Fractional, …
  • Fractional CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Fractional CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Fractional DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    This instance implements IEEE 754 standard with all its usual pitfalls about NaN, infinities and negative zero.

    Example4 expressions
    0 == (-0 :: Double)Truerecip 0 == recip (-0 :: Double)Falsemap (/ 0) [-1, 0, 1][-Infinity,NaN,Infinity]map (* 0) $ map (/ 0) [-1, 0, 1][NaN,NaN,NaN]
  • Fractional FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    This instance implements IEEE 754 standard with all its usual pitfalls about NaN, infinities and negative zero.

    Example4 expressions
    0 == (-0 :: Float)Truerecip 0 == recip (-0 :: Float)Falsemap (/ 0) [-1, 0, 1 :: Float][-Infinity,NaN,Infinity]map (* 0) $ map (/ 0) [-1, 0, 1 :: Float][NaN,NaN,NaN]
  • RealFloat a => Fractional (Complex a)Defined in base-4.20.2.0 · Data.Complex
  • Fractional a => Fractional (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Fractional a => Fractional (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • Integral a => Fractional (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • HasResolution a => Fractional (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • Fractional a => Fractional (Op a b)Defined in base-4.20.2.0 · Data.Functor.Contravariant
  • Fractional a => Fractional (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • Fractional (f (g a)) => Fractional (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
classclass (Real a, Fractional a) => RealFrac a where
#

Extracting components of fractions.

Methods

Instances10RealFrac, …
  • RealFrac CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • RealFrac CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • RealFrac DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    Beware that results for non-finite arguments are garbage:

    Example2 expressions
    [ f x | f <- [round, floor, ceiling], x <- [-1/0, 0/0, 1/0] ] :: [Int][0,0,0,0,0,0,0,0,0]map properFraction [-1/0, 0/0, 1/0] :: [(Int, Double)][(0,0.0),(0,0.0),(0,0.0)]

    and get even more non-sensical if you ask for Integer instead of Int.

  • RealFrac FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan

    Beware that results for non-finite arguments are garbage:

    Example2 expressions
    [ f x | f <- [round, floor, ceiling], x <- [-1/0, 0/0, 1/0 :: Float] ] :: [Int][0,0,0,0,0,0,0,0,0]map properFraction [-1/0, 0/0, 1/0] :: [(Int, Float)][(0,0.0),(0,0.0),(0,0.0)]

    and get even more non-sensical if you ask for Integer instead of Int.

  • Integral a => RealFrac (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • RealFrac a => RealFrac (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • RealFrac a => RealFrac (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • HasResolution a => RealFrac (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • RealFrac a => RealFrac (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • RealFrac (f (g a)) => RealFrac (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
classclass (RealFrac a, Floating a) => RealFloat a where
#

Efficient, machine-independent access to the components of a floating-point number.

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 decodeFloat x yields (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) <= abs m < b^d, where d is the value of floatDigits x. In particular, decodeFloat 0 = (0,0). If the type contains a negative zero, also decodeFloat (-0.0) = (0,0). The result of decodeFloat x is unspecified if either of isNaN x or isInfinite x is True.

  • encodeFloat :: Integer -> Int -> a

    encodeFloat performs the inverse of decodeFloat in the sense that for finite x with the exception of -0.0, Prelude.uncurry encodeFloat (decodeFloat x) = x. encodeFloat m n is one of the two closest representable floating-point numbers to m*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 :: a -> Int

    exponent corresponds to the second component of decodeFloat. exponent 0 = 0 and for finite nonzero x, exponent x = snd (decodeFloat x) + floatDigits x. If x is a finite floating-point number, it is equal in value to significand x * b ^^ exponent x, where b 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

  • isNaN :: a -> Bool

    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

  • isIEEE :: a -> Bool

    True if the argument is an IEEE floating point number

  • atan2 :: a -> a -> a

    a version of arctangent taking two real floating-point arguments. For real floating x and y, atan2 y x computes the angle (from the positive x-axis) of the vector from the origin to the point (x,y). atan2 y x returns a value in the range [-pi, pi]. It follows the Common Lisp semantics for the origin when signed zeroes are supported. atan2 y 1, with y in a type that is RealFloat, should return the same value as atan y. A default definition of atan2 is provided, but implementors can provide a more accurate implementation.

Instances8RealFloat, …

Numeric functions

valuesubtract :: Num a => a -> a -> a
#

the same as flip (-).

Because - is treated specially in the Haskell grammar, (- e) is not a section, but an application of prefix negation. However, (subtract exp) is equivalent to the disallowed section.

valuegcd :: Integral a => a -> a -> a
#

gcd x y is the non-negative factor of both x 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 4 = 4. gcd 0 0 = 0. (That is, the common divisor that is "greatest" in the divisibility preordering.)

Note: Since for signed fixed-width integer types, abs minBound < 0, the result may be negative if one of the arguments is minBound (and necessarily is if the other is 0 or minBound) for such types.

valuelcm :: Integral a => a -> a -> a
#

lcm x y is the smallest positive integer that both x and y divide.

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

raise a number to a non-negative integral power

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

General coercion from Integral types.

WARNING: This function performs silent truncation if the result type is not at least as big as the argument's type.

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

General coercion to Fractional types.

WARNING: This function goes through the Rational type, which does not have values for NaN for example. This means it does not round-trip.

For Double it also behaves differently with or without -O0:

Prelude> realToFrac nan -- With -O0
-Infinity
Prelude> realToFrac nan
NaN

Monads and functors

value(<*) :: (Applicative f, Consumable b) => f a %1 -> f b %1 -> f a
#

Linearly typed replacement for the standard (Prelude.<*) function.

Semigroups and monoids

Miscellaneous functions

valueid :: a %q -> a
#
valueconst :: a %q -> b -> a
#
value(.) :: (b %1 -> c) %q -> (a %1 -> b) %m -> a %n -> c
#

Beware: (.) is not compatible with the standard one because it is higher-order and we don't have sufficient multiplicity polymorphism yet.

valueflip :: (a %p -> b %q -> c) %r -> b %q -> a %p -> c
#

Replacement for the flip function with generalized multiplicities.

value($) :: (a %p -> b) %q -> a %p -> b
#
value(&) :: a %p -> (a %p -> b) %q -> b
#
valueuntil :: (a -> Bool) -> (a -> a) -> a -> a
#

until p f yields the result of applying f until p holds.

valueundefined :: HasCallStack => a
#

A special case of error. It is expected that compilers will recognize this and insert error messages which are more appropriate to the context in which undefined appears.

valueseq :: a -> b %q -> b
#

seq x y only forces x to head normal form, therefore is not guaranteed to consume x when the resulting computation is consumed. Therefore, seq cannot be linear in it's first argument.

value($!) :: (a %p -> b) %q -> a %p -> b
#

List operations

0 declarations

Functions on strings

6 declarations
typetype String = [Char]
#

String is an alias for a list of characters.

String constants in Haskell are values of type String. That means if you write a string literal like "hello world", it will have the type [Char], which is the same as String.

Note: You can ask the compiler to automatically infer different types with the -XOverloadedStrings language extension, for example "hello world" :: Text. See IsString for more information.

Because String is just a list of characters, you can use normal list functions to do basic string manipulation. See Data.List for operations on lists.

Performance considerations

[Char] is a relatively memory-inefficient type. It is a linked list of boxed word-size characters, internally it looks something like:

╭─────┬───┬──╮  ╭─────┬───┬──╮  ╭─────┬───┬──╮  ╭────╮
│ (:) │   │ ─┼─>│ (:) │   │ ─┼─>│ (:) │   │ ─┼─>│ [] │
╰─────┴─┼─┴──╯  ╰─────┴─┼─┴──╯  ╰─────┴─┼─┴──╯  ╰────╯
        v               v               v
       'a'             'b'             'c'

The String "abc" will use 5*3+1 = 16 (in general 5n+1) words of space in memory.

Furthermore, operations like (++) (string concatenation) are O(n) (in the left argument).

For historical reasons, the base library uses String in a lot of places for the conceptual simplicity, but library code dealing with user-data should use the text package for Unicode text, or the the bytestring package for binary data.

valuelines :: String -> [String]
#

Splits the argument into a list of lines stripped of their terminating \n characters. The \n terminator is optional in a final non-empty line of the argument string.

When the argument string is empty, or ends in a \n character, it can be recovered by passing the result of lines to the unlines function. Otherwise, unlines appends the missing terminating \n. This makes unlines . lines idempotent:

(unlines . lines) . (unlines . lines) = (unlines . lines)
Examples
Example1 expression
lines ""           -- empty input contains no lines[]
Example1 expression
lines "\n"         -- single empty line[""]
Example1 expression
lines "one"        -- single unterminated line["one"]
Example1 expression
lines "one\n"      -- single non-empty line["one"]
Example1 expression
lines "one\n\n"    -- second line is empty["one",""]
Example1 expression
lines "one\ntwo"   -- second line is unterminated["one","two"]
Example1 expression
lines "one\ntwo\n" -- two non-empty lines["one","two"]
valueunlines :: [String] -> String
#

Appends a \n character to each input string, then concatenates the results. Equivalent to foldMap (s -> s ++ "\n").

Examples
Example1 expression
unlines ["Hello", "World", "!"]"Hello\nWorld\n!\n"

Note that unlines . lines /= id when the input is not \n-terminated:

Example1 expression
unlines . lines $ "foo\nbar""foo\nbar\n"
valueunwords :: [String] -> String
#

unwords joins words with separating spaces (U+0020 SPACE).

unwords is neither left nor right inverse of words:

Example2 expressions
words (unwords [" "])[]unwords (words "foo\nbar")"foo bar"
Examples
Example1 expression
unwords ["Lorem", "ipsum", "dolor"]"Lorem ipsum dolor"
Example1 expression
unwords ["foo", "bar", "", "baz"]"foo bar  baz"
valuewords :: String -> [String]
#

words breaks a string up into a list of words, which were delimited by white space (as defined by isSpace). This function trims any white spaces at the beginning and at the end.

Examples
Example1 expression
words "Lorem ipsum\ndolor"["Lorem","ipsum","dolor"]
Example1 expression
words " foo bar "["foo","bar"]
classclass IsString a where
#

IsString is used in combination with the -XOverloadedStrings language extension to convert the literals to different string types.

For example, if you use the text package, you can say

{-# LANGUAGE OverloadedStrings  #-}

myText = "hello world" :: Text

Internally, the extension will convert this to the equivalent of

myText = fromString @Text ("hello world" :: String)

Note: You can use fromString in normal code as well, but the usual performance/memory efficiency problems with String apply.

Methods

Instances14IsString, …
  • IsString BuilderDefined in bytestring-0.12.2.0 · Data.ByteString.Builder · orphan
  • IsString ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type

    Beware: fromString truncates multi-byte characters to octets. e.g. "枯朶に烏のとまりけり秋の暮" becomes �6k�nh~�Q��n�

  • IsString ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Lazy.Internal

    Beware: fromString truncates multi-byte characters to octets. e.g. "枯朶に烏のとまりけり秋の暮" becomes �6k�nh~�Q��n�

  • IsString ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.Internal

    Beware: fromString truncates multi-byte characters to octets. e.g. "枯朶に烏のとまりけり秋の暮" becomes �6k�nh~�Q��n�

  • IsString DocDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJ
  • IsString TextDefined in text-2.1.3 · Data.Text · orphan

    Performs replacement on invalid scalar values:

    Example2 expressions
    :set -XOverloadedStrings"\55555" :: Text"\65533"
  • IsString BuilderDefined in text-2.1.3 · Data.Text.Internal.Builder

    Performs replacement on invalid scalar values:

    Example2 expressions
    :set -XOverloadedStrings"\55555" :: Builder"\65533"
  • IsString TextDefined in text-2.1.3 · Data.Text.Lazy · orphan

    Performs replacement on invalid scalar values:

    Example2 expressions
    :set -XOverloadedStrings"\55555" :: Data.Text.Lazy.Text"\65533"
  • IsString (Doc a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • IsString a => IsString (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.String
  • (IsString a, Hashable a) => IsString (Hashed a)Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • a ~ Char => IsString (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • a ~ Char => IsString [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.String

    (a ~ Char) context was introduced in 4.9.0.0

  • IsString a => IsString (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.String

Converting to and from String

12 declarations
typetype ShowS = String -> String
#

The shows functions return a function that prepends the output String to an existing String. This allows constant-time concatenation of results using function composition.

classclass Show a where
#

Conversion of values to readable Strings.

Derived instances of Show have the following properties, which are compatible with derived instances of Text.Read.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 than d (associativity is ignored). Thus, if d is 0 then the result is never surrounded in parentheses; if d is 11 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,

  • show (Leaf 1 :^: Leaf 2 :^: Leaf 3) produces the string "Leaf 1 :^: (Leaf 2 :^: Leaf 3)".

Methods

  • showsPrec :: Int -> 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 Text.Read.Read and Show satisfy the following:

    That is, readsPrec parses the string produced by showsPrec, and delivers the value that showsPrec started with.

  • show :: a -> String

    A specialised variant of showsPrec, using precedence context zero, and returning an ordinary String.

  • showList :: [a] -> ShowS

    The method showList is provided to allow the programmer to give a specialised way of showing lists of values. For example, this is used by the predefined Show instance of the Char type, where values of type String should be shown in double quotes, rather than between square brackets.

Instances454Show, …
  • Show ASCIIStringDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show PrintableStringDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show UnicodeStringDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show ADefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Poly
  • Show BDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Poly
  • Show CDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Poly
  • Show OrdADefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Poly
  • Show OrdBDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Poly
  • Show OrdCDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Poly
  • Show WitnessDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Property
  • Show QCGenDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Random
  • Show ConfidenceDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.State
  • Show ArgsDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Test
  • Show ResultDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Test
  • Show CellDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Text
  • Show StrDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Text
  • Show ByteArrayDefined in base-4.20.2.0 · Data.Array.Byte
  • Show TimeoutDefined in base-4.20.2.0 · System.Timeout
  • Show BuilderDefined in bytestring-0.12.2.0 · Data.ByteString.Builder · orphan
  • Show FormatModeDefined in bytestring-0.12.2.0 · Data.ByteString.Builder.RealFloat
  • Show FloatingDecimalDefined in bytestring-0.12.2.0 · Data.ByteString.Builder.RealFloat.D2S
  • Show FloatingDecimalDefined in bytestring-0.12.2.0 · Data.ByteString.Builder.RealFloat.F2S
  • Show ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Show SizeOverflowExceptionDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Show ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Lazy.Internal
  • Show ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.Internal
  • Show IntSetDefined in containers-0.7 · Data.IntSet.Internal
  • Show BitQueueDefined in containers-0.7 · Utils.Containers.Internal.BitQueue
  • Show BitQueueBDefined in containers-0.7 · Utils.Containers.Internal.BitQueue
  • Show IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show ForeignSrcLangDefined in ghc-boot-th-9.10.3 · GHC.ForeignSrcLang.Type
  • Show ExtensionDefined in ghc-boot-th-9.10.3 · GHC.LanguageExtensions.Type
  • Show VoidDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show ByteOrderDefined in ghc-internal-9.1003.0 · GHC.Internal.ByteOrder
  • Show ClosureTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.ClosureTypes
  • Show BlockReasonDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Show ThreadIdDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Show ThreadStatusDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Show NestedAtomicallyDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
  • Show NoMatchingContinuationPromptDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
  • Show NoMethodErrorDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
  • Show NonTerminationDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
  • Show PatternMatchFailDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
  • Show RecConErrorDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
  • Show RecSelErrorDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
  • Show RecUpdErrorDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
  • Show TypeErrorDefined in ghc-internal-9.1003.0 · GHC.Internal.Control.Exception.Base
  • Show ConstrDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Show ConstrRepDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Show DataRepDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Show DataTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Show FixityDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Data
  • Show DynamicDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Dynamic
  • Show AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Show AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Show SomeTypeRepDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Typeable.Internal
  • Show VersionDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Version
  • Show ControlMessageDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Control
  • Show EPollFdDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.EPoll
  • Show EventDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.EPoll
  • Show EventTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.EPoll
  • Show EventDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types
  • Show EventLifetimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types
  • Show LifetimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types
  • Show TimeoutDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types
  • Show FdKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Manager
  • Show StateDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Manager
  • Show EventDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Poll
  • Show PollFdDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Poll
  • Show StateDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.TimerManager
  • Show UniqueDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Unique
  • Show ErrorCallDefined in ghc-internal-9.1003.0 · GHC.Internal.Exception
  • Show ArithExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.Exception.Type
  • Show SomeExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.Exception.Type
  • Show FingerprintDefined in ghc-internal-9.1003.0 · GHC.Internal.Fingerprint.Type
  • Show CBoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CClockDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CLLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CPtrdiffDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CSCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CSUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CSigAtomicDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CTimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CUCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CUIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CUIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CUIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CULLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CULongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CUShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show CWcharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Show IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Show WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Show AssociativityDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show DecidedStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show FixityDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show SourceStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show SourceUnpackednessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show MaskingStateDefined in ghc-internal-9.1003.0 · GHC.Internal.IO
  • Show SeekModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Device
  • Show CodingFailureModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Encoding.Failure
  • Show CodingProgressDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Encoding.Types
  • Show TextEncodingDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Encoding.Types
  • Show AllocationLimitExceededDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show ArrayExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show AssertionFailedDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show AsyncExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show BlockedIndefinitelyOnMVarDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show BlockedIndefinitelyOnSTMDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show CompactionFailedDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show DeadlockDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show ExitCodeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show FixIOExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show IOErrorTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show IOExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show SomeAsyncExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Show FDDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.FD
  • Show HandlePosnDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle
  • Show FileLockingNotSupportedDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Lock.Common
  • Show BufferModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Show HandleDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Show HandleTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Show NewlineDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Show NewlineModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Show IOModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.IOMode
  • Show IOPortExceptionDefined in ghc-internal-9.1003.0 · GHC.Internal.IOPort
  • Show InfoProvDefined in ghc-internal-9.1003.0 · GHC.Internal.InfoProv.Types
  • Show Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Show Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Show Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Show Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Show CCFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show ConcFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show DebugFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show DoCostCentresDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show DoHeapProfileDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show DoTraceDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show GCFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show GiveGCStatsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show HpcFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show IoSubSystemDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show MiscFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show ParFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show ProfFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show RTSFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show TickyFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show TraceFlagsDefined in ghc-internal-9.1003.0 · GHC.Internal.RTS.Flags
  • Show FractionalExponentBaseDefined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Show StackEntryDefined in ghc-internal-9.1003.0 · GHC.Internal.Stack.CloneStack
  • Show CallStackDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show SrcLocDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show StaticPtrInfoDefined in ghc-internal-9.1003.0 · GHC.Internal.StaticPtr
  • Show GCDetailsDefined in ghc-internal-9.1003.0 · GHC.Internal.Stats
  • Show RTSStatsDefined in ghc-internal-9.1003.0 · GHC.Internal.Stats
  • Show CBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CBlkSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CCcDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CClockIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CDevDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CFsBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CFsFilCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CGidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CInoDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CModeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CNfdsDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CNlinkDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show COffDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CPidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CRLimDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CSocklenDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CSpeedDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CSsizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CTcflagDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CTimerDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show CUidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show FdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Show LexemeDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.Read.Lex
  • Show NumberDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.Read.Lex
  • Show SomeCharDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Show SomeSymbolDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Show SomeNatDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeNats
  • Show GeneralCategoryDefined in ghc-internal-9.1003.0 · GHC.Internal.Unicode
  • Show Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Show Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Show Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Show Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Word
  • Show BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show CharDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan
  • Show FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Float · orphan
  • Show IntDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show KindRepDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show LevityDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show ModuleDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show OrderingDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show RuntimeRepDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show TrNameDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show TyConDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show TypeLitSortDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show VecCountDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show VecElemDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show WordDefined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show PSLDefined in linear-base-0.4.0 · Data.HashMap.Mutable.Linear.Internal
  • Show EncodingExceptionDefined in os-string-2.0.7 · System.OsString.Encoding.Internal
  • Show OsCharDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Show OsStringDefined in os-string-2.0.7 · System.OsString.Internal.Types

    On windows, decodes as UCS-2. On unix prints the raw bytes without decoding.

  • Show PosixCharDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Show PosixStringDefined in os-string-2.0.7 · System.OsString.Internal.Types

    Prints the raw bytes without decoding.

  • Show WindowsCharDefined in os-string-2.0.7 · System.OsString.Internal.Types
  • Show WindowsStringDefined in os-string-2.0.7 · System.OsString.Internal.Types

    Decodes as UCS-2.

  • Show ModeDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Show StyleDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Show TextDetailsDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Show PrettyLevelDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJClass
  • Show DocDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJ
  • Show PrettyLevelDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJClass
  • Show CardinalityDefined in random-1.2.1.3 · System.Random.GFinite
  • Show StdGenDefined in random-1.2.1.3 · System.Random.Internal
  • Show SMGenDefined in splitmix-0.1.3.1 · System.Random.SplitMix
  • Show SMGenDefined in splitmix-0.1.3.1 · System.Random.SplitMix32
  • Show ForallVisFlagDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Ppr
  • Show DocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.PprLib
  • Show AnnLookupDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show AnnTargetDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show BangDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show BndrVisDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show BodyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show BytesDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show CallconvDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show ClauseDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show ConDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show DecDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show DecidedStrictnessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show DerivClauseDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show DerivStrategyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show DocLocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show ExpDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show FamilyResultSigDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show FixityDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show FixityDirectionDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show ForeignDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show FunDepDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show GuardDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show InfoDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show InjectivityAnnDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show InlineDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show LitDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show LocDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show MatchDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show ModNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show ModuleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show ModuleInfoDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show NameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show NameFlavourDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show NameSpaceDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show NamespaceSpecifierDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show OccNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show OverlapDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show PatDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show PatSynArgsDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show PatSynDirDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show PhasesDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show PkgNameDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show PragmaDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show RangeDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show RoleDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show RuleBndrDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show RuleMatchDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show SafetyDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show SourceStrictnessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show SourceUnpackednessDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show SpecificityDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show StmtDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show TyLitDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show TySynEqnDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show TypeDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show TypeFamilyHeadDefined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show DecodingDefined in text-2.1.3 · Data.Text.Encoding
  • Show UnicodeExceptionDefined in text-2.1.3 · Data.Text.Encoding.Error
  • Show I8Defined in text-2.1.3 · Data.Text.Foreign
  • Show TextDefined in text-2.1.3 · Data.Text.Show · orphan
  • Show BuilderDefined in text-2.1.3 · Data.Text.Internal.Builder
  • Show PartialUtf8CodePointDefined in text-2.1.3 · Data.Text.Internal.Encoding
  • Show Utf8StateDefined in text-2.1.3 · Data.Text.Internal.Encoding
  • Show DecoderStateDefined in text-2.1.3 · Data.Text.Internal.Encoding.Utf8
  • Show SizeDefined in text-2.1.3 · Data.Text.Internal.Fusion.Size
  • Show TextDefined in text-2.1.3 · Data.Text.Lazy · orphan
  • Show FPFormatDefined in text-2.1.3 · Data.Text.Lazy.Builder.RealFloat
  • Show IterDefined in text-2.1.3 · Data.Text.Unsafe
  • Show ConstructorInfoDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Show ConstructorVariantDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Show DatatypeInfoDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Show DatatypeVariantDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Show FieldStrictnessDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Show StrictnessDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Show UnpackednessDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Show SizeDefined in vector-0.13.2.0 · Data.Vector.Fusion.Bundle.Size
  • Show ()Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show (Blind a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show (ConstPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.ConstPtr
  • Show (ForeignPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.ForeignPtr
  • Show (FunPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ptr
  • Show (Ptr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Ptr
  • Show (SChar c)Defined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Show (SSymbol s)Defined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Show (SNat n)Defined in ghc-internal-9.1003.0 · GHC.Internal.TypeNats
  • Show (Doc a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Show a => Show (Fixed a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (InfiniteList a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (Large a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (Negative a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (NonEmptyList a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (NonNegative a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (NonPositive a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (NonZero a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (OrderedList a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (Positive a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (Shrink2 a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (Small a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (Smart a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (SortedList a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (Complex a)Defined in base-4.20.2.0 · Data.Complex
  • Show a => Show (First a)Defined in base-4.20.2.0 · Data.Semigroup
  • Show a => Show (Last a)Defined in base-4.20.2.0 · Data.Semigroup
  • Show a => Show (Max a)Defined in base-4.20.2.0 · Data.Semigroup
  • Show a => Show (Min a)Defined in base-4.20.2.0 · Data.Semigroup
  • Show a => Show (Decoder a)Defined in binary-0.8.9.3 · Data.Binary.Get.Internal
  • Show a => Show (IntMap a)Defined in containers-0.7 · Data.IntMap.Internal
  • Show a => Show (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • Show a => Show (ViewL a)Defined in containers-0.7 · Data.Sequence.Internal
  • Show a => Show (ViewR a)Defined in containers-0.7 · Data.Sequence.Internal
  • Show a => Show (Intersection a)Defined in containers-0.7 · Data.Set.Internal
  • Show a => Show (Set a)Defined in containers-0.7 · Data.Set.Internal
  • Show a => Show (Tree a)Defined in containers-0.7 · Data.Tree
  • Show a => Show (ExitCase a)Defined in exceptions-0.10.9 · Control.Monad.Catch
  • Show a => Show (NonEmpty a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show a => Show (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Show a => Show (Iff a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Show a => Show (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Show a => Show (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Show a => Show (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity

    This instance would be equivalent to the derived instances of the Identity newtype if the runIdentity field were removed

  • Show a => Show (First a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Show a => Show (Last a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Show a => Show (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord

    This instance would be equivalent to the derived instances of the Down newtype if the getDown field were removed

  • Show a => Show (Dual a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Show a => Show (Product a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Show a => Show (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Show a => Show (ExceptionWithContext a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Exception.Type
  • Show a => Show (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipList
  • Show a => Show (Maybe a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show a => Show (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Real
  • Show a => Show (Hashed a)Defined in hashable-1.4.7.0 · Data.Hashable.Class
  • Show a => Show (Adding a)Defined in linear-base-0.4.0 · Data.Num.Linear
  • Show a => Show (Multiplying a)Defined in linear-base-0.4.0 · Data.Num.Linear
  • Show a => Show (AnnotDetails a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Show a => Show (Span a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Show a => Show (Array a)Defined in primitive-0.9.1.0 · Data.Primitive.Array
  • Show a => Show (SmallArray a)Defined in primitive-0.9.1.0 · Data.Primitive.SmallArray
  • Show a => Show (Tuple a)Defined in storable-record-0.0.7 · Foreign.Storable.Record.Tuple
  • Show a => Show (Vector a)Defined in vector-0.13.2.0 · Data.Vector
  • Show a => Show (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Strict
  • Show a => Show (a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show a => Show [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show e => Show (NoBacktrace e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Exception.Type
  • Show flag => Show (TyVarBndr flag)Defined in template-haskell-2.22.0.0 · Language.Haskell.TH.Syntax
  • Show g => Show (StateGen g)Defined in random-1.2.1.3 · System.Random.Internal
  • Show g => Show (AtomicGen g)Defined in random-1.2.1.3 · System.Random.Stateful
  • Show g => Show (IOGen g)Defined in random-1.2.1.3 · System.Random.Stateful
  • Show g => Show (STGen g)Defined in random-1.2.1.3 · System.Random.Stateful
  • Show g => Show (TGen g)Defined in random-1.2.1.3 · System.Random.Stateful
  • Show m => Show (WrappedMonoid m)Defined in base-4.20.2.0 · Data.Semigroup
  • Show p => Show (Par1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show vertex => Show (SCC vertex)Defined in containers-0.7 · Data.Graph
  • (Show a, Storable a) => Show (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Storable
  • (Show a, Prim a) => Show (PrimArray a)Defined in primitive-0.9.1.0 · Data.Primitive.PrimArray
  • (Show a, Prim a) => Show (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Primitive
  • (Show a, Unbox a) => Show (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Unboxed · orphan
  • HasResolution a => Show (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • Show (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Show (TypeRep a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Typeable.Internal
  • Show (U1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (UAddr p)Defined in base-orphans-0.9.3 · Data.Orphans · orphan
  • Show (V1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (ST s a)Defined in ghc-internal-9.1003.0 · GHC.Internal.ST
  • Show (a -> b)Defined in base-4.20.2.0 · Text.Show.Functions · orphan
  • Show a => Show (Shrinking s a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (V n a)Defined in linear-base-0.4.0 · Data.V.Linear.Internal
  • (Show1 f, Show a) => Show (Lift f a)Defined in transformers-0.6.1.1 · Control.Applicative.Lift
  • (Show1 m, Show a) => Show (MaybeT m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Maybe
  • (Ix a, Show a, Show b) => Show (Array a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Arr
  • (Ix ix, Show ix, Show e, IArray UArray e) => Show (UArray ix e)Defined in array-0.5.8.0 · Data.Array.Base
  • (Show a, Show b) => Show (Fun a b)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Function
  • (Show a, Show b) => Show (Arg a b)Defined in base-4.20.2.0 · Data.Semigroup
  • (Show a, Show b) => Show (Either a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Either
  • (Show a, Show b) => Show (a, b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show a, Show b) => Show (a :-> b)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Function
  • (Show k, Show a) => Show (Map k a)Defined in containers-0.7 · Data.Map.Internal
  • (Show k, Show v) => Show (RobinVal k v)Defined in linear-base-0.4.0 · Data.HashMap.Mutable.Linear.Internal
  • Show (Coercion a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Coercion
  • Show (OrderingI a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Ord
  • Show (URec Char p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (URec Double p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (URec Float p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (URec Int p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (URec Word p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Show (f a) => Show (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Show (f a) => Show (Alt f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Show (f p) => Show (Rec1 f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show a => Show (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const

    This instance would be equivalent to the derived instances of the Const newtype if the getConst field were removed

  • Show a => Show (Constant a b)Defined in transformers-0.6.1.1 · Data.Functor.Constant
  • (Show1 f, Show a) => Show (Backwards f a)Defined in transformers-0.6.1.1 · Control.Applicative.Backwards
  • (Show1 f, Show a) => Show (IdentityT f a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Identity
  • (Show1 f, Show a) => Show (Reverse f a)Defined in transformers-0.6.1.1 · Data.Functor.Reverse
  • (Show a, Show b, Show c) => Show (a, b, c)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show e, Show1 m, Show a) => Show (ExceptT e m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except
  • (Show w, Show1 m, Show a) => Show (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy
  • (Show w, Show1 m, Show a) => Show (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Strict
  • Show (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Show (f a) => Show (MP1 m f a)Defined in linear-generics-0.2.3 · Generics.Linear.Class
  • Show c => Show (K1 i c p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Show (f a), Show (g a)) => Show (Product f g a)Defined in base-4.20.2.0 · Data.Functor.Product
  • (Show (f a), Show (g a)) => Show (Sum f g a)Defined in base-4.20.2.0 · Data.Functor.Sum
  • (Show (f p), Show (g p)) => Show ((:*:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Show (f p), Show (g p)) => Show ((:+:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Show a, Show b, Show c, Show d) => Show (a, b, c, d)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • Show (f (g a)) => Show (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
  • Show (f (g p)) => Show ((:.:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Show (f (g x)) => Show ((:.:) f g x)Defined in linear-generics-0.2.3 · Generics.Linear.Class
  • Show (f p) => Show (M1 i c f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Show a, Show b, Show c, Show d, Show e) => Show (a, b, c, d, e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show a, Show b, Show c, Show d, Show e, Show f) => Show (a, b, c, d, e, f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show a, Show b, Show c, Show d, Show e, Show f, Show g) => Show (a, b, c, d, e, f, g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h) => Show (a, b, c, d, e, f, g, h)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i) => Show (a, b, c, d, e, f, g, h, i)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j) => Show (a, b, c, d, e, f, g, h, i, j)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k) => Show (a, b, c, d, e, f, g, h, i, j, k)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l) => Show (a, b, c, d, e, f, g, h, i, j, k, l)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m, Show n) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m, n)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
  • (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k, Show l, Show m, Show n, Show o) => Show (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)Defined in ghc-internal-9.1003.0 · GHC.Internal.Show
valueshowChar :: Char -> ShowS
#

utility function converting a Char to a show function that simply prepends the character unchanged.

typetype ReadS a = String -> [(a, String)]
#

A parser for a type a, represented as a function that takes a String and returns a list of possible parses as (a,String) pairs.

Note that this kind of backtracking parser is very inefficient; reading a large structure may be quite slow (cf ReadP).

classclass Read a where
#

Parsing of Strings, producing values.

Derived instances of Read make the following assumptions, which derived instances of Text.Show.Show obey:

  • If the constructor is defined to be an infix operator, then the derived Read instance will parse only infix applications of the constructor (not the prefix form).

  • Associativity is not used to reduce the occurrence of parentheses, although precedence may be.

  • If the constructor is defined using record syntax, the derived Read will parse only the record-syntax form, and furthermore, the fields must be given in the same order as the original declaration.

  • The derived Read instance allows arbitrary Haskell whitespace between tokens of the input string. Extra parentheses are also allowed.

For example, given the declarations

infixr 5 :^:
data Tree a =  Leaf a  |  Tree a :^: Tree a

the derived instance of Read in Haskell 2010 is equivalent to

instance (Read a) => Read (Tree a) where

        readsPrec d r =  readParen (d > app_prec)
                         (\r -> [(Leaf m,t) |
                                 ("Leaf",s) <- lex r,
                                 (m,t) <- readsPrec (app_prec+1) s]) r

                      ++ readParen (d > up_prec)
                         (\r -> [(u:^:v,w) |
                                 (u,s) <- readsPrec (up_prec+1) r,
                                 (":^:",t) <- lex s,
                                 (v,w) <- readsPrec (up_prec+1) t]) r

          where app_prec = 10
                up_prec = 5

Note that right-associativity of :^: is unused.

The derived instance in GHC is equivalent to

instance (Read a) => Read (Tree a) where

        readPrec = parens $ (prec app_prec $ do
                                 Ident "Leaf" <- lexP
                                 m <- step readPrec
                                 return (Leaf m))

                     +++ (prec up_prec $ do
                                 u <- step readPrec
                                 Symbol ":^:" <- lexP
                                 v <- step readPrec
                                 return (u :^: v))

          where app_prec = 10
                up_prec = 5

        readListPrec = readListPrecDefault

Why do both readsPrec and readPrec exist, and why does GHC opt to implement readPrec in derived Read instances instead of readsPrec? The reason is that readsPrec is based on the ReadS type, and although ReadS is mentioned in the Haskell 2010 Report, it is not a very efficient parser data structure.

readPrec, on the other hand, is based on a much more efficient ReadPrec datatype (a.k.a "new-style parsers"), but its definition relies on the use of the RankNTypes language extension. Therefore, readPrec (and its cousin, readListPrec) are marked as GHC-only. Nevertheless, it is recommended to use readPrec instead of readsPrec whenever possible for the efficiency improvements it brings.

As mentioned above, derived Read instances in GHC will implement readPrec instead of readsPrec. The default implementations of readsPrec (and its cousin, readList) will simply use readPrec under the hood. If you are writing a Read instance by hand, it is recommended to write it like so:

instance Read T where
  readPrec     = ...
  readListPrec = readListPrecDefault

Methods

  • readsPrec :: Int -> ReadS a

    attempts to parse a value from the front of the string, returning a list of (parsed value, remaining string) pairs. If there is no successful parse, the returned list is empty.

    Derived instances of Read and Text.Show.Show satisfy the following:

    That is, readsPrec parses the string produced by showsPrec, and delivers the value that showsPrec started with.

  • readList :: ReadS [a]

    The method readList is provided to allow the programmer to give a specialised way of parsing lists of values. For example, this is used by the predefined Read instance of the Char type, where values of type String are expected to use double quotes, rather than square brackets.

Instances207Read, …
  • Read ASCIIStringDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Read PrintableStringDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Read UnicodeStringDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Read QCGenDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Random
  • Read ArgsDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Test
  • Read ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.Type
  • Read ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Lazy.Internal
  • Read ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.Internal
  • Read IntSetDefined in containers-0.7 · Data.IntSet.Internal
  • Read IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read VoidDefined in ghc-internal-9.1003.0 · GHC.Internal.Read

    Reading a Void value is always a parse error, considering Void as a data type with no constructors.

  • Read ByteOrderDefined in ghc-internal-9.1003.0 · GHC.Internal.ByteOrder
  • Read AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read VersionDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Version
  • Read CBoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CClockDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CLLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CPtrdiffDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CSCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CSUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CSigAtomicDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CTimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CUCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CUIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CUIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CUIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CULLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CULongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CUShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read CWcharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.Types
  • Read IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Read WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.Ptr
  • Read AssociativityDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read DecidedStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read FixityDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read SourceStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read SourceUnpackednessDefined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read SeekModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Device
  • Read ExitCodeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Exception
  • Read BufferModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Read NewlineDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Read NewlineModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.Types
  • Read IOModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.IOMode
  • Read Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Read Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Read Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Read Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.Int
  • Read GCDetailsDefined in ghc-internal-9.1003.0 · GHC.Internal.Stats
  • Read RTSStatsDefined in ghc-internal-9.1003.0 · GHC.Internal.Stats
  • Read CBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CBlkSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CCcDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CClockIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CDevDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CFsBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CFsFilCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CGidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CInoDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CModeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CNfdsDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CNlinkDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read COffDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CPidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CRLimDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CSocklenDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CSpeedDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CSsizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CTcflagDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read CUidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read FdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.Types
  • Read LexemeDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read SomeCharDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Read SomeSymbolDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeLits
  • Read SomeNatDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeNats
  • Read GeneralCategoryDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read CharDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read IntDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read OrderingDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read WordDefined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read SMGenDefined in splitmix-0.1.3.1 · System.Random.SplitMix
    Example1 expression
    readMaybe "SMGen 1 1" :: Maybe SMGenJust (SMGen 1 1)
    Example1 expression
    readMaybe "SMGen 1 2" :: Maybe SMGenNothing
    Example1 expression
    readMaybe (show (mkSMGen 42)) :: Maybe SMGenJust (SMGen 9297814886316923340 13679457532755275413)
  • Read SMGenDefined in splitmix-0.1.3.1 · System.Random.SplitMix32
    Example1 expression
    readMaybe "SMGen 1 1" :: Maybe SMGenJust (SMGen 1 1)
    Example1 expression
    readMaybe "SMGen 1 2" :: Maybe SMGenNothing
    Example1 expression
    readMaybe (show (mkSMGen 42)) :: Maybe SMGenJust (SMGen 142593372 1604540297)
  • Read I8Defined in text-2.1.3 · Data.Text.Foreign
  • Read TextDefined in text-2.1.3 · Data.Text · orphan
  • Read TextDefined in text-2.1.3 · Data.Text.Lazy · orphan
  • Read FPFormatDefined in text-2.1.3 · Data.Text.Lazy.Builder.RealFloat
  • Read DatatypeVariantDefined in th-abstraction-0.7.1.0 · Language.Haskell.TH.Datatype
  • Read ()Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read a => Read (Fixed a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Read a => Read (Large a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Read a => Read (Negative a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Read a => Read (NonEmptyList a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Read a => Read (NonNegative a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Read a => Read (NonPositive a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Read a => Read (NonZero a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Read a => Read (OrderedList a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Read a => Read (Positive a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Read a => Read (Shrink2 a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Read a => Read (Small a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Read a => Read (SortedList a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Read a => Read (Complex a)Defined in base-4.20.2.0 · Data.Complex
  • Read a => Read (First a)Defined in base-4.20.2.0 · Data.Semigroup
  • Read a => Read (Last a)Defined in base-4.20.2.0 · Data.Semigroup
  • Read a => Read (Max a)Defined in base-4.20.2.0 · Data.Semigroup
  • Read a => Read (Min a)Defined in base-4.20.2.0 · Data.Semigroup
  • Read a => Read (Seq a)Defined in containers-0.7 · Data.Sequence.Internal
  • Read a => Read (ViewL a)Defined in containers-0.7 · Data.Sequence.Internal
  • Read a => Read (ViewR a)Defined in containers-0.7 · Data.Sequence.Internal
  • Read a => Read (Tree a)Defined in containers-0.7 · Data.Tree
  • Read a => Read (NonEmpty a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read a => Read (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Read a => Read (Iff a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Read a => Read (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Read a => Read (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Read a => Read (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity

    This instance would be equivalent to the derived instances of the Identity newtype if the runIdentity field were removed

  • Read a => Read (First a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Read a => Read (Last a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Read a => Read (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord

    This instance would be equivalent to the derived instances of the Down newtype if the getDown field were removed

  • Read a => Read (Dual a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read a => Read (Product a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read a => Read (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read a => Read (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipList
  • Read a => Read (Maybe a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read a => Read (Array a)Defined in primitive-0.9.1.0 · Data.Primitive.Array
  • Read a => Read (SmallArray a)Defined in primitive-0.9.1.0 · Data.Primitive.SmallArray
  • Read a => Read (Vector a)Defined in vector-0.13.2.0 · Data.Vector
  • Read a => Read (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Strict
  • Read a => Read (a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read a => Read [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • Read e => Read (IntMap e)Defined in containers-0.7 · Data.IntMap.Internal
  • Read m => Read (WrappedMonoid m)Defined in base-4.20.2.0 · Data.Semigroup
  • Read p => Read (Par1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read vertex => Read (SCC vertex)Defined in containers-0.7 · Data.Graph
  • (Read a, Storable a) => Read (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Storable
  • (Read a, Ord a) => Read (Set a)Defined in containers-0.7 · Data.Set.Internal
  • (Read a, Prim a) => Read (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Primitive
  • (Read a, Unbox a) => Read (Vector a)Defined in vector-0.13.2.0 · Data.Vector.Unboxed · orphan
  • (Integral a, Read a) => Read (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • HasResolution a => Read (Fixed a)Defined in base-4.20.2.0 · Data.Fixed
  • Read (Proxy t)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Read (U1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read (V1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Read1 f, Read a) => Read (Lift f a)Defined in transformers-0.6.1.1 · Control.Applicative.Lift
  • (Read1 m, Read a) => Read (MaybeT m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Maybe
  • (Ix a, Read a, Read b) => Read (Array a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Ix ix, Read ix, Read e, IArray UArray e) => Read (UArray ix e)Defined in array-0.5.8.0 · Data.Array.Base
  • (Read a, Read b) => Read (Arg a b)Defined in base-4.20.2.0 · Data.Semigroup
  • (Read a, Read b) => Read (Either a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Either
  • (Read a, Read b) => Read (a, b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Ord k, Read k, Read e) => Read (Map k e)Defined in containers-0.7 · Data.Map.Internal
  • Read (f a) => Read (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Read (f a) => Read (Alt f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Read (f p) => Read (Rec1 f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read a => Read (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const

    This instance would be equivalent to the derived instances of the Const newtype if the getConst field were removed

  • Read a => Read (Constant a b)Defined in transformers-0.6.1.1 · Data.Functor.Constant
  • Coercible a b => Read (Coercion a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Coercion
  • (Read1 f, Read a) => Read (Backwards f a)Defined in transformers-0.6.1.1 · Control.Applicative.Backwards
  • (Read1 f, Read a) => Read (IdentityT f a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Identity
  • (Read1 f, Read a) => Read (Reverse f a)Defined in transformers-0.6.1.1 · Data.Functor.Reverse
  • (Read a, Read b, Read c) => Read (a, b, c)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read e, Read1 m, Read a) => Read (ExceptT e m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except
  • (Read w, Read1 m, Read a) => Read (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy
  • (Read w, Read1 m, Read a) => Read (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Strict
  • a ~ b => Read (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Read (f a) => Read (MP1 m f a)Defined in linear-generics-0.2.3 · Generics.Linear.Class
  • Read c => Read (K1 i c p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Read (f a), Read (g a)) => Read (Product f g a)Defined in base-4.20.2.0 · Data.Functor.Product
  • (Read (f a), Read (g a)) => Read (Sum f g a)Defined in base-4.20.2.0 · Data.Functor.Sum
  • (Read (f p), Read (g p)) => Read ((:*:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Read (f p), Read (g p)) => Read ((:+:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Read a, Read b, Read c, Read d) => Read (a, b, c, d)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • a ~~ b => Read (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
  • Read (f (g a)) => Read (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
  • Read (f (g p)) => Read ((:.:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Read (f (g x)) => Read ((:.:) f g x)Defined in linear-generics-0.2.3 · Generics.Linear.Class
  • Read (f p) => Read (M1 i c f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Read a, Read b, Read c, Read d, Read e) => Read (a, b, c, d, e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f) => Read (a, b, c, d, e, f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g) => Read (a, b, c, d, e, f, g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h) => Read (a, b, c, d, e, f, g, h)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i) => Read (a, b, c, d, e, f, g, h, i)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j) => Read (a, b, c, d, e, f, g, h, i, j)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k) => Read (a, b, c, d, e, f, g, h, i, j, k)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l) => Read (a, b, c, d, e, f, g, h, i, j, k, l)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m, Read n) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m, n)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
  • (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m, Read n, Read o) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
valueread :: Read a => String -> a
#

The read function reads input from a string, which must be completely consumed by the input process. read fails with an error if the parse is unsuccessful, and it is therefore discouraged from being used in real applications. Use readMaybe or readEither for safe alternatives.

Example1 expression
read "123" :: Int123
Example1 expression
read "hello" :: Int*** Exception: Prelude.read: no parse
valuelex :: ReadS String
#

The lex function reads a single lexeme from the input, discarding initial white space, and returning the characters that constitute the lexeme. If the input string contains only white space, lex returns a single successful `lexeme' consisting of the empty string. (Thus lex "" = [("","")].) If there is no legal lexeme at the beginning of the input string, lex fails (i.e. returns []).

This lexer is not completely faithful to the Haskell lexical syntax in the following respects:

  • Qualified names are not handled properly

  • Octal and hexadecimal numerics are not recognized as a single token

  • Comments are not treated properly

Basic input and output

9 declarations
newtypenewtype IO a
#

A value of type IO a is a computation which, when performed, does some I/O before returning a value of type a.

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 Prelude.>> and Prelude.>>= operations from the Prelude.Monad class.

Instances42Monad, Functor, MonadFix, MonadFail, Applicative, GHCiSandboxIO, …
valueprint :: 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]])
valueinteract :: (String -> String) -> IO ()
#

The interact function takes a function of type String->String as its argument. The entire input from the standard input device is passed to this function as its argument, and the resulting string is output on the standard output device.

Files

typetype FilePath = String
#

File and directory names are values of type String, whose precise meaning is operating system dependent. Files can be opened, yielding a handle which can then be used to operate on the contents of that file.

valueappendFile :: FilePath -> String -> IO ()
#

The computation appendFile file str function appends the string str, to the file file.

Note that writeFile and appendFile write a literal string to a file. To write a value of any printable type, as with print, use the show function to convert the value to a string first.

main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]])
valuereadIO :: Read a => String -> IO a
#

The readIO function is similar to read except that it signals parse failure to the IO monad instead of terminating the program.

Using Ur values in linear code

2 declarations
datadata Ur a where
#

Ur a represents unrestricted values of type a in a linear context. The key idea is that because the contructor holds a with a regular arrow, a function that uses Ur a linearly can use a however it likes.

someLinear :: Ur a %1-> (a,a)
someLinear (Ur a) = (a,a)

Constructors

Instances24Monad, Foldable, Traversable, Functor, Applicative, Generic1, …
  • Monad UrDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Ur
  • Functor UrDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Ur
  • Applicative UrDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Ur
  • Foldable UrDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Ur
  • Traversable UrDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Ur
  • Functor UrDefined in linear-base-0.4.0 · Data.Functor.Linear.Internal.Functor
  • Applicative UrDefined in linear-base-0.4.0 · Data.Functor.Linear.Internal.Applicative
  • Generic1 UrDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Ur
  • Generic1 UrDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Ur
  • Generic (Ur a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Ur
  • Storable a => Storable (Ur a)Defined in linear-base-0.4.0 · Foreign.Marshal.Pure.Internal · orphan
  • Generic (Ur a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Ur
  • Monoid a => Monoid (Ur a)Defined in linear-base-0.4.0 · Data.Monoid.Linear.Internal.Monoid

    Useful to treat unrestricted monoids as linear ones.

  • Consumable (Ur a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Dupable (Ur a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • Semigroup a => Semigroup (Ur a)Defined in linear-base-0.4.0 · Data.Monoid.Linear.Internal.Semigroup

    Useful to treat unrestricted semigroups as linear ones.

  • Movable (Ur a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • Eq a => Eq (Ur a)Defined in linear-base-0.4.0 · Data.Ord.Linear.Internal.Eq
  • Ord a => Ord (Ur a)Defined in linear-base-0.4.0 · Data.Ord.Linear.Internal.Ord
  • KnownRepresentable a => KnownRepresentable (Ur a)Defined in linear-base-0.4.0 · Foreign.Marshal.Pure.Internal
  • type Rep (Ur a) = D1 ('MetaData "Ur" "Data.Unrestricted.Linear.Internal.Ur" "linear-base-0.4.0-D8wukxS5KYmLhv3s1GSepB" 'False) (C1 ('MetaCons "Ur" 'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Ur
  • type Rep1 Ur = D1 ('MetaData "Ur" "Data.Unrestricted.Linear.Internal.Ur" "linear-base-0.4.0-D8wukxS5KYmLhv3s1GSepB" 'False) (C1 ('MetaCons "Ur" 'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Ur
  • type Rep (Ur a) = FixupMetaData (Ur a) (D1 Any (C1 Any (S1 Any (MP1 'Many (Rec0 a)))))Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Ur
  • type Rep1 Ur = FixupMetaData1 Ur (D1 Any (C1 Any (S1 Any (MP1 'Many Par1))))Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Ur
valueunur :: Ur a %1 -> a
#

Get an a out of an Ur a. If you call this function on a linearly bound Ur a, then the a you get out has to be used linearly, for example:

restricted :: Ur a %1-> b
restricted x = f (unur x)
  where
    -- f __must__ be linear
    f :: a %1-> b
    f x = ...

Doing non-linear operations inside linear functions

7 declarations
classclass Consumable a where
#

Methods

Instances55Consumable, …
  • Consumable VoidDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable AllDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable AnyDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable Int16Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Consumable Int32Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Consumable Int64Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Consumable Int8Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Consumable Word16Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Consumable Word32Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Consumable Word64Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Consumable Word8Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Consumable BoolDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable CharDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable DoubleDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable FloatDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable IntDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable OrderingDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable WordDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable PoolDefined in linear-base-0.4.0 · Foreign.Marshal.Pure.Internal
  • Consumable ()Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable (Array a)Defined in linear-base-0.4.0 · Data.Array.Mutable.Linear.Internal
  • Consumable (Replicator a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable (ReplicationStream a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable (Set a)Defined in linear-base-0.4.0 · Data.Set.Mutable.Linear.Internal
  • Consumable (Ur a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable (Vector a)Defined in linear-base-0.4.0 · Data.Vector.Mutable.Linear.Internal
  • Consumable a => Consumable (First a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable a => Consumable (Last a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable a => Consumable (Max a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable a => Consumable (Min a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable a => Consumable (WrappedMonoid a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable a => Consumable (NonEmpty a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable a => Consumable (First a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable a => Consumable (Last a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable a => Consumable (Dual a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable a => Consumable (Product a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable a => Consumable (Sum a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable a => Consumable (Maybe a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable a => Consumable (MovableNum a)Defined in linear-base-0.4.0 · Data.Num.Linear
  • Consumable a => Consumable (Vector a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable a => Consumable (a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable a => Consumable [a]Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Movable a => Consumable (AsMovable a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances
  • (Generic a, GConsumable (Rep a)) => Consumable (Generically a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable (HashMap k v)Defined in linear-base-0.4.0 · Data.HashMap.Mutable.Linear.Internal
  • Consumable (V 0 a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • (KnownNat n, Consumable a) => Consumable (V n a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • (Consumable a, Consumable b) => Consumable (Arg a b)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • (Consumable a, Consumable b) => Consumable (a, b)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • (Consumable e, Consumable a) => Consumable (Either e a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable (f a) => Consumable (Ap f a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Consumable (f a) => Consumable (Alt f a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • (Consumable a, Consumable b, Consumable c) => Consumable (a, b, c)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • (Consumable a, Consumable b, Consumable c, Consumable d) => Consumable (a, b, c, d)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • (Consumable a, Consumable b, Consumable c, Consumable d, Consumable e) => Consumable (a, b, c, d, e)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
classclass Consumable a => Dupable a where
#

The laws of Dupable are dual to those of Monoid:

  • 1. first consume (dup2 a) ≃ a ≃ second consume (dup2 a) (dup2 neutrality)

  • 2. first dup2 (dup2 a) ≃ (second dup2 (dup2 a)) (dup2 associativity)

where the (≃) sign represents equality up to type isomorphism.

  • 3. dup2 = Replicator.elim (,) . dupR (coherence between dup2 and dupR)

  • 4. consume = Replicator.elim () . dupR (coherence between consume and dupR)

  • 5. Replicator.extract . dupR = id (dupR identity)

  • 6. dupR . dupR = (Replicator.map dupR) . dupR (dupR interchange)

(Laws 1-2 and 5-6 are equivalent)

Implementation of Dupable for Data.Unrestricted.Movable types should be done with deriving via Data.Unrestricted.AsMovable.

Implementation of Dupable for other types can be done with deriving via Generically. Note that at present this mechanism can have performance problems for recursive parameterized types. Specifically, the methods will not specialize to underlying Dupable instances. See this GHC issue.

Methods

  • dupR :: a %1 -> Replicator a

    Creates a Replicator for the given a.

    You usually want to define this method using Replicator's Applicative instance. For instance, here is an implementation of Dupable [a]:

    instance Dupable a => Dupable [a] where
      dupR [] = pure []
      dupR (a : as) = (:) <$> dupR a <*> dupR as
  • dup2 :: a %1 -> (a, a)

    Creates two as from a Dupable a, in a linear fashion.

Instances41Dupable, …
  • Dupable AllDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • Dupable AnyDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • Dupable Int16Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Dupable Int32Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Dupable Int64Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Dupable Int8Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Dupable Word16Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Dupable Word32Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Dupable Word64Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Dupable Word8Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Dupable BoolDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • Dupable CharDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • Dupable DoubleDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • Dupable FloatDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • Dupable IntDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • Dupable OrderingDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • Dupable WordDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • Dupable PoolDefined in linear-base-0.4.0 · Foreign.Marshal.Pure.Internal
  • Dupable ()Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • Dupable (Array a)Defined in linear-base-0.4.0 · Data.Array.Mutable.Linear.Internal
  • Dupable (Replicator a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • Dupable (ReplicationStream a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • Dupable (Set a)Defined in linear-base-0.4.0 · Data.Set.Mutable.Linear.Internal
  • Dupable (Ur a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • Dupable (Vector a)Defined in linear-base-0.4.0 · Data.Vector.Mutable.Linear.Internal
  • Dupable a => Dupable (NonEmpty a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • Dupable a => Dupable (Product a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • Dupable a => Dupable (Sum a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • Dupable a => Dupable (Maybe a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • Dupable a => Dupable (MovableNum a)Defined in linear-base-0.4.0 · Data.Num.Linear
  • Dupable a => Dupable (a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • Dupable a => Dupable [a]Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • Movable a => Dupable (AsMovable a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances
  • (Generic a, GDupable (Rep a)) => Dupable (Generically a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • Dupable (HashMap k v)Defined in linear-base-0.4.0 · Data.HashMap.Mutable.Linear.Internal
  • (KnownNat n, Dupable a) => Dupable (V n a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • (Dupable a, Dupable b) => Dupable (Either a b)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • (Dupable a, Dupable b) => Dupable (a, b)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • (Dupable a, Dupable b, Dupable c) => Dupable (a, b, c)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • (Dupable a, Dupable b, Dupable c, Dupable d) => Dupable (a, b, c, d)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
  • (Dupable a, Dupable b, Dupable c, Dupable d, Dupable e) => Dupable (a, b, c, d, e)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
classclass Dupable a => Movable a where
#

Use Movable a to represent a type which can be used many times even when given linearly. Simple data types such as Bool or [] are Movable. Though, bear in mind that this typically induces a deep copy of the value.

Formally, Movable a is the class of coalgebras of the Ur comonad. That is

  • unur (move x) = x
  • move @(Ur a) (move @a x) = fmap (move @a) $ move @a x

Additionally, a Movable instance must be compatible with its Dupable parent instance. That is:

  • case move x of {Ur _ -> ()} = consume x
  • case move x of {Ur x -> (x, x)} = dup2 x

Methods

Instances33Movable, …
  • Movable AllDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • Movable AnyDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • Movable Int16Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Movable Int32Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Movable Int64Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Movable Int8Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Movable Word16Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Movable Word32Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Movable Word64Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Movable Word8Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances · orphan
  • Movable BoolDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • Movable CharDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • Movable DoubleDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • Movable FloatDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • Movable IntDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • Movable OrderingDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • Movable WordDefined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • Movable ()Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • Movable (Ur a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • Movable a => Movable (NonEmpty a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • Movable a => Movable (Product a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • Movable a => Movable (Sum a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • Movable a => Movable (Maybe a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • Movable a => Movable (MovableNum a)Defined in linear-base-0.4.0 · Data.Num.Linear
  • Movable a => Movable (AsMovable a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Instances
  • Movable a => Movable (a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • Movable a => Movable [a]Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • (Generic a, GMovable (Rep a)) => Movable (Generically a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • (Movable a, Movable b) => Movable (Either a b)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • (Movable a, Movable b) => Movable (a, b)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • (Movable a, Movable b, Movable c) => Movable (a, b, c)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • (Movable a, Movable b, Movable c, Movable d) => Movable (a, b, c, d)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
  • (Movable a, Movable b, Movable c, Movable d, Movable e) => Movable (a, b, c, d, e)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Movable
valuelseq :: Consumable a => a %1 -> b %1 -> b
#

Consume the first argument and return the second argument. This is like seq but the first argument is restricted to be Consumable.

valuedup3 :: Dupable a => a %1 -> (a, a, a)
#

Creates 3 as from a Dupable a, in a linear fashion.

valueforget :: (a %1 -> b) %1 -> a -> b
#

Convenience operator when a higher-order function expects a non-linear arrow but we have a linear arrow.