-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | The GHC API -- -- GHC's functionality can be useful for more things than just compiling -- Haskell programs. Important use cases are programs that analyse (and -- perhaps transform) Haskell code. Others include loading Haskell code -- dynamically in a GHCi-like manner. For this reason, a lot of GHC's -- functionality is made available through this package. -- -- See -- https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler -- for more information. @package ghc @version 9.2.3 module GHC.Platform.Constants data PlatformConstants PlatformConstants :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> !Integer -> !Integer -> !Integer -> PlatformConstants [pc_CONTROL_GROUP_CONST_291] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_STD_HDR_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_PROF_HDR_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_BLOCK_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_BLOCKS_PER_MBLOCK] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_TICKY_BIN_COUNT] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR2] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR3] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR4] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR5] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR6] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR7] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR8] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR9] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR10] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rF1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rF2] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rF3] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rF4] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rF5] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rF6] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rD1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rD2] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rD3] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rD4] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rD5] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rD6] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rXMM1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rXMM2] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rXMM3] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rXMM4] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rXMM5] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rXMM6] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rYMM1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rYMM2] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rYMM3] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rYMM4] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rYMM5] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rYMM6] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rZMM1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rZMM2] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rZMM3] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rZMM4] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rZMM5] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rZMM6] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rL1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rSp] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rSpLim] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rHp] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rHpLim] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rCCCS] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rCurrentTSO] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rCurrentNursery] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rHpAlloc] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_stgEagerBlackholeInfo] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_stgGCEnter1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_stgGCFun] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_Capability_r] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_bdescr_start] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_bdescr_free] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_bdescr_blocks] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_bdescr_flags] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_SIZEOF_CostCentreStack] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_CostCentreStack_mem_alloc] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_REP_CostCentreStack_mem_alloc] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_CostCentreStack_scc_count] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_REP_CostCentreStack_scc_count] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgHeader_ccs] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgHeader_ldvw] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_SIZEOF_StgSMPThunkHeader] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgEntCounter_allocs] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_REP_StgEntCounter_allocs] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgEntCounter_allocd] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_REP_StgEntCounter_allocd] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgEntCounter_registeredp] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgEntCounter_link] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgEntCounter_entry_count] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_SIZEOF_StgUpdateFrame_NoHdr] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_SIZEOF_StgMutArrPtrs_NoHdr] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgMutArrPtrs_ptrs] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgMutArrPtrs_size] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_SIZEOF_StgSmallMutArrPtrs_NoHdr] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgSmallMutArrPtrs_ptrs] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_SIZEOF_StgArrBytes_NoHdr] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgArrBytes_bytes] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgTSO_alloc_limit] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgTSO_cccs] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgTSO_stackobj] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgStack_sp] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgStack_stack] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgUpdateFrame_updatee] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgFunInfoExtraFwd_arity] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_REP_StgFunInfoExtraFwd_arity] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_SIZEOF_StgFunInfoExtraRev] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgFunInfoExtraRev_arity] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_REP_StgFunInfoExtraRev_arity] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_SPEC_SELECTEE_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_SPEC_AP_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MIN_PAYLOAD_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MIN_INTLIKE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_INTLIKE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MIN_CHARLIKE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_CHARLIKE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MUT_ARR_PTRS_CARD_BITS] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Vanilla_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Float_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Double_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Long_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_XMM_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Real_Vanilla_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Real_Float_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Real_Double_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Real_XMM_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Real_Long_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_RESERVED_C_STACK_BYTES] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_RESERVED_STACK_WORDS] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_AP_STACK_SPLIM] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_WORD_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_CINT_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_CLONG_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_CLONG_LONG_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_BITMAP_BITS_SHIFT] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_TAG_BITS] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_LDV_SHIFT] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_ILDV_CREATE_MASK] :: PlatformConstants -> !Integer [pc_ILDV_STATE_CREATE] :: PlatformConstants -> !Integer [pc_ILDV_STATE_USE] :: PlatformConstants -> !Integer parseConstantsHeader :: FilePath -> IO PlatformConstants instance GHC.Classes.Eq GHC.Platform.Constants.PlatformConstants instance GHC.Read.Read GHC.Platform.Constants.PlatformConstants instance GHC.Show.Show GHC.Platform.Constants.PlatformConstants -- | Custom GHC Prelude -- -- This module serves as a replacement for the Prelude module and -- abstracts over differences between the bootstrapping GHC version, and -- may also provide a common default vocabulary. module GHC.Prelude -- | Append two lists, i.e., -- --
-- [x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn] -- [x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...] ---- -- If the first list is not finite, the result is the first list. (++) :: [a] -> [a] -> [a] infixr 5 ++ seq :: forall {r :: RuntimeRep} a (b :: TYPE r). a -> b -> b -- | <math>. filter, applied to a predicate and a list, -- returns the list of those elements that satisfy the predicate; i.e., -- --
-- filter p xs = [ x | x <- xs, p x] ---- --
-- >>> filter odd [1, 2, 3] -- [1,3] --filter :: (a -> Bool) -> [a] -> [a] -- | <math>. zip takes two lists and returns a list of -- corresponding pairs. -- --
-- >>> zip [1, 2] ['a', 'b'] -- [(1,'a'),(2,'b')] ---- -- If one input list is shorter than the other, excess elements of the -- longer list are discarded, even if one of the lists is infinite: -- --
-- >>> zip [1] ['a', 'b'] -- [(1,'a')] -- -- >>> zip [1, 2] ['a'] -- [(1,'a')] -- -- >>> zip [] [1..] -- [] -- -- >>> zip [1..] [] -- [] ---- -- zip is right-lazy: -- --
-- >>> zip [] undefined -- [] -- -- >>> zip undefined [] -- *** Exception: Prelude.undefined -- ... ---- -- zip is capable of list fusion, but it is restricted to its -- first list argument and its resulting list. zip :: [a] -> [b] -> [(a, b)] -- | 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]]) --print :: Show a => a -> IO () -- | Extract the first component of a pair. fst :: (a, b) -> a -- | Extract the second component of a pair. snd :: (a, b) -> b -- | otherwise is defined as the value True. It helps to make -- guards more readable. eg. -- --
-- f x | x < 0 = ... -- | otherwise = ... --otherwise :: Bool -- | <math>. map f xs is the list obtained by -- applying f to each element of xs, i.e., -- --
-- map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn] -- map f [x1, x2, ...] == [f x1, f x2, ...] ---- --
-- >>> map (+1) [1, 2, 3] -- [2,3,4] --map :: (a -> b) -> [a] -> [b] -- | Application operator. This operator is redundant, since ordinary -- application (f x) means the same as (f $ x). -- However, $ has low, right-associative binding precedence, so it -- sometimes allows parentheses to be omitted; for example: -- --
-- f $ g $ h x = f (g (h x)) ---- -- It is also useful in higher-order situations, such as map -- ($ 0) xs, or zipWith ($) fs xs. -- -- Note that ($) is levity-polymorphic in its result -- type, so that foo $ True where foo :: Bool -> -- Int# is well-typed. ($) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b infixr 0 $ -- | general coercion from integral types fromIntegral :: (Integral a, Num b) => a -> b -- | general coercion to fractional types realToFrac :: (Real a, Fractional b) => a -> b -- | 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. class Bounded a minBound :: Bounded a => a maxBound :: Bounded a => a -- | 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 --class Enum a -- | the successor of a value. For numeric types, succ adds 1. succ :: Enum a => a -> a -- | the predecessor of a value. For numeric types, pred subtracts -- 1. pred :: Enum a => a -> a -- | Convert from an Int. toEnum :: Enum a => Int -> a -- | 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. fromEnum :: Enum a => a -> Int -- | Used in Haskell's translation of [n..] with [n..] = -- enumFrom n, a possible implementation being enumFrom n = n : -- enumFrom (succ n). For example: -- --
enumFrom 4 :: [Integer] = [4,5,6,7,...]
enumFrom 6 :: [Int] = [6,7,8,9,...,maxBound :: -- Int]
enumFromThen 4 6 :: [Integer] = [4,6,8,10...]
enumFromThen 6 2 :: [Int] = [6,2,-2,-6,...,minBound :: -- Int]
enumFromTo 6 10 :: [Int] = [6,7,8,9,10]
enumFromTo 42 1 :: [Integer] = []
enumFromThenTo 4 2 -6 :: [Integer] = -- [4,2,0,-2,-4,-6]
enumFromThenTo 6 8 2 :: [Int] = []
-- (x `quot` y)*y + (x `rem` y) == x --rem :: Integral a => a -> a -> a -- | integer division truncated toward negative infinity div :: Integral a => a -> a -> a -- | integer modulus, satisfying -- --
-- (x `div` y)*y + (x `mod` y) == x --mod :: Integral a => a -> a -> a -- | simultaneous quot and rem quotRem :: Integral a => a -> a -> (a, a) -- | simultaneous div and mod divMod :: Integral a => a -> a -> (a, a) -- | conversion to Integer toInteger :: Integral a => a -> Integer infixl 7 `rem` infixl 7 `quot` infixl 7 `mod` infixl 7 `div` -- | The Monad class defines the basic operations over a -- monad, a concept from a branch of mathematics known as -- category theory. From the perspective of a Haskell programmer, -- however, it is best to think of a monad as an abstract datatype -- of actions. Haskell's do expressions provide a convenient -- syntax for writing monadic expressions. -- -- Instances of Monad should satisfy the following: -- --
-- do a <- as -- bs a --(>>=) :: Monad m => m a -> (a -> m b) -> m b -- | Sequentially compose two actions, discarding any value produced by the -- first, like sequencing operators (such as the semicolon) in imperative -- languages. -- -- 'as >> bs' can be understood as the do -- expression -- --
-- do as -- bs --(>>) :: Monad m => m a -> m b -> m b -- | Inject a value into the monadic type. return :: Monad m => a -> m a infixl 1 >> infixl 1 >>= -- | A type f is a Functor if it provides a function fmap -- which, given any types a and b lets you apply any -- function from (a -> b) to turn an f a into an -- f b, preserving the structure of f. Furthermore -- f needs to adhere to the following: -- -- -- -- Note, that the second law follows from the free theorem of the type -- fmap and the first law, so you need only check that the former -- condition holds. class Functor (f :: Type -> Type) -- | fmap is used to apply a function of type (a -> b) -- to a value of type f a, where f is a functor, to produce a -- value of type f b. Note that for any type constructor with -- more than one parameter (e.g., Either), only the last type -- parameter can be modified with fmap (e.g., b in -- `Either a b`). -- -- Some type constructors with two parameters or more have a -- Bifunctor instance that allows both the last and the -- penultimate parameters to be mapped over. -- --
-- >>> fmap show Nothing -- Nothing -- -- >>> fmap show (Just 3) -- Just "3" ---- -- Convert from an Either Int Int to an Either Int -- String using show: -- --
-- >>> fmap show (Left 17) -- Left 17 -- -- >>> fmap show (Right 17) -- Right "17" ---- -- Double each element of a list: -- --
-- >>> fmap (*2) [1,2,3] -- [2,4,6] ---- -- Apply even to the second element of a pair: -- --
-- >>> fmap even (2,2) -- (2,True) ---- -- It may seem surprising that the function is only applied to the last -- element of the tuple compared to the list example above which applies -- it to every element in the list. To understand, remember that tuples -- are type constructors with multiple type parameters: a tuple of 3 -- elements (a,b,c) can also be written (,,) a b c and -- its Functor instance is defined for Functor ((,,) a -- b) (i.e., only the third parameter is free to be mapped over with -- fmap). -- -- It explains why fmap can be used with tuples containing -- values of different types as in the following example: -- --
-- >>> fmap even ("hello", 1.0, 4)
-- ("hello",1.0,True)
--
fmap :: Functor f => (a -> b) -> f a -> f b
-- | Replace all locations in the input with the same value. The default
-- definition is fmap . const, but this may be
-- overridden with a more efficient version.
(<$) :: Functor f => a -> f b -> f a
infixl 4 <$
-- | Basic numeric class.
--
-- The Haskell Report defines no laws for Num. However,
-- (+) and (*) are customarily expected
-- to define a ring and have the following properties:
--
-- -- abs x * signum x == x ---- -- For real numbers, the signum is either -1 (negative), -- 0 (zero) or 1 (positive). signum :: Num a => a -> a -- | Conversion from an Integer. An integer literal represents the -- application of the function fromInteger to the appropriate -- value of type Integer, so such literals have type -- (Num a) => a. fromInteger :: Num a => Integer -> a infixl 7 * infixl 6 + infixl 6 - class Eq a => Ord a compare :: Ord a => a -> a -> Ordering (<) :: Ord a => a -> a -> Bool (<=) :: Ord a => a -> a -> Bool (>) :: Ord a => a -> a -> Bool (>=) :: Ord a => a -> a -> Bool max :: Ord a => a -> a -> a min :: Ord a => a -> a -> a -- | Parsing of Strings, producing values. -- -- Derived instances of Read make the following assumptions, which -- derived instances of Show obey: -- --
-- 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 --class Read 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 Show satisfy the -- following: -- -- -- -- That is, readsPrec parses the string produced by -- showsPrec, and delivers the value that showsPrec started -- with. readsPrec :: Read a => Int -> 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 should be are expected to use -- double quotes, rather than square brackets. readList :: Read a => ReadS [a] class (Num a, Ord a) => Real a -- | the rational equivalent of its real argument with full precision toRational :: Real a => a -> Rational -- | Efficient, machine-independent access to the components of a -- floating-point number. class (RealFrac a, Floating a) => RealFloat a -- | a constant function, returning the radix of the representation (often -- 2) floatRadix :: RealFloat a => a -> Integer -- | a constant function, returning the number of digits of -- floatRadix in the significand floatDigits :: RealFloat a => a -> Int -- | a constant function, returning the lowest and highest values the -- exponent may assume floatRange :: RealFloat a => a -> (Int, 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. decodeFloat :: RealFloat a => a -> (Integer, Int) -- | encodeFloat performs the inverse of decodeFloat in the -- sense that for finite x with the exception of -0.0, -- 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. encodeFloat :: RealFloat a => Integer -> Int -> a -- | 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. exponent :: RealFloat a => a -> Int -- | 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. significand :: RealFloat a => a -> a -- | multiplies a floating-point number by an integer power of the radix scaleFloat :: RealFloat a => Int -> a -> a -- | True if the argument is an IEEE "not-a-number" (NaN) value isNaN :: RealFloat a => a -> Bool -- | True if the argument is an IEEE infinity or negative infinity isInfinite :: RealFloat a => a -> Bool -- | True if the argument is too small to be represented in -- normalized format isDenormalized :: RealFloat a => a -> Bool -- | True if the argument is an IEEE negative zero isNegativeZero :: RealFloat a => a -> Bool -- | True if the argument is an IEEE floating point number isIEEE :: RealFloat a => a -> Bool -- | 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. atan2 :: RealFloat a => a -> a -> a -- | Extracting components of fractions. class (Real a, Fractional a) => RealFrac a -- | The function properFraction takes a real fractional number -- x and returns a pair (n,f) such that x = -- n+f, and: -- --
-- 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, -- --
-- showsPrec d x r ++ s == showsPrec d x (r ++ s) ---- -- Derived instances of Read and Show satisfy the -- following: -- -- -- -- That is, readsPrec parses the string produced by -- showsPrec, and delivers the value that showsPrec started -- with. showsPrec :: Show a => Int -> a -> ShowS -- | A specialised variant of showsPrec, using precedence context -- zero, and returning an ordinary String. show :: Show a => a -> String -- | 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. showList :: Show a => [a] -> ShowS -- | When a value is bound in do-notation, the pattern on the left -- hand side of <- might not match. In this case, this class -- provides a function to recover. -- -- A Monad without a MonadFail instance may only be used in -- conjunction with pattern that always match, such as newtypes, tuples, -- data types with only a single data constructor, and irrefutable -- patterns (~pat). -- -- Instances of MonadFail should satisfy the following law: -- fail s should be a left zero for >>=, -- --
-- fail s >>= f = fail s ---- -- If your Monad is also MonadPlus, a popular definition is -- --
-- fail _ = mzero --class Monad m => MonadFail (m :: Type -> Type) fail :: MonadFail m => String -> m a -- | A functor with application, providing operations to -- --
-- (<*>) = liftA2 id ---- --
-- liftA2 f x y = f <$> x <*> y ---- -- Further, any definition must satisfy the following: -- --
pure id <*> v = -- v
pure (.) <*> u -- <*> v <*> w = u <*> (v -- <*> w)
pure f <*> -- pure x = pure (f x)
u <*> pure y = -- pure ($ y) <*> u
-- forall x y. p (q x y) = f x . g y ---- -- it follows from the above that -- --
-- liftA2 p (liftA2 q u v) = liftA2 f u . liftA2 g v ---- -- If f is also a Monad, it should satisfy -- -- -- -- (which implies that pure and <*> satisfy the -- applicative functor laws). class Functor f => Applicative (f :: Type -> Type) -- | Lift a value. pure :: Applicative f => a -> f a -- | Sequential application. -- -- A few functors support an implementation of <*> that is -- more efficient than the default one. -- --
-- >>> data MyState = MyState {arg1 :: Foo, arg2 :: Bar, arg3 :: Baz}
--
--
-- -- >>> produceFoo :: Applicative f => f Foo ---- --
-- >>> produceBar :: Applicative f => f Bar -- -- >>> produceBaz :: Applicative f => f Baz ---- --
-- >>> mkState :: Applicative f => f MyState -- -- >>> mkState = MyState <$> produceFoo <*> produceBar <*> produceBaz --(<*>) :: Applicative f => f (a -> b) -> f a -> f b -- | Sequence actions, discarding the value of the first argument. -- --
-- >>> Just 2 *> Just 3 -- Just 3 ---- --
-- >>> Nothing *> Just 3 -- Nothing ---- -- Of course a more interesting use case would be to have effectful -- computations instead of just returning pure values. -- --
-- >>> import Data.Char
--
-- >>> import Text.ParserCombinators.ReadP
--
-- >>> let p = string "my name is " *> munch1 isAlpha <* eof
--
-- >>> readP_to_S p "my name is Simon"
-- [("Simon","")]
--
(*>) :: Applicative f => f a -> f b -> f b
-- | Sequence actions, discarding the value of the second argument.
(<*) :: Applicative f => f a -> f b -> f a
infixl 4 <*
infixl 4 *>
infixl 4 <*>
-- | The Foldable class represents data structures that can be reduced to a
-- summary value one element at a time. Strict left-associative folds are
-- a good fit for space-efficient reduction, while lazy right-associative
-- folds are a good fit for corecursive iteration, or for folds that
-- short-circuit after processing an initial subsequence of the
-- structure's elements.
--
-- Instances can be derived automatically by enabling the
-- DeriveFoldable extension. For example, a derived instance for
-- a binary tree might be:
--
--
-- {-# LANGUAGE DeriveFoldable #-}
-- data Tree a = Empty
-- | Leaf a
-- | Node (Tree a) a (Tree a)
-- deriving Foldable
--
--
-- A more detailed description can be found in the Overview
-- section of Data.Foldable#overview.
--
-- For the class laws see the Laws section of
-- Data.Foldable#laws.
class Foldable (t :: TYPE LiftedRep -> Type)
-- | Map each element of the structure into a monoid, and combine the
-- results with (<>). This fold is
-- right-associative and lazy in the accumulator. For strict
-- left-associative folds consider foldMap' instead.
--
--
-- >>> foldMap Sum [1, 3, 5]
-- Sum {getSum = 9}
--
--
--
-- >>> foldMap Product [1, 3, 5]
-- Product {getProduct = 15}
--
--
-- -- >>> foldMap (replicate 3) [1, 2, 3] -- [1,1,1,2,2,2,3,3,3] ---- -- When a Monoid's (<>) is lazy in its second -- argument, foldMap can return a result even from an unbounded -- structure. For example, lazy accumulation enables -- Data.ByteString.Builder to efficiently serialise large data -- structures and produce the output incrementally: -- --
-- >>> import qualified Data.ByteString.Lazy as L -- -- >>> import qualified Data.ByteString.Builder as B -- -- >>> let bld :: Int -> B.Builder; bld i = B.intDec i <> B.word8 0x20 -- -- >>> let lbs = B.toLazyByteString $ foldMap bld [0..] -- -- >>> L.take 64 lbs -- "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24" --foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m -- | Right-associative fold of a structure, lazy in the accumulator. -- -- In the case of lists, foldr, when applied to a binary operator, -- a starting value (typically the right-identity of the operator), and a -- list, reduces the list using the binary operator, from right to left: -- --
-- foldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...) ---- -- Note that since the head of the resulting expression is produced by an -- application of the operator to the first element of the list, given an -- operator lazy in its right argument, foldr can produce a -- terminating expression from an unbounded list. -- -- For a general Foldable structure this should be semantically -- identical to, -- --
-- foldr f z = foldr f z . toList ---- --
-- >>> foldr (||) False [False, True, False] -- True ---- --
-- >>> foldr (||) False [] -- False ---- --
-- >>> foldr (\c acc -> acc ++ [c]) "foo" ['a', 'b', 'c', 'd'] -- "foodcba" ---- --
-- >>> foldr (||) False (True : repeat False) -- True ---- -- But the following doesn't terminate: -- --
-- >>> foldr (||) False (repeat False ++ [True]) -- * Hangs forever * ---- --
-- >>> take 5 $ foldr (\i acc -> i : fmap (+3) acc) [] (repeat 1) -- [1,4,7,10,13] --foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b -- | Left-associative fold of a structure, lazy in the accumulator. This is -- rarely what you want, but can work well for structures with efficient -- right-to-left sequencing and an operator that is lazy in its left -- argument. -- -- In the case of lists, foldl, when applied to a binary operator, -- a starting value (typically the left-identity of the operator), and a -- list, reduces the list using the binary operator, from left to right: -- --
-- foldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn ---- -- Note that to produce the outermost application of the operator the -- entire input list must be traversed. Like all left-associative folds, -- foldl will diverge if given an infinite list. -- -- If you want an efficient strict left-fold, you probably want to use -- foldl' instead of foldl. The reason for this is that the -- latter does not force the inner results (e.g. z `f` x1 -- in the above example) before applying them to the operator (e.g. to -- (`f` x2)). This results in a thunk chain <math> -- elements long, which then must be evaluated from the outside-in. -- -- For a general Foldable structure this should be semantically -- identical to: -- --
-- foldl f z = foldl f z . toList ---- --
-- >>> foldl (+) 42 [1,2,3,4] -- 52 ---- -- Though the result below is lazy, the input is reversed before -- prepending it to the initial accumulator, so corecursion begins only -- after traversing the entire input string. -- --
-- >>> foldl (\acc c -> c : acc) "abcd" "efgh" -- "hgfeabcd" ---- -- A left fold of a structure that is infinite on the right cannot -- terminate, even when for any finite input the fold just returns the -- initial accumulator: -- --
-- >>> foldl (\a _ -> a) 0 $ repeat 1 -- * Hangs forever * ---- -- WARNING: When it comes to lists, you always want to use either -- foldl' or foldr instead. foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b -- | Left-associative fold of a structure but with strict application of -- the operator. -- -- This ensures that each step of the fold is forced to Weak Head Normal -- Form before being applied, avoiding the collection of thunks that -- would otherwise occur. This is often what you want to strictly reduce -- a finite structure to a single strict result (e.g. sum). -- -- For a general Foldable structure this should be semantically -- identical to, -- --
-- foldl' f z = foldl' f z . toList --foldl' :: Foldable t => (b -> a -> b) -> b -> t a -> b -- | A variant of foldr that has no base case, and thus may only be -- applied to non-empty structures. -- -- This function is non-total and will raise a runtime exception if the -- structure happens to be empty. -- --
-- >>> foldr1 (+) [1..4] -- 10 ---- --
-- >>> foldr1 (+) [] -- Exception: Prelude.foldr1: empty list ---- --
-- >>> foldr1 (+) Nothing -- *** Exception: foldr1: empty structure ---- --
-- >>> foldr1 (-) [1..4] -- -2 ---- --
-- >>> foldr1 (&&) [True, False, True, True] -- False ---- --
-- >>> foldr1 (||) [False, False, True, True] -- True ---- --
-- >>> foldr1 (+) [1..] -- * Hangs forever * --foldr1 :: Foldable t => (a -> a -> a) -> t a -> a -- | A variant of foldl that has no base case, and thus may only be -- applied to non-empty structures. -- -- This function is non-total and will raise a runtime exception if the -- structure happens to be empty. -- --
-- foldl1 f = foldl1 f . toList ---- --
-- >>> foldl1 (+) [1..4] -- 10 ---- --
-- >>> foldl1 (+) [] -- *** Exception: Prelude.foldl1: empty list ---- --
-- >>> foldl1 (+) Nothing -- *** Exception: foldl1: empty structure ---- --
-- >>> foldl1 (-) [1..4] -- -8 ---- --
-- >>> foldl1 (&&) [True, False, True, True] -- False ---- --
-- >>> foldl1 (||) [False, False, True, True] -- True ---- --
-- >>> foldl1 (+) [1..] -- * Hangs forever * --foldl1 :: Foldable t => (a -> a -> a) -> t a -> a -- | Test whether the structure is empty. The default implementation is -- Left-associative and lazy in both the initial element and the -- accumulator. Thus optimised for structures where the first element can -- be accessed in constant time. Structures where this is not the case -- should have a non-default implementation. -- --
-- >>> null [] -- True ---- --
-- >>> null [1] -- False ---- -- null is expected to terminate even for infinite structures. The -- default implementation terminates provided the structure is bounded on -- the left (there is a leftmost element). -- --
-- >>> null [1..] -- False --null :: Foldable t => t a -> Bool -- | Returns the size/length of a finite structure as an Int. The -- default implementation just counts elements starting with the -- leftmost. Instances for structures that can compute the element count -- faster than via element-by-element counting, should provide a -- specialised implementation. -- --
-- >>> length [] -- 0 ---- --
-- >>> length ['a', 'b', 'c'] -- 3 -- -- >>> length [1..] -- * Hangs forever * --length :: Foldable t => t a -> Int -- | Does the element occur in the structure? -- -- Note: elem is often used in infix form. -- --
-- >>> 3 `elem` [] -- False ---- --
-- >>> 3 `elem` [1,2] -- False ---- --
-- >>> 3 `elem` [1,2,3,4,5] -- True ---- -- For infinite structures, the default implementation of elem -- terminates if the sought-after value exists at a finite distance from -- the left side of the structure: -- --
-- >>> 3 `elem` [1..] -- True ---- --
-- >>> 3 `elem` ([4..] ++ [3]) -- * Hangs forever * --elem :: (Foldable t, Eq a) => a -> t a -> Bool -- | The largest element of a non-empty structure. -- -- This function is non-total and will raise a runtime exception if the -- structure happens to be empty. A structure that supports random access -- and maintains its elements in order should provide a specialised -- implementation to return the maximum in faster than linear time. -- --
-- >>> maximum [1..10] -- 10 ---- --
-- >>> maximum [] -- *** Exception: Prelude.maximum: empty list ---- --
-- >>> maximum Nothing -- *** Exception: maximum: empty structure ---- -- WARNING: This function is partial for possibly-empty structures like -- lists. maximum :: (Foldable t, Ord a) => t a -> a -- | The least element of a non-empty structure. -- -- This function is non-total and will raise a runtime exception if the -- structure happens to be empty. A structure that supports random access -- and maintains its elements in order should provide a specialised -- implementation to return the minimum in faster than linear time. -- --
-- >>> minimum [1..10] -- 1 ---- --
-- >>> minimum [] -- *** Exception: Prelude.minimum: empty list ---- --
-- >>> minimum Nothing -- *** Exception: minimum: empty structure ---- -- WARNING: This function is partial for possibly-empty structures like -- lists. minimum :: (Foldable t, Ord a) => t a -> a -- | The sum function computes the sum of the numbers of a -- structure. -- --
-- >>> sum [] -- 0 ---- --
-- >>> sum [42] -- 42 ---- --
-- >>> sum [1..10] -- 55 ---- --
-- >>> sum [4.1, 2.0, 1.7] -- 7.8 ---- --
-- >>> sum [1..] -- * Hangs forever * --sum :: (Foldable t, Num a) => t a -> a -- | The product function computes the product of the numbers of a -- structure. -- --
-- >>> product [] -- 1 ---- --
-- >>> product [42] -- 42 ---- --
-- >>> product [1..10] -- 3628800 ---- --
-- >>> product [4.1, 2.0, 1.7] -- 13.939999999999998 ---- --
-- >>> product [1..] -- * Hangs forever * --product :: (Foldable t, Num a) => t a -> a infix 4 `elem` -- | Functors representing data structures that can be transformed to -- structures of the same shape by performing an -- Applicative (or, therefore, Monad) action on each -- element from left to right. -- -- A more detailed description of what same shape means, the -- various methods, how traversals are constructed, and example advanced -- use-cases can be found in the Overview section of -- Data.Traversable#overview. -- -- For the class laws see the Laws section of -- Data.Traversable#laws. class (Functor t, Foldable t) => Traversable (t :: Type -> Type) -- | Map each element of a structure to an action, evaluate these actions -- from left to right, and collect the results. For a version that -- ignores the results see traverse_. -- --
-- >>> traverse Just [1,2,3,4] -- Just [1,2,3,4] ---- --
-- >>> traverse id [Right 1, Right 2, Right 3, Right 4] -- Right [1,2,3,4] ---- -- In the next examples, we show that Nothing and Left -- values short circuit the created structure. -- --
-- >>> traverse (const Nothing) [1,2,3,4] -- Nothing ---- --
-- >>> traverse (\x -> if odd x then Just x else Nothing) [1,2,3,4] -- Nothing ---- --
-- >>> traverse id [Right 1, Right 2, Right 3, Right 4, Left 0] -- Left 0 --traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) -- | Evaluate each action in the structure from left to right, and collect -- the results. For a version that ignores the results see -- sequenceA_. -- --
-- >>> sequenceA [Just 1, Just 2, Just 3] -- Just [1,2,3] ---- --
-- >>> sequenceA [Right 1, Right 2, Right 3] -- Right [1,2,3] ---- -- The next two example show Nothing and Just will short -- circuit the resulting structure if present in the input. For more -- context, check the Traversable instances for Either and -- Maybe. -- --
-- >>> sequenceA [Just 1, Just 2, Just 3, Nothing] -- Nothing ---- --
-- >>> sequenceA [Right 1, Right 2, Right 3, Left 4] -- Left 4 --sequenceA :: (Traversable t, Applicative f) => t (f a) -> f (t a) -- | Map each element of a structure to a monadic action, evaluate these -- actions from left to right, and collect the results. For a version -- that ignores the results see mapM_. -- --
-- >>> sequence $ Right [1,2,3,4] -- [Right 1,Right 2,Right 3,Right 4] ---- --
-- >>> sequence $ [Right 1,Right 2,Right 3,Right 4] -- Right [1,2,3,4] ---- -- The following examples demonstrate short circuit behavior for -- sequence. -- --
-- >>> sequence $ Left [1,2,3,4] -- Left [1,2,3,4] ---- --
-- >>> sequence $ [Left 0, Right 1,Right 2,Right 3,Right 4] -- Left 0 --sequence :: (Traversable t, Monad m) => t (m a) -> m (t a) -- | The class of semigroups (types with an associative binary operation). -- -- Instances should satisfy the following: -- -- class Semigroup a -- | The class of monoids (types with an associative binary operation that -- has an identity). Instances should satisfy the following: -- --
-- >>> "Hello world" <> mempty -- "Hello world" --mempty :: Monoid a => a -- | An associative operation -- -- NOTE: This method is redundant and has the default -- implementation mappend = (<>) since -- base-4.11.0.0. Should it be implemented manually, since -- mappend is a synonym for (<>), it is expected that -- the two functions are defined the same way. In a future GHC release -- mappend will be removed from Monoid. mappend :: Monoid a => a -> a -> a -- | Fold a list using the monoid. -- -- For most types, the default definition for mconcat will be -- used, but the function is included in the class definition so that an -- optimized version can be provided for specific types. -- --
-- >>> mconcat ["Hello", " ", "Haskell", "!"] -- "Hello Haskell!" --mconcat :: Monoid a => [a] -> a data Bool False :: Bool True :: Bool -- | A String is a list of characters. String constants in Haskell -- are values of type String. -- -- See Data.List for operations on lists. type String = [Char] data Char data Double data Float data Int data Integer -- | The Maybe type encapsulates an optional value. A value of type -- Maybe a either contains a value of type a -- (represented as Just a), or it is empty (represented -- as Nothing). Using Maybe is a good way to deal with -- errors or exceptional cases without resorting to drastic measures such -- as error. -- -- The Maybe type is also a monad. It is a simple kind of error -- monad, where all errors are represented by Nothing. A richer -- error monad can be built using the Either type. data Maybe a Nothing :: Maybe a Just :: a -> Maybe a data Ordering LT :: Ordering EQ :: Ordering GT :: Ordering -- | Arbitrary-precision rational numbers, represented as a ratio of two -- Integer values. A rational number may be constructed using the -- % operator. type Rational = Ratio Integer data IO a data Word -- | The Either type represents values with two possibilities: a -- value of type Either a b is either Left -- a or Right b. -- -- The Either type is sometimes used to represent a value which is -- either correct or an error; by convention, the Left constructor -- is used to hold an error value and the Right constructor is -- used to hold a correct value (mnemonic: "right" also means "correct"). -- --
-- >>> let s = Left "foo" :: Either String Int -- -- >>> s -- Left "foo" -- -- >>> let n = Right 3 :: Either String Int -- -- >>> n -- Right 3 -- -- >>> :type s -- s :: Either String Int -- -- >>> :type n -- n :: Either String Int ---- -- The fmap from our Functor instance will ignore -- Left values, but will apply the supplied function to values -- contained in a Right: -- --
-- >>> let s = Left "foo" :: Either String Int -- -- >>> let n = Right 3 :: Either String Int -- -- >>> fmap (*2) s -- Left "foo" -- -- >>> fmap (*2) n -- Right 6 ---- -- The Monad instance for Either allows us to chain -- together multiple actions which may fail, and fail overall if any of -- the individual steps failed. First we'll write a function that can -- either parse an Int from a Char, or fail. -- --
-- >>> import Data.Char ( digitToInt, isDigit )
--
-- >>> :{
-- let parseEither :: Char -> Either String Int
-- parseEither c
-- | isDigit c = Right (digitToInt c)
-- | otherwise = Left "parse error"
--
-- >>> :}
--
--
-- The following should work, since both '1' and '2'
-- can be parsed as Ints.
--
--
-- >>> :{
-- let parseMultiple :: Either String Int
-- parseMultiple = do
-- x <- parseEither '1'
-- y <- parseEither '2'
-- return (x + y)
--
-- >>> :}
--
--
-- -- >>> parseMultiple -- Right 3 ---- -- But the following should fail overall, since the first operation where -- we attempt to parse 'm' as an Int will fail: -- --
-- >>> :{
-- let parseMultiple :: Either String Int
-- parseMultiple = do
-- x <- parseEither 'm'
-- y <- parseEither '2'
-- return (x + y)
--
-- >>> :}
--
--
-- -- >>> parseMultiple -- Left "parse error" --data Either a b Left :: a -> Either a b Right :: b -> Either a b -- | The computation writeFile file str function writes the -- string str, to the file file. writeFile :: FilePath -> String -> IO () -- | The readLn function combines getLine and readIO. readLn :: Read a => IO a -- | The readIO function is similar to read except that it -- signals parse failure to the IO monad instead of terminating -- the program. readIO :: Read a => String -> IO a -- | The readFile function reads a file and returns the contents of -- the file as a string. The file is read lazily, on demand, as with -- getContents. readFile :: FilePath -> IO String -- | The same as putStr, but adds a newline character. putStrLn :: String -> IO () -- | Write a string to the standard output device (same as hPutStr -- stdout). putStr :: String -> IO () -- | Write a character to the standard output device (same as -- hPutChar stdout). putChar :: Char -> 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. interact :: (String -> String) -> IO () -- | Read a line from the standard input device (same as hGetLine -- stdin). getLine :: IO String -- | The getContents operation returns all user input as a single -- string, which is read lazily as it is needed (same as -- hGetContents stdin). getContents :: IO String -- | Read a character from the standard input device (same as -- hGetChar stdin). getChar :: IO Char -- | 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]]) --appendFile :: FilePath -> String -> IO () -- | Raise an IOException in the IO monad. ioError :: IOError -> IO a -- | 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. type FilePath = String -- | The Haskell 2010 type for exceptions in the IO monad. Any I/O -- operation may raise an IOException instead of returning a -- result. For a more general type of exception, including also those -- that arise in pure code, see Exception. -- -- In Haskell 2010, this is an opaque type. type IOError = IOException -- | Construct an IOException value with a string describing the -- error. The fail method of the IO instance of the -- Monad class raises a userError, thus: -- --
-- instance Monad IO where -- ... -- fail s = ioError (userError s) --userError :: String -> IOError -- | Evaluate each monadic action in the structure from left to right, and -- ignore the results. For a version that doesn't ignore the results see -- sequence. -- -- sequence_ is just like sequenceA_, but specialised to -- monadic actions. sequence_ :: (Foldable t, Monad m) => t (m a) -> m () -- | or returns the disjunction of a container of Bools. For the -- result to be False, the container must be finite; True, -- however, results from a True value finitely far from the left -- end. -- --
-- >>> or [] -- False ---- --
-- >>> or [True] -- True ---- --
-- >>> or [False] -- False ---- --
-- >>> or [True, True, False] -- True ---- --
-- >>> or (True : repeat False) -- Infinite list [True,False,False,False,... -- True ---- --
-- >>> or (repeat False) -- * Hangs forever * --or :: Foldable t => t Bool -> Bool -- | notElem is the negation of elem. -- --
-- >>> 3 `notElem` [] -- True ---- --
-- >>> 3 `notElem` [1,2] -- True ---- --
-- >>> 3 `notElem` [1,2,3,4,5] -- False ---- -- For infinite structures, notElem terminates if the value exists -- at a finite distance from the left side of the structure: -- --
-- >>> 3 `notElem` [1..] -- False ---- --
-- >>> 3 `notElem` ([4..] ++ [3]) -- * Hangs forever * --notElem :: (Foldable t, Eq a) => a -> t a -> Bool infix 4 `notElem` -- | Map each element of a structure to a monadic action, evaluate these -- actions from left to right, and ignore the results. For a version that -- doesn't ignore the results see mapM. -- -- mapM_ is just like traverse_, but specialised to monadic -- actions. mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m () -- | Map a function over all the elements of a container and concatenate -- the resulting lists. -- --
-- >>> concatMap (take 3) [[1..], [10..], [100..], [1000..]] -- [1,2,3,10,11,12,100,101,102,1000,1001,1002] ---- --
-- >>> concatMap (take 3) (Just [1..]) -- [1,2,3] --concatMap :: Foldable t => (a -> [b]) -> t a -> [b] -- | The concatenation of all the elements of a container of lists. -- --
-- >>> concat (Just [1, 2, 3]) -- [1,2,3] ---- --
-- >>> concat (Left 42) -- [] ---- --
-- >>> concat [[1, 2, 3], [4, 5], [6], []] -- [1,2,3,4,5,6] --concat :: Foldable t => t [a] -> [a] -- | Determines whether any element of the structure satisfies the -- predicate. -- --
-- >>> any (> 3) [] -- False ---- --
-- >>> any (> 3) [1,2] -- False ---- --
-- >>> any (> 3) [1,2,3,4,5] -- True ---- --
-- >>> any (> 3) [1..] -- True ---- --
-- >>> any (> 3) [0, -1..] -- * Hangs forever * --any :: Foldable t => (a -> Bool) -> t a -> Bool -- | and returns the conjunction of a container of Bools. For the -- result to be True, the container must be finite; False, -- however, results from a False value finitely far from the left -- end. -- --
-- >>> and [] -- True ---- --
-- >>> and [True] -- True ---- --
-- >>> and [False] -- False ---- --
-- >>> and [True, True, False] -- False ---- --
-- >>> and (False : repeat True) -- Infinite list [False,True,True,True,... -- False ---- --
-- >>> and (repeat True) -- * Hangs forever * --and :: Foldable t => t Bool -> Bool -- | Determines whether all elements of the structure satisfy the -- predicate. -- --
-- >>> all (> 3) [] -- True ---- --
-- >>> all (> 3) [1,2] -- False ---- --
-- >>> all (> 3) [1,2,3,4,5] -- False ---- --
-- >>> all (> 3) [1..] -- False ---- --
-- >>> all (> 3) [4..] -- * Hangs forever * --all :: Foldable t => (a -> Bool) -> t a -> Bool -- | words breaks a string up into a list of words, which were -- delimited by white space. -- --
-- >>> words "Lorem ipsum\ndolor" -- ["Lorem","ipsum","dolor"] --words :: String -> [String] -- | unwords is an inverse operation to words. It joins words -- with separating spaces. -- --
-- >>> unwords ["Lorem", "ipsum", "dolor"] -- "Lorem ipsum dolor" --unwords :: [String] -> String -- | unlines is an inverse operation to lines. It joins -- lines, after appending a terminating newline to each. -- --
-- >>> unlines ["Hello", "World", "!"] -- "Hello\nWorld\n!\n" --unlines :: [String] -> String -- | lines breaks a string up into a list of strings at newline -- characters. The resulting strings do not contain newlines. -- -- Note that after splitting the string at newline characters, the last -- part of the string is considered a line even if it doesn't end with a -- newline. For example, -- --
-- >>> lines "" -- [] ---- --
-- >>> lines "\n" -- [""] ---- --
-- >>> lines "one" -- ["one"] ---- --
-- >>> lines "one\n" -- ["one"] ---- --
-- >>> lines "one\n\n" -- ["one",""] ---- --
-- >>> lines "one\ntwo" -- ["one","two"] ---- --
-- >>> lines "one\ntwo\n" -- ["one","two"] ---- -- Thus lines s contains at least as many elements as -- newlines in s. lines :: String -> [String] -- | equivalent to readsPrec with a precedence of 0. reads :: Read a => ReadS 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. -- --
-- >>> read "123" :: Int -- 123 ---- --
-- >>> read "hello" :: Int -- *** Exception: Prelude.read: no parse --read :: Read a => String -> a -- | Case analysis for the Either type. If the value is -- Left a, apply the first function to a; if it -- is Right b, apply the second function to b. -- --
-- >>> let s = Left "foo" :: Either String Int -- -- >>> let n = Right 3 :: Either String Int -- -- >>> either length (*2) s -- 3 -- -- >>> either length (*2) n -- 6 --either :: (a -> c) -> (b -> c) -> Either a b -> c -- | readParen True p parses what p parses, -- but surrounded with parentheses. -- -- readParen False p parses what p -- parses, but optionally surrounded with parentheses. readParen :: Bool -> ReadS a -> ReadS a -- | 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: -- --
-- zipWith3 (,,) xs ys zs == zip3 xs ys zs -- zipWith3 f [x1,x2,x3..] [y1,y2,y3..] [z1,z2,z3..] == [f x1 y1 z1, f x2 y2 z2, f x3 y3 z3..] --zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d] -- | <math>. zipWith generalises zip by zipping with -- the function given as the first argument, instead of a tupling -- function. -- --
-- zipWith (,) xs ys == zip xs ys -- zipWith f [x1,x2,x3..] [y1,y2,y3..] == [f x1 y1, f x2 y2, f x3 y3..] ---- -- For example, zipWith (+) is applied to two lists to -- produce the list of corresponding sums: -- --
-- >>> zipWith (+) [1, 2, 3] [4, 5, 6] -- [5,7,9] ---- -- zipWith is right-lazy: -- --
-- >>> let f = undefined -- -- >>> zipWith f [] undefined -- [] ---- -- zipWith is capable of list fusion, but it is restricted to its -- first list argument and its resulting list. zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] -- | zip3 takes three lists and returns a list of triples, analogous -- to zip. It is capable of list fusion, but it is restricted to -- its first list argument and its resulting list. zip3 :: [a] -> [b] -> [c] -> [(a, b, c)] -- | The unzip3 function takes a list of triples and returns three -- lists, analogous to unzip. -- --
-- >>> unzip3 [] -- ([],[],[]) -- -- >>> unzip3 [(1, 'a', True), (2, 'b', False)] -- ([1,2],"ab",[True,False]) --unzip3 :: [(a, b, c)] -> ([a], [b], [c]) -- | unzip transforms a list of pairs into a list of first -- components and a list of second components. -- --
-- >>> unzip [] -- ([],[]) -- -- >>> unzip [(1, 'a'), (2, 'b')] -- ([1,2],"ab") --unzip :: [(a, b)] -> ([a], [b]) -- | takeWhile, applied to a predicate p and a list -- xs, returns the longest prefix (possibly empty) of -- xs of elements that satisfy p. -- --
-- >>> takeWhile (< 3) [1,2,3,4,1,2,3,4] -- [1,2] -- -- >>> takeWhile (< 9) [1,2,3] -- [1,2,3] -- -- >>> takeWhile (< 0) [1,2,3] -- [] --takeWhile :: (a -> Bool) -> [a] -> [a] -- | take n, applied to a list xs, returns the -- prefix of xs of length n, or xs itself if -- n >= length xs. -- --
-- >>> take 5 "Hello World!" -- "Hello" -- -- >>> take 3 [1,2,3,4,5] -- [1,2,3] -- -- >>> take 3 [1,2] -- [1,2] -- -- >>> take 3 [] -- [] -- -- >>> take (-1) [1,2] -- [] -- -- >>> take 0 [1,2] -- [] ---- -- It is an instance of the more general genericTake, in which -- n may be of any integral type. take :: Int -> [a] -> [a] -- | <math>. Extract the elements after the head of a list, which -- must be non-empty. -- --
-- >>> tail [1, 2, 3] -- [2,3] -- -- >>> tail [1] -- [] -- -- >>> tail [] -- *** Exception: Prelude.tail: empty list --tail :: [a] -> [a] -- | splitAt n xs returns a tuple where first element is -- xs prefix of length n and second element is the -- remainder of the list: -- --
-- >>> splitAt 6 "Hello World!"
-- ("Hello ","World!")
--
-- >>> splitAt 3 [1,2,3,4,5]
-- ([1,2,3],[4,5])
--
-- >>> splitAt 1 [1,2,3]
-- ([1],[2,3])
--
-- >>> splitAt 3 [1,2,3]
-- ([1,2,3],[])
--
-- >>> splitAt 4 [1,2,3]
-- ([1,2,3],[])
--
-- >>> splitAt 0 [1,2,3]
-- ([],[1,2,3])
--
-- >>> splitAt (-1) [1,2,3]
-- ([],[1,2,3])
--
--
-- It is equivalent to (take n xs, drop n xs) when
-- n is not _|_ (splitAt _|_ xs = _|_).
-- splitAt is an instance of the more general
-- genericSplitAt, in which n may be of any integral
-- type.
splitAt :: Int -> [a] -> ([a], [a])
-- | span, applied to a predicate p and a list xs,
-- returns a tuple where first element is longest prefix (possibly empty)
-- of xs of elements that satisfy p and second element
-- is the remainder of the list:
--
-- -- >>> span (< 3) [1,2,3,4,1,2,3,4] -- ([1,2],[3,4,1,2,3,4]) -- -- >>> span (< 9) [1,2,3] -- ([1,2,3],[]) -- -- >>> span (< 0) [1,2,3] -- ([],[1,2,3]) ---- -- span p xs is equivalent to (takeWhile p xs, -- dropWhile p xs) span :: (a -> Bool) -> [a] -> ([a], [a]) -- | <math>. scanr1 is a variant of scanr that has no -- starting value argument. -- --
-- >>> scanr1 (+) [1..4] -- [10,9,7,4] -- -- >>> scanr1 (+) [] -- [] -- -- >>> scanr1 (-) [1..4] -- [-2,3,-1,4] -- -- >>> scanr1 (&&) [True, False, True, True] -- [False,False,True,True] -- -- >>> scanr1 (||) [True, True, False, False] -- [True,True,False,False] -- -- >>> force $ scanr1 (+) [1..] -- *** Exception: stack overflow --scanr1 :: (a -> a -> a) -> [a] -> [a] -- | <math>. scanr is the right-to-left dual of scanl. -- Note that the order of parameters on the accumulating function are -- reversed compared to scanl. Also note that -- --
-- head (scanr f z xs) == foldr f z xs. ---- --
-- >>> scanr (+) 0 [1..4] -- [10,9,7,4,0] -- -- >>> scanr (+) 42 [] -- [42] -- -- >>> scanr (-) 100 [1..4] -- [98,-97,99,-96,100] -- -- >>> scanr (\nextChar reversedString -> nextChar : reversedString) "foo" ['a', 'b', 'c', 'd'] -- ["abcdfoo","bcdfoo","cdfoo","dfoo","foo"] -- -- >>> force $ scanr (+) 0 [1..] -- *** Exception: stack overflow --scanr :: (a -> b -> b) -> b -> [a] -> [b] -- | <math>. scanl1 is a variant of scanl that has no -- starting value argument: -- --
-- scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...] ---- --
-- >>> scanl1 (+) [1..4] -- [1,3,6,10] -- -- >>> scanl1 (+) [] -- [] -- -- >>> scanl1 (-) [1..4] -- [1,-1,-4,-8] -- -- >>> scanl1 (&&) [True, False, True, True] -- [True,False,False,False] -- -- >>> scanl1 (||) [False, False, True, True] -- [False,False,True,True] -- -- >>> scanl1 (+) [1..] -- * Hangs forever * --scanl1 :: (a -> a -> a) -> [a] -> [a] -- | <math>. scanl is similar to foldl, but returns a -- list of successive reduced values from the left: -- --
-- scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...] ---- -- Note that -- --
-- last (scanl f z xs) == foldl f z xs ---- --
-- >>> scanl (+) 0 [1..4] -- [0,1,3,6,10] -- -- >>> scanl (+) 42 [] -- [42] -- -- >>> scanl (-) 100 [1..4] -- [100,99,97,94,90] -- -- >>> scanl (\reversedString nextChar -> nextChar : reversedString) "foo" ['a', 'b', 'c', 'd'] -- ["foo","afoo","bafoo","cbafoo","dcbafoo"] -- -- >>> scanl (+) 0 [1..] -- * Hangs forever * --scanl :: (b -> a -> b) -> b -> [a] -> [b] -- | reverse xs returns the elements of xs in -- reverse order. xs must be finite. -- --
-- >>> reverse [] -- [] -- -- >>> reverse [42] -- [42] -- -- >>> reverse [2,5,7] -- [7,5,2] -- -- >>> reverse [1..] -- * Hangs forever * --reverse :: [a] -> [a] -- | replicate n x is a list of length n with -- x the value of every element. It is an instance of the more -- general genericReplicate, in which n may be of any -- integral type. -- --
-- >>> replicate 0 True -- [] -- -- >>> replicate (-1) True -- [] -- -- >>> replicate 4 True -- [True,True,True,True] --replicate :: Int -> a -> [a] -- | repeat x is an infinite list, with x the -- value of every element. -- --
-- >>> take 20 $ repeat 17 -- [17,17,17,17,17,17,17,17,17... --repeat :: a -> [a] -- | <math>. lookup key assocs looks up a key in an -- association list. -- --
-- >>> lookup 2 [] -- Nothing -- -- >>> lookup 2 [(1, "first")] -- Nothing -- -- >>> lookup 2 [(1, "first"), (2, "second"), (3, "third")] -- Just "second" --lookup :: Eq a => a -> [(a, b)] -> Maybe b -- | <math>. Extract the last element of a list, which must be finite -- and non-empty. -- --
-- >>> last [1, 2, 3] -- 3 -- -- >>> last [1..] -- * Hangs forever * -- -- >>> last [] -- *** Exception: Prelude.last: empty list --last :: [a] -> a -- | iterate f x returns an infinite list of repeated -- applications of f to x: -- --
-- iterate f x == [x, f x, f (f x), ...] ---- -- Note that iterate is lazy, potentially leading to thunk -- build-up if the consumer doesn't force each iterate. See -- iterate' for a strict variant of this function. -- --
-- >>> take 10 $ iterate not True -- [True,False,True,False... -- -- >>> take 10 $ iterate (+3) 42 -- [42,45,48,51,54,57,60,63... --iterate :: (a -> a) -> a -> [a] -- | <math>. Return all the elements of a list except the last one. -- The list must be non-empty. -- --
-- >>> init [1, 2, 3] -- [1,2] -- -- >>> init [1] -- [] -- -- >>> init [] -- *** Exception: Prelude.init: empty list --init :: [a] -> [a] -- | <math>. Extract the first element of a list, which must be -- non-empty. -- --
-- >>> head [1, 2, 3] -- 1 -- -- >>> head [1..] -- 1 -- -- >>> head [] -- *** Exception: Prelude.head: empty list --head :: [a] -> a -- | dropWhile p xs returns the suffix remaining after -- takeWhile p xs. -- --
-- >>> dropWhile (< 3) [1,2,3,4,5,1,2,3] -- [3,4,5,1,2,3] -- -- >>> dropWhile (< 9) [1,2,3] -- [] -- -- >>> dropWhile (< 0) [1,2,3] -- [1,2,3] --dropWhile :: (a -> Bool) -> [a] -> [a] -- | drop n xs returns the suffix of xs after the -- first n elements, or [] if n >= length -- xs. -- --
-- >>> drop 6 "Hello World!" -- "World!" -- -- >>> drop 3 [1,2,3,4,5] -- [4,5] -- -- >>> drop 3 [1,2] -- [] -- -- >>> drop 3 [] -- [] -- -- >>> drop (-1) [1,2] -- [1,2] -- -- >>> drop 0 [1,2] -- [1,2] ---- -- It is an instance of the more general genericDrop, in which -- n may be of any integral type. drop :: Int -> [a] -> [a] -- | cycle ties a finite list into a circular one, or equivalently, -- the infinite repetition of the original list. It is the identity on -- infinite lists. -- --
-- >>> cycle [] -- *** Exception: Prelude.cycle: empty list -- -- >>> take 20 $ cycle [42] -- [42,42,42,42,42,42,42,42,42,42... -- -- >>> take 20 $ cycle [2, 5, 7] -- [2,5,7,2,5,7,2,5,7,2,5,7... --cycle :: [a] -> [a] -- | break, applied to a predicate p and a list -- xs, returns a tuple where first element is longest prefix -- (possibly empty) of xs of elements that do not satisfy -- p and second element is the remainder of the list: -- --
-- >>> break (> 3) [1,2,3,4,1,2,3,4] -- ([1,2,3],[4,1,2,3,4]) -- -- >>> break (< 9) [1,2,3] -- ([],[1,2,3]) -- -- >>> break (> 9) [1,2,3] -- ([1,2,3],[]) ---- -- break p is equivalent to span (not . -- p). break :: (a -> Bool) -> [a] -> ([a], [a]) -- | List index (subscript) operator, starting from 0. It is an instance of -- the more general genericIndex, which takes an index of any -- integral type. -- --
-- >>> ['a', 'b', 'c'] !! 0 -- 'a' -- -- >>> ['a', 'b', 'c'] !! 2 -- 'c' -- -- >>> ['a', 'b', 'c'] !! 3 -- *** Exception: Prelude.!!: index too large -- -- >>> ['a', 'b', 'c'] !! (-1) -- *** Exception: Prelude.!!: negative index --(!!) :: [a] -> Int -> a infixl 9 !! -- | The maybe function takes a default value, a function, and a -- Maybe value. If the Maybe value is Nothing, the -- function returns the default value. Otherwise, it applies the function -- to the value inside the Just and returns the result. -- --
-- >>> maybe False odd (Just 3) -- True ---- --
-- >>> maybe False odd Nothing -- False ---- -- Read an integer from a string using readMaybe. If we succeed, -- return twice the integer; that is, apply (*2) to it. If -- instead we fail to parse an integer, return 0 by default: -- --
-- >>> import Text.Read ( readMaybe ) -- -- >>> maybe 0 (*2) (readMaybe "5") -- 10 -- -- >>> maybe 0 (*2) (readMaybe "") -- 0 ---- -- Apply show to a Maybe Int. If we have Just n, -- we want to show the underlying Int n. But if we have -- Nothing, we return the empty string instead of (for example) -- "Nothing": -- --
-- >>> maybe "" show (Just 5) -- "5" -- -- >>> maybe "" show Nothing -- "" --maybe :: b -> (a -> b) -> Maybe a -> b -- | An infix synonym for fmap. -- -- The name of this operator is an allusion to $. Note the -- similarities between their types: -- --
-- ($) :: (a -> b) -> a -> b -- (<$>) :: Functor f => (a -> b) -> f a -> f b ---- -- Whereas $ is function application, <$> is function -- application lifted over a Functor. -- --
-- >>> show <$> Nothing -- Nothing -- -- >>> show <$> Just 3 -- Just "3" ---- -- Convert from an Either Int Int to an -- Either Int String using show: -- --
-- >>> show <$> Left 17 -- Left 17 -- -- >>> show <$> Right 17 -- Right "17" ---- -- Double each element of a list: -- --
-- >>> (*2) <$> [1,2,3] -- [2,4,6] ---- -- Apply even to the second element of a pair: -- --
-- >>> even <$> (2,2) -- (2,True) --(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 <$> -- | uncurry converts a curried function to a function on pairs. -- --
-- >>> uncurry (+) (1,2) -- 3 ---- --
-- >>> uncurry ($) (show, 1) -- "1" ---- --
-- >>> map (uncurry max) [(1,2), (3,4), (6,8)] -- [2,4,8] --uncurry :: (a -> b -> c) -> (a, b) -> c -- | curry converts an uncurried function to a curried function. -- --
-- >>> curry fst 1 2 -- 1 --curry :: ((a, b) -> c) -> a -> b -> c -- | 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. subtract :: Num a => a -> a -> a -- | until p f yields the result of applying f -- until p holds. until :: (a -> Bool) -> (a -> a) -> a -> a -- | Identity function. -- --
-- id x = x --id :: a -> a -- | flip f takes its (first) two arguments in the reverse -- order of f. -- --
-- >>> flip (++) "hello" "world" -- "worldhello" --flip :: (a -> b -> c) -> b -> a -> c -- | const x is a unary function which evaluates to x for -- all inputs. -- --
-- >>> const 42 "hello" -- 42 ---- --
-- >>> map (const 42) [0..3] -- [42,42,42,42] --const :: a -> b -> a -- | asTypeOf is a type-restricted version of const. It is -- usually used as an infix operator, and its typing forces its first -- argument (which is usually overloaded) to have the same type as the -- second. asTypeOf :: a -> a -> a -- | Same as >>=, but with the arguments interchanged. (=<<) :: Monad m => (a -> m b) -> m a -> m b infixr 1 =<< -- | Function composition. (.) :: (b -> c) -> (a -> b) -> a -> c infixr 9 . -- | Strict (call-by-value) application operator. It takes a function and -- an argument, evaluates the argument to weak head normal form (WHNF), -- then calls the function with that value. ($!) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b infixr 0 $! -- | 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. undefined :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => a -- | A variant of error that does not produce a stack trace. errorWithoutStackTrace :: forall (r :: RuntimeRep) (a :: TYPE r). [Char] -> a -- | error stops execution and displays an error message. error :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => [Char] -> a (&&) :: Bool -> Bool -> Bool not :: Bool -> Bool (||) :: Bool -> Bool -> Bool -- | The FiniteBits class denotes types with a finite, fixed number -- of bits. class Bits b => FiniteBits b -- | Return the number of bits in the type of the argument. The actual -- value of the argument is ignored. Moreover, finiteBitSize is -- total, in contrast to the deprecated bitSize function it -- replaces. -- --
-- finiteBitSize = bitSize -- bitSizeMaybe = Just . finiteBitSize --finiteBitSize :: FiniteBits b => b -> Int -- | Count number of zero bits preceding the most significant set bit. -- --
-- countLeadingZeros (zeroBits :: a) = finiteBitSize (zeroBits :: a) ---- -- countLeadingZeros can be used to compute log base 2 via -- --
-- logBase2 x = finiteBitSize x - 1 - countLeadingZeros x ---- -- Note: The default implementation for this method is intentionally -- naive. However, the instances provided for the primitive integral -- types are implemented using CPU specific machine instructions. countLeadingZeros :: FiniteBits b => b -> Int -- | Count number of zero bits following the least significant set bit. -- --
-- countTrailingZeros (zeroBits :: a) = finiteBitSize (zeroBits :: a) -- countTrailingZeros . negate = countTrailingZeros ---- -- The related find-first-set operation can be expressed in terms -- of countTrailingZeros as follows -- --
-- findFirstSet x = 1 + countTrailingZeros x ---- -- Note: The default implementation for this method is intentionally -- naive. However, the instances provided for the primitive integral -- types are implemented using CPU specific machine instructions. countTrailingZeros :: FiniteBits b => b -> Int -- | The Bits class defines bitwise operations over integral types. -- --
clearBit zeroBits n == -- zeroBits
setBit zeroBits n == bit -- n
testBit zeroBits n == False
popCount zeroBits == 0
-- toIntegral :: (Integral a, Integral b) => a -> Maybe b -- toIntegral x -- | toInteger x == y = Just (fromInteger y) -- | otherwise = Nothing -- where -- y = toInteger x ---- -- This version requires going through Integer, which can be -- inefficient. However, toIntegralSized is optimized to allow -- GHC to statically determine the relative type sizes (as measured by -- bitSizeMaybe and isSigned) and avoid going through -- Integer for many types. (The implementation uses -- fromIntegral, which is itself optimized with rules for -- base types but may go through Integer for some type -- pairs.) toIntegralSized :: (Integral a, Integral b, Bits a, Bits b) => a -> Maybe b -- | Default implementation for testBit. -- -- Note that: testBitDefault x i = (x .&. bit i) /= 0 testBitDefault :: (Bits a, Num a) => a -> Int -> Bool -- | Default implementation for popCount. -- -- This implementation is intentionally naive. Instances are expected to -- provide an optimized implementation for their size. popCountDefault :: (Bits a, Num a) => a -> Int -- | Default implementation for bit. -- -- Note that: bitDefault i = 1 shiftL i bitDefault :: (Bits a, Num a) => Int -> a shiftL :: Bits a => a -> Int -> a shiftR :: Bits a => a -> Int -> a module GHC.Linker module GHC.Data.UnionFind -- | A variable which can be unified; alternately, this can be thought of -- as an equivalence class with a distinguished representative. newtype Point s a Point :: STRef s (Link s a) -> Point s a -- | Mutable write to a Point writePoint :: Point s a -> Link s a -> ST s () -- | Read the current value of Point. readPoint :: Point s a -> ST s (Link s a) -- | The internal data structure for a Point, which either records -- the representative element of an equivalence class, or a link to the -- Point that actually stores the representative type. data Link s a Info :: {-# UNPACK #-} !STRef s Int -> {-# UNPACK #-} !STRef s a -> Link s a Link :: {-# UNPACK #-} !Point s a -> Link s a -- | Create a fresh equivalence class with one element. fresh :: a -> ST s (Point s a) -- | Flatten any chains of links, returning a Point which points -- directly to the canonical representation. repr :: Point s a -> ST s (Point s a) -- | Return the canonical element of an equivalence class Point. find :: Point s a -> ST s a -- | Unify two equivalence classes, so that they share a canonical element. -- Keeps the descriptor of point2. union :: Point s a -> Point s a -> ST s () -- | Test if two points are in the same equivalence class. equivalent :: Point s a -> Point s a -> ST s Bool instance GHC.Classes.Eq (GHC.Data.UnionFind.Point s a) -- | Monadic streams module GHC.Data.Stream -- | Stream m a b is a computation in some Monad m that -- delivers a sequence of elements of type a followed by a -- result of type b. -- -- More concretely, a value of type Stream m a b can be run -- using runStreamInternal in the Monad m, and it -- delivers either -- --
-- import Control.Monad.Trans.State -- from the "transformers" library -- -- printState :: Show s => StateT s IO () -- printState = do -- state <- get -- liftIO $ print state ---- -- Had we omitted liftIO, we would have ended up with -- this error: -- --
-- • Couldn't match type ‘IO’ with ‘StateT s IO’ -- Expected type: StateT s IO () -- Actual type: IO () ---- -- The important part here is the mismatch between StateT s IO -- () and IO (). -- -- Luckily, we know of a function that takes an IO a and -- returns an (m a): liftIO, enabling us to run -- the program and see the expected results: -- --
-- > evalStateT printState "hello" -- "hello" -- -- > evalStateT printState 3 -- 3 --liftIO :: MonadIO m => IO a -> m a -- | Turn a Stream into an ordinary list, by demanding all the elements. collect :: Monad m => Stream m a () -> m [a] consume :: (Monad m, Monad n) => Stream m a b -> (forall a. m a -> n a) -> (a -> n ()) -> n b -- | Turn a list into a Stream, by yielding each element in turn. fromList :: Monad m => [a] -> Stream m a () -- | Apply a function to each element of a Stream, lazily map :: Monad m => (a -> b) -> Stream m a x -> Stream m b x -- | Apply a monadic operation to each element of a Stream, lazily mapM :: Monad m => (a -> m b) -> Stream m a x -> Stream m b x -- | Note this is not very efficient because it traverses the whole stream -- before rebuilding it, avoid using it if you can. mapAccumL used to -- implemented but it wasn't used anywhere in the compiler and has -- similar effiency problems. mapAccumL_ :: forall m a b c r. Monad m => (c -> a -> m (c, b)) -> c -> Stream m a r -> Stream m b (c, r) instance GHC.Base.Functor (GHC.Data.Stream.Stream f a) instance GHC.Base.Applicative (GHC.Data.Stream.Stream m a) instance GHC.Base.Monad (GHC.Data.Stream.Stream m a) instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (GHC.Data.Stream.Stream m b) instance GHC.Base.Monad m => GHC.Base.Functor (GHC.Data.Stream.StreamS m a) instance GHC.Base.Monad m => GHC.Base.Applicative (GHC.Data.Stream.StreamS m a) instance GHC.Base.Monad m => GHC.Base.Monad (GHC.Data.Stream.StreamS m a) module GHC.Data.FiniteMap insertList :: Ord key => [(key, elt)] -> Map key elt -> Map key elt insertListWith :: Ord key => (elt -> elt -> elt) -> [(key, elt)] -> Map key elt -> Map key elt deleteList :: Ord key => [key] -> Map key elt -> Map key elt foldRight :: (elt -> a -> a) -> a -> Map key elt -> a foldRightWithKey :: (key -> elt -> a -> a) -> a -> Map key elt -> a module GHC.Data.FastMutInt data FastMutInt newFastMutInt :: Int -> IO FastMutInt readFastMutInt :: FastMutInt -> IO Int writeFastMutInt :: FastMutInt -> Int -> IO () atomicFetchAddFastMut :: FastMutInt -> Int -> IO Int -- | A tiny wrapper around IntSet for representing sets of -- Enum things. module GHC.Data.EnumSet data EnumSet a member :: Enum a => a -> EnumSet a -> Bool insert :: Enum a => a -> EnumSet a -> EnumSet a delete :: Enum a => a -> EnumSet a -> EnumSet a toList :: Enum a => EnumSet a -> [a] fromList :: Enum a => [a] -> EnumSet a empty :: EnumSet a difference :: EnumSet a -> EnumSet a -> EnumSet a module GHC.CmmToAsm.X86.Cond data Cond ALWAYS :: Cond EQQ :: Cond GE :: Cond GEU :: Cond GTT :: Cond GU :: Cond LE :: Cond LEU :: Cond LTT :: Cond LU :: Cond NE :: Cond NEG :: Cond POS :: Cond CARRY :: Cond OFLO :: Cond PARITY :: Cond NOTPARITY :: Cond condToUnsigned :: Cond -> Cond -- | maybeFlipCond c returns Just c' if it is possible to -- flip the arguments to the conditional c, and the new -- condition should be c'. maybeFlipCond :: Cond -> Maybe Cond -- | If we apply maybeInvertCond to the condition of a jump we -- turn jumps taken into jumps not taken and vice versa. -- -- Careful! If the used comparison and the conditional jump don't match -- the above behaviour will NOT hold. When used for FP comparisons this -- does not consider unordered numbers. Also inverting twice might return -- a synonym for the original condition. maybeInvertCond :: Cond -> Maybe Cond instance GHC.Classes.Eq GHC.CmmToAsm.X86.Cond.Cond module GHC.CmmToAsm.SPARC.Cond -- | Branch condition codes. data Cond ALWAYS :: Cond EQQ :: Cond GE :: Cond GEU :: Cond GTT :: Cond GU :: Cond LE :: Cond LEU :: Cond LTT :: Cond LU :: Cond NE :: Cond NEG :: Cond NEVER :: Cond POS :: Cond VC :: Cond VS :: Cond instance GHC.Classes.Eq GHC.CmmToAsm.SPARC.Cond.Cond -- | The Lengauer-Tarjan graph dominators algorithm. -- -- <math> Lengauer, Tarjan, A Fast Algorithm for Finding -- Dominators in a Flowgraph, 1979. -- -- <math> Muchnick, Advanced Compiler Design and -- Implementation, 1997. -- -- <math> Brisk, Sarrafzadeh, Interference Graphs for Procedures -- in Static Single Information Form are Interval Graphs, -- 2007. -- --
-- (<*>) = liftA2 id ---- --
-- liftA2 f x y = f <$> x <*> y ---- -- Further, any definition must satisfy the following: -- --
pure id <*> v = -- v
pure (.) <*> u -- <*> v <*> w = u <*> (v -- <*> w)
pure f <*> -- pure x = pure (f x)
u <*> pure y = -- pure ($ y) <*> u
-- forall x y. p (q x y) = f x . g y ---- -- it follows from the above that -- --
-- liftA2 p (liftA2 q u v) = liftA2 f u . liftA2 g v ---- -- If f is also a Monad, it should satisfy -- -- -- -- (which implies that pure and <*> satisfy the -- applicative functor laws). class Functor f => Applicative (f :: Type -> Type) -- | Lift a value. pure :: Applicative f => a -> f a -- | Sequential application. -- -- A few functors support an implementation of <*> that is -- more efficient than the default one. -- --
-- >>> data MyState = MyState {arg1 :: Foo, arg2 :: Bar, arg3 :: Baz}
--
--
-- -- >>> produceFoo :: Applicative f => f Foo ---- --
-- >>> produceBar :: Applicative f => f Bar -- -- >>> produceBaz :: Applicative f => f Baz ---- --
-- >>> mkState :: Applicative f => f MyState -- -- >>> mkState = MyState <$> produceFoo <*> produceBar <*> produceBaz --(<*>) :: Applicative f => f (a -> b) -> f a -> f b -- | Lift a binary function to actions. -- -- Some functors support an implementation of liftA2 that is more -- efficient than the default one. In particular, if fmap is an -- expensive operation, it is likely better to use liftA2 than to -- fmap over the structure and then use <*>. -- -- This became a typeclass method in 4.10.0.0. Prior to that, it was a -- function defined in terms of <*> and fmap. -- --
-- >>> liftA2 (,) (Just 3) (Just 5) -- Just (3,5) --liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c -- | Sequence actions, discarding the value of the first argument. -- --
-- >>> Just 2 *> Just 3 -- Just 3 ---- --
-- >>> Nothing *> Just 3 -- Nothing ---- -- Of course a more interesting use case would be to have effectful -- computations instead of just returning pure values. -- --
-- >>> import Data.Char
--
-- >>> import Text.ParserCombinators.ReadP
--
-- >>> let p = string "my name is " *> munch1 isAlpha <* eof
--
-- >>> readP_to_S p "my name is Simon"
-- [("Simon","")]
--
(*>) :: Applicative f => f a -> f b -> f b
-- | Sequence actions, discarding the value of the second argument.
(<*) :: Applicative f => f a -> f b -> f a
infixl 4 <*>
infixl 4 *>
infixl 4 <*
-- | An infix synonym for fmap.
--
-- The name of this operator is an allusion to $. Note the
-- similarities between their types:
--
-- -- ($) :: (a -> b) -> a -> b -- (<$>) :: Functor f => (a -> b) -> f a -> f b ---- -- Whereas $ is function application, <$> is function -- application lifted over a Functor. -- --
-- >>> show <$> Nothing -- Nothing -- -- >>> show <$> Just 3 -- Just "3" ---- -- Convert from an Either Int Int to an -- Either Int String using show: -- --
-- >>> show <$> Left 17 -- Left 17 -- -- >>> show <$> Right 17 -- Right "17" ---- -- Double each element of a list: -- --
-- >>> (*2) <$> [1,2,3] -- [2,4,6] ---- -- Apply even to the second element of a pair: -- --
-- >>> even <$> (2,2) -- (2,True) --(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 <$> -- | Monads having fixed points with a 'knot-tying' semantics. Instances of -- MonadFix should satisfy the following laws: -- --
-- import Control.Monad.Trans.State -- from the "transformers" library -- -- printState :: Show s => StateT s IO () -- printState = do -- state <- get -- liftIO $ print state ---- -- Had we omitted liftIO, we would have ended up with -- this error: -- --
-- • Couldn't match type ‘IO’ with ‘StateT s IO’ -- Expected type: StateT s IO () -- Actual type: IO () ---- -- The important part here is the mismatch between StateT s IO -- () and IO (). -- -- Luckily, we know of a function that takes an IO a and -- returns an (m a): liftIO, enabling us to run -- the program and see the expected results: -- --
-- > evalStateT printState "hello" -- "hello" -- -- > evalStateT printState 3 -- 3 --liftIO :: MonadIO m => IO a -> m a zipWith3M :: Monad m => (a -> b -> c -> m d) -> [a] -> [b] -> [c] -> m [d] zipWith3M_ :: Monad m => (a -> b -> c -> m d) -> [a] -> [b] -> [c] -> m () zipWith4M :: Monad m => (a -> b -> c -> d -> m e) -> [a] -> [b] -> [c] -> [d] -> m [e] zipWithAndUnzipM :: Monad m => (a -> b -> m (c, d)) -> [a] -> [b] -> m ([c], [d]) -- | The mapAndUnzipM function maps its first argument over a list, -- returning the result as a pair of lists. This function is mainly used -- with complicated data structures or a state monad. mapAndUnzipM :: Applicative m => (a -> m (b, c)) -> [a] -> m ([b], [c]) -- | mapAndUnzipM for triples mapAndUnzip3M :: Monad m => (a -> m (b, c, d)) -> [a] -> m ([b], [c], [d]) mapAndUnzip4M :: Monad m => (a -> m (b, c, d, e)) -> [a] -> m ([b], [c], [d], [e]) mapAndUnzip5M :: Monad m => (a -> m (b, c, d, e, f)) -> [a] -> m ([b], [c], [d], [e], [f]) -- | Monadic version of mapAccumL mapAccumLM :: Monad m => (acc -> x -> m (acc, y)) -> acc -> [x] -> m (acc, [y]) liftFstM :: Monad m => (a -> b) -> m (a, r) -> m (b, r) liftSndM :: Monad m => (a -> b) -> m (r, a) -> m (r, b) -- | Monadic version of mapSnd mapSndM :: Monad m => (b -> m c) -> [(a, b)] -> m [(a, c)] -- | Monadic version of concatMap concatMapM :: Monad m => (a -> m [b]) -> [a] -> m [b] -- | Applicative version of mapMaybe mapMaybeM :: Applicative m => (a -> m (Maybe b)) -> [a] -> m [b] -- | Monadic version of fmap fmapMaybeM :: Monad m => (a -> m b) -> Maybe a -> m (Maybe b) -- | Monadic version of fmap fmapEitherM :: Monad m => (a -> m b) -> (c -> m d) -> Either a c -> m (Either b d) -- | Monadic version of any, aborts the computation at the first -- True value anyM :: Monad m => (a -> m Bool) -> [a] -> m Bool -- | Monad version of all, aborts the computation at the first -- False value allM :: Monad m => (a -> m Bool) -> [a] -> m Bool -- | Monadic version of or orM :: Monad m => m Bool -> m Bool -> m Bool -- | Left-to-right monadic fold over the elements of a structure. -- -- Given a structure t with elements (a, b, ..., w, x, -- y), the result of a fold with an operator function f is -- equivalent to: -- --
-- foldlM f z t = do -- aa <- f z a -- bb <- f aa b -- ... -- xx <- f ww x -- yy <- f xx y -- return yy -- Just @return z@ when the structure is empty ---- -- For a Monad m, given two functions f1 :: a -> m b -- and f2 :: b -> m c, their Kleisli composition (f1 -- >=> f2) :: a -> m c is defined by: -- --
-- (f1 >=> f2) a = f1 a >>= f2 ---- -- Another way of thinking about foldlM is that it amounts to an -- application to z of a Kleisli composition: -- --
-- foldlM f z t = -- flip f a >=> flip f b >=> ... >=> flip f x >=> flip f y $ z ---- -- The monadic effects of foldlM are sequenced from left to -- right. -- -- If at some step the bind operator (>>=) -- short-circuits (as with, e.g., mzero in a MonadPlus), -- the evaluated effects will be from an initial segment of the element -- sequence. If you want to evaluate the monadic effects in right-to-left -- order, or perhaps be able to short-circuit after processing a tail of -- the sequence of elements, you'll need to use foldrM instead. -- -- If the monadic effects don't short-circuit, the outermost application -- of f is to the rightmost element y, so that, -- ignoring effects, the result looks like a left fold: -- --
-- ((((z `f` a) `f` b) ... `f` w) `f` x) `f` y ---- --
-- >>> let f a e = do { print e ; return $ e : a }
--
-- >>> foldlM f [] [0..3]
-- 0
-- 1
-- 2
-- 3
-- [3,2,1,0]
--
foldlM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b
-- | Monadic version of foldl that discards its result
foldlM_ :: (Monad m, Foldable t) => (a -> b -> m a) -> a -> t b -> m ()
-- | Right-to-left monadic fold over the elements of a structure.
--
-- Given a structure t with elements (a, b, c, ..., x,
-- y), the result of a fold with an operator function f is
-- equivalent to:
--
-- -- foldrM f z t = do -- yy <- f y z -- xx <- f x yy -- ... -- bb <- f b cc -- aa <- f a bb -- return aa -- Just @return z@ when the structure is empty ---- -- For a Monad m, given two functions f1 :: a -> m b -- and f2 :: b -> m c, their Kleisli composition (f1 -- >=> f2) :: a -> m c is defined by: -- --
-- (f1 >=> f2) a = f1 a >>= f2 ---- -- Another way of thinking about foldrM is that it amounts to an -- application to z of a Kleisli composition: -- --
-- foldrM f z t = f y >=> f x >=> ... >=> f b >=> f a $ z ---- -- The monadic effects of foldrM are sequenced from right to -- left, and e.g. folds of infinite lists will diverge. -- -- If at some step the bind operator (>>=) -- short-circuits (as with, e.g., mzero in a MonadPlus), -- the evaluated effects will be from a tail of the element sequence. If -- you want to evaluate the monadic effects in left-to-right order, or -- perhaps be able to short-circuit after an initial sequence of -- elements, you'll need to use foldlM instead. -- -- If the monadic effects don't short-circuit, the outermost application -- of f is to the leftmost element a, so that, ignoring -- effects, the result looks like a right fold: -- --
-- a `f` (b `f` (c `f` (... (x `f` (y `f` z))))). ---- --
-- >>> let f i acc = do { print i ; return $ i : acc }
--
-- >>> foldrM f [] [0..3]
-- 3
-- 2
-- 1
-- 0
-- [0,1,2,3]
--
foldrM :: (Foldable t, Monad m) => (a -> b -> m b) -> b -> t a -> m b
-- | Monadic version of fmap specialised for Maybe
maybeMapM :: Monad m => (a -> m b) -> Maybe a -> m (Maybe b)
-- | Monadic version of when, taking the condition in the monad
whenM :: Monad m => m Bool -> m () -> m ()
-- | Monadic version of unless, taking the condition in the monad
unlessM :: Monad m => m Bool -> m () -> m ()
-- | Like filterM, only it reverses the sense of the test.
filterOutM :: Applicative m => (a -> m Bool) -> [a] -> m [a]
module GHC.Utils.Monad.State
newtype State s a
State :: (s -> (# a, s #)) -> State s a
[runState'] :: State s a -> s -> (# a, s #)
get :: State s s
gets :: (s -> a) -> State s a
put :: s -> State s ()
modify :: (s -> s) -> State s ()
evalState :: State s a -> s -> a
execState :: State s a -> s -> s
runState :: State s a -> s -> (a, s)
instance GHC.Base.Functor (GHC.Utils.Monad.State.State s)
instance GHC.Base.Applicative (GHC.Utils.Monad.State.State s)
instance GHC.Base.Monad (GHC.Utils.Monad.State.State s)
-- | Defines a simple exception type and utilities to throw it. The
-- PlainGhcException type is a subset of the GhcException
-- type. It omits the exception constructors that involve pretty-printing
-- via SDoc.
--
-- There are two reasons for this:
--
-- -- filterByLists [True, False, True, False] "abcd" "wxyz" = "axcz" ---- -- This function does not check whether the lists have equal length. filterByLists :: [Bool] -> [a] -> [a] -> [a] -- | partitionByList takes a list of Bools and a list of some -- elements and partitions the list according to the list of Bools. -- Elements corresponding to True go to the left; elements -- corresponding to False go to the right. For example, -- partitionByList [True, False, True] [1,2,3] == ([1,3], [2]) -- This function does not check whether the lists have equal length; when -- one list runs out, the function stops. partitionByList :: [Bool] -> [a] -> ([a], [a]) unzipWith :: (a -> b -> c) -> [(a, b)] -> [c] mapFst :: (a -> c) -> [(a, b)] -> [(c, b)] mapSnd :: (b -> c) -> [(a, b)] -> [(a, c)] chkAppend :: [a] -> [a] -> [a] mapAndUnzip :: (a -> (b, c)) -> [a] -> ([b], [c]) mapAndUnzip3 :: (a -> (b, c, d)) -> [a] -> ([b], [c], [d]) -- | Like filter, only it reverses the sense of the test filterOut :: (a -> Bool) -> [a] -> [a] -- | Uses a function to determine which of two output lists an input -- element should join partitionWith :: (a -> Either b c) -> [a] -> ([b], [c]) dropWhileEndLE :: (a -> Bool) -> [a] -> [a] -- | spanEnd p l == reverse (span p (reverse l)). The first list -- returns actually comes after the second list (when you look at the -- input list). spanEnd :: (a -> Bool) -> [a] -> ([a], [a]) -- | Get the last two elements in a list. Partial! last2 :: [a] -> (a, a) lastMaybe :: [a] -> Maybe a -- | A strict version of foldl1. foldl1' :: (a -> a -> a) -> [a] -> a foldl2 :: (acc -> a -> b -> acc) -> acc -> [a] -> [b] -> acc count :: (a -> Bool) -> [a] -> Int countWhile :: (a -> Bool) -> [a] -> Int all2 :: (a -> b -> Bool) -> [a] -> [b] -> Bool -- |
-- (lengthExceeds xs n) = (length xs > n) --lengthExceeds :: [a] -> Int -> Bool -- |
-- (lengthIs xs n) = (length xs == n) --lengthIs :: [a] -> Int -> Bool -- |
-- (lengthIsNot xs n) = (length xs /= n) --lengthIsNot :: [a] -> Int -> Bool -- |
-- (lengthAtLeast xs n) = (length xs >= n) --lengthAtLeast :: [a] -> Int -> Bool -- |
-- (lengthAtMost xs n) = (length xs <= n) --lengthAtMost :: [a] -> Int -> Bool -- |
-- (lengthLessThan xs n) == (length xs < n) --lengthLessThan :: [a] -> Int -> Bool listLengthCmp :: [a] -> Int -> Ordering -- | atLength atLen atEnd ls n unravels list ls to -- position n. Precisely: -- --
-- atLength atLenPred atEndPred ls n -- | n < 0 = atLenPred ls -- | length ls < n = atEndPred (n - length ls) -- | otherwise = atLenPred (drop n ls) --atLength :: ([a] -> b) -> b -> [a] -> Int -> b -- | True if length xs == length ys equalLength :: [a] -> [b] -> Bool compareLength :: [a] -> [b] -> Ordering -- | True if length xs <= length ys leLength :: [a] -> [b] -> Bool -- | True if length xs < length ys ltLength :: [a] -> [b] -> Bool isSingleton :: [a] -> Bool only :: [a] -> a singleton :: a -> [a] notNull :: Foldable f => f a -> Bool -- | Split a list into its last element and the initial part of the list. -- snocView xs = Just (init xs, last xs) for non-empty lists. -- snocView xs = Nothing otherwise. Unless both parts of the -- result are guaranteed to be used prefer separate calls to -- last + init. If you are guaranteed to use both, this -- will be more efficient. snocView :: [a] -> Maybe ([a], a) isIn :: Eq a => String -> a -> [a] -> Bool isn'tIn :: Eq a => String -> a -> [a] -> Bool -- | Split a list into chunks of n elements chunkList :: Int -> [a] -> [[a]] -- | Replace the last element of a list with another element. changeLast :: [a] -> a -> [a] -- | Apply an effectful function to the last list element. Assumes a -- non-empty list (panics otherwise). mapLastM :: Functor f => (a -> f a) -> [a] -> f [a] whenNonEmpty :: Applicative m => [a] -> (NonEmpty a -> m ()) -> m () -- | Merge an unsorted list of sorted lists, for example: -- --
-- mergeListsBy compare [ [2,5,15], [1,10,100] ] = [1,2,5,10,15,100] ---- -- <math> mergeListsBy :: forall a. (a -> a -> Ordering) -> [[a]] -> [a] isSortedBy :: (a -> a -> Ordering) -> [a] -> Bool fstOf3 :: (a, b, c) -> a sndOf3 :: (a, b, c) -> b thdOf3 :: (a, b, c) -> c firstM :: Monad m => (a -> m c) -> (a, b) -> m (c, b) first3M :: Monad m => (a -> m d) -> (a, b, c) -> m (d, b, c) secondM :: Monad m => (b -> m c) -> (a, b) -> m (a, c) fst3 :: (a -> d) -> (a, b, c) -> (d, b, c) snd3 :: (b -> d) -> (a, b, c) -> (a, d, c) third3 :: (c -> d) -> (a, b, c) -> (a, b, d) uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d liftFst :: (a -> b) -> (a, c) -> (b, c) liftSnd :: (a -> b) -> (c, a) -> (c, b) takeList :: [b] -> [a] -> [a] dropList :: [b] -> [a] -> [a] -- | Given two lists xs and ys, return `splitAt (length xs) ys`. splitAtList :: [b] -> [a] -> ([a], [a]) split :: Char -> String -> [String] dropTail :: Int -> [a] -> [a] -- | Convert a word to title case by capitalising the first letter capitalise :: String -> String -- | The sortWith function sorts a list of elements using the user -- supplied function to project something out of each element sortWith :: Ord b => (a -> b) -> [a] -> [a] minWith :: Ord b => (a -> b) -> [a] -> a nubSort :: Ord a => [a] -> [a] -- | Remove duplicates but keep elements in order. O(n * log n) ordNub :: Ord a => [a] -> [a] isEqual :: Ordering -> Bool eqListBy :: (a -> a -> Bool) -> [a] -> [a] -> Bool eqMaybeBy :: (a -> a -> Bool) -> Maybe a -> Maybe a -> Bool thenCmp :: Ordering -> Ordering -> Ordering infixr 9 `thenCmp` cmpList :: (a -> a -> Ordering) -> [a] -> [a] -> Ordering removeSpaces :: String -> String (<&&>) :: Applicative f => f Bool -> f Bool -> f Bool infixr 3 <&&> (<||>) :: Applicative f => f Bool -> f Bool -> f Bool infixr 2 <||> fuzzyMatch :: String -> [String] -> [String] -- | Search for possible matches to the users input in the given list, -- returning a small number of ranked results fuzzyLookup :: String -> [(String, a)] -> [a] transitiveClosure :: (a -> [a]) -> (a -> a -> Bool) -> [a] -> [a] seqList :: [a] -> b -> b strictMap :: (a -> b) -> [a] -> [b] strictZipWith :: (a -> b -> c) -> [a] -> [b] -> [c] looksLikeModuleName :: String -> Bool looksLikePackageName :: String -> Bool getCmd :: String -> Either String (String, String) toCmdArgs :: String -> Either String (String, [String]) toArgs :: String -> Either String [String] -- | Determine the $log_2$ of exact powers of 2 exactLog2 :: Integer -> Maybe Integer readRational :: String -> Rational -- | Parse a string into a significand and exponent. A trivial example -- might be: ghci> readSignificandExponentPair "1E2" (1,2) In a more -- complex case we might return a exponent different than that which the -- user wrote. This is needed in order to use a Integer significand. -- ghci> readSignificandExponentPair "-1.11E5" (-111,3) readSignificandExponentPair :: String -> (Integer, Integer) readHexRational :: String -> Rational -- | Parse a string into a significand and exponent according to the -- "Hexadecimal Floats in Haskell" proposal. A trivial example might be: -- ghci> readHexSignificandExponentPair "0x1p+1" (1,1) Behaves similar -- to readSignificandExponentPair but the base is 16 and numbers are -- given in hexadecimal: ghci> readHexSignificandExponentPair "0xAp-4" -- (10,-4) ghci> readHexSignificandExponentPair "0x1.2p3" (18,-1) readHexSignificandExponentPair :: String -> (Integer, Integer) doesDirNameExist :: FilePath -> IO Bool getModificationUTCTime :: FilePath -> IO UTCTime modificationTimeIfExists :: FilePath -> IO (Maybe UTCTime) withAtomicRename :: MonadIO m => FilePath -> (FilePath -> m a) -> m a type Suffix = String splitLongestPrefix :: String -> (Char -> Bool) -> (String, String) escapeSpaces :: String -> String data Direction Forwards :: Direction Backwards :: Direction reslash :: Direction -> FilePath -> FilePath makeRelativeTo :: FilePath -> FilePath -> FilePath abstractConstr :: String -> Constr abstractDataType :: String -> DataType -- | Constructs a non-representation for a non-representable type mkNoRepType :: String -> DataType charToC :: Word8 -> String -- | A sample hash function for Strings. We keep multiplying by the golden -- ratio and adding. The implementation is: -- --
-- hashString = foldl' f golden -- where f m c = fromIntegral (ord c) * magic + hashInt32 m -- magic = 0xdeadbeef ---- -- Where hashInt32 works just as hashInt shown above. -- -- Knuth argues that repeated multiplication by the golden ratio will -- minimize gaps in the hash space, and thus it's a good choice for -- combining together multiple keys to form one. -- -- Here we know that individual characters c are often small, and this -- produces frequent collisions if we use ord c alone. A particular -- problem are the shorter low ASCII and ISO-8859-1 character strings. We -- pre-multiply by a magic twiddle factor to obtain a good distribution. -- In fact, given the following test: -- --
-- testp :: Int32 -> Int -- testp k = (n - ) . length . group . sort . map hs . take n $ ls -- where ls = [] : [c : l | l <- ls, c <- ['\0'..'\xff']] -- hs = foldl' f golden -- f m c = fromIntegral (ord c) * k + hashInt32 m -- n = 100000 ---- -- We discover that testp magic = 0. hashString :: String -> Int32 -- | Request a CallStack. -- -- NOTE: The implicit parameter ?callStack :: CallStack is an -- implementation detail and should not be considered part of the -- CallStack API, we may decide to change the implementation in -- the future. type HasCallStack = ?callStack :: CallStack -- | A call stack constraint, but only when isDebugOn. type HasDebugCallStack = (() :: Constraint) data OverridingBool Auto :: OverridingBool Always :: OverridingBool Never :: OverridingBool overrideWith :: Bool -> OverridingBool -> Bool instance GHC.Show.Show GHC.Utils.Misc.OverridingBool module GHC.Data.Maybe data MaybeErr err val Succeeded :: val -> MaybeErr err val Failed :: err -> MaybeErr err val failME :: err -> MaybeErr err val isSuccess :: MaybeErr err val -> Bool -- | Flipped version of fromMaybe, useful for chaining. orElse :: Maybe a -> a -> a infixr 4 `orElse` firstJust :: Maybe a -> Maybe a -> Maybe a -- | Takes a list of Maybes and returns the first Just if -- there is one, or Nothing otherwise. firstJusts :: Foldable f => f (Maybe a) -> Maybe a -- | Takes computations returnings Maybes; tries each one in -- order. The first one to return a Just wins. Returns -- Nothing if all computations return Nothing. firstJustsM :: (Monad m, Foldable f) => f (m (Maybe a)) -> m (Maybe a) whenIsJust :: Monad m => Maybe a -> (a -> m ()) -> m () expectJust :: HasCallStack => String -> Maybe a -> a rightToMaybe :: Either a b -> Maybe b -- | The parameterizable maybe monad, obtained by composing an arbitrary -- monad with the Maybe monad. -- -- Computations are actions that may produce a value or exit. -- -- The return function yields a computation that produces that -- value, while >>= sequences two subcomputations, exiting -- if either computation does. newtype MaybeT (m :: Type -> Type) a MaybeT :: m (Maybe a) -> MaybeT (m :: Type -> Type) a [runMaybeT] :: MaybeT (m :: Type -> Type) a -> m (Maybe a) liftMaybeT :: Monad m => m a -> MaybeT m a -- | Try performing an IO action, failing on error. tryMaybeT :: IO a -> MaybeT IO a instance GHC.Base.Functor (GHC.Data.Maybe.MaybeErr err) instance GHC.Base.Applicative (GHC.Data.Maybe.MaybeErr err) instance GHC.Base.Monad (GHC.Data.Maybe.MaybeErr err) -- | Platform description module GHC.Platform -- | Platform description -- -- This is used to describe platforms so that we can generate code for -- them. data Platform Platform :: !ArchOS -> !PlatformWordSize -> !ByteOrder -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Maybe PlatformConstants -> Platform -- | Architecture and OS [platformArchOS] :: Platform -> !ArchOS -- | Word size [platformWordSize] :: Platform -> !PlatformWordSize -- | Byte order (endianness) [platformByteOrder] :: Platform -> !ByteOrder [platformUnregisterised] :: Platform -> !Bool [platformHasGnuNonexecStack] :: Platform -> !Bool [platformHasIdentDirective] :: Platform -> !Bool [platformHasSubsectionsViaSymbols] :: Platform -> !Bool [platformIsCrossCompiling] :: Platform -> !Bool -- | Symbols need underscore prefix [platformLeadingUnderscore] :: Platform -> !Bool -- | Determines whether we will be compiling info tables that reside just -- before the entry code, or with an indirection to the entry code. See -- TABLES_NEXT_TO_CODE in includesrtsstorage/InfoTables.h. [platformTablesNextToCode] :: Platform -> !Bool -- | Constants such as structure offsets, type sizes, etc. [platform_constants] :: Platform -> !Maybe PlatformConstants data PlatformWordSize -- | A 32-bit platform PW4 :: PlatformWordSize -- | A 64-bit platform PW8 :: PlatformWordSize -- | Platform architecture platformArch :: Platform -> Arch -- | Platform OS platformOS :: Platform -> OS -- | Platform architecture and OS. data ArchOS ArchOS :: Arch -> OS -> ArchOS [archOS_arch] :: ArchOS -> Arch [archOS_OS] :: ArchOS -> OS -- | Architectures -- -- TODO: It might be nice to extend these constructors with information -- about what instruction set extensions an architecture might support. data Arch ArchUnknown :: Arch ArchX86 :: Arch ArchX86_64 :: Arch ArchPPC :: Arch ArchPPC_64 :: PPC_64ABI -> Arch ArchS390X :: Arch ArchSPARC :: Arch ArchSPARC64 :: Arch ArchARM :: ArmISA -> [ArmISAExt] -> ArmABI -> Arch ArchAArch64 :: Arch ArchAlpha :: Arch ArchMipseb :: Arch ArchMipsel :: Arch ArchRISCV64 :: Arch ArchJavaScript :: Arch -- | Operating systems. -- -- Using OSUnknown to generate code should produce a sensible default, -- but no promises. data OS OSUnknown :: OS OSLinux :: OS OSDarwin :: OS OSSolaris2 :: OS OSMinGW32 :: OS OSFreeBSD :: OS OSDragonFly :: OS OSOpenBSD :: OS OSNetBSD :: OS OSKFreeBSD :: OS OSHaiku :: OS OSQNXNTO :: OS OSAIX :: OS OSHurd :: OS -- | ARM Instruction Set Architecture data ArmISA ARMv5 :: ArmISA ARMv6 :: ArmISA ARMv7 :: ArmISA -- | ARM extensions data ArmISAExt VFPv2 :: ArmISAExt VFPv3 :: ArmISAExt VFPv3D16 :: ArmISAExt NEON :: ArmISAExt IWMMX2 :: ArmISAExt -- | ARM ABI data ArmABI SOFT :: ArmABI SOFTFP :: ArmABI HARD :: ArmABI -- | PowerPC 64-bit ABI data PPC_64ABI -- | PowerPC64 ELF_V1 :: PPC_64ABI -- | PowerPC64 LE ELF_V2 :: PPC_64ABI -- | Byte ordering. data ByteOrder -- | most-significant-byte occurs in lowest address. BigEndian :: ByteOrder -- | least-significant-byte occurs in lowest address. LittleEndian :: ByteOrder -- | This predicate tells us whether the platform is 32-bit. target32Bit :: Platform -> Bool isARM :: Arch -> Bool -- | This predicate tells us whether the OS supports ELF-like shared -- libraries. osElfTarget :: OS -> Bool -- | This predicate tells us whether the OS support Mach-O shared -- libraries. osMachOTarget :: OS -> Bool osSubsectionsViaSymbols :: OS -> Bool platformUsesFrameworks :: Platform -> Bool platformWordSizeInBytes :: Platform -> Int platformWordSizeInBits :: Platform -> Int -- | Minimum representable Int value for the given platform platformMinInt :: Platform -> Integer -- | Maximum representable Int value for the given platform platformMaxInt :: Platform -> Integer -- | Maximum representable Word value for the given platform platformMaxWord :: Platform -> Integer -- | Test if the given Integer is representable with a platform Int platformInIntRange :: Platform -> Integer -> Bool -- | Test if the given Integer is representable with a platform Word platformInWordRange :: Platform -> Integer -> Bool -- | For some architectures the C calling convention is that any integer -- shorter than 64 bits is replaced by its 64 bits representation using -- sign or zero extension. platformCConvNeedsExtension :: Platform -> Bool -- | Platform-specific settings formerly hard-coded in Config.hs. -- -- These should probably be all be triaged whether they can be computed -- from other settings or belong in another another place (like -- Platform above). data PlatformMisc PlatformMisc :: String -> Bool -> Bool -> String -> Bool -> Bool -> String -> PlatformMisc [platformMisc_targetPlatformString] :: PlatformMisc -> String [platformMisc_ghcWithInterpreter] :: PlatformMisc -> Bool [platformMisc_ghcWithSMP] :: PlatformMisc -> Bool [platformMisc_ghcRTSWays] :: PlatformMisc -> String [platformMisc_libFFI] :: PlatformMisc -> Bool [platformMisc_ghcRtsWithLibdw] :: PlatformMisc -> Bool [platformMisc_llvmTarget] :: PlatformMisc -> String -- | x86 SSE instructions data SseVersion SSE1 :: SseVersion SSE2 :: SseVersion SSE3 :: SseVersion SSE4 :: SseVersion SSE42 :: SseVersion -- | x86 BMI (bit manipulation) instructions data BmiVersion BMI1 :: BmiVersion BMI2 :: BmiVersion data PlatformConstants PlatformConstants :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> !Integer -> !Integer -> !Integer -> PlatformConstants [pc_CONTROL_GROUP_CONST_291] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_STD_HDR_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_PROF_HDR_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_BLOCK_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_BLOCKS_PER_MBLOCK] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_TICKY_BIN_COUNT] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR2] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR3] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR4] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR5] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR6] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR7] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR8] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR9] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR10] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rF1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rF2] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rF3] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rF4] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rF5] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rF6] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rD1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rD2] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rD3] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rD4] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rD5] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rD6] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rXMM1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rXMM2] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rXMM3] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rXMM4] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rXMM5] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rXMM6] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rYMM1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rYMM2] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rYMM3] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rYMM4] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rYMM5] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rYMM6] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rZMM1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rZMM2] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rZMM3] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rZMM4] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rZMM5] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rZMM6] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rL1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rSp] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rSpLim] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rHp] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rHpLim] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rCCCS] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rCurrentTSO] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rCurrentNursery] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rHpAlloc] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_stgEagerBlackholeInfo] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_stgGCEnter1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_stgGCFun] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_Capability_r] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_bdescr_start] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_bdescr_free] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_bdescr_blocks] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_bdescr_flags] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_SIZEOF_CostCentreStack] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_CostCentreStack_mem_alloc] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_REP_CostCentreStack_mem_alloc] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_CostCentreStack_scc_count] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_REP_CostCentreStack_scc_count] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgHeader_ccs] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgHeader_ldvw] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_SIZEOF_StgSMPThunkHeader] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgEntCounter_allocs] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_REP_StgEntCounter_allocs] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgEntCounter_allocd] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_REP_StgEntCounter_allocd] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgEntCounter_registeredp] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgEntCounter_link] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgEntCounter_entry_count] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_SIZEOF_StgUpdateFrame_NoHdr] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_SIZEOF_StgMutArrPtrs_NoHdr] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgMutArrPtrs_ptrs] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgMutArrPtrs_size] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_SIZEOF_StgSmallMutArrPtrs_NoHdr] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgSmallMutArrPtrs_ptrs] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_SIZEOF_StgArrBytes_NoHdr] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgArrBytes_bytes] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgTSO_alloc_limit] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgTSO_cccs] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgTSO_stackobj] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgStack_sp] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgStack_stack] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgUpdateFrame_updatee] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgFunInfoExtraFwd_arity] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_REP_StgFunInfoExtraFwd_arity] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_SIZEOF_StgFunInfoExtraRev] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgFunInfoExtraRev_arity] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_REP_StgFunInfoExtraRev_arity] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_SPEC_SELECTEE_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_SPEC_AP_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MIN_PAYLOAD_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MIN_INTLIKE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_INTLIKE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MIN_CHARLIKE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_CHARLIKE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MUT_ARR_PTRS_CARD_BITS] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Vanilla_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Float_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Double_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Long_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_XMM_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Real_Vanilla_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Real_Float_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Real_Double_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Real_XMM_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Real_Long_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_RESERVED_C_STACK_BYTES] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_RESERVED_STACK_WORDS] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_AP_STACK_SPLIM] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_WORD_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_CINT_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_CLONG_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_CLONG_LONG_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_BITMAP_BITS_SHIFT] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_TAG_BITS] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_LDV_SHIFT] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_ILDV_CREATE_MASK] :: PlatformConstants -> !Integer [pc_ILDV_STATE_CREATE] :: PlatformConstants -> !Integer [pc_ILDV_STATE_USE] :: PlatformConstants -> !Integer -- | Try to locate "DerivedConstants.h" file in the given dirs and to parse -- the PlatformConstants from it. -- -- See Note [Platform constants] lookupPlatformConstants :: [FilePath] -> IO (Maybe PlatformConstants) platformConstants :: Platform -> PlatformConstants platformSOName :: Platform -> FilePath -> FilePath platformHsSOName :: Platform -> FilePath -> FilePath platformSOExt :: Platform -> FilePath genericPlatform :: Platform instance GHC.Classes.Ord GHC.Platform.PlatformWordSize instance GHC.Classes.Eq GHC.Platform.PlatformWordSize instance GHC.Classes.Eq GHC.Platform.Platform instance GHC.Show.Show GHC.Platform.Platform instance GHC.Read.Read GHC.Platform.Platform instance GHC.Classes.Ord GHC.Platform.SseVersion instance GHC.Classes.Eq GHC.Platform.SseVersion instance GHC.Classes.Ord GHC.Platform.BmiVersion instance GHC.Classes.Eq GHC.Platform.BmiVersion instance GHC.Show.Show GHC.Platform.PlatformWordSize instance GHC.Read.Read GHC.Platform.PlatformWordSize -- | Run-time settings module GHC.Settings data Settings Settings :: {-# UNPACK #-} !GhcNameVersion -> {-# UNPACK #-} !FileSettings -> Platform -> {-# UNPACK #-} !ToolSettings -> {-# UNPACK #-} !PlatformMisc -> [(String, String)] -> Settings [sGhcNameVersion] :: Settings -> {-# UNPACK #-} !GhcNameVersion [sFileSettings] :: Settings -> {-# UNPACK #-} !FileSettings [sTargetPlatform] :: Settings -> Platform [sToolSettings] :: Settings -> {-# UNPACK #-} !ToolSettings [sPlatformMisc] :: Settings -> {-# UNPACK #-} !PlatformMisc [sRawSettings] :: Settings -> [(String, String)] -- | Settings for other executables GHC calls. -- -- Probably should further split down by phase, or split between -- platform-specific and platform-agnostic. data ToolSettings ToolSettings :: Bool -> Bool -> Bool -> Bool -> Bool -> String -> (String, [Option]) -> String -> String -> (String, [Option]) -> (String, [Option]) -> (String, [Option]) -> (String, [Option]) -> String -> String -> String -> String -> String -> String -> String -> (String, [Option]) -> (String, [Option]) -> (String, [Option]) -> String -> [String] -> [String] -> Fingerprint -> [String] -> [String] -> [String] -> [String] -> [String] -> [String] -> [String] -> [String] -> [String] -> [String] -> [String] -> [String] -> ToolSettings [toolSettings_ldSupportsCompactUnwind] :: ToolSettings -> Bool [toolSettings_ldSupportsBuildId] :: ToolSettings -> Bool [toolSettings_ldSupportsFilelist] :: ToolSettings -> Bool [toolSettings_ldIsGnuLd] :: ToolSettings -> Bool [toolSettings_ccSupportsNoPie] :: ToolSettings -> Bool [toolSettings_pgm_L] :: ToolSettings -> String [toolSettings_pgm_P] :: ToolSettings -> (String, [Option]) [toolSettings_pgm_F] :: ToolSettings -> String [toolSettings_pgm_c] :: ToolSettings -> String [toolSettings_pgm_a] :: ToolSettings -> (String, [Option]) [toolSettings_pgm_l] :: ToolSettings -> (String, [Option]) [toolSettings_pgm_lm] :: ToolSettings -> (String, [Option]) [toolSettings_pgm_dll] :: ToolSettings -> (String, [Option]) [toolSettings_pgm_T] :: ToolSettings -> String [toolSettings_pgm_windres] :: ToolSettings -> String [toolSettings_pgm_libtool] :: ToolSettings -> String [toolSettings_pgm_ar] :: ToolSettings -> String [toolSettings_pgm_otool] :: ToolSettings -> String [toolSettings_pgm_install_name_tool] :: ToolSettings -> String [toolSettings_pgm_ranlib] :: ToolSettings -> String -- | LLVM: opt llvm optimiser [toolSettings_pgm_lo] :: ToolSettings -> (String, [Option]) -- | LLVM: llc static compiler [toolSettings_pgm_lc] :: ToolSettings -> (String, [Option]) -- | LLVM: c compiler [toolSettings_pgm_lcc] :: ToolSettings -> (String, [Option]) [toolSettings_pgm_i] :: ToolSettings -> String [toolSettings_opt_L] :: ToolSettings -> [String] [toolSettings_opt_P] :: ToolSettings -> [String] -- | cached Fingerprint of sOpt_P See Note [Repeated -optP hashing] [toolSettings_opt_P_fingerprint] :: ToolSettings -> Fingerprint [toolSettings_opt_F] :: ToolSettings -> [String] [toolSettings_opt_c] :: ToolSettings -> [String] [toolSettings_opt_cxx] :: ToolSettings -> [String] [toolSettings_opt_a] :: ToolSettings -> [String] [toolSettings_opt_l] :: ToolSettings -> [String] [toolSettings_opt_lm] :: ToolSettings -> [String] [toolSettings_opt_windres] :: ToolSettings -> [String] -- | LLVM: llvm optimiser [toolSettings_opt_lo] :: ToolSettings -> [String] -- | LLVM: llc static compiler [toolSettings_opt_lc] :: ToolSettings -> [String] -- | LLVM: c compiler [toolSettings_opt_lcc] :: ToolSettings -> [String] -- | iserv options [toolSettings_opt_i] :: ToolSettings -> [String] [toolSettings_extraGccViaCFlags] :: ToolSettings -> [String] -- | Paths to various files and directories used by GHC, including those -- that provide more settings. data FileSettings FileSettings :: FilePath -> FilePath -> Maybe FilePath -> FilePath -> String -> FilePath -> FileSettings [fileSettings_ghcUsagePath] :: FileSettings -> FilePath [fileSettings_ghciUsagePath] :: FileSettings -> FilePath [fileSettings_toolDir] :: FileSettings -> Maybe FilePath [fileSettings_topDir] :: FileSettings -> FilePath [fileSettings_tmpDir] :: FileSettings -> String [fileSettings_globalPackageDatabase] :: FileSettings -> FilePath -- | Settings for what GHC this is. data GhcNameVersion GhcNameVersion :: String -> String -> GhcNameVersion [ghcNameVersion_programName] :: GhcNameVersion -> String [ghcNameVersion_projectVersion] :: GhcNameVersion -> String -- | Platform description -- -- This is used to describe platforms so that we can generate code for -- them. data Platform Platform :: !ArchOS -> !PlatformWordSize -> !ByteOrder -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Maybe PlatformConstants -> Platform -- | Architecture and OS [platformArchOS] :: Platform -> !ArchOS -- | Word size [platformWordSize] :: Platform -> !PlatformWordSize -- | Byte order (endianness) [platformByteOrder] :: Platform -> !ByteOrder [platformUnregisterised] :: Platform -> !Bool [platformHasGnuNonexecStack] :: Platform -> !Bool [platformHasIdentDirective] :: Platform -> !Bool [platformHasSubsectionsViaSymbols] :: Platform -> !Bool [platformIsCrossCompiling] :: Platform -> !Bool -- | Symbols need underscore prefix [platformLeadingUnderscore] :: Platform -> !Bool -- | Determines whether we will be compiling info tables that reside just -- before the entry code, or with an indirection to the entry code. See -- TABLES_NEXT_TO_CODE in includesrtsstorage/InfoTables.h. [platformTablesNextToCode] :: Platform -> !Bool -- | Constants such as structure offsets, type sizes, etc. [platform_constants] :: Platform -> !Maybe PlatformConstants -- | Platform-specific settings formerly hard-coded in Config.hs. -- -- These should probably be all be triaged whether they can be computed -- from other settings or belong in another another place (like -- Platform above). data PlatformMisc PlatformMisc :: String -> Bool -> Bool -> String -> Bool -> Bool -> String -> PlatformMisc [platformMisc_targetPlatformString] :: PlatformMisc -> String [platformMisc_ghcWithInterpreter] :: PlatformMisc -> Bool [platformMisc_ghcWithSMP] :: PlatformMisc -> Bool [platformMisc_ghcRTSWays] :: PlatformMisc -> String [platformMisc_libFFI] :: PlatformMisc -> Bool [platformMisc_ghcRtsWithLibdw] :: PlatformMisc -> Bool [platformMisc_llvmTarget] :: PlatformMisc -> String -- | Dynamic library suffix dynLibSuffix :: GhcNameVersion -> String sProgramName :: Settings -> String sProjectVersion :: Settings -> String sGhcUsagePath :: Settings -> FilePath sGhciUsagePath :: Settings -> FilePath sToolDir :: Settings -> Maybe FilePath sTopDir :: Settings -> FilePath sTmpDir :: Settings -> String sGlobalPackageDatabasePath :: Settings -> FilePath sLdSupportsCompactUnwind :: Settings -> Bool sLdSupportsBuildId :: Settings -> Bool sLdSupportsFilelist :: Settings -> Bool sLdIsGnuLd :: Settings -> Bool sGccSupportsNoPie :: Settings -> Bool sPgm_L :: Settings -> String sPgm_P :: Settings -> (String, [Option]) sPgm_F :: Settings -> String sPgm_c :: Settings -> String sPgm_a :: Settings -> (String, [Option]) sPgm_l :: Settings -> (String, [Option]) sPgm_lm :: Settings -> (String, [Option]) sPgm_dll :: Settings -> (String, [Option]) sPgm_T :: Settings -> String sPgm_windres :: Settings -> String sPgm_libtool :: Settings -> String sPgm_ar :: Settings -> String sPgm_otool :: Settings -> String sPgm_install_name_tool :: Settings -> String sPgm_ranlib :: Settings -> String sPgm_lo :: Settings -> (String, [Option]) sPgm_lc :: Settings -> (String, [Option]) sPgm_lcc :: Settings -> (String, [Option]) sPgm_i :: Settings -> String sOpt_L :: Settings -> [String] sOpt_P :: Settings -> [String] sOpt_P_fingerprint :: Settings -> Fingerprint sOpt_F :: Settings -> [String] sOpt_c :: Settings -> [String] sOpt_cxx :: Settings -> [String] sOpt_a :: Settings -> [String] sOpt_l :: Settings -> [String] sOpt_lm :: Settings -> [String] sOpt_windres :: Settings -> [String] sOpt_lo :: Settings -> [String] sOpt_lc :: Settings -> [String] sOpt_lcc :: Settings -> [String] sOpt_i :: Settings -> [String] sExtraGccViaCFlags :: Settings -> [String] sTargetPlatformString :: Settings -> String sGhcWithInterpreter :: Settings -> Bool sGhcWithSMP :: Settings -> Bool sGhcRTSWays :: Settings -> String sLibFFI :: Settings -> Bool sGhcRtsWithLibdw :: Settings -> Bool -- | Code generation backends module GHC.Driver.Backend -- | Code generation backends. -- -- GHC supports several code generation backends serving different -- purposes (producing machine code, producing ByteCode for the -- interpreter) and supporting different platforms. data Backend -- | Native code generator backend. -- -- Compiles Cmm code into textual assembler, then relies on an external -- assembler toolchain to produce machine code. -- -- Only supports a few platforms (X86, PowerPC, SPARC). -- -- See GHC.CmmToAsm. NCG :: Backend -- | LLVM backend. -- -- Compiles Cmm code into LLVM textual IR, then relies on LLVM toolchain -- to produce machine code. -- -- It relies on LLVM support for the calling convention used by the NCG -- backend to produce code objects ABI compatible with it (see "cc 10" or -- "ghccc" calling convention in -- https://llvm.org/docs/LangRef.html#calling-conventions). -- -- Support a few platforms (X86, AArch64, s390x, ARM). -- -- See GHC.CmmToLlvm LLVM :: Backend -- | Via-C backend. -- -- Compiles Cmm code into C code, then relies on a C compiler to produce -- machine code. -- -- It produces code objects that are *not* ABI compatible with those -- produced by NCG and LLVM backends. -- -- Produced code is expected to be less efficient than the one produced -- by NCG and LLVM backends because STG registers are not pinned into -- real registers. On the other hand, it supports more target platforms -- (those having a valid C toolchain). -- -- See GHC.CmmToC ViaC :: Backend -- | ByteCode interpreter. -- -- Produce ByteCode objects (BCO, see GHC.ByteCode) that can be -- interpreted. It is used by GHCi. -- -- Currently some extensions are not supported (foreign primops). -- -- See GHC.StgToByteCode Interpreter :: Backend -- | No code generated. -- -- Use this to disable code generation. It is particularly useful when -- GHC is used as a library for other purpose than generating code (e.g. -- to generate documentation with Haddock) or when the user requested it -- (via -fno-code) for some reason. NoBackend :: Backend -- | Default backend to use for the given platform. platformDefaultBackend :: Platform -> Backend -- | Is the platform supported by the Native Code Generator? platformNcgSupported :: Platform -> Bool -- | Will this backend produce an object file on the disk? backendProducesObject :: Backend -> Bool -- | Does this backend retain *all* top-level bindings for a module, rather -- than just the exported bindings, in the TypeEnv and compiled code (if -- any)? -- -- Interpreter backend does this, so that GHCi can call functions inside -- a module. -- -- When no backend is used we also do it, so that Haddock can get access -- to the GlobalRdrEnv for a module after typechecking it. backendRetainsAllBindings :: Backend -> Bool instance GHC.Read.Read GHC.Driver.Backend.Backend instance GHC.Show.Show GHC.Driver.Backend.Backend instance GHC.Classes.Ord GHC.Driver.Backend.Backend instance GHC.Classes.Eq GHC.Driver.Backend.Backend -- | There are two principal string types used internally by GHC: -- --
-- text "hi" $$ nest 5 (text "there") ---- -- lays out as -- --
-- hi there ---- -- rather than -- --
-- hi -- there ---- -- $$ is associative, with identity empty, and also -- satisfies -- -- ($$) :: Doc -> Doc -> Doc infixl 5 $$ -- | Above, with no overlapping. $+$ is associative, with identity -- empty. ($+$) :: Doc -> Doc -> Doc infixl 5 $+$ -- | List version of $$. vcat :: [Doc] -> Doc -- | Either hsep or vcat. sep :: [Doc] -> Doc -- | Either hcat or vcat. cat :: [Doc] -> Doc -- | "Paragraph fill" version of sep. fsep :: [Doc] -> Doc -- | "Paragraph fill" version of cat. fcat :: [Doc] -> Doc -- | Nest (or indent) a document by a given number of positions (which may -- also be negative). nest satisfies the laws: -- --
nest 0 x = x
nest k (nest k' x) = nest (k+k') -- x
nest k (x <> y) = nest k z -- <> nest k y
nest k (x $$ y) = nest k x $$ -- nest k y
nest k empty = empty
-- hang d1 n d2 = sep [d1, nest n d2] --hang :: Doc -> Int -> Doc -> Doc -- | Apply hang to the arguments if the first Doc is not -- empty. hangNotEmpty :: Doc -> Int -> Doc -> Doc -- |
-- punctuate p [d1, ... dn] = [d1 <> p, d2 <> p, ... dn-1 <> p, dn] --punctuate :: Doc -> [Doc] -> [Doc] -- | Returns True if the document is empty isEmpty :: Doc -> Bool -- | A rendering style. data Style Style :: Mode -> Int -> Float -> Style -- | The rendering mode [mode] :: Style -> Mode -- | Length of line, in chars [lineLength] :: Style -> Int -- | Ratio of line length to ribbon length [ribbonsPerLine] :: Style -> Float -- | The default style (mode=PageMode False, lineLength=100, -- ribbonsPerLine=1.5). style :: Style -- | Render the Doc to a String using the given Style. renderStyle :: Style -> Doc -> String -- | Rendering mode. data Mode -- | Normal PageMode :: Bool -> Mode [asciiSpace] :: Mode -> Bool -- | With zig-zag cuts ZigZagMode :: Mode -- | No indentation, infinitely long lines LeftMode :: Mode -- | All on one line OneLineMode :: Mode -- | The general rendering interface. fullRender :: Mode -> Int -> Float -> (TextDetails -> a -> a) -> a -> Doc -> a -- | Default TextDetails printer txtPrinter :: TextDetails -> String -> String printDoc :: Mode -> Int -> Handle -> Doc -> IO () printDoc_ :: Mode -> Int -> Handle -> Doc -> IO () bufLeftRender :: BufHandle -> Doc -> IO () instance GHC.Show.Show GHC.Utils.Ppr.Doc module GHC.Utils.Ppr.Colour -- | A colour/style for use with coloured. newtype PprColour PprColour :: String -> PprColour [renderColour] :: PprColour -> String renderColourAfresh :: PprColour -> String colCustom :: String -> PprColour colReset :: PprColour colBold :: PprColour colBlackFg :: PprColour colRedFg :: PprColour colGreenFg :: PprColour colYellowFg :: PprColour colBlueFg :: PprColour colMagentaFg :: PprColour colCyanFg :: PprColour colWhiteFg :: PprColour data Scheme Scheme :: PprColour -> PprColour -> PprColour -> PprColour -> PprColour -> PprColour -> Scheme [sHeader] :: Scheme -> PprColour [sMessage] :: Scheme -> PprColour [sWarning] :: Scheme -> PprColour [sError] :: Scheme -> PprColour [sFatal] :: Scheme -> PprColour [sMargin] :: Scheme -> PprColour defaultScheme :: Scheme -- | Parse the colour scheme from a string (presumably from the -- GHC_COLORS environment variable). parseScheme :: String -> (OverridingBool, Scheme) -> (OverridingBool, Scheme) instance GHC.Base.Semigroup GHC.Utils.Ppr.Colour.PprColour instance GHC.Base.Monoid GHC.Utils.Ppr.Colour.PprColour module Language.Haskell.Syntax.Type -- | Mult is a type alias for Type. -- -- Mult must contain Type because multiplicity variables are mere type -- variables (of kind Multiplicity) in Haskell. So the simplest -- implementation is to make Mult be Type. -- -- Multiplicities can be formed with: - One: GHC.Types.One (= oneDataCon) -- - Many: GHC.Types.Many (= manyDataCon) - Multiplication: -- GHC.Types.MultMul (= multMulTyCon) -- -- So that Mult feels a bit more structured, we provide pattern synonyms -- and smart constructors for these. type Mult = Type -- | This is used in the syntax. In constructor declaration. It must keep -- the arrow representation. data HsScaled pass a HsScaled :: HsArrow pass -> a -> HsScaled pass a hsMult :: HsScaled pass a -> HsArrow pass hsScaledThing :: HsScaled pass a -> a -- | Denotes the type of arrows in the surface language data HsArrow pass -- | a -> b or a → b HsUnrestrictedArrow :: IsUnicodeSyntax -> HsArrow pass -- | a %1 -> b or a %1 → b, or a ⊸ b HsLinearArrow :: IsUnicodeSyntax -> Maybe AddEpAnn -> HsArrow pass -- | a %m -> b or a %m → b (very much including `a %Many -> b`! This -- is how the programmer wrote it). It is stored as an HsType so -- as to preserve the syntax as written in the program. HsExplicitMult :: IsUnicodeSyntax -> Maybe AddEpAnn -> LHsType pass -> HsArrow pass -- | When creating syntax we use the shorthands. It's better for printing, -- also, the shorthands work trivially at each pass. hsLinear :: a -> HsScaled pass a -- | When creating syntax we use the shorthands. It's better for printing, -- also, the shorthands work trivially at each pass. hsUnrestricted :: a -> HsScaled pass a -- | Haskell Type data HsType pass -- |
-- (?x :: ty) ---- --
-- (ty :: kind) ---- --
-- type instance forall a. F [a] = Tree a ---- -- The notion of specificity is irrelevant in type family equations, so -- we use () for the HsOuterTyVarBndrs flag. type HsOuterFamEqnTyVarBndrs = HsOuterTyVarBndrs () -- | Used for signatures, e.g., -- --
-- f :: forall a {b}. blah
--
--
-- We use Specificity for the HsOuterTyVarBndrs
-- flag to allow distinguishing between specified and inferred
-- type variables.
type HsOuterSigTyVarBndrs = HsOuterTyVarBndrs Specificity
-- | Haskell Wildcard Binders
data HsWildCardBndrs pass thing
HsWC :: XHsWC pass thing -> thing -> HsWildCardBndrs pass thing
[hswc_ext] :: HsWildCardBndrs pass thing -> XHsWC pass thing
[hswc_body] :: HsWildCardBndrs pass thing -> thing
XHsWildCardBndrs :: !XXHsWildCardBndrs pass thing -> HsWildCardBndrs pass thing
-- | Types that can appear in pattern signatures, as well as the signatures
-- for term-level binders in RULES. See Note [Pattern signature
-- binders and scoping].
--
-- This is very similar to HsSigWcType, but with slightly
-- different semantics: see Note [HsType binders]. See also
-- Note [The wildcard story for types].
data HsPatSigType pass
HsPS :: XHsPS pass -> LHsType pass -> HsPatSigType pass
-- | After renamer: HsPSRn
[hsps_ext] :: HsPatSigType pass -> XHsPS pass
-- | Main payload (the type itself)
[hsps_body] :: HsPatSigType pass -> LHsType pass
XHsPatSigType :: !XXHsPatSigType pass -> HsPatSigType pass
-- | The extension field for HsPatSigType, which is only used in the
-- renamer onwards. See Note [Pattern signature binders and
-- scoping].
data HsPSRn
HsPSRn :: [Name] -> [Name] -> HsPSRn
-- | Wildcard names
[hsps_nwcs] :: HsPSRn -> [Name]
-- | Implicitly bound variable names
[hsps_imp_tvs] :: HsPSRn -> [Name]
-- | A type signature that obeys the forall-or-nothing rule. In
-- other words, an LHsType that uses an
-- HsOuterSigTyVarBndrs to represent its outermost type variable
-- quantification. See Note [Representing type signatures].
data HsSigType pass
HsSig :: XHsSig pass -> HsOuterSigTyVarBndrs pass -> LHsType pass -> HsSigType pass
[sig_ext] :: HsSigType pass -> XHsSig pass
[sig_bndrs] :: HsSigType pass -> HsOuterSigTyVarBndrs pass
[sig_body] :: HsSigType pass -> LHsType pass
XHsSigType :: !XXHsSigType pass -> HsSigType pass
-- | Located Haskell Signature Type
type LHsSigType pass = XRec pass (HsSigType pass)
-- | Located Haskell Signature Wildcard Type
type LHsSigWcType pass = HsWildCardBndrs pass (LHsSigType pass)
-- | Located Haskell Wildcard Type
type LHsWcType pass = HsWildCardBndrs pass (LHsType pass)
-- | Haskell Tuple Sort
data HsTupleSort
HsUnboxedTuple :: HsTupleSort
HsBoxedOrConstraintTuple :: HsTupleSort
-- | Haskell Context
type HsContext pass = [LHsType pass]
-- | Located Haskell Context
type LHsContext pass = XRec pass (HsContext pass) " 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnUnit' For details on above see note [exact print annotations] in GHC.Parser.Annotation"
-- | Haskell Type Literal
data HsTyLit
HsNumTy :: SourceText -> Integer -> HsTyLit
HsStrTy :: SourceText -> FastString -> HsTyLit
HsCharTy :: SourceText -> Char -> HsTyLit
-- | These names are used early on to store the names of implicit
-- parameters. They completely disappear after type-checking.
newtype HsIPName
HsIPName :: FastString -> HsIPName
hsIPNameFS :: HsIPName -> FastString
data HsArg tm ty
HsValArg :: tm -> HsArg tm ty
HsTypeArg :: SrcSpan -> ty -> HsArg tm ty
HsArgPar :: SrcSpan -> HsArg tm ty
numVisibleArgs :: [HsArg tm ty] -> Arity
type LHsTypeArg p = HsArg (LHsType p) (LHsKind p)
-- | Located Bang Type
type LBangType pass = XRec pass (BangType pass)
-- | Bang Type
--
-- In the parser, strictness and packedness annotations bind more tightly
-- than docstrings. This means that when consuming a BangType (and
-- looking for HsBangTy) we must be ready to peer behind a
-- potential layer of HsDocTy. See #15206 for motivation and
-- getBangType for an example.
type BangType pass = HsType pass
-- | Haskell Source Bang
--
-- Bangs on data constructor arguments as the user wrote them in the
-- source code.
--
-- (HsSrcBang _ SrcUnpack SrcLazy) and (HsSrcBang _
-- SrcUnpack NoSrcStrict) (without StrictData) makes no sense, we
-- emit a warning (in checkValidDataCon) and treat it like (HsSrcBang
-- _ NoSrcUnpack SrcLazy)
data HsSrcBang
HsSrcBang :: SourceText -> SrcUnpackedness -> SrcStrictness -> HsSrcBang
-- | Haskell Implementation Bang
--
-- Bangs of data constructor arguments as generated by the compiler after
-- consulting HsSrcBang, flags, etc.
data HsImplBang
-- | Lazy field, or one with an unlifted type
HsLazy :: HsImplBang
-- | Strict but not unpacked field
HsStrict :: HsImplBang
-- | Strict and unpacked field co :: arg-ty ~ product-ty HsBang
HsUnpack :: Maybe Coercion -> HsImplBang
-- | Source Strictness
--
-- What strictness annotation the user wrote
data SrcStrictness
-- | Lazy, ie ~
SrcLazy :: SrcStrictness
-- | Strict, ie !
SrcStrict :: SrcStrictness
-- | no strictness annotation
NoSrcStrict :: SrcStrictness
-- | Source Unpackedness
--
-- What unpackedness the user requested
data SrcUnpackedness
-- | {-# UNPACK #-} specified
SrcUnpack :: SrcUnpackedness
-- | {-# NOUNPACK #-} specified
SrcNoUnpack :: SrcUnpackedness
-- | no unpack pragma
NoSrcUnpack :: SrcUnpackedness
-- | Constructor Declaration Field
data ConDeclField pass
ConDeclField :: XConDeclField pass -> [LFieldOcc pass] -> LBangType pass -> Maybe LHsDocString -> ConDeclField pass
[cd_fld_ext] :: ConDeclField pass -> XConDeclField pass
-- | See Note [ConDeclField passs]
[cd_fld_names] :: ConDeclField pass -> [LFieldOcc pass]
[cd_fld_type] :: ConDeclField pass -> LBangType pass
-- | -- [x,y,z] ==> `x', `y', `z' --pprQuotedList :: Outputable a => [a] -> SDoc pprWithCommas :: (a -> SDoc) -> [a] -> SDoc quotedListWithOr :: [SDoc] -> SDoc quotedListWithNor :: [SDoc] -> SDoc pprWithBars :: (a -> SDoc) -> [a] -> SDoc empty :: SDoc isEmpty :: SDocContext -> SDoc -> Bool -- | Indent SDoc some specified amount nest :: Int -> SDoc -> SDoc char :: Char -> SDoc text :: String -> SDoc ftext :: FastString -> SDoc ptext :: PtrString -> SDoc ztext :: FastZString -> SDoc int :: Int -> SDoc intWithCommas :: Integral a => a -> SDoc integer :: Integer -> SDoc word :: Integer -> SDoc float :: Float -> SDoc double :: Double -> SDoc rational :: Rational -> SDoc -- | doublePrec p n shows a floating point number n with -- p digits of precision after the decimal point. doublePrec :: Int -> Double -> SDoc parens :: SDoc -> SDoc cparen :: Bool -> SDoc -> SDoc brackets :: SDoc -> SDoc braces :: SDoc -> SDoc quotes :: SDoc -> SDoc quote :: SDoc -> SDoc doubleQuotes :: SDoc -> SDoc angleBrackets :: SDoc -> SDoc semi :: SDoc comma :: SDoc colon :: SDoc dcolon :: SDoc space :: SDoc equals :: SDoc dot :: SDoc vbar :: SDoc arrow :: SDoc lollipop :: SDoc larrow :: SDoc darrow :: SDoc arrowt :: SDoc larrowt :: SDoc arrowtt :: SDoc larrowtt :: SDoc lambda :: SDoc lparen :: SDoc rparen :: SDoc lbrack :: SDoc rbrack :: SDoc lbrace :: SDoc rbrace :: SDoc underscore :: SDoc mulArrow :: SDoc -> SDoc blankLine :: SDoc forAllLit :: SDoc bullet :: SDoc -- | Join two SDoc together horizontally without a gap (<>) :: SDoc -> SDoc -> SDoc -- | Join two SDoc together horizontally with a gap between them (<+>) :: SDoc -> SDoc -> SDoc -- | Concatenate SDoc horizontally hcat :: [SDoc] -> SDoc -- | Concatenate SDoc horizontally with a space between each one hsep :: [SDoc] -> SDoc -- | Join two SDoc together vertically; if there is no vertical -- overlap it "dovetails" the two onto one line ($$) :: SDoc -> SDoc -> SDoc -- | Join two SDoc together vertically ($+$) :: SDoc -> SDoc -> SDoc -- | Concatenate SDoc vertically with dovetailing vcat :: [SDoc] -> SDoc -- | Separate: is either like hsep or like vcat, depending on -- what fits sep :: [SDoc] -> SDoc -- | Catenate: is either like hcat or like vcat, depending on -- what fits cat :: [SDoc] -> SDoc -- | A paragraph-fill combinator. It's much like sep, only it keeps fitting -- things on one line until it can't fit any more. fsep :: [SDoc] -> SDoc -- | This behaves like fsep, but it uses <> for -- horizontal conposition rather than <+> fcat :: [SDoc] -> SDoc hang :: SDoc -> Int -> SDoc -> SDoc -- | This behaves like hang, but does not indent the second document -- when the header is empty. hangNotEmpty :: SDoc -> Int -> SDoc -> SDoc punctuate :: SDoc -> [SDoc] -> [SDoc] ppWhen :: Bool -> SDoc -> SDoc ppUnless :: Bool -> SDoc -> SDoc ppWhenOption :: (SDocContext -> Bool) -> SDoc -> SDoc ppUnlessOption :: (SDocContext -> Bool) -> SDoc -> SDoc -- | Converts an integer to a verbal index: -- --
-- speakNth 1 = text "first" -- speakNth 5 = text "fifth" -- speakNth 21 = text "21st" --speakNth :: Int -> SDoc -- | Converts an integer to a verbal multiplicity: -- --
-- speakN 0 = text "none" -- speakN 5 = text "five" -- speakN 10 = text "10" --speakN :: Int -> SDoc -- | Converts an integer and object description to a statement about the -- multiplicity of those objects: -- --
-- speakNOf 0 (text "melon") = text "no melons" -- speakNOf 1 (text "melon") = text "one melon" -- speakNOf 3 (text "melon") = text "three melons" --speakNOf :: Int -> SDoc -> SDoc -- | Determines the pluralisation suffix appropriate for the length of a -- list: -- --
-- plural [] = char 's' -- plural ["Hello"] = empty -- plural ["Hello", "World"] = char 's' --plural :: [a] -> SDoc -- | Determines the form of to be appropriate for the length of a list: -- --
-- isOrAre [] = text "are" -- isOrAre ["Hello"] = text "is" -- isOrAre ["Hello", "World"] = text "are" --isOrAre :: [a] -> SDoc -- | Determines the form of to do appropriate for the length of a list: -- --
-- doOrDoes [] = text "do" -- doOrDoes ["Hello"] = text "does" -- doOrDoes ["Hello", "World"] = text "do" --doOrDoes :: [a] -> SDoc -- | Determines the form of possessive appropriate for the length of a -- list: -- --
-- itsOrTheir [x] = text "its" -- itsOrTheir [x,y] = text "their" -- itsOrTheir [] = text "their" -- probably avoid this --itsOrTheir :: [a] -> SDoc unicodeSyntax :: SDoc -> SDoc -> SDoc -- | Apply the given colour/style for the argument. -- -- Only takes effect if colours are enabled. coloured :: PprColour -> SDoc -> SDoc keyword :: SDoc -> SDoc -- | The analog of printDoc_ for SDoc, which tries to make -- sure the terminal doesn't get screwed up by the ANSI color codes if an -- exception is thrown during pretty-printing. printSDoc :: SDocContext -> Mode -> Handle -> SDoc -> IO () -- | Like printSDoc but appends an extra newline. printSDocLn :: SDocContext -> Mode -> Handle -> SDoc -> IO () -- | An efficient variant of printSDoc specialized for -- LeftMode that outputs to a BufHandle. bufLeftRenderSDoc :: SDocContext -> BufHandle -> SDoc -> IO () pprCode :: LabelStyle -> SDoc -> SDoc showSDocUnsafe :: SDoc -> String showPprUnsafe :: Outputable a => a -> String showSDocOneLine :: SDocContext -> SDoc -> String renderWithContext :: SDocContext -> SDoc -> String pprInfixVar :: Bool -> SDoc -> SDoc pprPrefixVar :: Bool -> SDoc -> SDoc -- | Special combinator for showing character literals. pprHsChar :: Char -> SDoc -- | Special combinator for showing string literals. pprHsString :: FastString -> SDoc -- | Special combinator for showing bytestring literals. pprHsBytes :: ByteString -> SDoc primFloatSuffix :: SDoc primCharSuffix :: SDoc primDoubleSuffix :: SDoc primInt8Suffix :: SDoc primWord8Suffix :: SDoc primInt16Suffix :: SDoc primWord16Suffix :: SDoc primInt32Suffix :: SDoc primWord32Suffix :: SDoc primInt64Suffix :: SDoc primWord64Suffix :: SDoc primIntSuffix :: SDoc primWordSuffix :: SDoc -- | Special combinator for showing unboxed literals. pprPrimChar :: Char -> SDoc pprPrimInt :: Integer -> SDoc pprPrimWord :: Integer -> SDoc pprPrimInt8 :: Integer -> SDoc pprPrimWord8 :: Integer -> SDoc pprPrimInt16 :: Integer -> SDoc pprPrimWord16 :: Integer -> SDoc pprPrimInt32 :: Integer -> SDoc pprPrimWord32 :: Integer -> SDoc pprPrimInt64 :: Integer -> SDoc pprPrimWord64 :: Integer -> SDoc pprFastFilePath :: FastString -> SDoc -- | Normalise, escape and render a string representing a path -- -- e.g. "c:\whatever" pprFilePathString :: FilePath -> SDoc -- | BindingSite is used to tell the thing that prints binder what -- language construct is binding the identifier. This can be used to -- decide how much info to print. Also see Note [Binding-site specific -- printing] in GHC.Core.Ppr data BindingSite -- | The x in (x. e) LambdaBind :: BindingSite -- | The x in case scrut of x { (y,z) -> ... } CaseBind :: BindingSite -- | The y,z in case scrut of x { (y,z) -> ... } CasePatBind :: BindingSite -- | The x in (let x = rhs in e) LetBind :: BindingSite data PprStyle PprUser :: PrintUnqualified -> Depth -> Coloured -> PprStyle PprDump :: PrintUnqualified -> PprStyle -- | Print code; either C or assembler PprCode :: LabelStyle -> PprStyle -- | Style of label pretty-printing. -- -- When we produce C sources or headers, we have to take into account -- that C compilers transform C labels when they convert them into -- symbols. For example, they can add prefixes (e.g., "_" on Darwin) or -- suffixes (size for stdcalls on Windows). So we provide two ways to -- pretty-print CLabels: C style or Asm style. data LabelStyle -- | C label style (used by C and LLVM backends) CStyle :: LabelStyle -- | Asm label style (used by NCG backend) AsmStyle :: LabelStyle -- | When printing code that contains original names, we need to map the -- original names back to something the user understands. This is the -- purpose of the triple of functions that gets passed around when -- rendering SDoc. data PrintUnqualified QueryQualify :: QueryQualifyName -> QueryQualifyModule -> QueryQualifyPackage -> PrintUnqualified [queryQualifyName] :: PrintUnqualified -> QueryQualifyName [queryQualifyModule] :: PrintUnqualified -> QueryQualifyModule [queryQualifyPackage] :: PrintUnqualified -> QueryQualifyPackage -- | Given a Name's Module and OccName, decide -- whether and how to qualify it. type QueryQualifyName = Module -> OccName -> QualifyName -- | For a given module, we need to know whether to print it with a package -- name to disambiguate it. type QueryQualifyModule = Module -> Bool -- | For a given package, we need to know whether to print it with the -- component id to disambiguate it. type QueryQualifyPackage = Unit -> Bool reallyAlwaysQualify :: PrintUnqualified reallyAlwaysQualifyNames :: QueryQualifyName alwaysQualify :: PrintUnqualified -- | NB: This won't ever show package IDs alwaysQualifyNames :: QueryQualifyName alwaysQualifyModules :: QueryQualifyModule neverQualify :: PrintUnqualified neverQualifyNames :: QueryQualifyName neverQualifyModules :: QueryQualifyModule alwaysQualifyPackages :: QueryQualifyPackage neverQualifyPackages :: QueryQualifyPackage data QualifyName NameUnqual :: QualifyName NameQual :: ModuleName -> QualifyName NameNotInScope1 :: QualifyName NameNotInScope2 :: QualifyName queryQual :: PprStyle -> PrintUnqualified sdocOption :: (SDocContext -> a) -> (a -> SDoc) -> SDoc updSDocContext :: (SDocContext -> SDocContext) -> SDoc -> SDoc data SDocContext SDC :: !PprStyle -> !Scheme -> !PprColour -> !Bool -> !Int -> !Int -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !FastString -> SDoc -> SDocContext [sdocStyle] :: SDocContext -> !PprStyle [sdocColScheme] :: SDocContext -> !Scheme -- | The most recently used colour. This allows nesting colours. [sdocLastColour] :: SDocContext -> !PprColour [sdocShouldUseColor] :: SDocContext -> !Bool [sdocDefaultDepth] :: SDocContext -> !Int [sdocLineLength] :: SDocContext -> !Int -- | True if Unicode encoding is supported and not disable by -- GHC_NO_UNICODE environment variable [sdocCanUseUnicode] :: SDocContext -> !Bool [sdocHexWordLiterals] :: SDocContext -> !Bool [sdocPprDebug] :: SDocContext -> !Bool [sdocPrintUnicodeSyntax] :: SDocContext -> !Bool [sdocPrintCaseAsLet] :: SDocContext -> !Bool [sdocPrintTypecheckerElaboration] :: SDocContext -> !Bool [sdocPrintAxiomIncomps] :: SDocContext -> !Bool [sdocPrintExplicitKinds] :: SDocContext -> !Bool [sdocPrintExplicitCoercions] :: SDocContext -> !Bool [sdocPrintExplicitRuntimeReps] :: SDocContext -> !Bool [sdocPrintExplicitForalls] :: SDocContext -> !Bool [sdocPrintPotentialInstances] :: SDocContext -> !Bool [sdocPrintEqualityRelations] :: SDocContext -> !Bool [sdocSuppressTicks] :: SDocContext -> !Bool [sdocSuppressTypeSignatures] :: SDocContext -> !Bool [sdocSuppressTypeApplications] :: SDocContext -> !Bool [sdocSuppressIdInfo] :: SDocContext -> !Bool [sdocSuppressCoercions] :: SDocContext -> !Bool [sdocSuppressUnfoldings] :: SDocContext -> !Bool [sdocSuppressVarKinds] :: SDocContext -> !Bool [sdocSuppressUniques] :: SDocContext -> !Bool [sdocSuppressModulePrefixes] :: SDocContext -> !Bool [sdocSuppressStgExts] :: SDocContext -> !Bool [sdocErrorSpans] :: SDocContext -> !Bool [sdocStarIsType] :: SDocContext -> !Bool [sdocLinearTypes] :: SDocContext -> !Bool [sdocImpredicativeTypes] :: SDocContext -> !Bool [sdocPrintTypeAbbreviations] :: SDocContext -> !Bool -- | Used to map UnitIds to more friendly "package-version:component" -- strings while pretty-printing. -- -- Use pprWithUnitState to set it. Users should never have to set -- it to pretty-print SDocs emitted by GHC, otherwise it's a bug. It's an -- internal field used to thread the UnitState so that the Outputable -- instance of UnitId can use it. -- -- See Note [Pretty-printing UnitId] in GHC.Unit for more details. -- -- Note that we use FastString instead of UnitId to avoid -- boring module inter-dependency issues. [sdocUnitIdForUser] :: SDocContext -> !FastString -> SDoc sdocWithContext :: (SDocContext -> SDoc) -> SDoc -- | Default pretty-printing options defaultSDocContext :: SDocContext getPprStyle :: (PprStyle -> SDoc) -> SDoc withPprStyle :: PprStyle -> SDoc -> SDoc setStyleColoured :: Bool -> PprStyle -> PprStyle pprDeeper :: SDoc -> SDoc -- | Truncate a list that is longer than the current depth. pprDeeperList :: ([SDoc] -> SDoc) -> [SDoc] -> SDoc pprSetDepth :: Depth -> SDoc -> SDoc codeStyle :: PprStyle -> Bool userStyle :: PprStyle -> Bool dumpStyle :: PprStyle -> Bool asmStyle :: PprStyle -> Bool qualName :: PprStyle -> QueryQualifyName qualModule :: PprStyle -> QueryQualifyModule qualPackage :: PprStyle -> QueryQualifyPackage -- | Style for printing error messages mkErrStyle :: PrintUnqualified -> PprStyle -- | Default style for error messages, when we don't know PrintUnqualified -- It's a bit of a hack because it doesn't take into account what's in -- scope Only used for desugarer warnings, and typechecker errors in -- interface sigs defaultErrStyle :: PprStyle defaultDumpStyle :: PprStyle mkDumpStyle :: PrintUnqualified -> PprStyle defaultUserStyle :: PprStyle mkUserStyle :: PrintUnqualified -> Depth -> PprStyle cmdlineParserStyle :: PprStyle data Depth AllTheWay :: Depth -- | 0 => stop PartWay :: Int -> Depth -- | Use sdocDefaultDepth field as depth DefaultDepth :: Depth withUserStyle :: PrintUnqualified -> Depth -> SDoc -> SDoc withErrStyle :: PrintUnqualified -> SDoc -> SDoc -- | Says what to do with and without -dppr-debug ifPprDebug :: SDoc -> SDoc -> SDoc -- | Says what to do with -dppr-debug; without, return empty whenPprDebug :: SDoc -> SDoc -- | Indicate if -dppr-debug mode is enabled getPprDebug :: (Bool -> SDoc) -> SDoc instance GHC.Show.Show GHC.Utils.Outputable.LabelStyle instance GHC.Classes.Ord GHC.Utils.Outputable.LabelStyle instance GHC.Classes.Eq GHC.Utils.Outputable.LabelStyle instance GHC.Utils.Outputable.Outputable GHC.Data.FastString.NonDetFastString instance GHC.Utils.Outputable.Outputable GHC.Data.FastString.LexicalFastString instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.OutputableP env (GHC.Utils.Outputable.PDoc a) instance GHC.Utils.Outputable.OutputableP env a => GHC.Utils.Outputable.OutputableP env [a] instance GHC.Utils.Outputable.OutputableP env a => GHC.Utils.Outputable.OutputableP env (GHC.Maybe.Maybe a) instance (GHC.Utils.Outputable.OutputableP env a, GHC.Utils.Outputable.OutputableP env b) => GHC.Utils.Outputable.OutputableP env (a, b) instance (GHC.Utils.Outputable.OutputableP env a, GHC.Utils.Outputable.OutputableP env b, GHC.Utils.Outputable.OutputableP env c) => GHC.Utils.Outputable.OutputableP env (a, b, c) instance (GHC.Utils.Outputable.OutputableP env key, GHC.Utils.Outputable.OutputableP env elt) => GHC.Utils.Outputable.OutputableP env (Data.Map.Internal.Map key elt) instance GHC.Utils.Outputable.OutputableP env a => GHC.Utils.Outputable.OutputableP env (Data.Graph.SCC a) instance GHC.Utils.Outputable.OutputableP env GHC.Utils.Outputable.SDoc instance GHC.Utils.Outputable.OutputableP env a => GHC.Utils.Outputable.OutputableP env (Data.Set.Internal.Set a) instance GHC.Utils.Outputable.Outputable GHC.Utils.Outputable.QualifyName instance GHC.Utils.Outputable.Outputable GHC.Utils.Outputable.PprStyle instance GHC.Utils.Outputable.Outputable GHC.Utils.Outputable.SDoc instance GHC.Utils.Outputable.Outputable GHC.Types.Char instance GHC.Utils.Outputable.Outputable GHC.Types.Bool instance GHC.Utils.Outputable.Outputable GHC.Types.Ordering instance GHC.Utils.Outputable.Outputable GHC.Int.Int32 instance GHC.Utils.Outputable.Outputable GHC.Int.Int64 instance GHC.Utils.Outputable.Outputable GHC.Types.Int instance GHC.Utils.Outputable.Outputable GHC.Num.Integer.Integer instance GHC.Utils.Outputable.Outputable GHC.Word.Word16 instance GHC.Utils.Outputable.Outputable GHC.Word.Word32 instance GHC.Utils.Outputable.Outputable GHC.Word.Word64 instance GHC.Utils.Outputable.Outputable GHC.Types.Word instance GHC.Utils.Outputable.Outputable GHC.Types.Float instance GHC.Utils.Outputable.Outputable GHC.Types.Double instance GHC.Utils.Outputable.Outputable () instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable [a] instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Base.NonEmpty a) instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (Data.Set.Internal.Set a) instance GHC.Utils.Outputable.Outputable Data.IntSet.Internal.IntSet instance (GHC.Utils.Outputable.Outputable a, GHC.Utils.Outputable.Outputable b) => GHC.Utils.Outputable.Outputable (a, b) instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Maybe.Maybe a) instance (GHC.Utils.Outputable.Outputable a, GHC.Utils.Outputable.Outputable b) => GHC.Utils.Outputable.Outputable (Data.Either.Either a b) instance (GHC.Utils.Outputable.Outputable a, GHC.Utils.Outputable.Outputable b, GHC.Utils.Outputable.Outputable c) => GHC.Utils.Outputable.Outputable (a, b, c) instance (GHC.Utils.Outputable.Outputable a, GHC.Utils.Outputable.Outputable b, GHC.Utils.Outputable.Outputable c, GHC.Utils.Outputable.Outputable d) => GHC.Utils.Outputable.Outputable (a, b, c, d) instance (GHC.Utils.Outputable.Outputable a, GHC.Utils.Outputable.Outputable b, GHC.Utils.Outputable.Outputable c, GHC.Utils.Outputable.Outputable d, GHC.Utils.Outputable.Outputable e) => GHC.Utils.Outputable.Outputable (a, b, c, d, e) instance (GHC.Utils.Outputable.Outputable a, GHC.Utils.Outputable.Outputable b, GHC.Utils.Outputable.Outputable c, GHC.Utils.Outputable.Outputable d, GHC.Utils.Outputable.Outputable e, GHC.Utils.Outputable.Outputable f) => GHC.Utils.Outputable.Outputable (a, b, c, d, e, f) instance (GHC.Utils.Outputable.Outputable a, GHC.Utils.Outputable.Outputable b, GHC.Utils.Outputable.Outputable c, GHC.Utils.Outputable.Outputable d, GHC.Utils.Outputable.Outputable e, GHC.Utils.Outputable.Outputable f, GHC.Utils.Outputable.Outputable g) => GHC.Utils.Outputable.Outputable (a, b, c, d, e, f, g) instance GHC.Utils.Outputable.Outputable GHC.Data.FastString.FastString instance (GHC.Utils.Outputable.Outputable key, GHC.Utils.Outputable.Outputable elt) => GHC.Utils.Outputable.Outputable (Data.Map.Internal.Map key elt) instance GHC.Utils.Outputable.Outputable elt => GHC.Utils.Outputable.Outputable (Data.IntMap.Internal.IntMap elt) instance GHC.Utils.Outputable.Outputable GHC.Fingerprint.Type.Fingerprint instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (Data.Graph.SCC a) instance GHC.Utils.Outputable.Outputable GHC.Serialized.Serialized instance GHC.Utils.Outputable.Outputable GHC.LanguageExtensions.Type.Extension instance Data.String.IsString GHC.Utils.Outputable.SDoc -- | Unit & Module types -- -- This module is used to resolve the loops between Unit and Module types -- (Module references a Unit and vice-versa). module GHC.Unit.Types -- | A generic module is a pair of a unit identifier and a -- ModuleName. data GenModule unit Module :: !unit -> !ModuleName -> GenModule unit -- | Unit the module belongs to [moduleUnit] :: GenModule unit -> !unit -- | Module name (e.g. A.B.C) [moduleName] :: GenModule unit -> !ModuleName -- | A Module is a pair of a Unit and a ModuleName. type Module = GenModule Unit -- | A InstalledModule is a Module whose unit is identified -- with an UnitId. type InstalledModule = GenModule UnitId -- | An InstantiatedModule is a Module whose unit is -- identified with an InstantiatedUnit. type InstantiatedModule = GenModule InstantiatedUnit mkModule :: u -> ModuleName -> GenModule u pprModule :: Module -> SDoc pprInstantiatedModule :: InstantiatedModule -> SDoc -- | Calculate the free holes of a Module. If this set is non-empty, -- this module was defined in an indefinite library that had required -- signatures. -- -- If a module has free holes, that means that substitutions can operate -- on it; if it has no free holes, substituting over a module has no -- effect. moduleFreeHoles :: GenModule (GenUnit u) -> UniqDSet ModuleName -- | Class for types that are used as unit identifiers (UnitKey, UnitId, -- Unit) -- -- We need this class because we create new unit ids for virtual units -- (see VirtUnit) and they have to to be made from units with different -- kinds of identifiers. class IsUnitId u -- | A unit identifier identifies a (possibly partially) instantiated -- library. It is primarily used as part of Module, which in turn -- is used in Name, which is used to give names to entities when -- typechecking. -- -- There are two possible forms for a Unit: -- -- 1) It can be a RealUnit, in which case we just have a -- DefUnitId that uniquely identifies some fully compiled, -- installed library we have on disk. -- -- 2) It can be an VirtUnit. When we are typechecking a library -- with missing holes, we may need to instantiate a library on the fly -- (in which case we don't have any on-disk representation.) In that -- case, you have an InstantiatedUnit, which explicitly records -- the instantiation, so that we can substitute over it. data GenUnit uid -- | Installed definite unit (either a fully instantiated unit or a closed -- unit) RealUnit :: !Definite uid -> GenUnit uid -- | Virtual unit instantiated on-the-fly. It may be definite if all the -- holes are instantiated but we don't have code objects for it. VirtUnit :: {-# UNPACK #-} !GenInstantiatedUnit uid -> GenUnit uid -- | Fake hole unit HoleUnit :: GenUnit uid type Unit = GenUnit UnitId -- | A UnitId identifies a built library in a database and is used to -- generate unique symbols, etc. It's usually of the form: -- -- pkgname-1.2:libname+hash -- -- These UnitId are provided to us via the -this-unit-id flag. -- -- The library in question may be definite or indefinite; if it is -- indefinite, none of the holes have been filled (we never install -- partially instantiated libraries as we can cheaply instantiate them -- on-the-fly, cf VirtUnit). Put another way, an installed unit id is -- either fully instantiated, or not instantiated at all. newtype UnitId UnitId :: FastString -> UnitId -- | The full hashed unit identifier, including the component id and the -- hash. [unitIdFS] :: UnitId -> FastString -- | A unit key in the database newtype UnitKey UnitKey :: FastString -> UnitKey -- | An instantiated unit. -- -- It identifies an indefinite library (with holes) that has been -- instantiated. -- -- This unit may be indefinite or not (i.e. with remaining holes or not). -- If it is definite, we don't know if it has already been compiled and -- installed in a database. Nevertheless, we have a mechanism called -- "improvement" to try to match a fully instantiated unit with existing -- compiled and installed units: see Note [VirtUnit to RealUnit -- improvement]. -- -- An indefinite unit identifier pretty-prints to something like -- p[H=H,A=aimpl:A>] (p is the -- IndefUnitId, and the brackets enclose the module substitution). data GenInstantiatedUnit unit InstantiatedUnit :: !FastString -> !Unique -> !Indefinite unit -> !GenInstantiations unit -> UniqDSet ModuleName -> GenInstantiatedUnit unit -- | A private, uniquely identifying representation of an InstantiatedUnit. -- This string is completely private to GHC and is just used to get a -- unique. [instUnitFS] :: GenInstantiatedUnit unit -> !FastString -- | Cached unique of unitFS. [instUnitKey] :: GenInstantiatedUnit unit -> !Unique -- | The indefinite unit being instantiated. [instUnitInstanceOf] :: GenInstantiatedUnit unit -> !Indefinite unit -- | The sorted (by ModuleName) instantiations of this unit. [instUnitInsts] :: GenInstantiatedUnit unit -> !GenInstantiations unit -- | A cache of the free module holes of instUnitInsts. This lets us -- efficiently tell if a InstantiatedUnit has been fully -- instantiated (empty set of free module holes) and whether or not a -- substitution can have any effect. [instUnitHoles] :: GenInstantiatedUnit unit -> UniqDSet ModuleName type InstantiatedUnit = GenInstantiatedUnit UnitId -- | An IndefUnitId is an UnitId with the invariant that it -- only refers to an indefinite library; i.e., one that can be -- instantiated. type IndefUnitId = Indefinite UnitId -- | A DefUnitId is an UnitId with the invariant that it only -- refers to a definite library; i.e., one we have generated code for. type DefUnitId = Definite UnitId type Instantiations = GenInstantiations UnitId type GenInstantiations unit = [(ModuleName, GenModule (GenUnit unit))] -- | Create a new GenInstantiatedUnit given an explicit module -- substitution. mkInstantiatedUnit :: IsUnitId u => Indefinite u -> GenInstantiations u -> GenInstantiatedUnit u -- | Generate a uniquely identifying hash (internal unit-id) for an -- instantiated unit. -- -- This is a one-way function. If the indefinite unit has not been -- instantiated at all, we return its unit-id. -- -- This hash is completely internal to GHC and is not used for symbol -- names or file paths. It is different from the hash Cabal would produce -- for the same instantiated unit. mkInstantiatedUnitHash :: IsUnitId u => Indefinite u -> [(ModuleName, GenModule (GenUnit u))] -> FastString -- | Smart constructor for instantiated GenUnit mkVirtUnit :: IsUnitId u => Indefinite u -> [(ModuleName, GenModule (GenUnit u))] -> GenUnit u -- | Map over the unit type of a GenUnit mapGenUnit :: IsUnitId v => (u -> v) -> GenUnit u -> GenUnit v -- | Map over the unit identifier of unit instantiations. mapInstantiations :: IsUnitId v => (u -> v) -> GenInstantiations u -> GenInstantiations v -- | Retrieve the set of free module holes of a Unit. unitFreeModuleHoles :: GenUnit u -> UniqDSet ModuleName -- | Create a new simple unit identifier from a FastString. -- Internally, this is primarily used to specify wired-in unit -- identifiers. fsToUnit :: FastString -> Unit unitFS :: IsUnitId u => u -> FastString unitString :: IsUnitId u => u -> String -- | Return the UnitId of the Unit. For on-the-fly instantiated units, -- return the UnitId of the indefinite unit this unit is an instance of. toUnitId :: Unit -> UnitId -- | Return the virtual UnitId of an on-the-fly instantiated unit. virtualUnitId :: InstantiatedUnit -> UnitId stringToUnit :: String -> Unit -- | Compares unit ids lexically, rather than by their Uniques stableUnitCmp :: Unit -> Unit -> Ordering -- | A Unit is definite if it has no free holes. unitIsDefinite :: Unit -> Bool isHoleUnit :: GenUnit u -> Bool unitIdString :: UnitId -> String stringToUnitId :: String -> UnitId -- | A definite unit (i.e. without any free module hole) newtype Definite unit Definite :: unit -> Definite unit [unDefinite] :: Definite unit -> unit newtype Indefinite unit Indefinite :: unit -> Indefinite unit [indefUnit] :: Indefinite unit -> unit primUnitId :: UnitId bignumUnitId :: UnitId baseUnitId :: UnitId rtsUnitId :: UnitId thUnitId :: UnitId -- | This is the package Id for the current program. It is the default -- package Id if you don't specify a package name. We don't add this -- prefix to symbol names, since there can be only one main package per -- program. mainUnitId :: UnitId thisGhcUnitId :: UnitId interactiveUnitId :: UnitId primUnit :: Unit bignumUnit :: Unit baseUnit :: Unit rtsUnit :: Unit thUnit :: Unit mainUnit :: Unit thisGhcUnit :: Unit interactiveUnit :: Unit isInteractiveModule :: Module -> Bool wiredInUnitIds :: [UnitId] -- | Indicates whether a module name is referring to a boot interface -- (hs-boot file) or regular module (hs file). We need to treat boot -- modules specially when building compilation graphs, since they break -- cycles. Regular source files and signature files are treated -- equivalently. data IsBootInterface NotBoot :: IsBootInterface IsBoot :: IsBootInterface -- | This data type just pairs a value mod with an IsBootInterface -- flag. In practice, mod is usually a Module or -- ModuleName'. data GenWithIsBoot mod GWIB :: mod -> IsBootInterface -> GenWithIsBoot mod [gwib_mod] :: GenWithIsBoot mod -> mod [gwib_isBoot] :: GenWithIsBoot mod -> IsBootInterface type ModuleNameWithIsBoot = GenWithIsBoot ModuleName type ModuleWithIsBoot = GenWithIsBoot Module instance GHC.Base.Functor GHC.Unit.Types.GenModule instance Data.Data.Data unit => Data.Data.Data (GHC.Unit.Types.GenModule unit) instance GHC.Classes.Ord unit => GHC.Classes.Ord (GHC.Unit.Types.GenModule unit) instance GHC.Classes.Eq unit => GHC.Classes.Eq (GHC.Unit.Types.GenModule unit) instance GHC.Unit.Types.IsUnitId unit => GHC.Unit.Types.IsUnitId (GHC.Unit.Types.Definite unit) instance GHC.Types.Unique.Uniquable unit => GHC.Types.Unique.Uniquable (GHC.Unit.Types.Definite unit) instance GHC.Utils.Binary.Binary unit => GHC.Utils.Binary.Binary (GHC.Unit.Types.Definite unit) instance GHC.Utils.Outputable.Outputable unit => GHC.Utils.Outputable.Outputable (GHC.Unit.Types.Definite unit) instance GHC.Classes.Ord unit => GHC.Classes.Ord (GHC.Unit.Types.Definite unit) instance GHC.Classes.Eq unit => GHC.Classes.Eq (GHC.Unit.Types.Definite unit) instance GHC.Base.Functor GHC.Unit.Types.Definite instance GHC.Unit.Types.IsUnitId unit => GHC.Unit.Types.IsUnitId (GHC.Unit.Types.Indefinite unit) instance GHC.Types.Unique.Uniquable unit => GHC.Types.Unique.Uniquable (GHC.Unit.Types.Indefinite unit) instance GHC.Utils.Binary.Binary unit => GHC.Utils.Binary.Binary (GHC.Unit.Types.Indefinite unit) instance GHC.Utils.Outputable.Outputable unit => GHC.Utils.Outputable.Outputable (GHC.Unit.Types.Indefinite unit) instance GHC.Classes.Ord unit => GHC.Classes.Ord (GHC.Unit.Types.Indefinite unit) instance GHC.Classes.Eq unit => GHC.Classes.Eq (GHC.Unit.Types.Indefinite unit) instance GHC.Base.Functor GHC.Unit.Types.Indefinite instance Data.Data.Data GHC.Unit.Types.IsBootInterface instance GHC.Show.Show GHC.Unit.Types.IsBootInterface instance GHC.Classes.Ord GHC.Unit.Types.IsBootInterface instance GHC.Classes.Eq GHC.Unit.Types.IsBootInterface instance Data.Traversable.Traversable GHC.Unit.Types.GenWithIsBoot instance Data.Foldable.Foldable GHC.Unit.Types.GenWithIsBoot instance GHC.Base.Functor GHC.Unit.Types.GenWithIsBoot instance GHC.Show.Show mod => GHC.Show.Show (GHC.Unit.Types.GenWithIsBoot mod) instance GHC.Classes.Ord mod => GHC.Classes.Ord (GHC.Unit.Types.GenWithIsBoot mod) instance GHC.Classes.Eq mod => GHC.Classes.Eq (GHC.Unit.Types.GenWithIsBoot mod) instance GHC.Utils.Binary.Binary a => GHC.Utils.Binary.Binary (GHC.Unit.Types.GenWithIsBoot a) instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Unit.Types.GenWithIsBoot a) instance GHC.Utils.Binary.Binary GHC.Unit.Types.IsBootInterface instance GHC.Types.Unique.Uniquable GHC.Unit.Types.Module instance GHC.Utils.Outputable.Outputable GHC.Unit.Types.Module instance GHC.Classes.Ord GHC.Unit.Types.Unit instance Data.Data.Data GHC.Unit.Types.Unit instance Control.DeepSeq.NFData GHC.Unit.Types.Unit instance GHC.Utils.Outputable.Outputable GHC.Unit.Types.Unit instance GHC.Show.Show GHC.Unit.Types.Unit instance GHC.Utils.Binary.Binary GHC.Unit.Types.Unit instance GHC.Utils.Outputable.Outputable GHC.Unit.Types.InstantiatedModule instance GHC.Utils.Outputable.Outputable GHC.Unit.Types.InstantiatedUnit instance GHC.Utils.Binary.Binary GHC.Unit.Types.InstantiatedUnit instance GHC.Unit.Types.IsUnitId u => GHC.Unit.Types.IsUnitId (GHC.Unit.Types.GenUnit u) instance GHC.Classes.Eq (GHC.Unit.Types.GenInstantiatedUnit unit) instance GHC.Classes.Ord (GHC.Unit.Types.GenInstantiatedUnit unit) instance GHC.Unit.Types.IsUnitId u => GHC.Classes.Eq (GHC.Unit.Types.GenUnit u) instance GHC.Unit.Types.IsUnitId u => GHC.Types.Unique.Uniquable (GHC.Unit.Types.GenUnit u) instance GHC.Utils.Outputable.Outputable GHC.Unit.Types.InstalledModule instance GHC.Unit.Types.IsUnitId GHC.Unit.Types.UnitId instance GHC.Utils.Binary.Binary GHC.Unit.Types.UnitId instance GHC.Classes.Eq GHC.Unit.Types.UnitId instance GHC.Classes.Ord GHC.Unit.Types.UnitId instance GHC.Types.Unique.Uniquable GHC.Unit.Types.UnitId instance GHC.Utils.Outputable.Outputable GHC.Unit.Types.UnitId instance GHC.Unit.Types.IsUnitId GHC.Unit.Types.UnitKey instance GHC.Utils.Binary.Binary a => GHC.Utils.Binary.Binary (GHC.Unit.Types.GenModule a) instance Control.DeepSeq.NFData (GHC.Unit.Types.GenModule a) module GHC.Utils.Binary data Bin a -- | Do not rely on instance sizes for general types, we use variable -- length encoding for many of them. class Binary a put_ :: Binary a => BinHandle -> a -> IO () put :: Binary a => BinHandle -> a -> IO (Bin a) get :: Binary a => BinHandle -> IO a data BinHandle type SymbolTable = Array Int Name type Dictionary = Array Int FastString data BinData BinData :: Int -> BinArray -> BinData dataHandle :: BinData -> IO BinHandle handleData :: BinHandle -> IO BinData openBinMem :: Int -> IO BinHandle seekBin :: BinHandle -> Bin a -> IO () tellBin :: BinHandle -> IO (Bin a) castBin :: Bin a -> Bin b -- | Get access to the underlying buffer. -- -- It is quite important that no references to the ByteString leak -- out of the continuation lest terrible things happen. withBinBuffer :: BinHandle -> (ByteString -> IO a) -> IO a writeBinMem :: BinHandle -> FilePath -> IO () readBinMem :: FilePath -> IO BinHandle putAt :: Binary a => BinHandle -> Bin a -> a -> IO () getAt :: Binary a => BinHandle -> Bin a -> IO a putByte :: BinHandle -> Word8 -> IO () getByte :: BinHandle -> IO Word8 putULEB128 :: forall a. (Integral a, FiniteBits a) => BinHandle -> a -> IO () getULEB128 :: forall a. (Integral a, FiniteBits a) => BinHandle -> IO a putSLEB128 :: forall a. (Integral a, Bits a) => BinHandle -> a -> IO () getSLEB128 :: forall a. (Show a, Integral a, FiniteBits a) => BinHandle -> IO a -- | Encode the argument in it's full length. This is different from many -- default binary instances which make no guarantee about the actual -- encoding and might do things use variable length encoding. newtype FixedLengthEncoding a FixedLengthEncoding :: a -> FixedLengthEncoding a [unFixedLength] :: FixedLengthEncoding a -> a lazyGet :: Binary a => BinHandle -> IO a lazyPut :: Binary a => BinHandle -> a -> IO () -- | Information we keep around during interface file -- serialization/deserialization. Namely we keep the functions for -- serializing and deserializing Names and FastStrings. We -- do this because we actually use serialization in two distinct -- settings, -- --
-- plusUFM_CD f {A: 1, B: 2} 23 {B: 3, C: 4} 42
-- == {A: f 1 42, B: f 2 3, C: f 23 4 }
--
plusUFM_CD :: (elta -> eltb -> eltc) -> UniqFM key elta -> elta -> UniqFM key eltb -> eltb -> UniqFM key eltc
-- | `plusUFM_CD2 f m1 m2` merges the maps using f as the
-- combining function. Unlike plusUFM_CD, a missing value is not
-- defaulted: it is instead passed as Nothing to f.
-- f can never have both its arguments be Nothing.
--
-- IMPORTANT NOTE: This function strictly applies the modification
-- function and forces the result.
--
-- `plusUFM_CD2 f m1 m2` is the same as `plusUFM_CD f (mapUFM Just m1)
-- Nothing (mapUFM Just m2) Nothing`.
plusUFM_CD2 :: (Maybe elta -> Maybe eltb -> eltc) -> UniqFM key elta -> UniqFM key eltb -> UniqFM key eltc
plusMaybeUFM_C :: (elt -> elt -> Maybe elt) -> UniqFM key elt -> UniqFM key elt -> UniqFM key elt
mergeUFM :: (elta -> eltb -> Maybe eltc) -> (UniqFM key elta -> UniqFM key eltc) -> (UniqFM key eltb -> UniqFM key eltc) -> UniqFM key elta -> UniqFM key eltb -> UniqFM key eltc
plusUFMList :: [UniqFM key elt] -> UniqFM key elt
minusUFM :: UniqFM key elt1 -> UniqFM key elt2 -> UniqFM key elt1
intersectUFM :: UniqFM key elt1 -> UniqFM key elt2 -> UniqFM key elt1
intersectUFM_C :: (elt1 -> elt2 -> elt3) -> UniqFM key elt1 -> UniqFM key elt2 -> UniqFM key elt3
disjointUFM :: UniqFM key elt1 -> UniqFM key elt2 -> Bool
equalKeysUFM :: UniqFM key a -> UniqFM key b -> Bool
nonDetStrictFoldUFM :: (elt -> a -> a) -> a -> UniqFM key elt -> a
foldUFM :: (elt -> a -> a) -> a -> UniqFM key elt -> a
nonDetStrictFoldUFM_Directly :: (Unique -> elt -> a -> a) -> a -> UniqFM key elt -> a
anyUFM :: (elt -> Bool) -> UniqFM key elt -> Bool
allUFM :: (elt -> Bool) -> UniqFM key elt -> Bool
seqEltsUFM :: ([elt] -> ()) -> UniqFM key elt -> ()
mapUFM :: (elt1 -> elt2) -> UniqFM key elt1 -> UniqFM key elt2
mapUFM_Directly :: (Unique -> elt1 -> elt2) -> UniqFM key elt1 -> UniqFM key elt2
mapMaybeUFM :: (elt1 -> Maybe elt2) -> UniqFM key elt1 -> UniqFM key elt2
elemUFM :: Uniquable key => key -> UniqFM key elt -> Bool
elemUFM_Directly :: Unique -> UniqFM key elt -> Bool
filterUFM :: (elt -> Bool) -> UniqFM key elt -> UniqFM key elt
filterUFM_Directly :: (Unique -> elt -> Bool) -> UniqFM key elt -> UniqFM key elt
partitionUFM :: (elt -> Bool) -> UniqFM key elt -> (UniqFM key elt, UniqFM key elt)
sizeUFM :: UniqFM key elt -> Int
isNullUFM :: UniqFM key elt -> Bool
lookupUFM :: Uniquable key => UniqFM key elt -> key -> Maybe elt
lookupUFM_Directly :: UniqFM key elt -> Unique -> Maybe elt
lookupWithDefaultUFM :: Uniquable key => UniqFM key elt -> elt -> key -> elt
lookupWithDefaultUFM_Directly :: UniqFM key elt -> elt -> Unique -> elt
nonDetEltsUFM :: UniqFM key elt -> [elt]
eltsUFM :: UniqFM key elt -> [elt]
nonDetKeysUFM :: UniqFM key elt -> [Unique]
ufmToSet_Directly :: UniqFM key elt -> IntSet
nonDetUFMToList :: UniqFM key elt -> [(Unique, elt)]
ufmToIntMap :: UniqFM key elt -> IntMap elt
unsafeIntMapToUFM :: IntMap elt -> UniqFM key elt
-- | Cast the key domain of a UniqFM.
--
-- As long as the domains don't overlap in their uniques this is safe.
unsafeCastUFMKey :: UniqFM key1 elt -> UniqFM key2 elt
pprUniqFM :: (a -> SDoc) -> UniqFM key a -> SDoc
-- | Pretty-print a non-deterministic set. The order of variables is
-- non-deterministic and for pretty-printing that shouldn't be a problem.
-- Having this function helps contain the non-determinism created with
-- nonDetEltsUFM.
pprUFM :: UniqFM key a -> ([a] -> SDoc) -> SDoc
-- | Pretty-print a non-deterministic set. The order of variables is
-- non-deterministic and for pretty-printing that shouldn't be a problem.
-- Having this function helps contain the non-determinism created with
-- nonDetUFMToList.
pprUFMWithKeys :: UniqFM key a -> ([(Unique, a)] -> SDoc) -> SDoc
-- | Determines the pluralisation suffix appropriate for the length of a
-- set in the same way that plural from Outputable does for lists.
pluralUFM :: UniqFM key a -> SDoc
instance GHC.Base.Functor (GHC.Types.Unique.FM.UniqFM key)
instance GHC.Classes.Eq ele => GHC.Classes.Eq (GHC.Types.Unique.FM.UniqFM key ele)
instance (Data.Data.Data key, Data.Data.Data ele) => Data.Data.Data (GHC.Types.Unique.FM.UniqFM key ele)
instance GHC.Base.Functor (GHC.Types.Unique.FM.NonDetUniqFM key)
instance Data.Foldable.Foldable (GHC.Types.Unique.FM.NonDetUniqFM key)
instance Data.Traversable.Traversable (GHC.Types.Unique.FM.NonDetUniqFM key)
instance GHC.Base.Semigroup (GHC.Types.Unique.FM.UniqFM key a)
instance GHC.Base.Monoid (GHC.Types.Unique.FM.UniqFM key a)
instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Types.Unique.FM.UniqFM key a)
-- | Defines basic functions for printing error messages.
--
-- It's hard to put these functions anywhere else without causing some
-- unnecessary loops in the module dependency graph.
module GHC.Utils.Panic
-- | GHC's own exception type error messages all take the form:
--
-- -- <location>: <error> -- ---- -- If the location is on the command line, or in GHC itself, then -- <location>="ghc". All of the error types below correspond to a -- <location> of "ghc", except for ProgramError (where the string -- is assumed to contain a location already, so we don't print one). data GhcException -- | Some other fatal signal (SIGHUP,SIGTERM) Signal :: Int -> GhcException -- | Prints the short usage msg after the error UsageError :: String -> GhcException -- | A problem with the command line arguments, but don't print usage. CmdLineError :: String -> GhcException -- | The impossible happened. Panic :: String -> GhcException PprPanic :: String -> SDoc -> GhcException -- | The user tickled something that's known not to work yet, but we're not -- counting it as a bug. Sorry :: String -> GhcException PprSorry :: String -> SDoc -> GhcException -- | An installation problem. InstallationError :: String -> GhcException -- | An error in the user's code, probably. ProgramError :: String -> GhcException PprProgramError :: String -> SDoc -> GhcException -- | Append a description of the given exception to this string. showGhcException :: SDocContext -> GhcException -> ShowS -- | Append a description of the given exception to this string. -- -- Note that this uses defaultSDocContext, which doesn't use the -- options set by the user via DynFlags. showGhcExceptionUnsafe :: GhcException -> ShowS throwGhcException :: GhcException -> a throwGhcExceptionIO :: GhcException -> IO a handleGhcException :: ExceptionMonad m => (GhcException -> m a) -> m a -> m a -- | The name of this GHC. progName :: String -- | Panics and asserts. pgmError :: String -> a -- | Panics and asserts. panic :: String -> a -- | Throw an exception saying "bug in GHC" with a callstack pprPanic :: HasCallStack => String -> SDoc -> a -- | Throw a failed assertion exception for a given filename and line -- number. assertPanic :: String -> Int -> a -- | Panic with an assertion failure, recording the given file and line -- number. Should typically be accessed with the ASSERT family of macros assertPprPanic :: HasCallStack => String -> Int -> SDoc -> a -- | Panics and asserts. sorry :: String -> a -- | The trace function outputs the trace message given as its first -- argument, before returning the second argument as its result. -- -- For example, this returns the value of f x and outputs the -- message to stderr. Depending on your terminal (settings), they may or -- may not be mixed. -- --
-- >>> let x = 123; f = show
--
-- >>> trace ("calling f with x = " ++ show x) (f x)
-- calling f with x = 123
-- "123"
--
--
-- The trace function should only be used for debugging, or
-- for monitoring execution. The function is not referentially
-- transparent: its type indicates that it is a pure function but it has
-- the side effect of outputting the trace message.
trace :: String -> a -> a
-- | Throw an exception saying "bug in GHC"
panicDoc :: String -> SDoc -> a
-- | Throw an exception saying "this isn't finished yet"
sorryDoc :: String -> SDoc -> a
-- | Throw an exception saying "bug in pgm being compiled" (used for
-- unusual program errors)
pgmErrorDoc :: String -> SDoc -> a
cmdLineError :: String -> a
cmdLineErrorIO :: String -> IO a
callStackDoc :: HasCallStack => SDoc
-- | Any type that you wish to throw or catch as an exception must be an
-- instance of the Exception class. The simplest case is a new
-- exception type directly below the root:
--
-- -- data MyException = ThisException | ThatException -- deriving Show -- -- instance Exception MyException ---- -- The default method definitions in the Exception class do what -- we need in this case. You can now throw and catch -- ThisException and ThatException as exceptions: -- --
-- *Main> throw ThisException `catch` \e -> putStrLn ("Caught " ++ show (e :: MyException))
-- Caught ThisException
--
--
-- In more complicated examples, you may wish to define a whole hierarchy
-- of exceptions:
--
-- -- --------------------------------------------------------------------- -- -- Make the root exception type for all the exceptions in a compiler -- -- data SomeCompilerException = forall e . Exception e => SomeCompilerException e -- -- instance Show SomeCompilerException where -- show (SomeCompilerException e) = show e -- -- instance Exception SomeCompilerException -- -- compilerExceptionToException :: Exception e => e -> SomeException -- compilerExceptionToException = toException . SomeCompilerException -- -- compilerExceptionFromException :: Exception e => SomeException -> Maybe e -- compilerExceptionFromException x = do -- SomeCompilerException a <- fromException x -- cast a -- -- --------------------------------------------------------------------- -- -- Make a subhierarchy for exceptions in the frontend of the compiler -- -- data SomeFrontendException = forall e . Exception e => SomeFrontendException e -- -- instance Show SomeFrontendException where -- show (SomeFrontendException e) = show e -- -- instance Exception SomeFrontendException where -- toException = compilerExceptionToException -- fromException = compilerExceptionFromException -- -- frontendExceptionToException :: Exception e => e -> SomeException -- frontendExceptionToException = toException . SomeFrontendException -- -- frontendExceptionFromException :: Exception e => SomeException -> Maybe e -- frontendExceptionFromException x = do -- SomeFrontendException a <- fromException x -- cast a -- -- --------------------------------------------------------------------- -- -- Make an exception type for a particular frontend compiler exception -- -- data MismatchedParentheses = MismatchedParentheses -- deriving Show -- -- instance Exception MismatchedParentheses where -- toException = frontendExceptionToException -- fromException = frontendExceptionFromException ---- -- We can now catch a MismatchedParentheses exception as -- MismatchedParentheses, SomeFrontendException or -- SomeCompilerException, but not other types, e.g. -- IOException: -- --
-- *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: MismatchedParentheses))
-- Caught MismatchedParentheses
-- *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeFrontendException))
-- Caught MismatchedParentheses
-- *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeCompilerException))
-- Caught MismatchedParentheses
-- *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: IOException))
-- *** Exception: MismatchedParentheses
--
class (Typeable e, Show e) => Exception e
toException :: Exception e => e -> SomeException
fromException :: Exception e => SomeException -> Maybe e
-- | Render this exception value in a human-friendly manner.
--
-- Default implementation: show.
displayException :: Exception e => e -> String
-- | Show an exception as a string.
showException :: Exception e => e -> String
-- | Show an exception which can possibly throw other exceptions. Used when
-- displaying exception thrown within TH code.
safeShowException :: Exception e => e -> IO String
-- | Similar to catch, but returns an Either result which is
-- (Right a) if no exception of type e was
-- raised, or (Left ex) if an exception of type
-- e was raised and its value is ex. If any other type
-- of exception is raised then it will be propagated up to the next
-- enclosing exception handler.
--
-- -- try a = catch (Right `liftM` a) (return . Left) --try :: Exception e => IO a -> IO (Either e a) -- | Like try, but pass through UserInterrupt and Panic exceptions. Used -- when we want soft failures when reading interface files, for example. -- TODO: I'm not entirely sure if this is catching what we really want to -- catch tryMost :: IO a -> IO (Either SomeException a) -- | throwTo raises an arbitrary exception in the target thread (GHC -- only). -- -- Exception delivery synchronizes between the source and target thread: -- throwTo does not return until the exception has been raised in -- the target thread. The calling thread can thus be certain that the -- target thread has received the exception. Exception delivery is also -- atomic with respect to other exceptions. Atomicity is a useful -- property to have when dealing with race conditions: e.g. if there are -- two threads that can kill each other, it is guaranteed that only one -- of the threads will get to kill the other. -- -- Whatever work the target thread was doing when the exception was -- raised is not lost: the computation is suspended until required by -- another thread. -- -- If the target thread is currently making a foreign call, then the -- exception will not be raised (and hence throwTo will not -- return) until the call has completed. This is the case regardless of -- whether the call is inside a mask or not. However, in GHC a -- foreign call can be annotated as interruptible, in which case -- a throwTo will cause the RTS to attempt to cause the call to -- return; see the GHC documentation for more details. -- -- Important note: the behaviour of throwTo differs from that -- described in the paper "Asynchronous exceptions in Haskell" -- (http://research.microsoft.com/~simonpj/Papers/asynch-exns.htm). -- In the paper, throwTo is non-blocking; but the library -- implementation adopts a more synchronous design in which -- throwTo does not return until the exception is received by the -- target thread. The trade-off is discussed in Section 9 of the paper. -- Like any blocking operation, throwTo is therefore interruptible -- (see Section 5.3 of the paper). Unlike other interruptible operations, -- however, throwTo is always interruptible, even if it -- does not actually block. -- -- There is no guarantee that the exception will be delivered promptly, -- although the runtime will endeavour to ensure that arbitrary delays -- don't occur. In GHC, an exception can only be raised when a thread -- reaches a safe point, where a safe point is where memory -- allocation occurs. Some loops do not perform any memory allocation -- inside the loop and therefore cannot be interrupted by a -- throwTo. -- -- If the target of throwTo is the calling thread, then the -- behaviour is the same as throwIO, except that the exception is -- thrown as an asynchronous exception. This means that if there is an -- enclosing pure computation, which would be the case if the current IO -- operation is inside unsafePerformIO or -- unsafeInterleaveIO, that computation is not permanently -- replaced by the exception, but is suspended as if it had received an -- asynchronous exception. -- -- Note that if throwTo is called with the current thread as the -- target, the exception will be thrown even if the thread is currently -- inside mask or uninterruptibleMask. throwTo :: Exception e => ThreadId -> e -> IO () -- | Temporarily install standard signal handlers for catching ^C, which -- just throw an exception in the current thread. withSignalHandlers :: ExceptionMonad m => m a -> m a instance GHC.Exception.Type.Exception GHC.Utils.Panic.GhcException instance GHC.Show.Show GHC.Utils.Panic.GhcException module GHC.Types.Unique -- | Unique identifier. -- -- The type of unique identifiers that are used in many places in GHC for -- fast ordering and equality tests. You should generate these with the -- functions from the UniqSupply module -- -- These are sometimes also referred to as "keys" in comments in GHC. data Unique -- | Class of things that we can obtain a Unique from class Uniquable a getUnique :: Uniquable a => a -> Unique uNIQUE_BITS :: Int hasKey :: Uniquable a => a -> Unique -> Bool pprUniqueAlways :: Unique -> SDoc mkUniqueGrimily :: Int -> Unique getKey :: Unique -> Int mkUnique :: Char -> Int -> Unique unpkUnique :: Unique -> (Char, Int) eqUnique :: Unique -> Unique -> Bool ltUnique :: Unique -> Unique -> Bool incrUnique :: Unique -> Unique stepUnique :: Unique -> Int -> Unique newTagUnique :: Unique -> Char -> Unique nonDetCmpUnique :: Unique -> Unique -> Ordering -- | The interface file symbol-table encoding assumes that known-key -- uniques fit in 30-bits; verify this. -- -- See Note [Symbol table representation of names] in -- GHC.Iface.Binary for details. isValidKnownKeyUnique :: Unique -> Bool mkLocalUnique :: Int -> Unique minLocalUnique :: Unique maxLocalUnique :: Unique instance GHC.Types.Unique.Uniquable GHC.Data.FastString.FastString instance GHC.Types.Unique.Uniquable GHC.Types.Int instance GHC.Types.Unique.Uniquable GHC.Types.Unique.Unique instance GHC.Classes.Eq GHC.Types.Unique.Unique instance GHC.Utils.Outputable.Outputable GHC.Types.Unique.Unique instance GHC.Show.Show GHC.Types.Unique.Unique -- | This module contains types that relate to the positions of things in -- source files, and allow tagging of those things with locations module GHC.Types.SrcLoc -- | Real Source Location -- -- Represents a single point within a file data RealSrcLoc -- | Source Location data SrcLoc RealSrcLoc :: !RealSrcLoc -> !Maybe BufPos -> SrcLoc UnhelpfulLoc :: FastString -> SrcLoc mkSrcLoc :: FastString -> Int -> Int -> SrcLoc mkRealSrcLoc :: FastString -> Int -> Int -> RealSrcLoc -- | Creates a "bad" SrcLoc that has no detailed information about -- its location mkGeneralSrcLoc :: FastString -> SrcLoc -- | Built-in "bad" SrcLoc values for particular locations noSrcLoc :: SrcLoc -- | Built-in "bad" SrcLoc values for particular locations generatedSrcLoc :: SrcLoc -- | Built-in "bad" SrcLoc values for particular locations interactiveSrcLoc :: SrcLoc -- | Move the SrcLoc down by one line if the character is a newline, -- to the next 8-char tabstop if it is a tab, and across by one character -- in any other case advanceSrcLoc :: RealSrcLoc -> Char -> RealSrcLoc advanceBufPos :: BufPos -> BufPos -- | Gives the filename of the SrcLoc srcLocFile :: RealSrcLoc -> FastString -- | Raises an error when used on a "bad" SrcLoc srcLocLine :: RealSrcLoc -> Int -- | Raises an error when used on a "bad" SrcLoc srcLocCol :: RealSrcLoc -> Int -- | A SrcSpan delimits a portion of a text file. It could be -- represented by a pair of (line,column) coordinates, but in fact we -- optimise slightly by using more compact representations for -- single-line and zero-length spans, both of which are quite common. -- -- The end position is defined to be the column after the end of -- the span. That is, a span of (1,1)-(1,2) is one character long, and a -- span of (1,1)-(1,1) is zero characters long. -- -- Real Source Span data RealSrcSpan -- | Source Span -- -- A SrcSpan identifies either a specific portion of a text file -- or a human-readable description of a location. data SrcSpan RealSrcSpan :: !RealSrcSpan -> !Maybe BufSpan -> SrcSpan UnhelpfulSpan :: !UnhelpfulSpanReason -> SrcSpan data UnhelpfulSpanReason UnhelpfulNoLocationInfo :: UnhelpfulSpanReason UnhelpfulWiredIn :: UnhelpfulSpanReason UnhelpfulInteractive :: UnhelpfulSpanReason UnhelpfulGenerated :: UnhelpfulSpanReason UnhelpfulOther :: !FastString -> UnhelpfulSpanReason -- | Create a "bad" SrcSpan that has not location information mkGeneralSrcSpan :: FastString -> SrcSpan -- | Create a SrcSpan between two points in a file mkSrcSpan :: SrcLoc -> SrcLoc -> SrcSpan -- | Create a SrcSpan between two points in a file mkRealSrcSpan :: RealSrcLoc -> RealSrcLoc -> RealSrcSpan -- | Built-in "bad" SrcSpans for common sources of location -- uncertainty noSrcSpan :: SrcSpan -- | Built-in "bad" SrcSpans for common sources of location -- uncertainty generatedSrcSpan :: SrcSpan isGeneratedSrcSpan :: SrcSpan -> Bool -- | Built-in "bad" SrcSpans for common sources of location -- uncertainty wiredInSrcSpan :: SrcSpan -- | Built-in "bad" SrcSpans for common sources of location -- uncertainty interactiveSrcSpan :: SrcSpan -- | Create a SrcSpan corresponding to a single point srcLocSpan :: SrcLoc -> SrcSpan realSrcLocSpan :: RealSrcLoc -> RealSrcSpan -- | Combines two SrcSpan into one that spans at least all the -- characters within both spans. Returns UnhelpfulSpan if the files -- differ. combineSrcSpans :: SrcSpan -> SrcSpan -> SrcSpan -- | Convert a SrcSpan into one that represents only its first character srcSpanFirstCharacter :: SrcSpan -> SrcSpan -- | Returns the location at the start of the SrcSpan or a "bad" -- SrcSpan if that is unavailable srcSpanStart :: SrcSpan -> SrcLoc -- | Returns the location at the end of the SrcSpan or a "bad" -- SrcSpan if that is unavailable srcSpanEnd :: SrcSpan -> SrcLoc realSrcSpanStart :: RealSrcSpan -> RealSrcLoc realSrcSpanEnd :: RealSrcSpan -> RealSrcLoc -- | Obtains the filename for a SrcSpan if it is "good" srcSpanFileName_maybe :: SrcSpan -> Maybe FastString pprUserRealSpan :: Bool -> RealSrcSpan -> SDoc pprUnhelpfulSpanReason :: UnhelpfulSpanReason -> SDoc pprUserSpan :: Bool -> SrcSpan -> SDoc unhelpfulSpanFS :: UnhelpfulSpanReason -> FastString srcSpanToRealSrcSpan :: SrcSpan -> Maybe RealSrcSpan srcSpanFile :: RealSrcSpan -> FastString srcSpanStartLine :: RealSrcSpan -> Int srcSpanEndLine :: RealSrcSpan -> Int srcSpanStartCol :: RealSrcSpan -> Int srcSpanEndCol :: RealSrcSpan -> Int -- | Test if a SrcSpan is "good", i.e. has precise location -- information isGoodSrcSpan :: SrcSpan -> Bool -- | True if the span is known to straddle only one line. For "bad" -- SrcSpan, it returns False isOneLineSpan :: SrcSpan -> Bool -- | True if the span has a width of zero, as returned for "virtual" -- semicolons in the lexer. For "bad" SrcSpan, it returns False isZeroWidthSpan :: SrcSpan -> Bool -- | Tests whether the first span "contains" the other span, meaning that -- it covers at least as much source code. True where spans are equal. containsSpan :: RealSrcSpan -> RealSrcSpan -> Bool -- | 0-based offset identifying the raw location in the -- StringBuffer. -- -- The lexer increments the BufPos every time a character (UTF-8 -- code point) is read from the input buffer. As UTF-8 is a -- variable-length encoding and StringBuffer needs a byte offset -- for indexing, a BufPos cannot be used for indexing. -- -- The parser guarantees that BufPos are monotonic. See #17632. -- This means that syntactic constructs that appear later in the -- StringBuffer are guaranteed to have a higher BufPos. -- Constrast that with SrcLoc, which does *not* make the analogous -- guarantee about higher line/column numbers. -- -- This is due to #line and {-# LINE ... #-} pragmas that can arbitrarily -- modify SrcLoc. Notice how setSrcLoc and -- resetAlrLastLoc in GHC.Parser.Lexer update -- PsLoc, modifying SrcLoc but preserving BufPos. -- -- Monotonicity makes BufPos useful to determine the order in -- which syntactic elements appear in the source. Consider this example -- (haddockA041 in the test suite): -- -- haddockA041.hs {-# LANGUAGE CPP #-} -- | Module header documentation -- module Comments_and_CPP_include where #include "IncludeMe.hs" -- -- IncludeMe.hs: -- | Comment on T data T = MkT -- ^ Comment on MkT -- -- After the C preprocessor runs, the StringBuffer will contain -- a program that looks like this (unimportant lines at the beginning -- removed): -- -- # 1 "haddockA041.hs" {-# LANGUAGE CPP #-} -- | Module header -- documentation module Comments_and_CPP_include where # 1 "IncludeMe.hs" -- 1 -- | Comment on T data T = MkT -- ^ Comment on MkT # 7 -- "haddockA041.hs" 2 -- -- The line pragmas inserted by CPP make the error messages more -- informative. The downside is that we can't use RealSrcLoc to determine -- the ordering of syntactic elements. -- -- With RealSrcLoc, we have the following location information recorded -- in the AST: * The module name is located at haddockA041.hs:3:8-31 * -- The Haddock comment "Comment on T" is located at IncludeMe:1:1-17 * -- The data declaration is located at IncludeMe.hs:2:1-32 -- -- Is the Haddock comment located between the module name and the data -- declaration? This is impossible to tell because the locations are not -- comparable; they even refer to different files. -- -- On the other hand, with BufPos, we have the following location -- information: * The module name is located at 846-870 * The Haddock -- comment "Comment on T" is located at 898-915 * The data declaration is -- located at 916-928 -- -- Aside: if you're wondering why the numbers are so high, try running -- ghc -E haddockA041.hs and see the extra fluff that CPP -- inserts at the start of the file. -- -- For error messages, BufPos is not useful at all. On the other -- hand, this is exactly what we need to determine the order of syntactic -- elements: 870 < 898, therefore the Haddock comment appears *after* -- the module name. 915 < 916, therefore the Haddock comment appears -- *before* the data declaration. -- -- We use BufPos in in GHC.Parser.PostProcess.Haddock to associate -- Haddock comments with parts of the AST using location information -- (#17544). newtype BufPos BufPos :: Int -> BufPos [bufPos] :: BufPos -> Int getBufPos :: SrcLoc -> Maybe BufPos -- | StringBuffer Source Span data BufSpan BufSpan :: {-# UNPACK #-} !BufPos -> BufSpan [bufSpanStart, bufSpanEnd] :: BufSpan -> {-# UNPACK #-} !BufPos getBufSpan :: SrcSpan -> Maybe BufSpan type Located = GenLocated SrcSpan type RealLocated = GenLocated RealSrcSpan -- | We attach SrcSpans to lots of things, so let's have a datatype for it. data GenLocated l e L :: l -> e -> GenLocated l e noLoc :: e -> Located e mkGeneralLocated :: String -> e -> Located e getLoc :: GenLocated l e -> l unLoc :: GenLocated l e -> e unRealSrcSpan :: RealLocated a -> a getRealSrcSpan :: RealLocated a -> RealSrcSpan pprLocated :: (Outputable l, Outputable e) => GenLocated l e -> SDoc mapLoc :: (a -> b) -> GenLocated l a -> GenLocated l b -- | Tests whether the two located things are equal eqLocated :: Eq a => GenLocated l a -> GenLocated l a -> Bool -- | Tests the ordering of the two located things cmpLocated :: Ord a => GenLocated l a -> GenLocated l a -> Ordering -- | Compare the BufSpan of two located things. -- -- Precondition: both operands have an associated BufSpan. cmpBufSpan :: HasDebugCallStack => Located a -> Located a -> Ordering combineLocs :: Located a -> Located b -> SrcSpan -- | Combine locations from two Located things and add them to a -- third thing addCLoc :: Located a -> Located b -> c -> Located c -- | Strategies for ordering SrcSpans leftmost_smallest :: SrcSpan -> SrcSpan -> Ordering -- | Strategies for ordering SrcSpans leftmost_largest :: SrcSpan -> SrcSpan -> Ordering -- | Strategies for ordering SrcSpans rightmost_smallest :: SrcSpan -> SrcSpan -> Ordering -- | Determines whether a span encloses a given line and column index spans :: SrcSpan -> (Int, Int) -> Bool -- | Determines whether a span is enclosed by another one isSubspanOf :: SrcSpan -> SrcSpan -> Bool -- | Determines whether a span is enclosed by another one isRealSubspanOf :: RealSrcSpan -> RealSrcSpan -> Bool sortLocated :: [Located a] -> [Located a] sortRealLocated :: [RealLocated a] -> [RealLocated a] lookupSrcLoc :: SrcLoc -> Map RealSrcLoc a -> Maybe a lookupSrcSpan :: SrcSpan -> Map RealSrcSpan a -> Maybe a liftL :: Monad m => (a -> m b) -> GenLocated l a -> m (GenLocated l b) -- | A location as produced by the parser. Consists of two components: -- --
-- class C a where { foo :: a; bar :: a }
--
ExplicitBraces :: LayoutInfo
-- | Virtual braces inserted by the layout algorithm.
--
-- -- class C a where -- foo :: a -- bar :: a --VirtualBraces :: !Int -> LayoutInfo -- | Empty or compiler-generated blocks do not have layout information -- associated with them. NoLayoutInfo :: LayoutInfo -- | Indentation level is 1-indexed, so the leftmost column is 1. leftmostColumn :: Int instance GHC.Classes.Ord GHC.Types.SrcLoc.RealSrcLoc instance GHC.Classes.Eq GHC.Types.SrcLoc.RealSrcLoc instance GHC.Show.Show GHC.Types.SrcLoc.BufPos instance GHC.Classes.Ord GHC.Types.SrcLoc.BufPos instance GHC.Classes.Eq GHC.Types.SrcLoc.BufPos instance GHC.Show.Show GHC.Types.SrcLoc.SrcLoc instance GHC.Classes.Eq GHC.Types.SrcLoc.SrcLoc instance GHC.Classes.Eq GHC.Types.SrcLoc.RealSrcSpan instance GHC.Show.Show GHC.Types.SrcLoc.BufSpan instance GHC.Classes.Ord GHC.Types.SrcLoc.BufSpan instance GHC.Classes.Eq GHC.Types.SrcLoc.BufSpan instance GHC.Show.Show GHC.Types.SrcLoc.UnhelpfulSpanReason instance GHC.Classes.Eq GHC.Types.SrcLoc.UnhelpfulSpanReason instance GHC.Show.Show GHC.Types.SrcLoc.SrcSpan instance GHC.Classes.Eq GHC.Types.SrcLoc.SrcSpan instance Data.Traversable.Traversable (GHC.Types.SrcLoc.GenLocated l) instance Data.Foldable.Foldable (GHC.Types.SrcLoc.GenLocated l) instance GHC.Base.Functor (GHC.Types.SrcLoc.GenLocated l) instance (Data.Data.Data l, Data.Data.Data e) => Data.Data.Data (GHC.Types.SrcLoc.GenLocated l e) instance (GHC.Classes.Ord l, GHC.Classes.Ord e) => GHC.Classes.Ord (GHC.Types.SrcLoc.GenLocated l e) instance (GHC.Classes.Eq l, GHC.Classes.Eq e) => GHC.Classes.Eq (GHC.Types.SrcLoc.GenLocated l e) instance GHC.Show.Show GHC.Types.SrcLoc.PsLoc instance GHC.Classes.Ord GHC.Types.SrcLoc.PsLoc instance GHC.Classes.Eq GHC.Types.SrcLoc.PsLoc instance GHC.Show.Show GHC.Types.SrcLoc.PsSpan instance GHC.Classes.Ord GHC.Types.SrcLoc.PsSpan instance GHC.Classes.Eq GHC.Types.SrcLoc.PsSpan instance Data.Data.Data GHC.Types.SrcLoc.LayoutInfo instance GHC.Show.Show GHC.Types.SrcLoc.LayoutInfo instance GHC.Classes.Ord GHC.Types.SrcLoc.LayoutInfo instance GHC.Classes.Eq GHC.Types.SrcLoc.LayoutInfo instance GHC.Utils.Outputable.Outputable e => GHC.Utils.Outputable.Outputable (GHC.Types.SrcLoc.Located e) instance GHC.Utils.Outputable.Outputable e => GHC.Utils.Outputable.Outputable (GHC.Types.SrcLoc.GenLocated GHC.Types.SrcLoc.RealSrcSpan e) instance Data.Data.Data GHC.Types.SrcLoc.SrcSpan instance GHC.Utils.Json.ToJson GHC.Types.SrcLoc.SrcSpan instance Control.DeepSeq.NFData GHC.Types.SrcLoc.SrcSpan instance GHC.Utils.Outputable.Outputable GHC.Types.SrcLoc.SrcSpan instance GHC.Utils.Outputable.Outputable GHC.Types.SrcLoc.UnhelpfulSpanReason instance GHC.Base.Semigroup GHC.Types.SrcLoc.BufSpan instance Data.Data.Data GHC.Types.SrcLoc.RealSrcSpan instance GHC.Utils.Json.ToJson GHC.Types.SrcLoc.RealSrcSpan instance GHC.Classes.Ord GHC.Types.SrcLoc.RealSrcSpan instance GHC.Show.Show GHC.Types.SrcLoc.RealSrcSpan instance GHC.Utils.Outputable.Outputable GHC.Types.SrcLoc.RealSrcSpan instance GHC.Utils.Outputable.Outputable GHC.Types.SrcLoc.SrcLoc instance GHC.Utils.Outputable.Outputable GHC.Types.SrcLoc.RealSrcLoc instance GHC.Show.Show GHC.Types.SrcLoc.RealSrcLoc module GHC.Utils.Json -- | Simple data type to represent JSON documents. data JsonDoc [JSNull] :: JsonDoc [JSBool] :: Bool -> JsonDoc [JSInt] :: Int -> JsonDoc [JSString] :: String -> JsonDoc [JSArray] :: [JsonDoc] -> JsonDoc [JSObject] :: [(String, JsonDoc)] -> JsonDoc renderJSON :: JsonDoc -> SDoc escapeJsonString :: String -> String class ToJson a json :: ToJson a => a -> JsonDoc -- | GHC uses several kinds of name internally: -- --
-- (\x1. \x2. e) arg1 --zapLamInfo :: IdInfo -> Maybe IdInfo -- | Zap info that depends on free variables zapFragileInfo :: IdInfo -> Maybe IdInfo -- | Remove all demand info on the IdInfo zapDemandInfo :: IdInfo -> Maybe IdInfo -- | Remove usage (but not strictness) info on the IdInfo zapUsageInfo :: IdInfo -> Maybe IdInfo -- | Remove usage environment info from the strictness signature on the -- IdInfo zapUsageEnvInfo :: IdInfo -> Maybe IdInfo zapUsedOnceInfo :: IdInfo -> Maybe IdInfo zapTailCallInfo :: IdInfo -> Maybe IdInfo zapCallArityInfo :: IdInfo -> IdInfo zapUnfolding :: Unfolding -> Unfolding -- | Arity Information -- -- An ArityInfo of n tells us that partial application of -- this Id to up to n-1 value arguments does -- essentially no work. -- -- That is not necessarily the same as saying that it has n -- leading lambdas, because coerces may get in the way. -- -- The arity might increase later in the compilation process, if an extra -- lambda floats up to the binding site. type ArityInfo = Arity -- | It is always safe to assume that an Id has an arity of 0 unknownArity :: Arity -- | Id arity, as computed by GHC.Core.Opt.Arity. Specifies -- how many arguments this Id has to be applied to before it -- doesn any meaningful work. arityInfo :: IdInfo -> ArityInfo setArityInfo :: IdInfo -> ArityInfo -> IdInfo infixl 1 `setArityInfo` ppArityInfo :: Int -> SDoc -- | How this is called. This is the number of arguments to which a binding -- can be eta-expanded without losing any sharing. n = all calls -- have at least n arguments callArityInfo :: IdInfo -> ArityInfo setCallArityInfo :: IdInfo -> ArityInfo -> IdInfo -- | A strictness signature. Digests how a function uses its arguments if -- applied to at least arityInfo arguments. strictnessInfo :: IdInfo -> StrictSig setStrictnessInfo :: IdInfo -> StrictSig -> IdInfo infixl 1 `setStrictnessInfo` -- | Information on whether the function will ultimately return a freshly -- allocated constructor. cprInfo :: IdInfo -> CprSig setCprInfo :: IdInfo -> CprSig -> IdInfo infixl 1 `setCprInfo` -- | ID demand information demandInfo :: IdInfo -> Demand setDemandInfo :: IdInfo -> Demand -> IdInfo infixl 1 `setDemandInfo` pprStrictness :: StrictSig -> SDoc -- | The Ids unfolding unfoldingInfo :: IdInfo -> Unfolding setUnfoldingInfo :: IdInfo -> Unfolding -> IdInfo infixl 1 `setUnfoldingInfo` -- | Inline Pragma Information -- -- Tells when the inlining is active. When it is active the thing may be -- inlined, depending on how big it is. -- -- If there was an INLINE pragma, then as a separate matter, the -- RHS will have been made to look small with a Core inline Note -- -- The default InlinePragInfo is AlwaysActive, so the info -- serves entirely as a way to inhibit inlining until we want it type InlinePragInfo = InlinePragma -- | Any inline pragma attached to the Id inlinePragInfo :: IdInfo -> InlinePragma setInlinePragInfo :: IdInfo -> InlinePragma -> IdInfo infixl 1 `setInlinePragInfo` -- | identifier Occurrence Information data OccInfo -- | There are many occurrences, or unknown occurrences ManyOccs :: !TailCallInfo -> OccInfo [occ_tail] :: OccInfo -> !TailCallInfo -- | Marks unused variables. Sometimes useful for lambda and case-bound -- variables. IAmDead :: OccInfo -- | Occurs exactly once (per branch), not inside a rule OneOcc :: !InsideLam -> {-# UNPACK #-} !BranchCount -> !InterestingCxt -> !TailCallInfo -> OccInfo [occ_in_lam] :: OccInfo -> !InsideLam [occ_n_br] :: OccInfo -> {-# UNPACK #-} !BranchCount [occ_int_cxt] :: OccInfo -> !InterestingCxt [occ_tail] :: OccInfo -> !TailCallInfo -- | This identifier breaks a loop of mutually recursive functions. The -- field marks whether it is only a loop breaker due to a reference in a -- rule IAmALoopBreaker :: !RulesOnly -> !TailCallInfo -> OccInfo [occ_rules_only] :: OccInfo -> !RulesOnly [occ_tail] :: OccInfo -> !TailCallInfo isDeadOcc :: OccInfo -> Bool isStrongLoopBreaker :: OccInfo -> Bool isWeakLoopBreaker :: OccInfo -> Bool -- | How the Id occurs in the program occInfo :: IdInfo -> OccInfo setOccInfo :: IdInfo -> OccInfo -> IdInfo infixl 1 `setOccInfo` -- | Inside Lambda data InsideLam -- | Occurs inside a non-linear lambda Substituting a redex for this -- occurrence is dangerous because it might duplicate work. IsInsideLam :: InsideLam NotInsideLam :: InsideLam type BranchCount = Int data TailCallInfo AlwaysTailCalled :: JoinArity -> TailCallInfo NoTailCallInfo :: TailCallInfo tailCallInfo :: OccInfo -> TailCallInfo isAlwaysTailCalled :: OccInfo -> Bool -- | Rule Information -- -- Records the specializations of this Id that we know about in -- the form of rewrite CoreRules that target them data RuleInfo RuleInfo :: [CoreRule] -> DVarSet -> RuleInfo -- | Assume that no specializations exist: always safe emptyRuleInfo :: RuleInfo isEmptyRuleInfo :: RuleInfo -> Bool -- | Retrieve the locally-defined free variables of both the left and right -- hand sides of the specialization rules ruleInfoFreeVars :: RuleInfo -> DVarSet ruleInfoRules :: RuleInfo -> [CoreRule] -- | Change the name of the function the rule is keyed on all of the -- CoreRules setRuleInfoHead :: Name -> RuleInfo -> RuleInfo -- | Specialisations of the Ids function which exist. See Note -- [Specialisations and RULES in IdInfo] ruleInfo :: IdInfo -> RuleInfo setRuleInfo :: IdInfo -> RuleInfo -> IdInfo infixl 1 `setRuleInfo` -- | Constant applicative form Information -- -- Records whether an Id makes Constant Applicative Form -- references data CafInfo -- | Indicates that the Id is for either: -- --
-- Dunno (nipc) -- | -- ExnOrDiv (nip) -- | -- Diverges (ni) ---- -- As you can see, we don't distinguish n and i. See Note -- [Precise exceptions and strictness analysis] for why p is so -- special compared to i. data Divergence -- | Definitely throws an imprecise exception or diverges. Diverges :: Divergence -- | Definitely throws a *precise* exception, an imprecise exception or -- diverges. Never converges, hence isDeadEndDiv! See scenario 1 -- in Note [Precise exceptions and strictness analysis]. ExnOrDiv :: Divergence -- | Might diverge, throw any kind of exception or converge. Dunno :: Divergence topDiv :: Divergence botDiv :: Divergence exnDiv :: Divergence lubDivergence :: Divergence -> Divergence -> Divergence -- | True if the Divergence indicates that evaluation will not -- return. See Note [Dead ends]. isDeadEndDiv :: Divergence -> Bool -- | Characterises how an expression * Evaluates its free variables -- (dt_env) * Evaluates its arguments (dt_args) * Diverges -- on every code path or not (dt_div) data DmdType DmdType :: !DmdEnv -> ![Demand] -> !Divergence -> DmdType -- | Demand on explicitly-mentioned free variables [dt_env] :: DmdType -> !DmdEnv -- | Demand on arguments [dt_args] :: DmdType -> ![Demand] -- | Whether evaluation diverges. See Note [Demand type Divergence] [dt_div] :: DmdType -> !Divergence dmdTypeDepth :: DmdType -> Arity -- | The demand type of doing nothing (lazy, absent, no Divergence -- information). Note that it is 'not' the top of the lattice -- (which would be "may use everything"), so it is (no longer) called -- topDmdType. nopDmdType :: DmdType botDmdType :: DmdType -- | Compute the least upper bound of two DmdTypes elicited /by the -- same incoming demand/! lubDmdType :: DmdType -> DmdType -> DmdType plusDmdType :: DmdType -> PlusDmdArg -> DmdType multDmdType :: Card -> DmdType -> DmdType type PlusDmdArg = (DmdEnv, Divergence) mkPlusDmdArg :: DmdEnv -> PlusDmdArg toPlusDmdArg :: DmdType -> PlusDmdArg peelFV :: DmdType -> Var -> (DmdType, Demand) findIdDemand :: DmdType -> Var -> Demand addDemand :: Demand -> DmdType -> DmdType splitDmdTy :: DmdType -> (Demand, DmdType) -- | When e is evaluated after executing an IO action that may throw a -- precise exception, we act as if there is an additional control flow -- path that is taken if e throws a precise exception. The demand type of -- this control flow path * is lazy and absent (topDmd) in all -- free variables and arguments * has exnDiv Divergence -- result So we can simply take a variant of nopDmdType, -- exnDmdType. Why not nopDmdType? Because then the result -- of e can never be exnDiv! That means failure to drop -- dead-ends, see #18086. See Note [Precise exceptions and strictness -- analysis] deferAfterPreciseException :: DmdType -> DmdType -- | See keepAliveDmdEnv. keepAliveDmdType :: DmdType -> VarSet -> DmdType -- | The depth of the wrapped DmdType encodes the arity at which it -- is safe to unleash. Better construct this through -- mkStrictSigForArity. See Note [Understanding DmdType and -- StrictSig] newtype StrictSig StrictSig :: DmdType -> StrictSig -- | Turns a DmdType computed for the particular Arity into a -- StrictSig unleashable at that arity. See Note [Understanding -- DmdType and StrictSig] mkStrictSigForArity :: Arity -> DmdType -> StrictSig mkClosedStrictSig :: [Demand] -> Divergence -> StrictSig splitStrictSig :: StrictSig -> ([Demand], Divergence) strictSigDmdEnv :: StrictSig -> DmdEnv hasDemandEnvSig :: StrictSig -> Bool nopSig :: StrictSig botSig :: StrictSig isTopSig :: StrictSig -> Bool -- | True if the signature diverges or throws an exception in a saturated -- call. See Note [Dead ends]. isDeadEndSig :: StrictSig -> Bool -- | Returns true if an application to n args would diverge or throw an -- exception. -- -- If a function having botDiv is applied to a less number of -- arguments than its syntactic arity, we cannot say for sure that it is -- going to diverge. Hence this function conservatively returns False in -- that case. See Note [Dead ends]. appIsDeadEnd :: StrictSig -> Int -> Bool -- | Add extra (topDmd) arguments to a strictness signature. In -- contrast to etaConvertStrictSig, this prepends -- additional argument demands. This is used by FloatOut. prependArgsStrictSig :: Int -> StrictSig -> StrictSig -- | We are expanding (x y. e) to (x y z. e z) or reducing from the latter -- to the former (when the Simplifier identifies a new join points, for -- example). In contrast to prependArgsStrictSig, this -- appends extra arg demands if necessary. This works by looking -- at the DmdType (which was produced under a call demand for the -- old arity) and trying to transfer as many facts as we can to the call -- demand of new arity. An arity increase (resulting in a stronger -- incoming demand) can retain much of the info, while an arity decrease -- (a weakening of the incoming demand) must fall back to a conservative -- default. etaConvertStrictSig :: Arity -> StrictSig -> StrictSig -- | A demand transformer is a monotone function from an incoming -- evaluation context (SubDemand) to a DmdType, describing -- how the denoted thing (i.e. expression, function) uses its arguments -- and free variables, and whether it diverges. -- -- See Note [Understanding DmdType and StrictSig] and Note [What are -- demand signatures?]. type DmdTransformer = SubDemand -> DmdType -- | Extrapolate a demand signature (StrictSig) into a -- DmdTransformer. -- -- Given a function's StrictSig and a SubDemand for the -- evaluation context, return how the function evaluates its free -- variables and arguments. dmdTransformSig :: StrictSig -> DmdTransformer -- | A special DmdTransformer for data constructors that feeds -- product demands into the constructor arguments. dmdTransformDataConSig :: Arity -> DmdTransformer -- | A special DmdTransformer for dictionary selectors that feeds -- the demand on the result into the indicated dictionary component (if -- saturated). dmdTransformDictSelSig :: StrictSig -> DmdTransformer data TypeShape TsFun :: TypeShape -> TypeShape TsProd :: [TypeShape] -> TypeShape TsUnk :: TypeShape trimToType :: Demand -> TypeShape -> Demand seqDemand :: Demand -> () seqDemandList :: [Demand] -> () seqDmdType :: DmdType -> () seqStrictSig :: StrictSig -> () zapUsageDemand :: Demand -> Demand -- | Remove the demand environment from the signature. zapDmdEnvSig :: StrictSig -> StrictSig -- | Remove all `C_01 :*` info (but not CM sub-demands) from the -- demand zapUsedOnceDemand :: Demand -> Demand -- | Remove all `C_01 :*` info (but not CM sub-demands) from the -- strictness signature zapUsedOnceSig :: StrictSig -> StrictSig instance GHC.Classes.Eq GHC.Types.Demand.Card instance GHC.Classes.Eq GHC.Types.Demand.Demand instance GHC.Classes.Eq GHC.Types.Demand.SubDemand instance GHC.Classes.Eq GHC.Types.Demand.Divergence instance GHC.Classes.Eq GHC.Types.Demand.StrictSig instance GHC.Utils.Outputable.Outputable GHC.Types.Demand.TypeShape instance GHC.Utils.Outputable.Outputable GHC.Types.Demand.StrictSig instance GHC.Utils.Binary.Binary GHC.Types.Demand.StrictSig instance GHC.Classes.Eq GHC.Types.Demand.DmdType instance GHC.Utils.Outputable.Outputable GHC.Types.Demand.DmdType instance GHC.Utils.Binary.Binary GHC.Types.Demand.DmdType instance GHC.Utils.Outputable.Outputable GHC.Types.Demand.Divergence instance GHC.Utils.Binary.Binary GHC.Types.Demand.Divergence instance GHC.Utils.Outputable.Outputable GHC.Types.Demand.Demand instance GHC.Utils.Outputable.Outputable GHC.Types.Demand.SubDemand instance GHC.Utils.Binary.Binary GHC.Types.Demand.Demand instance GHC.Utils.Binary.Binary GHC.Types.Demand.SubDemand instance GHC.Utils.Outputable.Outputable GHC.Types.Demand.Card instance GHC.Utils.Binary.Binary GHC.Types.Demand.Card module GHC.Types.Var.Env -- | Variable Environment type VarEnv elt = UniqFM Var elt -- | Identifier Environment type IdEnv elt = UniqFM Id elt -- | Type Variable Environment type TyVarEnv elt = UniqFM Var elt -- | Coercion Variable Environment type CoVarEnv elt = UniqFM CoVar elt -- | Type or Coercion Variable Environment type TyCoVarEnv elt = UniqFM TyCoVar elt emptyVarEnv :: VarEnv a unitVarEnv :: Var -> a -> VarEnv a mkVarEnv :: [(Var, a)] -> VarEnv a mkVarEnv_Directly :: [(Unique, a)] -> VarEnv a elemVarEnv :: Var -> VarEnv a -> Bool disjointVarEnv :: VarEnv a -> VarEnv a -> Bool extendVarEnv :: VarEnv a -> Var -> a -> VarEnv a extendVarEnv_C :: (a -> a -> a) -> VarEnv a -> Var -> a -> VarEnv a extendVarEnv_Acc :: (a -> b -> b) -> (a -> b) -> VarEnv b -> Var -> a -> VarEnv b extendVarEnvList :: VarEnv a -> [(Var, a)] -> VarEnv a plusVarEnv :: VarEnv a -> VarEnv a -> VarEnv a plusVarEnv_C :: (a -> a -> a) -> VarEnv a -> VarEnv a -> VarEnv a plusVarEnv_CD :: (a -> a -> a) -> VarEnv a -> a -> VarEnv a -> a -> VarEnv a plusMaybeVarEnv_C :: (a -> a -> Maybe a) -> VarEnv a -> VarEnv a -> VarEnv a plusVarEnvList :: [VarEnv a] -> VarEnv a alterVarEnv :: (Maybe a -> Maybe a) -> VarEnv a -> Var -> VarEnv a delVarEnvList :: VarEnv a -> [Var] -> VarEnv a delVarEnv :: VarEnv a -> Var -> VarEnv a minusVarEnv :: VarEnv a -> VarEnv b -> VarEnv a lookupVarEnv :: VarEnv a -> Var -> Maybe a lookupVarEnv_NF :: VarEnv a -> Var -> a lookupWithDefaultVarEnv :: VarEnv a -> a -> Var -> a mapVarEnv :: (a -> b) -> VarEnv a -> VarEnv b zipVarEnv :: [Var] -> [a] -> VarEnv a modifyVarEnv :: (a -> a) -> VarEnv a -> Var -> VarEnv a modifyVarEnv_Directly :: (a -> a) -> UniqFM key a -> Unique -> UniqFM key a isEmptyVarEnv :: VarEnv a -> Bool elemVarEnvByKey :: Unique -> VarEnv a -> Bool filterVarEnv :: (a -> Bool) -> VarEnv a -> VarEnv a restrictVarEnv :: VarEnv a -> VarSet -> VarEnv a partitionVarEnv :: (a -> Bool) -> VarEnv a -> (VarEnv a, VarEnv a) -- | Deterministic Variable Environment type DVarEnv elt = UniqDFM Var elt -- | Deterministic Identifier Environment Sadly not always indexed by Id, -- but it is in the common case. type DIdEnv elt = UniqDFM Var elt -- | Deterministic Type Variable Environment type DTyVarEnv elt = UniqDFM TyVar elt emptyDVarEnv :: DVarEnv a mkDVarEnv :: [(Var, a)] -> DVarEnv a dVarEnvElts :: DVarEnv a -> [a] extendDVarEnv :: DVarEnv a -> Var -> a -> DVarEnv a extendDVarEnv_C :: (a -> a -> a) -> DVarEnv a -> Var -> a -> DVarEnv a extendDVarEnvList :: DVarEnv a -> [(Var, a)] -> DVarEnv a lookupDVarEnv :: DVarEnv a -> Var -> Maybe a elemDVarEnv :: Var -> DVarEnv a -> Bool isEmptyDVarEnv :: DVarEnv a -> Bool foldDVarEnv :: (a -> b -> b) -> b -> DVarEnv a -> b nonDetStrictFoldDVarEnv :: (a -> b -> b) -> b -> DVarEnv a -> b mapDVarEnv :: (a -> b) -> DVarEnv a -> DVarEnv b filterDVarEnv :: (a -> Bool) -> DVarEnv a -> DVarEnv a modifyDVarEnv :: (a -> a) -> DVarEnv a -> Var -> DVarEnv a alterDVarEnv :: (Maybe a -> Maybe a) -> DVarEnv a -> Var -> DVarEnv a plusDVarEnv :: DVarEnv a -> DVarEnv a -> DVarEnv a plusDVarEnv_C :: (a -> a -> a) -> DVarEnv a -> DVarEnv a -> DVarEnv a unitDVarEnv :: Var -> a -> DVarEnv a delDVarEnv :: DVarEnv a -> Var -> DVarEnv a delDVarEnvList :: DVarEnv a -> [Var] -> DVarEnv a minusDVarEnv :: DVarEnv a -> DVarEnv a' -> DVarEnv a partitionDVarEnv :: (a -> Bool) -> DVarEnv a -> (DVarEnv a, DVarEnv a) anyDVarEnv :: (a -> Bool) -> DVarEnv a -> Bool -- | A set of variables that are in scope at some point "Secrets of the -- Glasgow Haskell Compiler inliner" Section 3.2 provides the motivation -- for this abstraction. data InScopeSet emptyInScopeSet :: InScopeSet mkInScopeSet :: VarSet -> InScopeSet delInScopeSet :: InScopeSet -> Var -> InScopeSet extendInScopeSet :: InScopeSet -> Var -> InScopeSet extendInScopeSetList :: InScopeSet -> [Var] -> InScopeSet extendInScopeSetSet :: InScopeSet -> VarSet -> InScopeSet getInScopeVars :: InScopeSet -> VarSet -- | Look up a variable the InScopeSet. This lets you map from the -- variable's identity (unique) to its full value. lookupInScope :: InScopeSet -> Var -> Maybe Var lookupInScope_Directly :: InScopeSet -> Unique -> Maybe Var unionInScope :: InScopeSet -> InScopeSet -> InScopeSet elemInScopeSet :: Var -> InScopeSet -> Bool -- | uniqAway in_scope v finds a unique that is not used in the -- in-scope set, and gives that to v. See Note [Local uniques]. uniqAway :: InScopeSet -> Var -> Var varSetInScope :: VarSet -> InScopeSet -> Bool -- | unsafeGetFreshUnique in_scope finds a unique that is not -- in-scope in the given InScopeSet. This must be used very -- carefully since one can very easily introduce non-unique -- Uniques this way. See Note [Local uniques]. unsafeGetFreshLocalUnique :: InScopeSet -> Unique -- | Rename Environment 2 -- -- When we are comparing (or matching) types or terms, we are faced with -- "going under" corresponding binders. E.g. when comparing: -- --
-- \x. e1 ~ \y. e2 ---- -- Basically we want to rename [x -> y] or -- [y -> x], but there are lots of things we must be -- careful of. In particular, x might be free in e2, or -- y in e1. So the idea is that we come up with a fresh binder -- that is free in neither, and rename x and y -- respectively. That means we must maintain: -- --
-- \x. f ~ \y. y ---- -- matching with [f -> y]. So for each expression we -- want to know that set of locally-bound variables. That is precisely -- the domain of the mappings 1. and 2., but we must ensure that we -- always extend the mappings as we go in. -- -- All of this information is bundled up in the RnEnv2 data RnEnv2 mkRnEnv2 :: InScopeSet -> RnEnv2 -- | rnBndr2 env bL bR goes under a binder bL in the Left -- term, and binder bR in the Right term. It finds a new binder, -- new_b, and returns an environment mapping bL -> -- new_b and bR -> new_b rnBndr2 :: RnEnv2 -> Var -> Var -> RnEnv2 -- | Applies rnBndr2 to several variables: the two variable lists -- must be of equal length rnBndrs2 :: RnEnv2 -> [Var] -> [Var] -> RnEnv2 -- | Similar to rnBndr2 but returns the new variable as well as the -- new environment rnBndr2_var :: RnEnv2 -> Var -> Var -> (RnEnv2, Var) -- | Look up the renaming of an occurrence in the left or right term rnOccL :: RnEnv2 -> Var -> Var -- | Look up the renaming of an occurrence in the left or right term rnOccR :: RnEnv2 -> Var -> Var -- | Tells whether a variable is locally bound inRnEnvL :: RnEnv2 -> Var -> Bool -- | Tells whether a variable is locally bound inRnEnvR :: RnEnv2 -> Var -> Bool -- | Look up the renaming of an occurrence in the left or right term rnOccL_maybe :: RnEnv2 -> Var -> Maybe Var -- | Look up the renaming of an occurrence in the left or right term rnOccR_maybe :: RnEnv2 -> Var -> Maybe Var -- | Similar to rnBndr2 but used when there's a binder on the left -- side only. rnBndrL :: RnEnv2 -> Var -> (RnEnv2, Var) -- | Similar to rnBndr2 but used when there's a binder on the right -- side only. rnBndrR :: RnEnv2 -> Var -> (RnEnv2, Var) -- | Wipe the left or right side renaming nukeRnEnvL :: RnEnv2 -> RnEnv2 -- | Wipe the left or right side renaming nukeRnEnvR :: RnEnv2 -> RnEnv2 -- | swap the meaning of left and right rnSwap :: RnEnv2 -> RnEnv2 delBndrL :: RnEnv2 -> Var -> RnEnv2 delBndrR :: RnEnv2 -> Var -> RnEnv2 delBndrsL :: RnEnv2 -> [Var] -> RnEnv2 delBndrsR :: RnEnv2 -> [Var] -> RnEnv2 extendRnInScopeSetList :: RnEnv2 -> [Var] -> RnEnv2 -- | Similar to rnBndrL but used for eta expansion See Note [Eta -- expansion] rnEtaL :: RnEnv2 -> Var -> (RnEnv2, Var) -- | Similar to rnBndr2 but used for eta expansion See Note [Eta -- expansion] rnEtaR :: RnEnv2 -> Var -> (RnEnv2, Var) rnInScope :: Var -> RnEnv2 -> Bool rnInScopeSet :: RnEnv2 -> InScopeSet lookupRnInScope :: RnEnv2 -> Var -> Var -- | Retrieve the left mapping rnEnvL :: RnEnv2 -> VarEnv Var -- | Retrieve the right mapping rnEnvR :: RnEnv2 -> VarEnv Var -- | Tidy Environment -- -- When tidying up print names, we keep a mapping of in-scope occ-names -- (the TidyOccEnv) and a Var-to-Var of the current renamings type TidyEnv = (TidyOccEnv, VarEnv Var) emptyTidyEnv :: TidyEnv mkEmptyTidyEnv :: TidyOccEnv -> TidyEnv delTidyEnvList :: TidyEnv -> [Var] -> TidyEnv instance GHC.Utils.Outputable.Outputable GHC.Types.Var.Env.InScopeSet -- | GHC uses several kinds of name internally: -- --
-- f :: (Eq a) => a -> Int
-- g :: (?x :: Int -> Int) => a -> Int
-- h :: (r\l) => {r} => {l::Int | r}
--
--
-- Here the Eq a and ?x :: Int -> Int and
-- rl are all called "predicates"
type PredType = Type
-- | A collection of PredTypes
type ThetaType = [PredType]
-- | Variable
--
-- Essentially a typed Name, that may also contain some additional
-- information about the Var and its use sites.
data Var
-- | Type or kind Variable
type TyVar = Var
-- | Is this a type-level (i.e., computationally irrelevant, thus erasable)
-- variable? Satisfies isTyVar = not . isId.
isTyVar :: Var -> Bool
-- | Type or Coercion Variable
type TyCoVar = Id
-- | A TyCoBinder represents an argument to a function. TyCoBinders
-- can be dependent (Named) or nondependent (Anon). They
-- may also be visible or not. See Note [TyCoBinders]
data TyCoBinder
-- | Variable Binder
--
-- A TyCoVarBinder is the binder of a ForAllTy It's convenient to
-- define this synonym here rather its natural home in
-- GHC.Core.TyCo.Rep, because it's used in
-- GHC.Core.DataCon.hs-boot
--
-- A TyVarBinder is a binder with only TyVar
type TyCoVarBinder = VarBndr TyCoVar ArgFlag
type TyVarBinder = VarBndr TyVar ArgFlag
-- | Mult is a type alias for Type.
--
-- Mult must contain Type because multiplicity variables are mere type
-- variables (of kind Multiplicity) in Haskell. So the simplest
-- implementation is to make Mult be Type.
--
-- Multiplicities can be formed with: - One: GHC.Types.One (= oneDataCon)
-- - Many: GHC.Types.Many (= manyDataCon) - Multiplication:
-- GHC.Types.MultMul (= multMulTyCon)
--
-- So that Mult feels a bit more structured, we provide pattern synonyms
-- and smart constructors for these.
type Mult = Type
-- | A shorthand for data with an attached Mult element (the
-- multiplicity).
data Scaled a
-- | A type labeled KnotTied might have knot-tied tycons in it. See
-- Note [Type checking recursive type and class declarations] in
-- GHC.Tc.TyCl
type KnotTied ty = ty
mkTyVarTy :: TyVar -> Type
mkTyVarTys :: [TyVar] -> [Type]
-- | Attempts to obtain the type variable underlying a Type, and
-- panics with the given message if this is not a type variable type. See
-- also getTyVar_maybe
getTyVar :: String -> Type -> TyVar
-- | Attempts to obtain the type variable underlying a Type
getTyVar_maybe :: Type -> Maybe TyVar
-- | Attempts to obtain the type variable underlying a Type, without
-- any expansion
repGetTyVar_maybe :: Type -> Maybe TyVar
-- | If the type is a tyvar, possibly under a cast, returns it, along with
-- the coercion. Thus, the co is :: kind tv ~N kind ty
getCastedTyVar_maybe :: Type -> Maybe (TyVar, CoercionN)
tyVarKind :: TyVar -> Kind
-- | The type or kind of the Var in question
varType :: Var -> Kind
-- | Applies a type to another, as in e.g. k a
mkAppTy :: Type -> Type -> Type
mkAppTys :: Type -> [Type] -> Type
-- | Attempts to take a type application apart, as in
-- splitAppTy_maybe, and panics if this is not possible
splitAppTy :: Type -> (Type, Type)
-- | Recursively splits a type as far as is possible, leaving a residual
-- type being applied to and the type arguments applied to it. Never
-- fails, even if that means returning an empty list of type
-- applications.
splitAppTys :: Type -> (Type, [Type])
-- | Like splitAppTys, but doesn't look through type synonyms
repSplitAppTys :: HasDebugCallStack => Type -> (Type, [Type])
-- | Attempt to take a type application apart, whether it is a function,
-- type constructor, or plain type application. Note that type family
-- applications are NEVER unsaturated by this!
splitAppTy_maybe :: Type -> Maybe (Type, Type)
-- | Does the AppTy split as in splitAppTy_maybe, but assumes that
-- any Core view stuff is already done
repSplitAppTy_maybe :: HasDebugCallStack => Type -> Maybe (Type, Type)
-- | Does the AppTy split as in tcSplitAppTy_maybe, but assumes
-- that any coreView stuff is already done. Refuses to look through (c
-- => t)
tcRepSplitAppTy_maybe :: Type -> Maybe (Type, Type)
mkFunTy :: AnonArgFlag -> Mult -> Type -> Type -> Type
infixr 3 `mkFunTy`
mkVisFunTy :: Mult -> Type -> Type -> Type
infixr 3 `mkVisFunTy`
mkInvisFunTy :: Mult -> Type -> Type -> Type
infixr 3 `mkInvisFunTy`
-- | Make nested arrow types
mkVisFunTys :: [Scaled Type] -> Type -> Type
-- | Special, common, case: Arrow type with mult Many
mkVisFunTyMany :: Type -> Type -> Type
infixr 3 `mkVisFunTyMany`
mkInvisFunTyMany :: Type -> Type -> Type
infixr 3 `mkInvisFunTyMany`
mkVisFunTysMany :: [Type] -> Type -> Type
mkInvisFunTysMany :: [Type] -> Type -> Type
-- | Attempts to extract the multiplicity, argument and result types from a
-- type, and panics if that is not possible. See also
-- splitFunTy_maybe
splitFunTy :: Type -> (Mult, Type, Type)
-- | Attempts to extract the multiplicity, argument and result types from a
-- type
splitFunTy_maybe :: Type -> Maybe (Mult, Type, Type)
splitFunTys :: Type -> ([Scaled Type], Type)
-- | Extract the function result type and panic if that is not possible
funResultTy :: Type -> Type
-- | Just like piResultTys but for a single argument Try not to
-- iterate piResultTy, because it's inefficient to substitute one
-- variable at a time; instead use 'piResultTys"
--
-- Extract the function argument type and panic if that is not possible
funArgTy :: Type -> Type
-- | A key function: builds a TyConApp or FunTy as
-- appropriate to its arguments. Applies its arguments to the constructor
-- from left to right.
mkTyConApp :: TyCon -> [Type] -> Type
-- | Create the plain type constructor type which has been applied to no
-- type arguments at all.
mkTyConTy :: TyCon -> Type
-- | Given a RuntimeRep, applies TYPE to it. See Note
-- [TYPE and RuntimeRep] in GHC.Builtin.Types.Prim.
tYPE :: Type -> Type
-- | The same as fst . splitTyConApp
tyConAppTyCon_maybe :: Type -> Maybe TyCon
-- | Retrieve the tycon heading this type, if there is one. Does not
-- look through synonyms.
tyConAppTyConPicky_maybe :: Type -> Maybe TyCon
-- | The same as snd . splitTyConApp
tyConAppArgs_maybe :: Type -> Maybe [Type]
tyConAppTyCon :: Type -> TyCon
tyConAppArgs :: Type -> [Type]
-- | Attempts to tease a type apart into a type constructor and the
-- application of a number of arguments to that constructor
splitTyConApp_maybe :: HasDebugCallStack => Type -> Maybe (TyCon, [Type])
-- | Attempts to tease a type apart into a type constructor and the
-- application of a number of arguments to that constructor. Panics if
-- that is not possible. See also splitTyConApp_maybe
splitTyConApp :: Type -> (TyCon, [Type])
tyConAppArgN :: Int -> Type -> Type
-- | Split a type constructor application into its type constructor and
-- applied types. Note that this may fail in the case of a FunTy
-- with an argument of unknown kind FunTy (e.g. FunTy (a :: k)
-- Int. since the kind of a isn't of the form TYPE
-- rep). Consequently, you may need to zonk your type before using
-- this function.
--
-- This does *not* split types headed with (=>), as that's not a TyCon
-- in the type-checker.
--
-- If you only need the TyCon, consider using
-- tcTyConAppTyCon_maybe.
tcSplitTyConApp_maybe :: HasCallStack => Type -> Maybe (TyCon, [Type])
-- | Attempts to tease a list type apart and gives the type of the elements
-- if successful (looks through type synonyms)
splitListTyConApp_maybe :: Type -> Maybe Type
-- | Like splitTyConApp_maybe, but doesn't look through synonyms.
-- This assumes the synonyms have already been dealt with.
repSplitTyConApp_maybe :: HasDebugCallStack => Type -> Maybe (TyCon, [Type])
-- | Like tcSplitTyConApp_maybe, but doesn't look through synonyms.
-- This assumes the synonyms have already been dealt with.
--
-- Moreover, for a FunTy, it only succeeds if the argument types have
-- enough info to extract the runtime-rep arguments that the funTyCon
-- requires. This will usually be true; but may be temporarily false
-- during canonicalization: see Note [Decomposing FunTy] in
-- GHC.Tc.Solver.Canonical and Note [The Purely Kinded Type Invariant
-- (PKTI)] in GHC.Tc.Gen.HsType, Wrinkle around FunTy
tcRepSplitTyConApp_maybe :: HasDebugCallStack => Type -> Maybe (TyCon, [Type])
-- | Like mkTyCoForAllTy, but does not check the occurrence of the
-- binder See Note [Unused coercion variable in ForAllTy]
mkForAllTy :: TyCoVar -> ArgFlag -> Type -> Type
-- | Wraps foralls over the type using the provided TyCoVars from
-- left to right
mkForAllTys :: [TyCoVarBinder] -> Type -> Type
-- | Wraps foralls over the type using the provided InvisTVBinders
-- from left to right
mkInvisForAllTys :: [InvisTVBinder] -> Type -> Type
-- | Like mkForAllTys, but assumes all variables are dependent and
-- Inferred, a common case
mkTyCoInvForAllTys :: [TyCoVar] -> Type -> Type
-- | Like mkForAllTy, but assumes the variable is dependent and
-- Specified, a common case
mkSpecForAllTy :: TyVar -> Type -> Type
-- | Like mkForAllTys, but assumes all variables are dependent and
-- Specified, a common case
mkSpecForAllTys :: [TyVar] -> Type -> Type
-- | Like mkForAllTys, but assumes all variables are dependent and visible
mkVisForAllTys :: [TyVar] -> Type -> Type
-- | Make a dependent forall over an Inferred variable
mkTyCoInvForAllTy :: TyCoVar -> Type -> Type
-- | Like mkTyCoInvForAllTy, but tv should be a tyvar
mkInfForAllTy :: TyVar -> Type -> Type
-- | Like mkTyCoInvForAllTys, but tvs should be a list of tyvar
mkInfForAllTys :: [TyVar] -> Type -> Type
-- | Take a ForAllTy apart, returning the list of tycovars and the result
-- type. This always succeeds, even if it returns only an empty list.
-- Note that the result type returned may have free variables that were
-- bound by a forall.
splitForAllTyCoVars :: Type -> ([TyCoVar], Type)
-- | Like splitForAllTyCoVars, but only splits ForAllTys with
-- Required type variable binders. Furthermore, each returned
-- tyvar is annotated with ().
splitForAllReqTVBinders :: Type -> ([ReqTVBinder], Type)
-- | Like splitForAllTyCoVars, but only splits ForAllTys with
-- Invisible type variable binders. Furthermore, each returned
-- tyvar is annotated with its Specificity.
splitForAllInvisTVBinders :: Type -> ([InvisTVBinder], Type)
-- | Like splitPiTys but split off only named binders and
-- returns TyCoVarBinders rather than TyCoBinders
splitForAllTyCoVarBinders :: Type -> ([TyCoVarBinder], Type)
-- | Attempts to take a forall type apart, but only if it's a proper
-- forall, with a named binder
splitForAllTyCoVar_maybe :: Type -> Maybe (TyCoVar, Type)
-- | Take a forall type apart, or panics if that is not possible.
splitForAllTyCoVar :: Type -> (TyCoVar, Type)
-- | Like splitForAllTyCoVar_maybe, but only returns Just if it is a
-- tyvar binder.
splitForAllTyVar_maybe :: Type -> Maybe (TyCoVar, Type)
-- | Like splitForAllTyCoVar_maybe, but only returns Just if it is a
-- covar binder.
splitForAllCoVar_maybe :: Type -> Maybe (TyCoVar, Type)
-- | Attempts to take a forall type apart; works with proper foralls and
-- functions
splitPiTy_maybe :: Type -> Maybe (TyCoBinder, Type)
-- | Takes a forall type apart, or panics
splitPiTy :: Type -> (TyCoBinder, Type)
-- | Split off all TyCoBinders to a type, splitting both proper foralls and
-- functions
splitPiTys :: Type -> ([TyCoBinder], Type)
-- | Given a list of type-level vars and the free vars of a result kind,
-- makes TyCoBinders, preferring anonymous binders if the variable is, in
-- fact, not dependent. e.g. mkTyConBindersPreferAnon
-- (k:*),(b:k),(c:k) We want (k:*) Named, (b:k) Anon, (c:k) Anon
--
-- All non-coercion binders are visible.
mkTyConBindersPreferAnon :: [TyVar] -> TyCoVarSet -> [TyConBinder]
mkPiTy :: TyCoBinder -> Type -> Type
mkPiTys :: [TyCoBinder] -> Type -> Type
piResultTy :: HasDebugCallStack => Type -> Type -> Type
-- | (piResultTys f_ty [ty1, .., tyn]) gives the type of (f ty1 .. tyn)
-- where f :: f_ty piResultTys is interesting because: 1.
-- f_ty may have more for-alls than there are args 2. Less
-- obviously, it may have fewer for-alls For case 2. think of:
-- piResultTys (forall a.a) [forall b.b, Int] This really can happen, but
-- only (I think) in situations involving undefined. For example:
-- undefined :: forall a. a Term: undefined (forall b. b->b)
-- Int This term should have type (Int -> Int), but notice that
-- there are more type args than foralls in undefineds type.
piResultTys :: HasDebugCallStack => Type -> [Type] -> Type
applyTysX :: [TyVar] -> Type -> [Type] -> Type
-- | Drops all ForAllTys
dropForAlls :: Type -> Type
-- | Given a family instance TyCon and its arg types, return the
-- corresponding family type. E.g:
--
-- -- data family T a -- data instance T (Maybe b) = MkT b ---- -- Where the instance tycon is :RTL, so: -- --
-- mkFamilyTyConApp :RTL Int = T (Maybe Int) --mkFamilyTyConApp :: TyCon -> [Type] -> Type buildSynTyCon :: Name -> [KnotTied TyConBinder] -> Kind -> [Role] -> KnotTied Type -> TyCon mkNumLitTy :: Integer -> Type -- | Is this a numeric literal. We also look through type synonyms. isNumLitTy :: Type -> Maybe Integer mkStrLitTy :: FastString -> Type -- | Is this a symbol literal. We also look through type synonyms. isStrLitTy :: Type -> Maybe FastString mkCharLitTy :: Char -> Type -- | Is this a char literal? We also look through type synonyms. isCharLitTy :: Type -> Maybe Char -- | Is this a type literal (symbol, numeric, or char)? isLitTy :: Type -> Maybe TyLit isPredTy :: HasDebugCallStack => Type -> Bool -- | Extract the RuntimeRep classifier of a type. For instance, -- getRuntimeRep_maybe Int = LiftedRep. Returns Nothing -- if this is not possible. getRuntimeRep_maybe :: HasDebugCallStack => Type -> Maybe Type -- | Given a kind (TYPE rr), extract its RuntimeRep classifier rr. For -- example, kindRep_maybe * = Just LiftedRep Returns -- Nothing if the kind is not of form (TYPE rr) Treats * and -- Constraint as the same kindRep_maybe :: HasDebugCallStack => Kind -> Maybe Type -- | Extract the RuntimeRep classifier of a type from its kind. For -- example, kindRep * = LiftedRep; Panics if this is not -- possible. Treats * and Constraint as the same kindRep :: HasDebugCallStack => Kind -> Type -- | Make a CastTy. The Coercion must be nominal. Checks the -- Coercion for reflexivity, dropping it if it's reflexive. See Note -- [Respecting definitional equality] in GHC.Core.TyCo.Rep mkCastTy :: Type -> Coercion -> Type mkCoercionTy :: Coercion -> Type splitCastTy_maybe :: Type -> Maybe (Type, Coercion) -- | Is this type a custom user error? If so, give us the kind and the -- error message. userTypeError_maybe :: Type -> Maybe Type -- | Render a type corresponding to a user type error into a SDoc. pprUserTypeErrorTy :: Type -> SDoc -- | Get the type on the LHS of a coercion induced by a type/data family -- instance. coAxNthLHS :: CoAxiom br -> Int -> Type stripCoercionTy :: Type -> Coercion -- | Like splitPiTys, but returns only *invisible* binders, -- including constraints. Stops at the first visible binder. splitInvisPiTys :: Type -> ([TyCoBinder], Type) -- | Same as splitInvisPiTys, but stop when - you have found -- n TyCoBinders, - or you run out of invisible binders splitInvisPiTysN :: Int -> Type -> ([TyCoBinder], Type) invisibleTyBndrCount :: Type -> Int -- | Given a TyCon and a list of argument types, filter out any -- invisible (i.e., Inferred or Specified) arguments. filterOutInvisibleTypes :: TyCon -> [Type] -> [Type] -- | Given a TyCon and a list of argument types, filter out any -- Inferred arguments. filterOutInferredTypes :: TyCon -> [Type] -> [Type] -- | Given a TyCon and a list of argument types, partition the -- arguments into: -- --
-- T :: forall k. k -> k -- tyConArgFlags T [forall m. m -> m -> m, S, R, Q] ---- -- After substituting, we get -- --
-- T (forall m. m -> m -> m) :: (forall m. m -> m -> m) -> forall n. n -> n -> n ---- -- Thus, the first argument is invisible, S is visible, -- R is invisible again, and Q is visible. tyConArgFlags :: TyCon -> [Type] -> [ArgFlag] -- | Given a Type and a list of argument types to which the -- Type is applied, determine each argument's visibility -- (Inferred, Specified, or Required). -- -- Most of the time, the arguments will be Required, but not -- always. Consider f :: forall a. a -> Type. In f Type -- Bool, the first argument (Type) is Specified and -- the second argument (Bool) is Required. It is -- precisely this sort of higher-rank situation in which -- appTyArgFlags comes in handy, since f Type Bool would -- be represented in Core using AppTys. (See also #15792). appTyArgFlags :: Type -> [Type] -> [ArgFlag] -- | This describes how a "map" operation over a type/coercion should -- behave data TyCoMapper env m TyCoMapper :: (env -> TyVar -> m Type) -> (env -> CoVar -> m Coercion) -> (env -> CoercionHole -> m Coercion) -> (env -> TyCoVar -> ArgFlag -> m (env, TyCoVar)) -> (TyCon -> m TyCon) -> TyCoMapper env m [tcm_tyvar] :: TyCoMapper env m -> env -> TyVar -> m Type [tcm_covar] :: TyCoMapper env m -> env -> CoVar -> m Coercion -- | What to do with coercion holes. See Note [Coercion holes] in -- GHC.Core.TyCo.Rep. [tcm_hole] :: TyCoMapper env m -> env -> CoercionHole -> m Coercion -- | The returned env is used in the extended scope [tcm_tycobinder] :: TyCoMapper env m -> env -> TyCoVar -> ArgFlag -> m (env, TyCoVar) -- | This is used only for TcTyCons a) To zonk TcTyCons b) To turn TcTyCons -- into TyCons. See Note [Type checking recursive type and class -- declarations] in GHC.Tc.TyCl [tcm_tycon] :: TyCoMapper env m -> TyCon -> m TyCon mapTyCo :: Monad m => TyCoMapper () m -> (Type -> m Type, [Type] -> m [Type], Coercion -> m Coercion, [Coercion] -> m [Coercion]) mapTyCoX :: Monad m => TyCoMapper env m -> (env -> Type -> m Type, env -> [Type] -> m [Type], env -> Coercion -> m Coercion, env -> [Coercion] -> m [Coercion]) data TyCoFolder env a TyCoFolder :: (Type -> Maybe Type) -> (env -> TyVar -> a) -> (env -> CoVar -> a) -> (env -> CoercionHole -> a) -> (env -> TyCoVar -> ArgFlag -> env) -> TyCoFolder env a [tcf_view] :: TyCoFolder env a -> Type -> Maybe Type [tcf_tyvar] :: TyCoFolder env a -> env -> TyVar -> a [tcf_covar] :: TyCoFolder env a -> env -> CoVar -> a -- | What to do with coercion holes. See Note [Coercion holes] in -- GHC.Core.TyCo.Rep. [tcf_hole] :: TyCoFolder env a -> env -> CoercionHole -> a -- | The returned env is used in the extended scope [tcf_tycobinder] :: TyCoFolder env a -> env -> TyCoVar -> ArgFlag -> env foldTyCo :: Monoid a => TyCoFolder env a -> env -> (Type -> a, [Type] -> a, Coercion -> a, [Coercion] -> a) -- | Unwrap one layer of newtype on a type constructor and its -- arguments, using an eta-reduced version of the newtype if -- possible. This requires tys to have at least newTyConInstArity -- tycon elements. newTyConInstRhs :: TyCon -> [Type] -> Type -- | Do these denote the same level of visibility? Required -- arguments are visible, others are not. So this function equates -- Specified and Inferred. Used for printing. sameVis :: ArgFlag -> ArgFlag -> Bool -- | Make a named binder mkTyCoVarBinder :: vis -> TyCoVar -> VarBndr TyCoVar vis -- | Make many named binders mkTyCoVarBinders :: vis -> [TyCoVar] -> [VarBndr TyCoVar vis] -- | Make a named binder var should be a type variable mkTyVarBinder :: vis -> TyVar -> VarBndr TyVar vis -- | Make many named binders Input vars should be type variables mkTyVarBinders :: vis -> [TyVar] -> [VarBndr TyVar vis] tyVarSpecToBinders :: [VarBndr a Specificity] -> [VarBndr a ArgFlag] -- | Make an anonymous binder mkAnonBinder :: AnonArgFlag -> Scaled Type -> TyCoBinder -- | Does this binder bind a variable that is not erased? Returns -- True for anonymous binders. isAnonTyCoBinder :: TyCoBinder -> Bool binderVar :: VarBndr tv argf -> tv binderVars :: [VarBndr tv argf] -> [tv] binderType :: VarBndr TyCoVar argf -> Type binderArgFlag :: VarBndr tv argf -> argf tyCoBinderType :: TyCoBinder -> Type tyCoBinderVar_maybe :: TyCoBinder -> Maybe TyCoVar tyBinderType :: TyBinder -> Type -- | Extract a relevant type, if there is one. binderRelevantType_maybe :: TyCoBinder -> Maybe Type -- | Does this ArgFlag classify an argument that is written in -- Haskell? isVisibleArgFlag :: ArgFlag -> Bool -- | Does this ArgFlag classify an argument that is not written in -- Haskell? isInvisibleArgFlag :: ArgFlag -> Bool -- | Does this binder bind a visible argument? isVisibleBinder :: TyCoBinder -> Bool -- | Does this binder bind an invisible argument? isInvisibleBinder :: TyCoBinder -> Bool isNamedBinder :: TyCoBinder -> Bool tyConBindersTyCoBinders :: [TyConBinder] -> [TyCoBinder] -- | The FUN type constructor. -- --
-- FUN :: forall (m :: Multiplicity) ->
-- forall {rep1 :: RuntimeRep} {rep2 :: RuntimeRep}.
-- TYPE rep1 -> TYPE rep2 -> *
--
--
-- The runtime representations quantification is left inferred. This
-- means they cannot be specified with -XTypeApplications.
--
-- This is a deliberate choice to allow future extensions to the function
-- arrow. To allow visible application a type synonym can be defined:
--
-- -- type Arr :: forall (rep1 :: RuntimeRep) (rep2 :: RuntimeRep). -- TYPE rep1 -> TYPE rep2 -> Type -- type Arr = FUN 'Many --funTyCon :: TyCon unrestrictedFunTyCon :: TyCon isTyVarTy :: Type -> Bool -- | Is this a function? isFunTy :: Type -> Bool isCoercionTy :: Type -> Bool isCoercionTy_maybe :: Type -> Maybe Coercion -- | Checks whether this is a proper forall (with a named binder) isForAllTy :: Type -> Bool -- | Like isForAllTy, but returns True only if it is a tyvar binder isForAllTy_ty :: Type -> Bool -- | Like isForAllTy, but returns True only if it is a covar binder isForAllTy_co :: Type -> Bool -- | Is this a function or forall? isPiTy :: Type -> Bool isTauTy :: Type -> Bool isFamFreeTy :: Type -> Bool -- | Does this type classify a core (unlifted) Coercion? At either role -- nominal or representational (t1 ~# t2) or (t1 ~R# t2) See Note [Types -- for coercions, predicates, and evidence] in GHC.Core.TyCo.Rep isCoVarType :: Type -> Bool isAtomicTy :: Type -> Bool -- | Determine whether a type could be the type of a join point of given -- total arity, according to the polymorphism rule. A join point cannot -- be polymorphic in its return type, since given join j a b x y -- z = e1 in e2, the types of e1 and e2 must be the same, and a and b are -- not in scope for e2. (See Note [The polymorphism rule of join points] -- in GHC.Core.) Returns False also if the type simply doesn't -- have enough arguments. -- -- Note that we need to know how many arguments (type *and* value) the -- putative join point takes; for instance, if j :: forall a. a -> Int -- then j could be a binary join point returning an Int, but it could -- *not* be a unary join point returning a -> Int. -- -- TODO: See Note [Excess polymorphism and join points] isValidJoinPointType :: JoinArity -> Type -> Bool -- | Does a TyCon (that is applied to some number of arguments) need -- to be ascribed with an explicit kind signature to resolve ambiguity if -- rendered as a source-syntax type? (See Note [When does a tycon -- application need an explicit kind signature?] for a full -- explanation of what this function checks for.) tyConAppNeedsKindSig :: Bool -> TyCon -> Int -> Bool -- | Returns Just True if this type is surely lifted, Just False if it is -- surely unlifted, Nothing if we can't be sure (i.e., it is levity -- polymorphic), and panics if the kind does not have the shape TYPE r. isLiftedType_maybe :: HasDebugCallStack => Type -> Maybe Bool -- | This version considers Constraint to be the same as *. Returns True if -- the argument is equivalent to Type/Constraint and False otherwise. See -- Note [Kind Constraint and kind Type] isLiftedTypeKind :: Kind -> Bool -- | Returns True if the kind classifies unlifted types (like 'Int#') and -- False otherwise. Note that this returns False for levity-polymorphic -- kinds, which may be specialized to a kind that classifies unlifted -- types. isUnliftedTypeKind :: Kind -> Bool -- | Returns True if the kind classifies types which are allocated on the -- GC'd heap and False otherwise. Note that this returns False for -- levity-polymorphic kinds, which may be specialized to a kind that -- classifies AddrRep or even unboxed kinds. isBoxedTypeKind :: Kind -> Bool pickyIsLiftedTypeKind :: Kind -> Bool isLiftedRuntimeRep :: Type -> Bool isUnliftedRuntimeRep :: Type -> Bool -- | See isBoxedRuntimeRep_maybe. isBoxedRuntimeRep :: Type -> Bool isLiftedLevity :: Type -> Bool isUnliftedLevity :: Type -> Bool -- | See Type#type_classification for what an unlifted type is. -- Panics on levity polymorphic types; See mightBeUnliftedType for -- a more approximate predicate that behaves better in the presence of -- levity polymorphism. isUnliftedType :: HasDebugCallStack => Type -> Bool -- | See Type#type_classification for what a boxed type is. Panics -- on levity polymorphic types; See mightBeUnliftedType for a more -- approximate predicate that behaves better in the presence of levity -- polymorphism. isBoxedType :: Type -> Bool -- | Returns: -- --
-- -fPIC --Opt_PIC :: GeneralFlag -- |
-- -fPIE --Opt_PIE :: GeneralFlag -- |
-- -pie --Opt_PICExecutable :: GeneralFlag Opt_ExternalDynamicRefs :: GeneralFlag Opt_Ticky :: GeneralFlag Opt_Ticky_Allocd :: GeneralFlag Opt_Ticky_LNE :: GeneralFlag Opt_Ticky_Dyn_Thunk :: GeneralFlag Opt_RPath :: GeneralFlag Opt_RelativeDynlibPaths :: GeneralFlag -- |
-- -fcompact-unwind --Opt_CompactUnwind :: GeneralFlag Opt_Hpc :: GeneralFlag Opt_FamAppCache :: GeneralFlag Opt_ExternalInterpreter :: GeneralFlag Opt_OptimalApplicativeDo :: GeneralFlag Opt_VersionMacros :: GeneralFlag Opt_WholeArchiveHsLibs :: GeneralFlag Opt_SingleLibFolder :: GeneralFlag Opt_ExposeInternalSymbols :: GeneralFlag Opt_KeepCAFs :: GeneralFlag Opt_KeepGoing :: GeneralFlag Opt_ByteCode :: GeneralFlag Opt_LinkRts :: GeneralFlag Opt_ErrorSpans :: GeneralFlag Opt_DeferDiagnostics :: GeneralFlag Opt_DiagnosticsShowCaret :: GeneralFlag Opt_PprCaseAsLet :: GeneralFlag Opt_PprShowTicks :: GeneralFlag Opt_ShowHoleConstraints :: GeneralFlag Opt_ShowValidHoleFits :: GeneralFlag Opt_SortValidHoleFits :: GeneralFlag Opt_SortBySizeHoleFits :: GeneralFlag Opt_SortBySubsumHoleFits :: GeneralFlag Opt_AbstractRefHoleFits :: GeneralFlag Opt_UnclutterValidHoleFits :: GeneralFlag Opt_ShowTypeAppOfHoleFits :: GeneralFlag Opt_ShowTypeAppVarsOfHoleFits :: GeneralFlag Opt_ShowDocsOfHoleFits :: GeneralFlag Opt_ShowTypeOfHoleFits :: GeneralFlag Opt_ShowProvOfHoleFits :: GeneralFlag Opt_ShowMatchesOfHoleFits :: GeneralFlag Opt_ShowLoadedModules :: GeneralFlag Opt_HexWordLiterals :: GeneralFlag Opt_SuppressCoercions :: GeneralFlag Opt_SuppressVarKinds :: GeneralFlag Opt_SuppressModulePrefixes :: GeneralFlag Opt_SuppressTypeApplications :: GeneralFlag Opt_SuppressIdInfo :: GeneralFlag Opt_SuppressUnfoldings :: GeneralFlag Opt_SuppressTypeSignatures :: GeneralFlag Opt_SuppressUniques :: GeneralFlag Opt_SuppressStgExts :: GeneralFlag Opt_SuppressTicks :: GeneralFlag -- | Suppress timestamps in dumps Opt_SuppressTimestamps :: GeneralFlag Opt_AutoLinkPackages :: GeneralFlag Opt_ImplicitImportQualified :: GeneralFlag Opt_KeepHscppFiles :: GeneralFlag Opt_KeepHiDiffs :: GeneralFlag Opt_KeepHcFiles :: GeneralFlag Opt_KeepSFiles :: GeneralFlag Opt_KeepTmpFiles :: GeneralFlag Opt_KeepRawTokenStream :: GeneralFlag Opt_KeepLlvmFiles :: GeneralFlag Opt_KeepHiFiles :: GeneralFlag Opt_KeepOFiles :: GeneralFlag Opt_BuildDynamicToo :: GeneralFlag Opt_DistrustAllPackages :: GeneralFlag Opt_PackageTrust :: GeneralFlag Opt_PluginTrustworthy :: GeneralFlag Opt_G_NoStateHack :: GeneralFlag Opt_G_NoOptCoercion :: GeneralFlag data WarningFlag Opt_WarnDuplicateExports :: WarningFlag Opt_WarnDuplicateConstraints :: WarningFlag Opt_WarnRedundantConstraints :: WarningFlag Opt_WarnHiShadows :: WarningFlag Opt_WarnImplicitPrelude :: WarningFlag Opt_WarnIncompletePatterns :: WarningFlag Opt_WarnIncompleteUniPatterns :: WarningFlag Opt_WarnIncompletePatternsRecUpd :: WarningFlag Opt_WarnOverflowedLiterals :: WarningFlag Opt_WarnEmptyEnumerations :: WarningFlag Opt_WarnMissingFields :: WarningFlag Opt_WarnMissingImportList :: WarningFlag Opt_WarnMissingMethods :: WarningFlag Opt_WarnMissingSignatures :: WarningFlag Opt_WarnMissingLocalSignatures :: WarningFlag Opt_WarnNameShadowing :: WarningFlag Opt_WarnOverlappingPatterns :: WarningFlag Opt_WarnTypeDefaults :: WarningFlag Opt_WarnMonomorphism :: WarningFlag Opt_WarnUnusedTopBinds :: WarningFlag Opt_WarnUnusedLocalBinds :: WarningFlag Opt_WarnUnusedPatternBinds :: WarningFlag Opt_WarnUnusedImports :: WarningFlag Opt_WarnUnusedMatches :: WarningFlag Opt_WarnUnusedTypePatterns :: WarningFlag Opt_WarnUnusedForalls :: WarningFlag Opt_WarnUnusedRecordWildcards :: WarningFlag Opt_WarnRedundantBangPatterns :: WarningFlag Opt_WarnRedundantRecordWildcards :: WarningFlag Opt_WarnWarningsDeprecations :: WarningFlag Opt_WarnDeprecatedFlags :: WarningFlag Opt_WarnMissingMonadFailInstances :: WarningFlag Opt_WarnSemigroup :: WarningFlag Opt_WarnDodgyExports :: WarningFlag Opt_WarnDodgyImports :: WarningFlag Opt_WarnOrphans :: WarningFlag Opt_WarnAutoOrphans :: WarningFlag Opt_WarnIdentities :: WarningFlag Opt_WarnTabs :: WarningFlag Opt_WarnUnrecognisedPragmas :: WarningFlag Opt_WarnDodgyForeignImports :: WarningFlag Opt_WarnUnusedDoBind :: WarningFlag Opt_WarnWrongDoBind :: WarningFlag Opt_WarnAlternativeLayoutRuleTransitional :: WarningFlag Opt_WarnUnsafe :: WarningFlag Opt_WarnSafe :: WarningFlag Opt_WarnTrustworthySafe :: WarningFlag Opt_WarnMissedSpecs :: WarningFlag Opt_WarnAllMissedSpecs :: WarningFlag Opt_WarnUnsupportedCallingConventions :: WarningFlag Opt_WarnUnsupportedLlvmVersion :: WarningFlag Opt_WarnMissedExtraSharedLib :: WarningFlag Opt_WarnInlineRuleShadowing :: WarningFlag Opt_WarnTypedHoles :: WarningFlag Opt_WarnPartialTypeSignatures :: WarningFlag Opt_WarnMissingExportedSignatures :: WarningFlag Opt_WarnUntickedPromotedConstructors :: WarningFlag Opt_WarnDerivingTypeable :: WarningFlag Opt_WarnDeferredTypeErrors :: WarningFlag Opt_WarnDeferredOutOfScopeVariables :: WarningFlag Opt_WarnNonCanonicalMonadInstances :: WarningFlag Opt_WarnNonCanonicalMonadFailInstances :: WarningFlag Opt_WarnNonCanonicalMonoidInstances :: WarningFlag Opt_WarnMissingPatternSynonymSignatures :: WarningFlag Opt_WarnUnrecognisedWarningFlags :: WarningFlag Opt_WarnSimplifiableClassConstraints :: WarningFlag Opt_WarnCPPUndef :: WarningFlag Opt_WarnUnbangedStrictPatterns :: WarningFlag Opt_WarnMissingHomeModules :: WarningFlag Opt_WarnPartialFields :: WarningFlag Opt_WarnMissingExportList :: WarningFlag Opt_WarnInaccessibleCode :: WarningFlag Opt_WarnStarIsType :: WarningFlag Opt_WarnStarBinder :: WarningFlag Opt_WarnImplicitKindVars :: WarningFlag Opt_WarnSpaceAfterBang :: WarningFlag Opt_WarnMissingDerivingStrategies :: WarningFlag Opt_WarnPrepositiveQualifiedModule :: WarningFlag Opt_WarnUnusedPackages :: WarningFlag Opt_WarnInferredSafeImports :: WarningFlag Opt_WarnMissingSafeHaskellMode :: WarningFlag Opt_WarnCompatUnqualifiedImports :: WarningFlag Opt_WarnDerivingDefaults :: WarningFlag Opt_WarnInvalidHaddock :: WarningFlag Opt_WarnOperatorWhitespaceExtConflict :: WarningFlag Opt_WarnOperatorWhitespace :: WarningFlag Opt_WarnAmbiguousFields :: WarningFlag Opt_WarnImplicitLift :: WarningFlag Opt_WarnMissingKindSignatures :: WarningFlag Opt_WarnUnicodeBidirectionalFormatCharacters :: WarningFlag -- | Used when outputting warnings: if a reason is given, it is displayed. -- If a warning isn't controlled by a flag, this is made explicit at the -- point of use. data WarnReason NoReason :: WarnReason -- | Warning was enabled with the flag Reason :: !WarningFlag -> WarnReason -- | Warning was made an error because of -Werror or -Werror=WarningFlag ErrReason :: !Maybe WarningFlag -> WarnReason data Language Haskell98 :: Language Haskell2010 :: Language GHC2021 :: Language optimisationFlags :: EnumSet GeneralFlag instance GHC.Enum.Enum GHC.Driver.Flags.DumpFlag instance GHC.Show.Show GHC.Driver.Flags.DumpFlag instance GHC.Classes.Eq GHC.Driver.Flags.DumpFlag instance GHC.Enum.Enum GHC.Driver.Flags.GeneralFlag instance GHC.Show.Show GHC.Driver.Flags.GeneralFlag instance GHC.Classes.Eq GHC.Driver.Flags.GeneralFlag instance GHC.Enum.Enum GHC.Driver.Flags.WarningFlag instance GHC.Show.Show GHC.Driver.Flags.WarningFlag instance GHC.Classes.Ord GHC.Driver.Flags.WarningFlag instance GHC.Classes.Eq GHC.Driver.Flags.WarningFlag instance GHC.Show.Show GHC.Driver.Flags.WarnReason instance GHC.Enum.Bounded GHC.Driver.Flags.Language instance GHC.Show.Show GHC.Driver.Flags.Language instance GHC.Enum.Enum GHC.Driver.Flags.Language instance GHC.Classes.Eq GHC.Driver.Flags.Language instance GHC.Utils.Outputable.Outputable GHC.Driver.Flags.Language instance GHC.Utils.Outputable.Outputable GHC.Driver.Flags.WarnReason instance GHC.Utils.Json.ToJson GHC.Driver.Flags.WarnReason module GHC.Data.Bag data Bag a emptyBag :: Bag a unitBag :: a -> Bag a unionBags :: Bag a -> Bag a -> Bag a unionManyBags :: [Bag a] -> Bag a mapBag :: (a -> b) -> Bag a -> Bag b elemBag :: Eq a => a -> Bag a -> Bool lengthBag :: Bag a -> Int filterBag :: (a -> Bool) -> Bag a -> Bag a partitionBag :: (a -> Bool) -> Bag a -> (Bag a, Bag a) partitionBagWith :: (a -> Either b c) -> Bag a -> (Bag b, Bag c) concatBag :: Bag (Bag a) -> Bag a catBagMaybes :: Bag (Maybe a) -> Bag a foldBag :: (r -> r -> r) -> (a -> r) -> r -> Bag a -> r isEmptyBag :: Bag a -> Bool isSingletonBag :: Bag a -> Bool consBag :: a -> Bag a -> Bag a infixr 3 `consBag` snocBag :: Bag a -> a -> Bag a infixl 3 `snocBag` anyBag :: (a -> Bool) -> Bag a -> Bool allBag :: (a -> Bool) -> Bag a -> Bool listToBag :: [a] -> Bag a nonEmptyToBag :: NonEmpty a -> Bag a bagToList :: Bag a -> [a] mapAccumBagL :: (acc -> x -> (acc, y)) -> acc -> Bag x -> (acc, Bag y) concatMapBag :: (a -> Bag b) -> Bag a -> Bag b concatMapBagPair :: (a -> (Bag b, Bag c)) -> Bag a -> (Bag b, Bag c) mapMaybeBag :: (a -> Maybe b) -> Bag a -> Bag b mapBagM :: Monad m => (a -> m b) -> Bag a -> m (Bag b) mapBagM_ :: Monad m => (a -> m b) -> Bag a -> m () flatMapBagM :: Monad m => (a -> m (Bag b)) -> Bag a -> m (Bag b) flatMapBagPairM :: Monad m => (a -> m (Bag b, Bag c)) -> Bag a -> m (Bag b, Bag c) mapAndUnzipBagM :: Monad m => (a -> m (b, c)) -> Bag a -> m (Bag b, Bag c) mapAccumBagLM :: Monad m => (acc -> x -> m (acc, y)) -> acc -> Bag x -> m (acc, Bag y) anyBagM :: Monad m => (a -> m Bool) -> Bag a -> m Bool filterBagM :: Monad m => (a -> m Bool) -> Bag a -> m (Bag a) instance GHC.Base.Functor GHC.Data.Bag.Bag instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Data.Bag.Bag a) instance Data.Data.Data a => Data.Data.Data (GHC.Data.Bag.Bag a) instance Data.Foldable.Foldable GHC.Data.Bag.Bag instance Data.Traversable.Traversable GHC.Data.Bag.Bag instance GHC.Exts.IsList (GHC.Data.Bag.Bag a) -- | Dynamic flags -- -- Most flags are dynamic flags, which means they can change from -- compilation to compilation using OPTIONS_GHC pragmas, and in -- a multi-session GHC each session can be using different dynamic flags. -- Dynamic flags can also be set at the prompt in GHCi. -- -- (c) The University of Glasgow 2005 module GHC.Driver.Session -- | Debugging flags data DumpFlag Opt_D_dump_cmm :: DumpFlag Opt_D_dump_cmm_from_stg :: DumpFlag Opt_D_dump_cmm_raw :: DumpFlag Opt_D_dump_cmm_verbose_by_proc :: DumpFlag Opt_D_dump_cmm_verbose :: DumpFlag Opt_D_dump_cmm_cfg :: DumpFlag Opt_D_dump_cmm_cbe :: DumpFlag Opt_D_dump_cmm_switch :: DumpFlag Opt_D_dump_cmm_proc :: DumpFlag Opt_D_dump_cmm_sp :: DumpFlag Opt_D_dump_cmm_sink :: DumpFlag Opt_D_dump_cmm_caf :: DumpFlag Opt_D_dump_cmm_procmap :: DumpFlag Opt_D_dump_cmm_split :: DumpFlag Opt_D_dump_cmm_info :: DumpFlag Opt_D_dump_cmm_cps :: DumpFlag -- | Dump the cfg used for block layout. Opt_D_dump_cfg_weights :: DumpFlag Opt_D_dump_asm :: DumpFlag Opt_D_dump_asm_native :: DumpFlag Opt_D_dump_asm_liveness :: DumpFlag Opt_D_dump_asm_regalloc :: DumpFlag Opt_D_dump_asm_regalloc_stages :: DumpFlag Opt_D_dump_asm_conflicts :: DumpFlag Opt_D_dump_asm_stats :: DumpFlag Opt_D_dump_asm_expanded :: DumpFlag Opt_D_dump_c_backend :: DumpFlag Opt_D_dump_llvm :: DumpFlag Opt_D_dump_core_stats :: DumpFlag Opt_D_dump_deriv :: DumpFlag Opt_D_dump_ds :: DumpFlag Opt_D_dump_ds_preopt :: DumpFlag Opt_D_dump_foreign :: DumpFlag Opt_D_dump_inlinings :: DumpFlag Opt_D_dump_rule_firings :: DumpFlag Opt_D_dump_rule_rewrites :: DumpFlag Opt_D_dump_simpl_trace :: DumpFlag Opt_D_dump_occur_anal :: DumpFlag Opt_D_dump_parsed :: DumpFlag Opt_D_dump_parsed_ast :: DumpFlag Opt_D_dump_rn :: DumpFlag Opt_D_dump_rn_ast :: DumpFlag Opt_D_dump_simpl :: DumpFlag Opt_D_dump_simpl_iterations :: DumpFlag Opt_D_dump_spec :: DumpFlag Opt_D_dump_prep :: DumpFlag -- | Initial STG (CoreToStg output) Opt_D_dump_stg_from_core :: DumpFlag -- | STG after unarise Opt_D_dump_stg_unarised :: DumpFlag -- | Final STG (after stg2stg) Opt_D_dump_stg_final :: DumpFlag Opt_D_dump_call_arity :: DumpFlag Opt_D_dump_exitify :: DumpFlag Opt_D_dump_stranal :: DumpFlag Opt_D_dump_str_signatures :: DumpFlag Opt_D_dump_cpranal :: DumpFlag Opt_D_dump_cpr_signatures :: DumpFlag Opt_D_dump_tc :: DumpFlag Opt_D_dump_tc_ast :: DumpFlag Opt_D_dump_hie :: DumpFlag Opt_D_dump_types :: DumpFlag Opt_D_dump_rules :: DumpFlag Opt_D_dump_cse :: DumpFlag Opt_D_dump_worker_wrapper :: DumpFlag Opt_D_dump_rn_trace :: DumpFlag Opt_D_dump_rn_stats :: DumpFlag Opt_D_dump_opt_cmm :: DumpFlag Opt_D_dump_simpl_stats :: DumpFlag Opt_D_dump_cs_trace :: DumpFlag Opt_D_dump_tc_trace :: DumpFlag Opt_D_dump_ec_trace :: DumpFlag Opt_D_dump_if_trace :: DumpFlag Opt_D_dump_vt_trace :: DumpFlag Opt_D_dump_splices :: DumpFlag Opt_D_th_dec_file :: DumpFlag Opt_D_dump_BCOs :: DumpFlag Opt_D_dump_ticked :: DumpFlag Opt_D_dump_rtti :: DumpFlag Opt_D_source_stats :: DumpFlag Opt_D_verbose_stg2stg :: DumpFlag Opt_D_dump_hi :: DumpFlag Opt_D_dump_hi_diffs :: DumpFlag Opt_D_dump_mod_cycles :: DumpFlag Opt_D_dump_mod_map :: DumpFlag Opt_D_dump_timings :: DumpFlag Opt_D_dump_view_pattern_commoning :: DumpFlag Opt_D_verbose_core2core :: DumpFlag Opt_D_dump_debug :: DumpFlag Opt_D_dump_json :: DumpFlag Opt_D_ppr_debug :: DumpFlag Opt_D_no_debug_output :: DumpFlag Opt_D_dump_faststrings :: DumpFlag -- | Enumerates the simple on-or-off dynamic flags data GeneralFlag -- | Append dump output to files instead of stdout. Opt_DumpToFile :: GeneralFlag Opt_D_faststring_stats :: GeneralFlag Opt_D_dump_minimal_imports :: GeneralFlag Opt_DoCoreLinting :: GeneralFlag Opt_DoLinearCoreLinting :: GeneralFlag Opt_DoStgLinting :: GeneralFlag Opt_DoCmmLinting :: GeneralFlag Opt_DoAsmLinting :: GeneralFlag Opt_DoAnnotationLinting :: GeneralFlag Opt_DoBoundsChecking :: GeneralFlag Opt_NoLlvmMangler :: GeneralFlag Opt_FastLlvm :: GeneralFlag Opt_NoTypeableBinds :: GeneralFlag Opt_DistinctConstructorTables :: GeneralFlag Opt_InfoTableMap :: GeneralFlag Opt_WarnIsError :: GeneralFlag Opt_ShowWarnGroups :: GeneralFlag Opt_HideSourcePaths :: GeneralFlag Opt_PrintExplicitForalls :: GeneralFlag Opt_PrintExplicitKinds :: GeneralFlag Opt_PrintExplicitCoercions :: GeneralFlag Opt_PrintExplicitRuntimeReps :: GeneralFlag Opt_PrintEqualityRelations :: GeneralFlag Opt_PrintAxiomIncomps :: GeneralFlag Opt_PrintUnicodeSyntax :: GeneralFlag Opt_PrintExpandedSynonyms :: GeneralFlag Opt_PrintPotentialInstances :: GeneralFlag Opt_PrintTypecheckerElaboration :: GeneralFlag Opt_CallArity :: GeneralFlag Opt_Exitification :: GeneralFlag Opt_Strictness :: GeneralFlag Opt_LateDmdAnal :: GeneralFlag Opt_KillAbsence :: GeneralFlag Opt_KillOneShot :: GeneralFlag Opt_FullLaziness :: GeneralFlag Opt_FloatIn :: GeneralFlag Opt_LateSpecialise :: GeneralFlag Opt_Specialise :: GeneralFlag Opt_SpecialiseAggressively :: GeneralFlag Opt_CrossModuleSpecialise :: GeneralFlag Opt_InlineGenerics :: GeneralFlag Opt_InlineGenericsAggressively :: GeneralFlag Opt_StaticArgumentTransformation :: GeneralFlag Opt_CSE :: GeneralFlag Opt_StgCSE :: GeneralFlag Opt_StgLiftLams :: GeneralFlag Opt_LiberateCase :: GeneralFlag Opt_SpecConstr :: GeneralFlag Opt_SpecConstrKeen :: GeneralFlag Opt_DoLambdaEtaExpansion :: GeneralFlag Opt_IgnoreAsserts :: GeneralFlag Opt_DoEtaReduction :: GeneralFlag Opt_CaseMerge :: GeneralFlag Opt_CaseFolding :: GeneralFlag Opt_UnboxStrictFields :: GeneralFlag Opt_UnboxSmallStrictFields :: GeneralFlag Opt_DictsCheap :: GeneralFlag Opt_EnableRewriteRules :: GeneralFlag Opt_EnableThSpliceWarnings :: GeneralFlag Opt_RegsGraph :: GeneralFlag Opt_RegsIterative :: GeneralFlag Opt_PedanticBottoms :: GeneralFlag Opt_LlvmTBAA :: GeneralFlag Opt_LlvmFillUndefWithGarbage :: GeneralFlag Opt_IrrefutableTuples :: GeneralFlag Opt_CmmSink :: GeneralFlag Opt_CmmStaticPred :: GeneralFlag Opt_CmmElimCommonBlocks :: GeneralFlag Opt_AsmShortcutting :: GeneralFlag Opt_OmitYields :: GeneralFlag Opt_FunToThunk :: GeneralFlag Opt_DictsStrict :: GeneralFlag -- | deprecated, no effect and behaviour is now default. Allowed switching -- of a special demand transformer for dictionary selectors Opt_DmdTxDictSel :: GeneralFlag Opt_Loopification :: GeneralFlag -- | Use the cfg based block layout algorithm. Opt_CfgBlocklayout :: GeneralFlag -- | Layout based on last instruction per block. Opt_WeightlessBlocklayout :: GeneralFlag Opt_CprAnal :: GeneralFlag Opt_WorkerWrapper :: GeneralFlag Opt_SolveConstantDicts :: GeneralFlag Opt_AlignmentSanitisation :: GeneralFlag Opt_CatchBottoms :: GeneralFlag Opt_NumConstantFolding :: GeneralFlag Opt_SimplPreInlining :: GeneralFlag Opt_IgnoreInterfacePragmas :: GeneralFlag Opt_OmitInterfacePragmas :: GeneralFlag Opt_ExposeAllUnfoldings :: GeneralFlag Opt_WriteInterface :: GeneralFlag Opt_WriteHie :: GeneralFlag Opt_AutoSccsOnIndividualCafs :: GeneralFlag Opt_ProfCountEntries :: GeneralFlag Opt_Pp :: GeneralFlag Opt_ForceRecomp :: GeneralFlag Opt_IgnoreOptimChanges :: GeneralFlag Opt_IgnoreHpcChanges :: GeneralFlag Opt_ExcessPrecision :: GeneralFlag Opt_EagerBlackHoling :: GeneralFlag Opt_NoHsMain :: GeneralFlag Opt_SplitSections :: GeneralFlag Opt_StgStats :: GeneralFlag Opt_HideAllPackages :: GeneralFlag Opt_HideAllPluginPackages :: GeneralFlag Opt_PrintBindResult :: GeneralFlag Opt_Haddock :: GeneralFlag Opt_HaddockOptions :: GeneralFlag Opt_BreakOnException :: GeneralFlag Opt_BreakOnError :: GeneralFlag Opt_PrintEvldWithShow :: GeneralFlag Opt_PrintBindContents :: GeneralFlag Opt_GenManifest :: GeneralFlag Opt_EmbedManifest :: GeneralFlag Opt_SharedImplib :: GeneralFlag Opt_BuildingCabalPackage :: GeneralFlag Opt_IgnoreDotGhci :: GeneralFlag Opt_GhciSandbox :: GeneralFlag Opt_GhciHistory :: GeneralFlag Opt_GhciLeakCheck :: GeneralFlag Opt_ValidateHie :: GeneralFlag Opt_LocalGhciHistory :: GeneralFlag Opt_NoIt :: GeneralFlag Opt_HelpfulErrors :: GeneralFlag Opt_DeferTypeErrors :: GeneralFlag Opt_DeferTypedHoles :: GeneralFlag Opt_DeferOutOfScopeVariables :: GeneralFlag -- |
-- -fPIC --Opt_PIC :: GeneralFlag -- |
-- -fPIE --Opt_PIE :: GeneralFlag -- |
-- -pie --Opt_PICExecutable :: GeneralFlag Opt_ExternalDynamicRefs :: GeneralFlag Opt_Ticky :: GeneralFlag Opt_Ticky_Allocd :: GeneralFlag Opt_Ticky_LNE :: GeneralFlag Opt_Ticky_Dyn_Thunk :: GeneralFlag Opt_RPath :: GeneralFlag Opt_RelativeDynlibPaths :: GeneralFlag -- |
-- -fcompact-unwind --Opt_CompactUnwind :: GeneralFlag Opt_Hpc :: GeneralFlag Opt_FamAppCache :: GeneralFlag Opt_ExternalInterpreter :: GeneralFlag Opt_OptimalApplicativeDo :: GeneralFlag Opt_VersionMacros :: GeneralFlag Opt_WholeArchiveHsLibs :: GeneralFlag Opt_SingleLibFolder :: GeneralFlag Opt_ExposeInternalSymbols :: GeneralFlag Opt_KeepCAFs :: GeneralFlag Opt_KeepGoing :: GeneralFlag Opt_ByteCode :: GeneralFlag Opt_LinkRts :: GeneralFlag Opt_ErrorSpans :: GeneralFlag Opt_DeferDiagnostics :: GeneralFlag Opt_DiagnosticsShowCaret :: GeneralFlag Opt_PprCaseAsLet :: GeneralFlag Opt_PprShowTicks :: GeneralFlag Opt_ShowHoleConstraints :: GeneralFlag Opt_ShowValidHoleFits :: GeneralFlag Opt_SortValidHoleFits :: GeneralFlag Opt_SortBySizeHoleFits :: GeneralFlag Opt_SortBySubsumHoleFits :: GeneralFlag Opt_AbstractRefHoleFits :: GeneralFlag Opt_UnclutterValidHoleFits :: GeneralFlag Opt_ShowTypeAppOfHoleFits :: GeneralFlag Opt_ShowTypeAppVarsOfHoleFits :: GeneralFlag Opt_ShowDocsOfHoleFits :: GeneralFlag Opt_ShowTypeOfHoleFits :: GeneralFlag Opt_ShowProvOfHoleFits :: GeneralFlag Opt_ShowMatchesOfHoleFits :: GeneralFlag Opt_ShowLoadedModules :: GeneralFlag Opt_HexWordLiterals :: GeneralFlag Opt_SuppressCoercions :: GeneralFlag Opt_SuppressVarKinds :: GeneralFlag Opt_SuppressModulePrefixes :: GeneralFlag Opt_SuppressTypeApplications :: GeneralFlag Opt_SuppressIdInfo :: GeneralFlag Opt_SuppressUnfoldings :: GeneralFlag Opt_SuppressTypeSignatures :: GeneralFlag Opt_SuppressUniques :: GeneralFlag Opt_SuppressStgExts :: GeneralFlag Opt_SuppressTicks :: GeneralFlag -- | Suppress timestamps in dumps Opt_SuppressTimestamps :: GeneralFlag Opt_AutoLinkPackages :: GeneralFlag Opt_ImplicitImportQualified :: GeneralFlag Opt_KeepHscppFiles :: GeneralFlag Opt_KeepHiDiffs :: GeneralFlag Opt_KeepHcFiles :: GeneralFlag Opt_KeepSFiles :: GeneralFlag Opt_KeepTmpFiles :: GeneralFlag Opt_KeepRawTokenStream :: GeneralFlag Opt_KeepLlvmFiles :: GeneralFlag Opt_KeepHiFiles :: GeneralFlag Opt_KeepOFiles :: GeneralFlag Opt_BuildDynamicToo :: GeneralFlag Opt_DistrustAllPackages :: GeneralFlag Opt_PackageTrust :: GeneralFlag Opt_PluginTrustworthy :: GeneralFlag Opt_G_NoStateHack :: GeneralFlag Opt_G_NoOptCoercion :: GeneralFlag data WarningFlag Opt_WarnDuplicateExports :: WarningFlag Opt_WarnDuplicateConstraints :: WarningFlag Opt_WarnRedundantConstraints :: WarningFlag Opt_WarnHiShadows :: WarningFlag Opt_WarnImplicitPrelude :: WarningFlag Opt_WarnIncompletePatterns :: WarningFlag Opt_WarnIncompleteUniPatterns :: WarningFlag Opt_WarnIncompletePatternsRecUpd :: WarningFlag Opt_WarnOverflowedLiterals :: WarningFlag Opt_WarnEmptyEnumerations :: WarningFlag Opt_WarnMissingFields :: WarningFlag Opt_WarnMissingImportList :: WarningFlag Opt_WarnMissingMethods :: WarningFlag Opt_WarnMissingSignatures :: WarningFlag Opt_WarnMissingLocalSignatures :: WarningFlag Opt_WarnNameShadowing :: WarningFlag Opt_WarnOverlappingPatterns :: WarningFlag Opt_WarnTypeDefaults :: WarningFlag Opt_WarnMonomorphism :: WarningFlag Opt_WarnUnusedTopBinds :: WarningFlag Opt_WarnUnusedLocalBinds :: WarningFlag Opt_WarnUnusedPatternBinds :: WarningFlag Opt_WarnUnusedImports :: WarningFlag Opt_WarnUnusedMatches :: WarningFlag Opt_WarnUnusedTypePatterns :: WarningFlag Opt_WarnUnusedForalls :: WarningFlag Opt_WarnUnusedRecordWildcards :: WarningFlag Opt_WarnRedundantBangPatterns :: WarningFlag Opt_WarnRedundantRecordWildcards :: WarningFlag Opt_WarnWarningsDeprecations :: WarningFlag Opt_WarnDeprecatedFlags :: WarningFlag Opt_WarnMissingMonadFailInstances :: WarningFlag Opt_WarnSemigroup :: WarningFlag Opt_WarnDodgyExports :: WarningFlag Opt_WarnDodgyImports :: WarningFlag Opt_WarnOrphans :: WarningFlag Opt_WarnAutoOrphans :: WarningFlag Opt_WarnIdentities :: WarningFlag Opt_WarnTabs :: WarningFlag Opt_WarnUnrecognisedPragmas :: WarningFlag Opt_WarnDodgyForeignImports :: WarningFlag Opt_WarnUnusedDoBind :: WarningFlag Opt_WarnWrongDoBind :: WarningFlag Opt_WarnAlternativeLayoutRuleTransitional :: WarningFlag Opt_WarnUnsafe :: WarningFlag Opt_WarnSafe :: WarningFlag Opt_WarnTrustworthySafe :: WarningFlag Opt_WarnMissedSpecs :: WarningFlag Opt_WarnAllMissedSpecs :: WarningFlag Opt_WarnUnsupportedCallingConventions :: WarningFlag Opt_WarnUnsupportedLlvmVersion :: WarningFlag Opt_WarnMissedExtraSharedLib :: WarningFlag Opt_WarnInlineRuleShadowing :: WarningFlag Opt_WarnTypedHoles :: WarningFlag Opt_WarnPartialTypeSignatures :: WarningFlag Opt_WarnMissingExportedSignatures :: WarningFlag Opt_WarnUntickedPromotedConstructors :: WarningFlag Opt_WarnDerivingTypeable :: WarningFlag Opt_WarnDeferredTypeErrors :: WarningFlag Opt_WarnDeferredOutOfScopeVariables :: WarningFlag Opt_WarnNonCanonicalMonadInstances :: WarningFlag Opt_WarnNonCanonicalMonadFailInstances :: WarningFlag Opt_WarnNonCanonicalMonoidInstances :: WarningFlag Opt_WarnMissingPatternSynonymSignatures :: WarningFlag Opt_WarnUnrecognisedWarningFlags :: WarningFlag Opt_WarnSimplifiableClassConstraints :: WarningFlag Opt_WarnCPPUndef :: WarningFlag Opt_WarnUnbangedStrictPatterns :: WarningFlag Opt_WarnMissingHomeModules :: WarningFlag Opt_WarnPartialFields :: WarningFlag Opt_WarnMissingExportList :: WarningFlag Opt_WarnInaccessibleCode :: WarningFlag Opt_WarnStarIsType :: WarningFlag Opt_WarnStarBinder :: WarningFlag Opt_WarnImplicitKindVars :: WarningFlag Opt_WarnSpaceAfterBang :: WarningFlag Opt_WarnMissingDerivingStrategies :: WarningFlag Opt_WarnPrepositiveQualifiedModule :: WarningFlag Opt_WarnUnusedPackages :: WarningFlag Opt_WarnInferredSafeImports :: WarningFlag Opt_WarnMissingSafeHaskellMode :: WarningFlag Opt_WarnCompatUnqualifiedImports :: WarningFlag Opt_WarnDerivingDefaults :: WarningFlag Opt_WarnInvalidHaddock :: WarningFlag Opt_WarnOperatorWhitespaceExtConflict :: WarningFlag Opt_WarnOperatorWhitespace :: WarningFlag Opt_WarnAmbiguousFields :: WarningFlag Opt_WarnImplicitLift :: WarningFlag Opt_WarnMissingKindSignatures :: WarningFlag Opt_WarnUnicodeBidirectionalFormatCharacters :: WarningFlag -- | Used when outputting warnings: if a reason is given, it is displayed. -- If a warning isn't controlled by a flag, this is made explicit at the -- point of use. data WarnReason NoReason :: WarnReason -- | Warning was enabled with the flag Reason :: !WarningFlag -> WarnReason -- | Warning was made an error because of -Werror or -Werror=WarningFlag ErrReason :: !Maybe WarningFlag -> WarnReason data Language Haskell98 :: Language Haskell2010 :: Language GHC2021 :: Language data PlatformConstants PlatformConstants :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> !Integer -> !Integer -> !Integer -> PlatformConstants [pc_CONTROL_GROUP_CONST_291] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_STD_HDR_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_PROF_HDR_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_BLOCK_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_BLOCKS_PER_MBLOCK] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_TICKY_BIN_COUNT] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR2] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR3] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR4] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR5] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR6] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR7] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR8] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR9] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rR10] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rF1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rF2] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rF3] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rF4] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rF5] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rF6] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rD1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rD2] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rD3] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rD4] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rD5] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rD6] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rXMM1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rXMM2] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rXMM3] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rXMM4] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rXMM5] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rXMM6] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rYMM1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rYMM2] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rYMM3] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rYMM4] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rYMM5] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rYMM6] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rZMM1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rZMM2] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rZMM3] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rZMM4] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rZMM5] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rZMM6] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rL1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rSp] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rSpLim] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rHp] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rHpLim] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rCCCS] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rCurrentTSO] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rCurrentNursery] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgRegTable_rHpAlloc] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_stgEagerBlackholeInfo] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_stgGCEnter1] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_stgGCFun] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_Capability_r] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_bdescr_start] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_bdescr_free] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_bdescr_blocks] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_bdescr_flags] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_SIZEOF_CostCentreStack] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_CostCentreStack_mem_alloc] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_REP_CostCentreStack_mem_alloc] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_CostCentreStack_scc_count] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_REP_CostCentreStack_scc_count] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgHeader_ccs] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgHeader_ldvw] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_SIZEOF_StgSMPThunkHeader] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgEntCounter_allocs] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_REP_StgEntCounter_allocs] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgEntCounter_allocd] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_REP_StgEntCounter_allocd] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgEntCounter_registeredp] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgEntCounter_link] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgEntCounter_entry_count] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_SIZEOF_StgUpdateFrame_NoHdr] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_SIZEOF_StgMutArrPtrs_NoHdr] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgMutArrPtrs_ptrs] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgMutArrPtrs_size] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_SIZEOF_StgSmallMutArrPtrs_NoHdr] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgSmallMutArrPtrs_ptrs] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_SIZEOF_StgArrBytes_NoHdr] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgArrBytes_bytes] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgTSO_alloc_limit] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgTSO_cccs] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgTSO_stackobj] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgStack_sp] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgStack_stack] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgUpdateFrame_updatee] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgFunInfoExtraFwd_arity] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_REP_StgFunInfoExtraFwd_arity] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_SIZEOF_StgFunInfoExtraRev] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_OFFSET_StgFunInfoExtraRev_arity] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_REP_StgFunInfoExtraRev_arity] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_SPEC_SELECTEE_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_SPEC_AP_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MIN_PAYLOAD_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MIN_INTLIKE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_INTLIKE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MIN_CHARLIKE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_CHARLIKE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MUT_ARR_PTRS_CARD_BITS] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Vanilla_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Float_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Double_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Long_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_XMM_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Real_Vanilla_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Real_Float_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Real_Double_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Real_XMM_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_MAX_Real_Long_REG] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_RESERVED_C_STACK_BYTES] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_RESERVED_STACK_WORDS] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_AP_STACK_SPLIM] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_WORD_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_CINT_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_CLONG_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_CLONG_LONG_SIZE] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_BITMAP_BITS_SHIFT] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_TAG_BITS] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_LDV_SHIFT] :: PlatformConstants -> {-# UNPACK #-} !Int [pc_ILDV_CREATE_MASK] :: PlatformConstants -> !Integer [pc_ILDV_STATE_CREATE] :: PlatformConstants -> !Integer [pc_ILDV_STATE_USE] :: PlatformConstants -> !Integer type FatalMessager = String -> IO () newtype FlushOut FlushOut :: IO () -> FlushOut newtype FlushErr FlushErr :: IO () -> FlushErr data ProfAuto -- | no SCC annotations added NoProfAuto :: ProfAuto -- | top-level and nested functions are annotated ProfAutoAll :: ProfAuto -- | top-level functions annotated only ProfAutoTop :: ProfAuto -- | exported functions annotated only ProfAutoExports :: ProfAuto -- | annotate call-sites ProfAutoCalls :: ProfAuto glasgowExtsFlags :: [Extension] -- | Warning groups. -- -- As all warnings are in the Weverything set, it is ignored when -- displaying to the user which group a warning is in. warningGroups :: [(String, [WarningFlag])] -- | Warning group hierarchies, where there is an explicit inclusion -- relation. -- -- Each inner list is a hierarchy of warning groups, ordered from -- smallest to largest, where each group is a superset of the one before -- it. -- -- Separating this from warningGroups allows for multiple -- hierarchies with no inherent relation to be defined. -- -- The special-case Weverything group is not included. warningHierarchies :: [[String]] hasPprDebug :: DynFlags -> Bool hasNoDebugOutput :: DynFlags -> Bool hasNoStateHack :: DynFlags -> Bool hasNoOptCoercion :: DynFlags -> Bool -- | Test whether a DumpFlag is set dopt :: DumpFlag -> DynFlags -> Bool -- | Set a DumpFlag dopt_set :: DynFlags -> DumpFlag -> DynFlags -- | Unset a DumpFlag dopt_unset :: DynFlags -> DumpFlag -> DynFlags -- | Test whether a GeneralFlag is set -- -- Note that dynamicNow (i.e., dynamic objects built with -- `-dynamic-too`) always implicitly enables Opt_PIC, -- Opt_ExternalDynamicRefs, and disables Opt_SplitSections. gopt :: GeneralFlag -> DynFlags -> Bool -- | Set a GeneralFlag gopt_set :: DynFlags -> GeneralFlag -> DynFlags -- | Unset a GeneralFlag gopt_unset :: DynFlags -> GeneralFlag -> DynFlags setGeneralFlag' :: GeneralFlag -> DynFlags -> DynFlags unSetGeneralFlag' :: GeneralFlag -> DynFlags -> DynFlags -- | Test whether a WarningFlag is set wopt :: WarningFlag -> DynFlags -> Bool -- | Set a WarningFlag wopt_set :: DynFlags -> WarningFlag -> DynFlags -- | Unset a WarningFlag wopt_unset :: DynFlags -> WarningFlag -> DynFlags -- | Test whether a WarningFlag is set as fatal wopt_fatal :: WarningFlag -> DynFlags -> Bool -- | Mark a WarningFlag as fatal (do not set the flag) wopt_set_fatal :: DynFlags -> WarningFlag -> DynFlags -- | Mark a WarningFlag as not fatal wopt_unset_fatal :: DynFlags -> WarningFlag -> DynFlags -- | Test whether a Extension is set xopt :: Extension -> DynFlags -> Bool -- | Set a Extension xopt_set :: DynFlags -> Extension -> DynFlags -- | Unset a Extension xopt_unset :: DynFlags -> Extension -> DynFlags -- | Set or unset a Extension, unless it has been explicitly set or -- unset before. xopt_set_unlessExplSpec :: Extension -> (DynFlags -> Extension -> DynFlags) -> DynFlags -> DynFlags xopt_DuplicateRecordFields :: DynFlags -> DuplicateRecordFields xopt_FieldSelectors :: DynFlags -> FieldSelectors lang_set :: DynFlags -> Maybe Language -> DynFlags data DynamicTooState -- | Don't try to build dynamic objects too DT_Dont :: DynamicTooState -- | Won't try to generate dynamic objects for some reason DT_Failed :: DynamicTooState -- | Will still try to generate dynamic objects DT_OK :: DynamicTooState -- | Currently generating dynamic objects (in the backend) DT_Dyn :: DynamicTooState dynamicTooState :: MonadIO m => DynFlags -> m DynamicTooState setDynamicNow :: DynFlags -> DynFlags setDynamicTooFailed :: MonadIO m => DynFlags -> m () -- | Compute the path of the dynamic object corresponding to an object -- file. dynamicOutputFile :: DynFlags -> FilePath -> FilePath dynamicOutputHi :: DynFlags -> FilePath -> FilePath -- | Indicate if cost-centre profiling is enabled sccProfilingEnabled :: DynFlags -> Bool -- | Indicate whether we need to generate source notes needSourceNotes :: DynFlags -> Bool -- | Contains not only a collection of GeneralFlags but also a -- plethora of information relating to the compilation of a single file -- or GHC session data DynFlags DynFlags :: GhcMode -> GhcLink -> !Backend -> {-# UNPACK #-} !GhcNameVersion -> {-# UNPACK #-} !FileSettings -> Platform -> {-# UNPACK #-} !ToolSettings -> {-# UNPACK #-} !PlatformMisc -> [(String, String)] -> LlvmConfig -> Int -> Int -> Int -> Int -> Int -> Maybe String -> Maybe String -> [Int] -> Maybe Int -> Bool -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Int -> Int -> Int -> Maybe Int -> Maybe Int -> Int -> Word -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Bool -> Maybe Int -> Int -> [FilePath] -> ModuleName -> Maybe String -> IntWithInf -> IntWithInf -> UnitId -> Maybe UnitId -> [(ModuleName, Module)] -> Ways -> Maybe (String, Int) -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> String -> String -> String -> String -> IORef Bool -> String -> String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> DynLibLoader -> !Bool -> Maybe FilePath -> Maybe FilePath -> [Option] -> IncludeSpecs -> [String] -> [String] -> [String] -> Maybe String -> RtsOptsEnabled -> Bool -> String -> [ModuleName] -> [(ModuleName, String)] -> [String] -> FilePath -> Bool -> Bool -> [ModuleName] -> [String] -> [PackageDBFlag] -> [IgnorePackageFlag] -> [PackageFlag] -> [PackageFlag] -> [TrustFlag] -> Maybe FilePath -> EnumSet DumpFlag -> EnumSet GeneralFlag -> EnumSet WarningFlag -> EnumSet WarningFlag -> Maybe Language -> SafeHaskellMode -> Bool -> Bool -> SrcSpan -> SrcSpan -> SrcSpan -> SrcSpan -> SrcSpan -> SrcSpan -> SrcSpan -> SrcSpan -> SrcSpan -> [OnOff Extension] -> EnumSet Extension -> !UnfoldingOpts -> Int -> Int -> FlushOut -> FlushErr -> Maybe FilePath -> Maybe String -> [String] -> Int -> Int -> Bool -> OverridingBool -> Bool -> Scheme -> ProfAuto -> [CallerCcFilter] -> Maybe String -> IORef (ModuleEnv Int) -> Maybe SseVersion -> Maybe BmiVersion -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> IORef (Maybe LinkerInfo) -> IORef (Maybe CompilerInfo) -> Int -> Int -> Int -> Bool -> Maybe Int -> Word -> Int -> Weights -> DynFlags [ghcMode] :: DynFlags -> GhcMode [ghcLink] :: DynFlags -> GhcLink -- | The backend to use (if any). -- -- Whenever you change the backend, also make sure to set ghcLink -- to something sensible. -- -- NoBackend can be used to avoid generating any output, however, -- note that: -- --
-- ghc -c Foo.hs --OneShot :: GhcMode -- | ghc -M, see GHC.Unit.Finder for why we need this MkDepend :: GhcMode isOneShot :: GhcMode -> Bool -- | What to do in the link step, if there is one. data GhcLink -- | Don't link at all NoLink :: GhcLink -- | Link object code into a binary LinkBinary :: GhcLink -- | Use the in-memory dynamic linker (works for both bytecode and object -- code). LinkInMemory :: GhcLink -- | Link objects into a dynamic lib (DLL on Windows, DSO on ELF platforms) LinkDynLib :: GhcLink -- | Link objects into a static lib LinkStaticLib :: GhcLink isNoLink :: GhcLink -> Bool -- | Flags for manipulating packages visibility. data PackageFlag -- | -package, -package-id ExposePackage :: String -> PackageArg -> ModRenaming -> PackageFlag -- |
-- -hide-package --HidePackage :: String -> PackageFlag -- | We accept flags which make packages visible, but how they select the -- package varies; this data type reflects what selection criterion is -- used. data PackageArg -- | -package, by PackageName PackageArg :: String -> PackageArg -- | -package-id, by Unit UnitIdArg :: Unit -> PackageArg -- | Represents the renaming that may be associated with an exposed -- package, e.g. the rns part of -package "foo (rns)". -- -- Here are some example parsings of the package flags (where a string -- literal is punned to be a ModuleName: -- --
-- -ignore-package --IgnorePackage :: String -> IgnorePackageFlag -- | Flags for manipulating package trust. data TrustFlag -- |
-- -trust --TrustPackage :: String -> TrustFlag -- |
-- -distrust --DistrustPackage :: String -> TrustFlag data PackageDBFlag PackageDB :: PkgDbRef -> PackageDBFlag NoUserPackageDB :: PackageDBFlag NoGlobalPackageDB :: PackageDBFlag ClearPackageDBs :: PackageDBFlag data PkgDbRef GlobalPkgDb :: PkgDbRef UserPkgDb :: PkgDbRef PkgDbPath :: FilePath -> PkgDbRef -- | When invoking external tools as part of the compilation pipeline, we -- pass these a sequence of options on the command-line. Rather than just -- using a list of Strings, we use a type that allows us to distinguish -- between filepaths and 'other stuff'. The reason for this is that this -- type gives us a handle on transforming filenames, and filenames only, -- to whatever format they're expected to be on a particular platform. data Option FileOption :: String -> String -> Option Option :: String -> Option showOpt :: Option -> String data DynLibLoader Deployable :: DynLibLoader SystemDependent :: DynLibLoader -- | These -f<blah> flags can all be reversed with -- -fno-<blah> fFlags :: [FlagSpec GeneralFlag] -- | These -f<blah> flags can all be reversed with -- -fno-<blah> fLangFlags :: [FlagSpec Extension] -- | These -Xblah flags can all be reversed with -XNoblah xFlags :: [FlagSpec Extension] -- | These -W<blah> flags can all be reversed with -- -Wno-<blah> wWarningFlags :: [FlagSpec WarningFlag] -- | Find the FlagSpec for a WarningFlag. wWarningFlagMap :: Map WarningFlag (FlagSpec WarningFlag) -- | Some modules have dependencies on others through the DynFlags rather -- than textual imports dynFlagDependencies :: DynFlags -> [ModuleName] -- | Resolve any internal inconsistencies in a set of DynFlags. -- Returns the consistent DynFlags as well as a list of warnings -- to report to the user. makeDynFlagsConsistent :: DynFlags -> (DynFlags, [Located String]) -- | Are we building with -fPIE or -fPIC enabled? positionIndependent :: DynFlags -> Bool optimisationFlags :: EnumSet GeneralFlag setFlagsFromEnvFile :: FilePath -> String -> DynP () -- | Pretty-print the difference between 2 DynFlags. -- -- For now only their general flags but it could be extended. Useful -- mostly for debugging. pprDynFlagsDiff :: DynFlags -> DynFlags -> SDoc flagSpecOf :: WarningFlag -> Maybe (FlagSpec WarningFlag) -- | Find the smallest group in every hierarchy which a warning belongs to, -- excluding Weverything. smallestGroups :: WarningFlag -> [String] -- | Get target profile targetProfile :: DynFlags -> Profile -- | Is Safe Haskell on in some way (including inference mode) safeHaskellOn :: DynFlags -> Bool safeHaskellModeEnabled :: DynFlags -> Bool -- | Test if Safe Imports are on in some form safeImportsOn :: DynFlags -> Bool -- | Is the Safe Haskell safe language in use safeLanguageOn :: DynFlags -> Bool -- | Is the Safe Haskell safe inference mode active safeInferOn :: DynFlags -> Bool -- | Is the -fpackage-trust mode on packageTrustOn :: DynFlags -> Bool -- | Are all direct imports required to be safe for this Safe Haskell mode? -- Direct imports are when the code explicitly imports a module safeDirectImpsReq :: DynFlags -> Bool -- | Are all implicit imports required to be safe for this Safe Haskell -- mode? Implicit imports are things in the prelude. e.g System.IO when -- print is used. safeImplicitImpsReq :: DynFlags -> Bool -- | A list of unsafe flags under Safe Haskell. Tuple elements are: * name -- of the flag * function to get srcspan that enabled the flag * function -- to test if the flag is on * function to turn the flag off unsafeFlags :: [(String, DynFlags -> SrcSpan, DynFlags -> Bool, DynFlags -> DynFlags)] -- | A list of unsafe flags under Safe Haskell. Tuple elements are: * name -- of the flag * function to get srcspan that enabled the flag * function -- to test if the flag is on * function to turn the flag off unsafeFlagsForInfer :: [(String, DynFlags -> SrcSpan, DynFlags -> Bool, DynFlags -> DynFlags)] data LlvmTarget LlvmTarget :: String -> String -> [String] -> LlvmTarget [lDataLayout] :: LlvmTarget -> String [lCPU] :: LlvmTarget -> String [lAttributes] :: LlvmTarget -> [String] -- | See Note [LLVM Configuration] in GHC.SysTools. data LlvmConfig LlvmConfig :: [(String, LlvmTarget)] -> [(Int, String)] -> LlvmConfig [llvmTargets] :: LlvmConfig -> [(String, LlvmTarget)] [llvmPasses] :: LlvmConfig -> [(Int, String)] data Settings Settings :: {-# UNPACK #-} !GhcNameVersion -> {-# UNPACK #-} !FileSettings -> Platform -> {-# UNPACK #-} !ToolSettings -> {-# UNPACK #-} !PlatformMisc -> [(String, String)] -> Settings [sGhcNameVersion] :: Settings -> {-# UNPACK #-} !GhcNameVersion [sFileSettings] :: Settings -> {-# UNPACK #-} !FileSettings [sTargetPlatform] :: Settings -> Platform [sToolSettings] :: Settings -> {-# UNPACK #-} !ToolSettings [sPlatformMisc] :: Settings -> {-# UNPACK #-} !PlatformMisc [sRawSettings] :: Settings -> [(String, String)] sProgramName :: Settings -> String sProjectVersion :: Settings -> String sGhcUsagePath :: Settings -> FilePath sGhciUsagePath :: Settings -> FilePath sToolDir :: Settings -> Maybe FilePath sTopDir :: Settings -> FilePath sTmpDir :: Settings -> String sGlobalPackageDatabasePath :: Settings -> FilePath sLdSupportsCompactUnwind :: Settings -> Bool sLdSupportsBuildId :: Settings -> Bool sLdSupportsFilelist :: Settings -> Bool sLdIsGnuLd :: Settings -> Bool sGccSupportsNoPie :: Settings -> Bool sPgm_L :: Settings -> String sPgm_P :: Settings -> (String, [Option]) sPgm_F :: Settings -> String sPgm_c :: Settings -> String sPgm_a :: Settings -> (String, [Option]) sPgm_l :: Settings -> (String, [Option]) sPgm_lm :: Settings -> (String, [Option]) sPgm_dll :: Settings -> (String, [Option]) sPgm_T :: Settings -> String sPgm_windres :: Settings -> String sPgm_libtool :: Settings -> String sPgm_ar :: Settings -> String sPgm_ranlib :: Settings -> String sPgm_lo :: Settings -> (String, [Option]) sPgm_lc :: Settings -> (String, [Option]) sPgm_lcc :: Settings -> (String, [Option]) sPgm_i :: Settings -> String sOpt_L :: Settings -> [String] sOpt_P :: Settings -> [String] sOpt_P_fingerprint :: Settings -> Fingerprint sOpt_F :: Settings -> [String] sOpt_c :: Settings -> [String] sOpt_cxx :: Settings -> [String] sOpt_a :: Settings -> [String] sOpt_l :: Settings -> [String] sOpt_lm :: Settings -> [String] sOpt_windres :: Settings -> [String] sOpt_lo :: Settings -> [String] sOpt_lc :: Settings -> [String] sOpt_lcc :: Settings -> [String] sOpt_i :: Settings -> [String] sExtraGccViaCFlags :: Settings -> [String] sTargetPlatformString :: Settings -> String sGhcWithInterpreter :: Settings -> Bool sGhcWithSMP :: Settings -> Bool sGhcRTSWays :: Settings -> String sLibFFI :: Settings -> Bool sGhcRtsWithLibdw :: Settings -> Bool -- | Settings for what GHC this is. data GhcNameVersion GhcNameVersion :: String -> String -> GhcNameVersion [ghcNameVersion_programName] :: GhcNameVersion -> String [ghcNameVersion_projectVersion] :: GhcNameVersion -> String -- | Paths to various files and directories used by GHC, including those -- that provide more settings. data FileSettings FileSettings :: FilePath -> FilePath -> Maybe FilePath -> FilePath -> String -> FilePath -> FileSettings [fileSettings_ghcUsagePath] :: FileSettings -> FilePath [fileSettings_ghciUsagePath] :: FileSettings -> FilePath [fileSettings_toolDir] :: FileSettings -> Maybe FilePath [fileSettings_topDir] :: FileSettings -> FilePath [fileSettings_tmpDir] :: FileSettings -> String [fileSettings_globalPackageDatabase] :: FileSettings -> FilePath -- | Platform-specific settings formerly hard-coded in Config.hs. -- -- These should probably be all be triaged whether they can be computed -- from other settings or belong in another another place (like -- Platform above). data PlatformMisc PlatformMisc :: String -> Bool -> Bool -> String -> Bool -> Bool -> String -> PlatformMisc [platformMisc_targetPlatformString] :: PlatformMisc -> String [platformMisc_ghcWithInterpreter] :: PlatformMisc -> Bool [platformMisc_ghcWithSMP] :: PlatformMisc -> Bool [platformMisc_ghcRTSWays] :: PlatformMisc -> String [platformMisc_libFFI] :: PlatformMisc -> Bool [platformMisc_ghcRtsWithLibdw] :: PlatformMisc -> Bool [platformMisc_llvmTarget] :: PlatformMisc -> String -- | "unbuild" a Settings from a DynFlags. This shouldn't be -- needed in the vast majority of code. But GHCi questionably uses this -- to produce a default DynFlags from which to compute a flags -- diff for printing. settings :: DynFlags -> Settings programName :: DynFlags -> String projectVersion :: DynFlags -> String ghcUsagePath :: DynFlags -> FilePath ghciUsagePath :: DynFlags -> FilePath topDir :: DynFlags -> FilePath tmpDir :: DynFlags -> String -- | The directory for this version of ghc in the user's app directory The -- appdir used to be in ~/.ghc but to respect the XDG specification we -- want to move it under $XDG_DATA_HOME/ However, old tooling (like -- cabal) might still write package environments to the old directory, so -- we prefer that if a subdirectory of ~/.ghc with the correct target and -- GHC version suffix exists. -- -- i.e. if ~.ghc$UNIQUE_SUBDIR exists we use that otherwise we use -- $XDG_DATA_HOME/$UNIQUE_SUBDIR -- -- UNIQUE_SUBDIR is typically a combination of the target platform and -- GHC version versionedAppDir :: String -> ArchOS -> MaybeT IO FilePath versionedFilePath :: ArchOS -> FilePath extraGccViaCFlags :: DynFlags -> [String] globalPackageDatabasePath :: DynFlags -> FilePath pgm_L :: DynFlags -> String pgm_P :: DynFlags -> (String, [Option]) pgm_F :: DynFlags -> String pgm_c :: DynFlags -> String pgm_a :: DynFlags -> (String, [Option]) pgm_l :: DynFlags -> (String, [Option]) pgm_lm :: DynFlags -> (String, [Option]) pgm_dll :: DynFlags -> (String, [Option]) pgm_T :: DynFlags -> String pgm_windres :: DynFlags -> String pgm_libtool :: DynFlags -> String pgm_ar :: DynFlags -> String pgm_otool :: DynFlags -> String pgm_install_name_tool :: DynFlags -> String pgm_ranlib :: DynFlags -> String pgm_lo :: DynFlags -> (String, [Option]) pgm_lc :: DynFlags -> (String, [Option]) pgm_lcc :: DynFlags -> (String, [Option]) pgm_i :: DynFlags -> String opt_L :: DynFlags -> [String] opt_P :: DynFlags -> [String] opt_F :: DynFlags -> [String] opt_c :: DynFlags -> [String] opt_cxx :: DynFlags -> [String] opt_a :: DynFlags -> [String] opt_l :: DynFlags -> [String] opt_lm :: DynFlags -> [String] opt_i :: DynFlags -> [String] opt_P_signature :: DynFlags -> ([String], Fingerprint) opt_windres :: DynFlags -> [String] opt_lo :: DynFlags -> [String] opt_lc :: DynFlags -> [String] opt_lcc :: DynFlags -> [String] updatePlatformConstants :: DynFlags -> Maybe PlatformConstants -> IO DynFlags addPluginModuleName :: String -> DynFlags -> DynFlags -- | The normal DynFlags. Note that they are not suitable for use in -- this form and must be fully initialized by runGhc first. defaultDynFlags :: Settings -> LlvmConfig -> DynFlags -- | Used by runGhc to partially initialize a new DynFlags -- value initDynFlags :: DynFlags -> IO DynFlags defaultFatalMessager :: FatalMessager defaultFlushOut :: FlushOut defaultFlushErr :: FlushErr -- | Retrieve the options corresponding to a particular opt_* -- field in the correct order getOpts :: DynFlags -> (DynFlags -> [a]) -> [a] -- | Gets the verbosity flag for the current verbosity level. This is fed -- to other tools, so GHC-specific verbosity flags like -- -ddump-most are not included getVerbFlags :: DynFlags -> [String] -- | Sets the DynFlags to be appropriate to the optimisation level updOptLevel :: Int -> DynFlags -> DynFlags setTmpDir :: FilePath -> DynFlags -> DynFlags setUnitId :: String -> DynFlags -> DynFlags type TurnOnFlag = Bool turnOn :: TurnOnFlag turnOff :: TurnOnFlag impliedGFlags :: [(GeneralFlag, TurnOnFlag, GeneralFlag)] impliedOffGFlags :: [(GeneralFlag, TurnOnFlag, GeneralFlag)] impliedXFlags :: [(Extension, TurnOnFlag, Extension)] -- | Parse dynamic flags from a list of command line arguments. Returns the -- parsed DynFlags, the left-over arguments, and a list of -- warnings. Throws a UsageError if errors occurred during parsing -- (such as unknown flags or missing arguments). parseDynamicFlagsCmdLine :: MonadIO m => DynFlags -> [Located String] -> m (DynFlags, [Located String], [Warn]) -- | Like parseDynamicFlagsCmdLine but does not allow the package -- flags (-package, -hide-package, -ignore-package, -hide-all-packages, -- -package-db). Used to parse flags set in a modules pragma. parseDynamicFilePragma :: MonadIO m => DynFlags -> [Located String] -> m (DynFlags, [Located String], [Warn]) -- | Parses the dynamically set flags for GHC. This is the most general -- form of the dynamic flag parser that the other methods simply wrap. It -- allows saying which flags are valid flags and indicating if we are -- parsing arguments from the command line or from a file pragma. parseDynamicFlagsFull :: MonadIO m => [Flag (CmdLineP DynFlags)] -> Bool -> DynFlags -> [Located String] -> m (DynFlags, [Located String], [Warn]) -- | All dynamic flags option strings without the deprecated ones. These -- are the user facing strings for enabling and disabling options. allNonDeprecatedFlags :: [String] flagsAll :: [Flag (CmdLineP DynFlags)] flagsDynamic :: [Flag (CmdLineP DynFlags)] flagsPackage :: [Flag (CmdLineP DynFlags)] -- | Make a list of flags for shell completion. Filter all available flags -- into two groups, for interactive GHC vs all other. flagsForCompletion :: Bool -> [String] supportedLanguagesAndExtensions :: ArchOS -> [String] -- | The language extensions implied by the various language variants. When -- updating this be sure to update the flag documentation in -- docsusers_guideexts. languageExtensions :: Maybe Language -> [Extension] picCCOpts :: DynFlags -> [String] picPOpts :: DynFlags -> [String] compilerInfo :: DynFlags -> [(String, String)] wordAlignment :: Platform -> Alignment setUnsafeGlobalDynFlags :: DynFlags -> IO () isSseEnabled :: Platform -> Bool isSse2Enabled :: Platform -> Bool isSse4_2Enabled :: DynFlags -> Bool isBmiEnabled :: DynFlags -> Bool isBmi2Enabled :: DynFlags -> Bool isAvxEnabled :: DynFlags -> Bool isAvx2Enabled :: DynFlags -> Bool isAvx512cdEnabled :: DynFlags -> Bool isAvx512erEnabled :: DynFlags -> Bool isAvx512fEnabled :: DynFlags -> Bool isAvx512pfEnabled :: DynFlags -> Bool data LinkerInfo GnuLD :: [Option] -> LinkerInfo GnuGold :: [Option] -> LinkerInfo LlvmLLD :: [Option] -> LinkerInfo DarwinLD :: [Option] -> LinkerInfo SolarisLD :: [Option] -> LinkerInfo AixLD :: [Option] -> LinkerInfo UnknownLD :: LinkerInfo data CompilerInfo GCC :: CompilerInfo Clang :: CompilerInfo AppleClang :: CompilerInfo AppleClang51 :: CompilerInfo UnknownCC :: CompilerInfo -- | Should we use `-XLinker -rpath` when linking or not? See Note -- [-fno-use-rpaths] useXLinkerRPath :: DynFlags -> OS -> Bool -- | Used to differentiate the scope an include needs to apply to. We have -- to split the include paths to avoid accidentally forcing recursive -- includes since -I overrides the system search paths. See #14312. data IncludeSpecs IncludeSpecs :: [String] -> [String] -> [String] -> IncludeSpecs [includePathsQuote] :: IncludeSpecs -> [String] [includePathsGlobal] :: IncludeSpecs -> [String] -- | See note [Implicit include paths] [includePathsQuoteImplicit] :: IncludeSpecs -> [String] -- | Append to the list of includes a path that shall be included using -- `-I` when the C compiler is called. These paths override system search -- paths. addGlobalInclude :: IncludeSpecs -> [String] -> IncludeSpecs -- | Append to the list of includes a path that shall be included using -- `-iquote` when the C compiler is called. These paths only apply when -- quoted includes are used. e.g. #include "foo.h" addQuoteInclude :: IncludeSpecs -> [String] -> IncludeSpecs -- | Concatenate and flatten the list of global and quoted includes -- returning just a flat list of paths. flattenIncludes :: IncludeSpecs -> [String] -- | These includes are not considered while fingerprinting the flags for -- iface | See note [Implicit include paths] addImplicitQuoteInclude :: IncludeSpecs -> [String] -> IncludeSpecs -- | Initialize the pretty-printing options initSDocContext :: DynFlags -> PprStyle -> SDocContext -- | Initialize the pretty-printing options using the default user style initDefaultSDocContext :: DynFlags -> SDocContext instance GHC.Show.Show GHC.Driver.Session.IncludeSpecs instance GHC.Enum.Enum GHC.Driver.Session.ProfAuto instance GHC.Classes.Eq GHC.Driver.Session.ProfAuto instance GHC.Classes.Eq GHC.Driver.Session.GhcMode instance GHC.Show.Show GHC.Driver.Session.GhcLink instance GHC.Classes.Eq GHC.Driver.Session.GhcLink instance GHC.Show.Show GHC.Driver.Session.PackageArg instance GHC.Classes.Eq GHC.Driver.Session.PackageArg instance GHC.Classes.Eq GHC.Driver.Session.ModRenaming instance GHC.Classes.Eq GHC.Driver.Session.IgnorePackageFlag instance GHC.Classes.Eq GHC.Driver.Session.TrustFlag instance GHC.Classes.Eq GHC.Driver.Session.PackageFlag instance GHC.Classes.Eq GHC.Driver.Session.DynLibLoader instance GHC.Show.Show GHC.Driver.Session.RtsOptsEnabled instance GHC.Classes.Ord GHC.Driver.Session.DynamicTooState instance GHC.Show.Show GHC.Driver.Session.DynamicTooState instance GHC.Classes.Eq GHC.Driver.Session.DynamicTooState instance GHC.Show.Show a => GHC.Show.Show (GHC.Driver.Session.OnOff a) instance GHC.Classes.Eq a => GHC.Classes.Eq (GHC.Driver.Session.OnOff a) instance GHC.Classes.Ord GHC.Driver.Session.Deprecation instance GHC.Classes.Eq GHC.Driver.Session.Deprecation instance GHC.Classes.Eq GHC.Driver.Session.PkgDbRef instance GHC.Classes.Eq GHC.Driver.Session.PackageDBFlag instance GHC.Classes.Eq GHC.Driver.Session.LinkerInfo instance GHC.Classes.Eq GHC.Driver.Session.CompilerInfo instance (GHC.Base.Monoid a, GHC.Base.Monad m, GHC.Driver.Session.HasDynFlags m) => GHC.Driver.Session.HasDynFlags (Control.Monad.Trans.Writer.Lazy.WriterT a m) instance (GHC.Base.Monad m, GHC.Driver.Session.HasDynFlags m) => GHC.Driver.Session.HasDynFlags (Control.Monad.Trans.Reader.ReaderT a m) instance (GHC.Base.Monad m, GHC.Driver.Session.HasDynFlags m) => GHC.Driver.Session.HasDynFlags (Control.Monad.Trans.Maybe.MaybeT m) instance (GHC.Base.Monad m, GHC.Driver.Session.HasDynFlags m) => GHC.Driver.Session.HasDynFlags (Control.Monad.Trans.Except.ExceptT e m) instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Driver.Session.OnOff a) instance GHC.Utils.Outputable.Outputable GHC.Driver.Session.PackageFlag instance GHC.Utils.Outputable.Outputable GHC.Driver.Session.ModRenaming instance GHC.Utils.Outputable.Outputable GHC.Driver.Session.PackageArg instance GHC.Utils.Outputable.Outputable GHC.Driver.Session.GhcMode -- | Parsers for unit/module identifiers module GHC.Unit.Parser parseUnit :: ReadP Unit parseIndefUnitId :: ReadP IndefUnitId parseHoleyModule :: ReadP Module parseModSubst :: ReadP [(ModuleName, Module)] -- | This stuff here is related to supporting the Safe Haskell extension, -- primarily about storing under what trust type a module has been -- compiled. module GHC.Types.SafeHaskell -- | Is an import a safe import? type IsSafeImport = Bool -- | The various Safe Haskell modes data SafeHaskellMode -- | inferred unsafe Sf_None :: SafeHaskellMode -- | declared and checked Sf_Unsafe :: SafeHaskellMode -- | declared and checked Sf_Trustworthy :: SafeHaskellMode -- | declared and checked Sf_Safe :: SafeHaskellMode -- | inferred as safe Sf_SafeInferred :: SafeHaskellMode -- | -fno-safe-haskell state Sf_Ignore :: SafeHaskellMode -- | Safe Haskell information for ModIface Simply a wrapper around -- SafeHaskellMode to sepperate iface and flags data IfaceTrustInfo getSafeMode :: IfaceTrustInfo -> SafeHaskellMode setSafeMode :: SafeHaskellMode -> IfaceTrustInfo noIfaceTrustInfo :: IfaceTrustInfo instance GHC.Classes.Eq GHC.Types.SafeHaskell.SafeHaskellMode instance GHC.Utils.Outputable.Outputable GHC.Types.SafeHaskell.IfaceTrustInfo instance GHC.Utils.Binary.Binary GHC.Types.SafeHaskell.IfaceTrustInfo instance GHC.Show.Show GHC.Types.SafeHaskell.SafeHaskellMode instance GHC.Utils.Outputable.Outputable GHC.Types.SafeHaskell.SafeHaskellMode module GHC.Types.FieldLabel -- | Field labels are just represented as strings; they are not necessarily -- unique (even within a module) type FieldLabelString = FastString -- | A map from labels to all the auxiliary information type FieldLabelEnv = DFastStringEnv FieldLabel -- | Fields in an algebraic record type; see Note [FieldLabel]. data FieldLabel FieldLabel :: FieldLabelString -> DuplicateRecordFields -> FieldSelectors -> Name -> FieldLabel -- | User-visible label of the field [flLabel] :: FieldLabel -> FieldLabelString -- | Was DuplicateRecordFields on in the defining module for this -- datatype? [flHasDuplicateRecordFields] :: FieldLabel -> DuplicateRecordFields -- | Was FieldSelectors enabled in the defining module for this -- datatype? See Note [NoFieldSelectors] in GHC.Rename.Env [flHasFieldSelector] :: FieldLabel -> FieldSelectors -- | Record selector function [flSelector] :: FieldLabel -> Name -- | Record selector OccNames are built from the underlying field name and -- the name of the first data constructor of the type, to support -- duplicate record field names. See Note [Why selector names include -- data constructors]. fieldSelectorOccName :: FieldLabelString -> OccName -> DuplicateRecordFields -> FieldSelectors -> OccName -- | Undo the name mangling described in Note [FieldLabel] to produce a -- Name that has the user-visible OccName (but the selector's unique). -- This should be used only when generating output, when we want to show -- the label, but may need to qualify it with a module prefix. fieldLabelPrintableName :: FieldLabel -> Name -- | Flag to indicate whether the DuplicateRecordFields extension is -- enabled. data DuplicateRecordFields -- | Fields may be duplicated in a single module DuplicateRecordFields :: DuplicateRecordFields -- | Fields must be unique within a module (the default) NoDuplicateRecordFields :: DuplicateRecordFields -- | Flag to indicate whether the FieldSelectors extension is enabled. data FieldSelectors -- | Selector functions are available (the default) FieldSelectors :: FieldSelectors -- | Selector functions are not available NoFieldSelectors :: FieldSelectors flIsOverloaded :: FieldLabel -> Bool instance Data.Data.Data GHC.Types.FieldLabel.DuplicateRecordFields instance GHC.Classes.Eq GHC.Types.FieldLabel.DuplicateRecordFields instance GHC.Show.Show GHC.Types.FieldLabel.DuplicateRecordFields instance Data.Data.Data GHC.Types.FieldLabel.FieldSelectors instance GHC.Classes.Eq GHC.Types.FieldLabel.FieldSelectors instance GHC.Show.Show GHC.Types.FieldLabel.FieldSelectors instance GHC.Classes.Eq GHC.Types.FieldLabel.FieldLabel instance Data.Data.Data GHC.Types.FieldLabel.FieldLabel instance GHC.Types.Name.Occurrence.HasOccName GHC.Types.FieldLabel.FieldLabel instance GHC.Utils.Outputable.Outputable GHC.Types.FieldLabel.FieldLabel instance GHC.Utils.Binary.Binary GHC.Types.Name.Name => GHC.Utils.Binary.Binary GHC.Types.FieldLabel.FieldLabel instance GHC.Utils.Binary.Binary GHC.Types.FieldLabel.FieldSelectors instance GHC.Utils.Outputable.Outputable GHC.Types.FieldLabel.FieldSelectors instance GHC.Utils.Binary.Binary GHC.Types.FieldLabel.DuplicateRecordFields instance GHC.Utils.Outputable.Outputable GHC.Types.FieldLabel.DuplicateRecordFields module GHC.SysTools.BaseDir -- | Expand occurrences of the $topdir interpolation in a string. expandTopDir :: FilePath -> String -> String -- | Expand occurrences of the $tooldir interpolation in a string -- on Windows, leave the string untouched otherwise. expandToolDir :: Maybe FilePath -> String -> String -- | Returns a Unix-format path pointing to TopDir. findTopDir :: Maybe String -> IO String findToolDir :: FilePath -> IO (Maybe FilePath) tryFindTopDir :: Maybe String -> IO (Maybe String) -- | Ways -- -- The central concept of a "way" is that all objects in a given program -- must be compiled in the same "way". Certain options change parameters -- of the virtual machine, eg. profiling adds an extra word to the object -- header, so profiling objects cannot be linked with non-profiling -- objects. -- -- After parsing the command-line options, we determine which "way" we -- are building - this might be a combination way, eg. -- profiling+threaded. -- -- There are two kinds of ways: - RTS only: only affect the runtime -- system (RTS) and don't affect code generation (e.g. threaded, debug) - -- Full ways: affect code generation and the RTS (e.g. profiling, dynamic -- linking) -- -- We then find the "build-tag" associated with this way, and this -- becomes the suffix used to find .hi files and libraries used in this -- compilation. module GHC.Platform.Ways -- | A way -- -- Don't change the constructor order as it us used by waysTag to -- create a unique tag (e.g. thr_debug_p) which is expected by other -- tools (e.g. Cabal). data Way -- | for GHC API clients building custom variants WayCustom :: String -> Way -- | (RTS only) Multithreaded runtime system WayThreaded :: Way -- | Debugging, enable trace messages and extra checks WayDebug :: Way -- | Profiling, enable cost-centre stacks and profiling reports WayProf :: Way -- | (RTS only) enable event logging (tracing) WayTracing :: Way -- | Dynamic linking WayDyn :: Way type Ways = Set Way -- | Test if a ways is enabled hasWay :: Ways -> Way -> Bool -- | Add a way addWay :: Way -> Ways -> Ways -- | Check if a combination of ways is allowed allowed_combination :: Ways -> Bool -- | Turn these flags on when enabling this way wayGeneralFlags :: Platform -> Way -> [GeneralFlag] -- | Turn these flags off when enabling this way wayUnsetGeneralFlags :: Platform -> Way -> [GeneralFlag] -- | Pass these options to the C compiler when enabling this way wayOptc :: Platform -> Way -> [String] -- | Pass these options to linker when enabling this way wayOptl :: Platform -> Way -> [String] -- | Pass these options to the preprocessor when enabling this way wayOptP :: Platform -> Way -> [String] wayDesc :: Way -> String -- | Return true for ways that only impact the RTS, not the generated code wayRTSOnly :: Way -> Bool -- | Unique build-tag associated to a way wayTag :: Way -> String -- | Unique tag associated to a list of ways waysTag :: Ways -> String -- | Unique build-tag associated to a list of ways -- -- RTS only ways are filtered out because they have no impact on the -- build. waysBuildTag :: Ways -> String -- | Filter ways that have an impact on compilation fullWays :: Ways -> Ways -- | Filter RTS-only ways (ways that don't have an impact on compilation) rtsWays :: Ways -> Ways -- | Host ways. hostWays :: Ways -- | Host "full" ways (i.e. ways that have an impact on the compilation, -- not RTS only ways). -- -- These ways must be used when compiling codes targeting the internal -- interpreter. hostFullWays :: Ways -- | Consult the RTS to find whether it has been built with profiling -- enabled. hostIsProfiled :: Bool -- | Consult the RTS to find whether GHC itself has been built with dynamic -- linking. This can't be statically known at compile-time, because we -- build both the static and dynamic versions together with -dynamic-too. hostIsDynamic :: Bool -- | Consult the RTS to find whether it is threaded. hostIsThreaded :: Bool -- | Consult the RTS to find whether it is debugged. hostIsDebugged :: Bool -- | Consult the RTS to find whether it is tracing. hostIsTracing :: Bool instance GHC.Show.Show GHC.Platform.Ways.Way instance GHC.Classes.Ord GHC.Platform.Ways.Way instance GHC.Classes.Eq GHC.Platform.Ways.Way -- | Platform profiles module GHC.Platform.Profile -- | A platform profile fully describes the kind of objects that are -- generated for a platform. -- -- Platform doesn't fully describe the ABI of an object. Compiler -- ways (profiling, debug, dynamic) also modify the ABI. data Profile Profile :: !Platform -> !Ways -> Profile -- | Platform [profilePlatform] :: Profile -> !Platform -- | Ways [profileWays] :: Profile -> !Ways -- | Unique build tag for the profile profileBuildTag :: Profile -> String -- | Get platform constants profileConstants :: Profile -> PlatformConstants -- | Is profiling enabled profileIsProfiling :: Profile -> Bool -- | Word size in bytes profileWordSizeInBytes :: Profile -> Int module GHC.Driver.Phases data Phase Unlit :: HscSource -> Phase Cpp :: HscSource -> Phase HsPp :: HscSource -> Phase Hsc :: HscSource -> Phase Ccxx :: Phase Cc :: Phase Cobjc :: Phase Cobjcxx :: Phase HCc :: Phase As :: Bool -> Phase LlvmOpt :: Phase LlvmLlc :: Phase LlvmMangle :: Phase CmmCpp :: Phase Cmm :: Phase MergeForeign :: Phase StopLn :: Phase happensBefore :: Platform -> Phase -> Phase -> Bool eqPhase :: Phase -> Phase -> Bool anyHsc :: Phase isStopLn :: Phase -> Bool startPhase :: String -> Phase phaseInputExt :: Phase -> String isHaskellishSuffix :: String -> Bool isHaskellSrcSuffix :: String -> Bool isBackpackishSuffix :: String -> Bool isObjectSuffix :: Platform -> String -> Bool isCishSuffix :: String -> Bool isDynLibSuffix :: Platform -> String -> Bool isHaskellUserSrcSuffix :: String -> Bool isHaskellSigSuffix :: String -> Bool isSourceSuffix :: String -> Bool -- | When we are given files (modified by -x arguments) we need to -- determine if they are Haskellish or not to figure out how we should -- try to compile it. The rules are: -- --
-- -- Given pointers to the start and end of a string, count how many zeros -- -- the string contains. -- countZeros :: Addr# -> Addr# -> -> Int -- countZeros start end = go start 0 -- where -- go off n -- | off addrEq# end = n -- | otherwise = go (off plusAddr# 1) n' -- where n' | isTrue# (indexInt8OffAddr# off 0# ==# 0#) = n + 1 -- | otherwise = n ---- -- Consider what happens if we considered strings to be trivial (and -- therefore duplicable) and emitted a call like countZeros "hello"# -- ("hello"# plusAddr# 5). The beginning and end pointers -- do not belong to the same string, meaning that an iteration like the -- above would blow up terribly. This is what happened in #12757. -- -- Ultimately the solution here is to make primitive strings a bit more -- structured, ensuring that the compiler can't inline in ways that will -- break user code. One approach to this is described in #8472. litIsTrivial :: Literal -> Bool litIsLifted :: Literal -> Bool inCharRange :: Char -> Bool -- | Tests whether the literal represents a zero of whatever type it is isZeroLit :: Literal -> Bool -- | Tests whether the literal represents a one of whatever type it is isOneLit :: Literal -> Bool litFitsInChar :: Literal -> Bool -- | Returns the Integer contained in the Literal, for when -- that makes sense, i.e. for Char, Int, Word, -- LitInteger and LitNatural. litValue :: Literal -> Integer -- | Apply a function to the Integer contained in the -- Literal, for when that makes sense, e.g. for Char and -- numbers. For fixed-size integral literals, the result will be wrapped -- in accordance with the semantics of the target type. See Note -- [WordInt underflowoverflow] mapLitValue :: Platform -> (Integer -> Integer) -> Literal -> Literal -- | Returns the Integer contained in the Literal, for when -- that makes sense, i.e. for Char and numbers. isLitValue_maybe :: Literal -> Maybe Integer narrowInt8Lit :: Literal -> Literal narrowInt16Lit :: Literal -> Literal narrowInt32Lit :: Literal -> Literal narrowInt64Lit :: Literal -> Literal narrowWord8Lit :: Literal -> Literal narrowWord16Lit :: Literal -> Literal narrowWord32Lit :: Literal -> Literal narrowWord64Lit :: Literal -> Literal -- | Extend or narrow a fixed-width literal (e.g. Int16#) to a -- target word-sized literal (Int# or Word#). Narrowing can -- only happen on 32-bit architectures when we convert a 64-bit literal -- into a 32-bit one. convertToIntLit :: Platform -> Literal -> Literal -- | Extend or narrow a fixed-width literal (e.g. Int16#) to a -- target word-sized literal (Int# or Word#). Narrowing can -- only happen on 32-bit architectures when we convert a 64-bit literal -- into a 32-bit one. convertToWordLit :: Platform -> Literal -> Literal charToIntLit :: Literal -> Literal intToCharLit :: Literal -> Literal floatToIntLit :: Literal -> Literal intToFloatLit :: Literal -> Literal doubleToIntLit :: Literal -> Literal intToDoubleLit :: Literal -> Literal nullAddrLit :: Literal floatToDoubleLit :: Literal -> Literal doubleToFloatLit :: Literal -> Literal -- | A rubbish literal; see Note [Rubbish literals] rubbishLit :: Bool -> Literal isRubbishLit :: Literal -> Bool instance GHC.Classes.Ord GHC.Types.Literal.LitNumType instance GHC.Classes.Eq GHC.Types.Literal.LitNumType instance GHC.Enum.Enum GHC.Types.Literal.LitNumType instance Data.Data.Data GHC.Types.Literal.LitNumType instance Data.Data.Data GHC.Types.Literal.Literal instance GHC.Utils.Binary.Binary GHC.Types.Literal.Literal instance GHC.Utils.Outputable.Outputable GHC.Types.Literal.Literal instance GHC.Classes.Eq GHC.Types.Literal.Literal instance GHC.Classes.Ord GHC.Types.Literal.Literal instance GHC.Utils.Binary.Binary GHC.Types.Literal.LitNumType module GHC.Core.TyCon -- | TyCons represent type constructors. Type constructors are introduced -- by things such as: -- -- 1) Data declarations: data Foo = ... creates the Foo -- type constructor of kind * -- -- 2) Type synonyms: type Foo = ... creates the Foo -- type constructor -- -- 3) Newtypes: newtype Foo a = MkFoo ... creates the -- Foo type constructor of kind * -> * -- -- 4) Class declarations: class Foo where creates the -- Foo type constructor of kind * -- -- This data type also encodes a number of primitive, built in type -- constructors such as those for function and tuple types. data TyCon -- | Represents right-hand-sides of TyCons for algebraic types data AlgTyConRhs -- | Says that we know nothing about this data type, except that it's -- represented by a pointer. Used when we export a data type abstractly -- into an .hi file. AbstractTyCon :: AlgTyConRhs -- | Information about those TyCons derived from a data -- declaration. This includes data types with no constructors at all. DataTyCon :: [DataCon] -> Int -> Bool -> AlgTyConRhs -- | The data type constructors; can be empty if the user declares the type -- to have no constructors -- -- INVARIANT: Kept in order of increasing DataCon tag (see the tag -- assignment in mkTyConTagMap) [data_cons] :: AlgTyConRhs -> [DataCon] -- | Cached value: length data_cons [data_cons_size] :: AlgTyConRhs -> Int -- | Cached value: is this an enumeration type? See Note [Enumeration -- types] [is_enum] :: AlgTyConRhs -> Bool TupleTyCon :: DataCon -> TupleSort -> AlgTyConRhs -- | The unique constructor for the newtype. It has no -- existentials [data_con] :: AlgTyConRhs -> DataCon -- | Is this a boxed, unboxed or constraint tuple? [tup_sort] :: AlgTyConRhs -> TupleSort -- | An unboxed sum type. SumTyCon :: [DataCon] -> Int -> AlgTyConRhs -- | The data type constructors; can be empty if the user declares the type -- to have no constructors -- -- INVARIANT: Kept in order of increasing DataCon tag (see the tag -- assignment in mkTyConTagMap) [data_cons] :: AlgTyConRhs -> [DataCon] -- | Cached value: length data_cons [data_cons_size] :: AlgTyConRhs -> Int -- | Information about those TyCons derived from a newtype -- declaration NewTyCon :: DataCon -> Type -> ([TyVar], Type) -> CoAxiom Unbranched -> Bool -> AlgTyConRhs -- | The unique constructor for the newtype. It has no -- existentials [data_con] :: AlgTyConRhs -> DataCon -- | Cached value: the argument type of the constructor, which is just the -- representation type of the TyCon (remember that -- newtypes do not exist at runtime so need a different -- representation type). -- -- The free TyVars of this type are the tyConTyVars from -- the corresponding TyCon [nt_rhs] :: AlgTyConRhs -> Type -- | Same as the nt_rhs, but this time eta-reduced. Hence the list -- of TyVars in this field may be shorter than the declared arity -- of the TyCon. [nt_etad_rhs] :: AlgTyConRhs -> ([TyVar], Type) [nt_co] :: AlgTyConRhs -> CoAxiom Unbranched [nt_lev_poly] :: AlgTyConRhs -> Bool -- | Both type classes as well as family instances imply implicit type -- constructors. These implicit type constructors refer to their parent -- structure (ie, the class or family from which they derive) using a -- type of the following form. -- -- Extract those DataCons that we are able to learn about. Note -- that visibility in this sense does not correspond to visibility in the -- context of any particular user program! visibleDataCons :: AlgTyConRhs -> [DataCon] data AlgTyConFlav -- | An ordinary type constructor has no parent. VanillaAlgTyCon :: TyConRepName -> AlgTyConFlav -- | An unboxed type constructor. The TyConRepName is a Maybe since we -- currently don't allow unboxed sums to be Typeable since there are too -- many of them. See #13276. UnboxedAlgTyCon :: Maybe TyConRepName -> AlgTyConFlav -- | Type constructors representing a class dictionary. See Note [ATyCon -- for classes] in GHC.Core.TyCo.Rep ClassTyCon :: Class -> TyConRepName -> AlgTyConFlav -- | Type constructors representing an *instance* of a *data* family. -- Parameters: -- -- 1) The type family in question -- -- 2) Instance types; free variables are the tyConTyVars of the -- current TyCon (not the family one). INVARIANT: the number of -- types matches the arity of the family TyCon -- -- 3) A CoTyCon identifying the representation type with the -- type instance family DataFamInstTyCon :: CoAxiom Unbranched -> TyCon -> [Type] -> AlgTyConFlav isNoParent :: AlgTyConFlav -> Bool -- | Information pertaining to the expansion of a type synonym -- (type) data FamTyConFlav -- | Represents an open type family without a fixed right hand side. -- Additional instances can appear at any time. -- -- These are introduced by either a top level declaration: -- --
-- data family T a :: * ---- -- Or an associated data type declaration, within a class declaration: -- --
-- class C a b where -- data T b :: * --DataFamilyTyCon :: TyConRepName -> FamTyConFlav -- | An open type synonym family e.g. type family F x y :: * -> -- * OpenSynFamilyTyCon :: FamTyConFlav -- | A closed type synonym family e.g. type family F x where { F Int = -- Bool } ClosedSynFamilyTyCon :: Maybe (CoAxiom Branched) -> FamTyConFlav -- | A closed type synonym family declared in an hs-boot file with type -- family F a where .. AbstractClosedSynFamilyTyCon :: FamTyConFlav -- | Built-in type family used by the TypeNats solver BuiltInSynFamTyCon :: BuiltInSynFamily -> FamTyConFlav data Role Nominal :: Role Representational :: Role Phantom :: Role data Injectivity NotInjective :: Injectivity Injective :: [Bool] -> Injectivity -- | Some promoted datacons signify extra info relevant to GHC. For -- example, the IntRep constructor of RuntimeRep -- corresponds to the IntRep constructor of PrimRep. This -- data structure allows us to store this information right in the -- TyCon. The other approach would be to look up things like -- RuntimeRep's PrimRep by known-key every time. See -- also Note [Getting from RuntimeRep to PrimRep] in -- GHC.Types.RepType data RuntimeRepInfo -- | an ordinary promoted data con NoRRI :: RuntimeRepInfo -- | A constructor of RuntimeRep. The argument to the function -- should be the list of arguments to the promoted datacon. RuntimeRep :: ([Type] -> [PrimRep]) -> RuntimeRepInfo -- | A constructor of VecCount VecCount :: Int -> RuntimeRepInfo -- | A constructor of VecElem VecElem :: PrimElemRep -> RuntimeRepInfo -- | A constructor of Levity LiftedInfo :: RuntimeRepInfo -- | A constructor of Levity UnliftedInfo :: RuntimeRepInfo -- | Paints a picture of what a TyCon represents, in broad strokes. -- This is used towards more informative error messages. data TyConFlavour ClassFlavour :: TyConFlavour TupleFlavour :: Boxity -> TyConFlavour SumFlavour :: TyConFlavour DataTypeFlavour :: TyConFlavour NewtypeFlavour :: TyConFlavour AbstractTypeFlavour :: TyConFlavour DataFamilyFlavour :: Maybe TyCon -> TyConFlavour OpenTypeFamilyFlavour :: Maybe TyCon -> TyConFlavour ClosedTypeFamilyFlavour :: TyConFlavour TypeSynonymFlavour :: TyConFlavour -- | e.g., the (->) TyCon. BuiltInTypeFlavour :: TyConFlavour PromotedDataConFlavour :: TyConFlavour type TyConBinder = VarBndr TyVar TyConBndrVis data TyConBndrVis NamedTCB :: ArgFlag -> TyConBndrVis AnonTCB :: AnonArgFlag -> TyConBndrVis type TyConTyCoBinder = VarBndr TyCoVar TyConBndrVis mkNamedTyConBinder :: ArgFlag -> TyVar -> TyConBinder mkNamedTyConBinders :: ArgFlag -> [TyVar] -> [TyConBinder] -- | Make a Required TyConBinder. It chooses between NamedTCB and AnonTCB -- based on whether the tv is mentioned in the dependent set mkRequiredTyConBinder :: TyCoVarSet -> TyVar -> TyConBinder mkAnonTyConBinder :: AnonArgFlag -> TyVar -> TyConBinder mkAnonTyConBinders :: AnonArgFlag -> [TyVar] -> [TyConBinder] tyConBinderArgFlag :: TyConBinder -> ArgFlag tyConBndrVisArgFlag :: TyConBndrVis -> ArgFlag isNamedTyConBinder :: TyConBinder -> Bool isVisibleTyConBinder :: VarBndr tv TyConBndrVis -> Bool isInvisibleTyConBinder :: VarBndr tv TyConBndrVis -> Bool -- | The labels for the fields of this particular TyCon tyConFieldLabels :: TyCon -> [FieldLabel] -- | Look up a field label belonging to this TyCon lookupTyConFieldLabel :: FieldLabelString -> TyCon -> Maybe FieldLabel -- | This is the making of an algebraic TyCon. mkAlgTyCon :: Name -> [TyConBinder] -> Kind -> [Role] -> Maybe CType -> [PredType] -> AlgTyConRhs -> AlgTyConFlav -> Bool -> TyCon -- | Simpler specialization of mkAlgTyCon for classes mkClassTyCon :: Name -> [TyConBinder] -> [Role] -> AlgTyConRhs -> Class -> Name -> TyCon -- | Given the name of the function type constructor and it's kind, create -- the corresponding TyCon. It is recommended to use -- funTyCon if you want this functionality mkFunTyCon :: Name -> [TyConBinder] -> Name -> TyCon -- | Create an unlifted primitive TyCon, such as Int#. mkPrimTyCon :: Name -> [TyConBinder] -> Kind -> [Role] -> TyCon -- | Kind constructors mkKindTyCon :: Name -> [TyConBinder] -> Kind -> [Role] -> Name -> TyCon -- | Create a lifted primitive TyCon such as RealWorld mkLiftedPrimTyCon :: Name -> [TyConBinder] -> Kind -> [Role] -> TyCon mkTupleTyCon :: Name -> [TyConBinder] -> Kind -> Arity -> DataCon -> TupleSort -> AlgTyConFlav -> TyCon mkSumTyCon :: Name -> [TyConBinder] -> Kind -> Arity -> [TyVar] -> [DataCon] -> AlgTyConFlav -> TyCon mkDataTyConRhs :: [DataCon] -> AlgTyConRhs -- | Create a type synonym TyCon mkSynonymTyCon :: Name -> [TyConBinder] -> Kind -> [Role] -> Type -> Bool -> Bool -> Bool -> TyCon -- | Create a type family TyCon mkFamilyTyCon :: Name -> [TyConBinder] -> Kind -> Maybe Name -> FamTyConFlav -> Maybe Class -> Injectivity -> TyCon -- | Create a promoted data constructor TyCon Somewhat dodgily, we -- give it the same Name as the data constructor itself; when we -- pretty-print the TyCon we add a quote; see the Outputable TyCon -- instance mkPromotedDataCon :: DataCon -> Name -> TyConRepName -> [TyConTyCoBinder] -> Kind -> [Role] -> RuntimeRepInfo -> TyCon -- | Makes a tycon suitable for use during type-checking. It stores a -- variety of details about the definition of the TyCon, but no -- right-hand side. It lives only during the type-checking of a -- mutually-recursive group of tycons; it is then zonked to a proper -- TyCon in zonkTcTyCon. See also Note [Kind checking recursive type and -- class declarations] in GHC.Tc.TyCl. mkTcTyCon :: Name -> [TyConBinder] -> Kind -> [(Name, TcTyVar)] -> Bool -> TyConFlavour -> TyCon -- | No scoped type variables (to be used with mkTcTyCon). noTcTyConScopedTyVars :: [(Name, TcTyVar)] -- | Returns True if the supplied TyCon resulted from -- either a data or newtype declaration isAlgTyCon :: TyCon -> Bool -- | Returns True for vanilla AlgTyCons -- that is, those created -- with a data or newtype declaration. isVanillaAlgTyCon :: TyCon -> Bool -- | Returns True for the TyCon of the Constraint -- kind. isConstraintKindCon :: TyCon -> Bool -- | Is this TyCon that for a class instance? isClassTyCon :: TyCon -> Bool -- | Is this TyCon that for a data family instance? isFamInstTyCon :: TyCon -> Bool isFunTyCon :: TyCon -> Bool -- | Does this TyCon represent something that cannot be defined in -- Haskell? isPrimTyCon :: TyCon -> Bool -- | Does this TyCon represent a tuple? -- -- NB: when compiling Data.Tuple, the tycons won't reply -- True to isTupleTyCon, because they are built as -- AlgTyCons. However they get spat into the interface file as -- tuple tycons, so I don't think it matters. isTupleTyCon :: TyCon -> Bool -- | Is this the TyCon for an unboxed tuple? isUnboxedTupleTyCon :: TyCon -> Bool -- | Is this the TyCon for a boxed tuple? isBoxedTupleTyCon :: TyCon -> Bool -- | Is this the TyCon for an unboxed sum? isUnboxedSumTyCon :: TyCon -> Bool -- | Is this the TyCon for a promoted tuple? isPromotedTupleTyCon :: TyCon -> Bool isLiftedAlgTyCon :: TyCon -> Bool -- | Is this a TyCon representing a regular H98 type synonym -- (type)? isTypeSynonymTyCon :: TyCon -> Bool -- | True iff we can decompose (T a b c) into ((T a b) c) I.e. is it -- injective and generative w.r.t nominal equality? That is, if (T a b) -- ~N d e f, is it always the case that (T ~N d), (a ~N e) and (b ~N f)? -- Specifically NOT true of synonyms (open and otherwise) -- -- It'd be unusual to call mustBeSaturated on a regular H98 type synonym, -- because you should probably have expanded it first But regardless, -- it's not decomposable mustBeSaturated :: TyCon -> Bool -- | Is this a PromotedDataCon? isPromotedDataCon :: TyCon -> Bool -- | Retrieves the promoted DataCon if this is a PromotedDataCon; isPromotedDataCon_maybe :: TyCon -> Maybe DataCon -- | Is this tycon really meant for use at the kind level? That is, should -- it be permitted without -XDataKinds? isKindTyCon :: TyCon -> Bool isLiftedTypeKindTyConName :: Name -> Bool isTauTyCon :: TyCon -> Bool -- | Is this tycon neither a type family nor a synonym that expands to a -- type family? isFamFreeTyCon :: TyCon -> Bool -- | Is this a forgetful type synonym? If this is a type synonym whose RHS -- does not mention one (or more) of its bound variables, returns True. -- Thus, False means that all bound variables appear on the RHS; True may -- not mean anything, as the test to set this flag is conservative. isForgetfulSynTyCon :: TyCon -> Bool -- | Returns True for data types that are definitely -- represented by heap-allocated constructors. These are scrutinised by -- Core-level case expressions, and they get info tables -- allocated for them. -- -- Generally, the function will be true for all data types and -- false for newtypes, unboxed tuples, unboxed sums and type -- family TyCons. But it is not guaranteed to return True -- in all cases that it could. -- -- NB: for a data type family, only the instance TyCons get -- an info table. The family declaration TyCon does not isDataTyCon :: TyCon -> Bool -- | Is this an algebraic TyCon which is just an enumeration of -- values? isEnumerationTyCon :: TyCon -> Bool -- | Is this TyCon that for a newtype isNewTyCon :: TyCon -> Bool -- | Test if the TyCon is algebraic but abstract (invisible data -- constructors) isAbstractTyCon :: TyCon -> Bool -- | Is this a TyCon, synonym or otherwise, that defines a family? isFamilyTyCon :: TyCon -> Bool -- | Is this a TyCon, synonym or otherwise, that defines a family -- with instances? isOpenFamilyTyCon :: TyCon -> Bool -- | Is this a synonym TyCon that can have may have further -- instances appear? isTypeFamilyTyCon :: TyCon -> Bool -- | Is this a synonym TyCon that can have may have further -- instances appear? isDataFamilyTyCon :: TyCon -> Bool -- | Is this an open type family TyCon? isOpenTypeFamilyTyCon :: TyCon -> Bool -- | Is this a non-empty closed type family? Returns Nothing for -- abstract or empty closed families. isClosedSynFamilyTyConWithAxiom_maybe :: TyCon -> Maybe (CoAxiom Branched) -- | tyConInjectivityInfo tc returns Injective -- is if tc is an injective tycon (where is states -- for which tyConBinders tc is injective), or -- NotInjective otherwise. tyConInjectivityInfo :: TyCon -> Injectivity isBuiltInSynFamTyCon_maybe :: TyCon -> Maybe BuiltInSynFamily -- | Is this TyCon unlifted (i.e. cannot contain bottom)? Note that -- this can only be true for primitive and unboxed-tuple TyCons isUnliftedTyCon :: TyCon -> Bool -- | Is this an algebraic TyCon declared with the GADT syntax? isGadtSyntaxTyCon :: TyCon -> Bool -- | isInjectiveTyCon is true of TyCons for which this -- property holds (where X is the role passed in): If (T a1 b1 c1) ~X (T -- a2 b2 c2), then (a1 ~X1 a2), (b1 ~X2 b2), and (c1 ~X3 c2) (where X1, -- X2, and X3, are the roles given by tyConRolesX tc X) See also Note -- [Decomposing equality] in GHC.Tc.Solver.Canonical isInjectiveTyCon :: TyCon -> Role -> Bool -- | isGenerativeTyCon is true of TyCons for which this -- property holds (where X is the role passed in): If (T tys ~X t), then -- (t's head ~X T). See also Note [Decomposing equality] in -- GHC.Tc.Solver.Canonical isGenerativeTyCon :: TyCon -> Role -> Bool -- | Is this an AlgTyConRhs of a TyCon that is generative and -- injective with respect to representational equality? isGenInjAlgRhs :: AlgTyConRhs -> Bool -- | Is this TyCon for an associated type? isTyConAssoc :: TyCon -> Bool -- | Get the enclosing class TyCon (if there is one) for the given TyCon. tyConAssoc_maybe :: TyCon -> Maybe TyCon -- | Get the enclosing class TyCon (if there is one) for the given -- TyConFlavour tyConFlavourAssoc_maybe :: TyConFlavour -> Maybe TyCon -- | Identifies implicit tycons that, in particular, do not go into -- interface files (because they are implicitly reconstructed when the -- interface is read). -- -- Note that: -- --
-- f :: (Eq a) => a -> Int
-- g :: (?x :: Int -> Int) => a -> Int
-- h :: (r\l) => {r} => {l::Int | r}
--
--
-- Here the Eq a and ?x :: Int -> Int and
-- rl are all called "predicates"
type PredType = Type
-- | A collection of PredTypes
type ThetaType = [PredType]
-- | Argument Flag
--
-- Is something required to appear in source Haskell (Required),
-- permitted by request (Specified) (visible type application), or
-- prohibited entirely from appearing in source Haskell
-- (Inferred)? See Note [VarBndrs, TyCoVarBinders, TyConBinders,
-- and visibility] in GHC.Core.TyCo.Rep
data ArgFlag
Invisible :: Specificity -> ArgFlag
Required :: ArgFlag
pattern Specified :: ArgFlag
pattern Inferred :: ArgFlag
-- | The non-dependent version of ArgFlag. See Note [AnonArgFlag]
-- Appears here partly so that it's together with its friends ArgFlag and
-- ForallVisFlag, but also because it is used in IfaceType, rather early
-- in the compilation chain
data AnonArgFlag
-- | Used for (->): an ordinary non-dependent arrow. The
-- argument is visible in source code.
VisArg :: AnonArgFlag
-- | Used for (=>): a non-dependent predicate arrow. The
-- argument is invisible in source code.
InvisArg :: AnonArgFlag
-- | A Coercion is concrete evidence of the equality/convertibility
-- of two types.
data Coercion
Refl :: Type -> Coercion
GRefl :: Role -> Type -> MCoercionN -> Coercion
TyConAppCo :: Role -> TyCon -> [Coercion] -> Coercion
AppCo :: Coercion -> CoercionN -> Coercion
ForAllCo :: TyCoVar -> KindCoercion -> Coercion -> Coercion
FunCo :: Role -> CoercionN -> Coercion -> Coercion -> Coercion
CoVarCo :: CoVar -> Coercion
AxiomInstCo :: CoAxiom Branched -> BranchIndex -> [Coercion] -> Coercion
AxiomRuleCo :: CoAxiomRule -> [Coercion] -> Coercion
UnivCo :: UnivCoProvenance -> Role -> Type -> Type -> Coercion
SymCo :: Coercion -> Coercion
TransCo :: Coercion -> Coercion -> Coercion
NthCo :: Role -> Int -> Coercion -> Coercion
LRCo :: LeftOrRight -> CoercionN -> Coercion
InstCo :: Coercion -> CoercionN -> Coercion
KindCo :: Coercion -> Coercion
SubCo :: CoercionN -> Coercion
-- | See Note [Coercion holes] Only present during typechecking
HoleCo :: CoercionHole -> Coercion
-- | For simplicity, we have just one UnivCo that represents a coercion
-- from some type to some other type, with (in general) no restrictions
-- on the type. The UnivCoProvenance specifies more exactly what the
-- coercion really is and why a program should (or shouldn't!) trust the
-- coercion. It is reasonable to consider each constructor of
-- UnivCoProvenance as a totally independent coercion form; their
-- only commonality is that they don't tell you what types they coercion
-- between. (That info is in the UnivCo constructor of
-- Coercion.
data UnivCoProvenance
-- | See Note [Phantom coercions]. Only in Phantom roled coercions
PhantomProv :: KindCoercion -> UnivCoProvenance
-- | From the fact that any two coercions are considered equivalent. See
-- Note [ProofIrrelProv]. Can be used in Nominal or Representational
-- coercions
ProofIrrelProv :: KindCoercion -> UnivCoProvenance
-- | From a plugin, which asserts that this coercion is sound. The string
-- is for the use of the plugin.
PluginProv :: String -> UnivCoProvenance
CorePrepProv :: Bool -> UnivCoProvenance
-- | A coercion to be filled in by the type-checker. See Note [Coercion
-- holes]
data CoercionHole
CoercionHole :: CoVar -> IORef (Maybe Coercion) -> CoercionHole
[ch_co_var] :: CoercionHole -> CoVar
[ch_ref] :: CoercionHole -> IORef (Maybe Coercion)
coHoleCoVar :: CoercionHole -> CoVar
setCoHoleCoVar :: CoercionHole -> CoVar -> CoercionHole
type CoercionN = Coercion
type CoercionR = Coercion
type CoercionP = Coercion
type KindCoercion = CoercionN
-- | A semantically more meaningful type to represent what may or may not
-- be a useful Coercion.
data MCoercion
MRefl :: MCoercion
MCo :: Coercion -> MCoercion
type MCoercionR = MCoercion
type MCoercionN = MCoercion
-- | Create a nullary TyConApp. In general you should rather use
-- mkTyConTy. This merely exists to break the import cycle between
-- TyCon and this module.
mkTyConTy_ :: TyCon -> Type
mkTyVarTy :: TyVar -> Type
mkTyVarTys :: [TyVar] -> [Type]
mkTyCoVarTy :: TyCoVar -> Type
mkTyCoVarTys :: [TyCoVar] -> [Type]
mkFunTy :: AnonArgFlag -> Mult -> Type -> Type -> Type
infixr 3 `mkFunTy`
mkVisFunTy :: Mult -> Type -> Type -> Type
infixr 3 `mkVisFunTy`
mkInvisFunTy :: Mult -> Type -> Type -> Type
infixr 3 `mkInvisFunTy`
-- | Make nested arrow types
mkVisFunTys :: [Scaled Type] -> Type -> Type
-- | Like mkTyCoForAllTy, but does not check the occurrence of the
-- binder See Note [Unused coercion variable in ForAllTy]
mkForAllTy :: TyCoVar -> ArgFlag -> Type -> Type
-- | Wraps foralls over the type using the provided TyCoVars from
-- left to right
mkForAllTys :: [TyCoVarBinder] -> Type -> Type
-- | Wraps foralls over the type using the provided InvisTVBinders
-- from left to right
mkInvisForAllTys :: [InvisTVBinder] -> Type -> Type
mkPiTy :: TyCoBinder -> Type -> Type
mkPiTys :: [TyCoBinder] -> Type -> Type
mkFunTyMany :: AnonArgFlag -> Type -> Type -> Type
mkScaledFunTy :: AnonArgFlag -> Scaled Type -> Type -> Type
-- | Special, common, case: Arrow type with mult Many
mkVisFunTyMany :: Type -> Type -> Type
infixr 3 `mkVisFunTyMany`
mkVisFunTysMany :: [Type] -> Type -> Type
mkInvisFunTyMany :: Type -> Type -> Type
infixr 3 `mkInvisFunTyMany`
mkInvisFunTysMany :: [Type] -> Type -> Type
nonDetCmpTyLit :: TyLit -> TyLit -> Ordering
cmpTyLit :: TyLit -> TyLit -> Ordering
-- | A TyCoBinder represents an argument to a function. TyCoBinders
-- can be dependent (Named) or nondependent (Anon). They
-- may also be visible or not. See Note [TyCoBinders]
data TyCoBinder
Named :: TyCoVarBinder -> TyCoBinder
Anon :: AnonArgFlag -> Scaled Type -> TyCoBinder
-- | Variable Binder
--
-- A TyCoVarBinder is the binder of a ForAllTy It's convenient to
-- define this synonym here rather its natural home in
-- GHC.Core.TyCo.Rep, because it's used in
-- GHC.Core.DataCon.hs-boot
--
-- A TyVarBinder is a binder with only TyVar
type TyCoVarBinder = VarBndr TyCoVar ArgFlag
-- | TyBinder is like TyCoBinder, but there can only be
-- TyVarBinder in the Named field.
type TyBinder = TyCoBinder
binderVar :: VarBndr tv argf -> tv
binderVars :: [VarBndr tv argf] -> [tv]
binderType :: VarBndr TyCoVar argf -> Type
binderArgFlag :: VarBndr tv argf -> argf
-- | Remove the binder's variable from the set, if the binder has a
-- variable.
delBinderVar :: VarSet -> TyCoVarBinder -> VarSet
-- | Does this ArgFlag classify an argument that is not written in
-- Haskell?
isInvisibleArgFlag :: ArgFlag -> Bool
-- | Does this ArgFlag classify an argument that is written in
-- Haskell?
isVisibleArgFlag :: ArgFlag -> Bool
-- | Does this binder bind an invisible argument?
isInvisibleBinder :: TyCoBinder -> Bool
-- | Does this binder bind a visible argument?
isVisibleBinder :: TyCoBinder -> Bool
-- | If its a named binder, is the binder a tyvar? Returns True for
-- nondependent binder. This check that we're really returning a
-- *Ty*Binder (as opposed to a coercion binder). That way, if/when we
-- allow coercion quantification in more places, we'll know we missed
-- updating some function.
isTyBinder :: TyCoBinder -> Bool
isNamedBinder :: TyCoBinder -> Bool
pickLR :: LeftOrRight -> (a, a) -> a
data TyCoFolder env a
TyCoFolder :: (Type -> Maybe Type) -> (env -> TyVar -> a) -> (env -> CoVar -> a) -> (env -> CoercionHole -> a) -> (env -> TyCoVar -> ArgFlag -> env) -> TyCoFolder env a
[tcf_view] :: TyCoFolder env a -> Type -> Maybe Type
[tcf_tyvar] :: TyCoFolder env a -> env -> TyVar -> a
[tcf_covar] :: TyCoFolder env a -> env -> CoVar -> a
-- | What to do with coercion holes. See Note [Coercion holes] in
-- GHC.Core.TyCo.Rep.
[tcf_hole] :: TyCoFolder env a -> env -> CoercionHole -> a
-- | The returned env is used in the extended scope
[tcf_tycobinder] :: TyCoFolder env a -> env -> TyCoVar -> ArgFlag -> env
foldTyCo :: Monoid a => TyCoFolder env a -> env -> (Type -> a, [Type] -> a, Coercion -> a, [Coercion] -> a)
typeSize :: Type -> Int
coercionSize :: Coercion -> Int
provSize :: UnivCoProvenance -> Int
-- | A shorthand for data with an attached Mult element (the
-- multiplicity).
data Scaled a
Scaled :: !Mult -> a -> Scaled a
scaledMult :: Scaled a -> Mult
scaledThing :: Scaled a -> a
-- | Apply a function to both the Mult and the Type in a 'Scaled Type'
mapScaledType :: (Type -> Type) -> Scaled Type -> Scaled Type
-- | Mult is a type alias for Type.
--
-- Mult must contain Type because multiplicity variables are mere type
-- variables (of kind Multiplicity) in Haskell. So the simplest
-- implementation is to make Mult be Type.
--
-- Multiplicities can be formed with: - One: GHC.Types.One (= oneDataCon)
-- - Many: GHC.Types.Many (= manyDataCon) - Multiplication:
-- GHC.Types.MultMul (= multMulTyCon)
--
-- So that Mult feels a bit more structured, we provide pattern synonyms
-- and smart constructors for these.
type Mult = Type
instance Data.Data.Data GHC.Core.TyCo.Rep.TyLit
instance GHC.Classes.Eq GHC.Core.TyCo.Rep.TyLit
instance Data.Data.Data GHC.Core.TyCo.Rep.MCoercion
instance Data.Data.Data GHC.Core.TyCo.Rep.UnivCoProvenance
instance Data.Data.Data GHC.Core.TyCo.Rep.Coercion
instance Data.Data.Data GHC.Core.TyCo.Rep.Type
instance Data.Data.Data a => Data.Data.Data (GHC.Core.TyCo.Rep.Scaled a)
instance Data.Data.Data GHC.Core.TyCo.Rep.TyCoBinder
instance GHC.Utils.Outputable.Outputable GHC.Core.TyCo.Rep.TyCoBinder
instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Core.TyCo.Rep.Scaled a)
instance GHC.Utils.Outputable.Outputable GHC.Core.TyCo.Rep.Type
instance GHC.Utils.Outputable.Outputable GHC.Core.TyCo.Rep.Coercion
instance GHC.Utils.Outputable.Outputable GHC.Core.TyCo.Rep.MCoercion
instance GHC.Utils.Outputable.Outputable GHC.Core.TyCo.Rep.UnivCoProvenance
instance Data.Data.Data GHC.Core.TyCo.Rep.CoercionHole
instance GHC.Utils.Outputable.Outputable GHC.Core.TyCo.Rep.CoercionHole
instance GHC.Types.Unique.Uniquable GHC.Core.TyCo.Rep.CoercionHole
instance GHC.Utils.Outputable.Outputable GHC.Core.TyCo.Rep.TyLit
module GHC.Iface.Type
type IfExtName = Name
type IfLclName = FastString
-- | A kind of universal type, used for types and kinds.
--
-- Any time a Type is pretty-printed, it is first converted to
-- an IfaceType before being printed. See Note [Pretty printing
-- via Iface syntax] in GHC.Types.TyThing.Ppr
data IfaceType
IfaceFreeTyVar :: TyVar -> IfaceType
IfaceTyVar :: IfLclName -> IfaceType
IfaceLitTy :: IfaceTyLit -> IfaceType
IfaceAppTy :: IfaceType -> IfaceAppArgs -> IfaceType
IfaceFunTy :: AnonArgFlag -> IfaceMult -> IfaceType -> IfaceType -> IfaceType
IfaceForAllTy :: IfaceForAllBndr -> IfaceType -> IfaceType
IfaceTyConApp :: IfaceTyCon -> IfaceAppArgs -> IfaceType
IfaceCastTy :: IfaceType -> IfaceCoercion -> IfaceType
IfaceCoercionTy :: IfaceCoercion -> IfaceType
IfaceTupleTy :: TupleSort -> PromotionFlag -> IfaceAppArgs -> IfaceType
type IfacePredType = IfaceType
type IfaceKind = IfaceType
data IfaceCoercion
IfaceReflCo :: IfaceType -> IfaceCoercion
IfaceGReflCo :: Role -> IfaceType -> IfaceMCoercion -> IfaceCoercion
IfaceFunCo :: Role -> IfaceCoercion -> IfaceCoercion -> IfaceCoercion -> IfaceCoercion
IfaceTyConAppCo :: Role -> IfaceTyCon -> [IfaceCoercion] -> IfaceCoercion
IfaceAppCo :: IfaceCoercion -> IfaceCoercion -> IfaceCoercion
IfaceForAllCo :: IfaceBndr -> IfaceCoercion -> IfaceCoercion -> IfaceCoercion
IfaceCoVarCo :: IfLclName -> IfaceCoercion
IfaceAxiomInstCo :: IfExtName -> BranchIndex -> [IfaceCoercion] -> IfaceCoercion
IfaceAxiomRuleCo :: IfLclName -> [IfaceCoercion] -> IfaceCoercion
IfaceUnivCo :: IfaceUnivCoProv -> Role -> IfaceType -> IfaceType -> IfaceCoercion
IfaceSymCo :: IfaceCoercion -> IfaceCoercion
IfaceTransCo :: IfaceCoercion -> IfaceCoercion -> IfaceCoercion
IfaceNthCo :: Int -> IfaceCoercion -> IfaceCoercion
IfaceLRCo :: LeftOrRight -> IfaceCoercion -> IfaceCoercion
IfaceInstCo :: IfaceCoercion -> IfaceCoercion -> IfaceCoercion
IfaceKindCo :: IfaceCoercion -> IfaceCoercion
IfaceSubCo :: IfaceCoercion -> IfaceCoercion
IfaceFreeCoVar :: CoVar -> IfaceCoercion
-- | See Note [Holes in IfaceCoercion]
IfaceHoleCo :: CoVar -> IfaceCoercion
data IfaceMCoercion
IfaceMRefl :: IfaceMCoercion
IfaceMCo :: IfaceCoercion -> IfaceMCoercion
data IfaceUnivCoProv
IfacePhantomProv :: IfaceCoercion -> IfaceUnivCoProv
IfaceProofIrrelProv :: IfaceCoercion -> IfaceUnivCoProv
IfacePluginProv :: String -> IfaceUnivCoProv
IfaceCorePrepProv :: Bool -> IfaceUnivCoProv
type IfaceMult = IfaceType
data IfaceTyCon
IfaceTyCon :: IfExtName -> IfaceTyConInfo -> IfaceTyCon
[ifaceTyConName] :: IfaceTyCon -> IfExtName
[ifaceTyConInfo] :: IfaceTyCon -> IfaceTyConInfo
data IfaceTyConInfo
IfaceTyConInfo :: PromotionFlag -> IfaceTyConSort -> IfaceTyConInfo
[ifaceTyConIsPromoted] :: IfaceTyConInfo -> PromotionFlag
[ifaceTyConSort] :: IfaceTyConInfo -> IfaceTyConSort
mkIfaceTyConInfo :: PromotionFlag -> IfaceTyConSort -> IfaceTyConInfo
-- | The various types of TyCons which have special, built-in syntax.
data IfaceTyConSort
-- | a regular tycon
IfaceNormalTyCon :: IfaceTyConSort
-- | e.g. (a, b, c) or (#a, b, c#). The arity is the
-- tuple width, not the tycon arity (which is twice the width in the case
-- of unboxed tuples).
IfaceTupleTyCon :: !Arity -> !TupleSort -> IfaceTyConSort
-- | e.g. (a | b | c)
IfaceSumTyCon :: !Arity -> IfaceTyConSort
-- | A heterogeneous equality TyCon (i.e. eqPrimTyCon, eqReprPrimTyCon,
-- heqTyCon) that is actually being applied to two types of the same
-- kind. This affects pretty-printing only: see Note [Equality predicates
-- in IfaceType]
IfaceEqualityTyCon :: IfaceTyConSort
data IfaceTyLit
IfaceNumTyLit :: Integer -> IfaceTyLit
IfaceStrTyLit :: FastString -> IfaceTyLit
IfaceCharTyLit :: Char -> IfaceTyLit
-- | Stores the arguments in a type application as a list. See Note
-- [Suppressing invisible arguments].
data IfaceAppArgs
IA_Nil :: IfaceAppArgs
IA_Arg :: IfaceType -> ArgFlag -> IfaceAppArgs -> IfaceAppArgs
type IfaceContext = [IfacePredType]
data IfaceBndr
IfaceIdBndr :: {-# UNPACK #-} !IfaceIdBndr -> IfaceBndr
IfaceTvBndr :: {-# UNPACK #-} !IfaceTvBndr -> IfaceBndr
data IfaceOneShot
IfaceNoOneShot :: IfaceOneShot
IfaceOneShot :: IfaceOneShot
type IfaceLamBndr = (IfaceBndr, IfaceOneShot)
type IfaceTvBndr = (IfLclName, IfaceKind)
type IfaceIdBndr = (IfaceType, IfLclName, IfaceType)
type IfaceTyConBinder = VarBndr IfaceBndr TyConBndrVis
type IfaceForAllSpecBndr = VarBndr IfaceBndr Specificity
type IfaceForAllBndr = VarBndr IfaceBndr ArgFlag
-- | Argument Flag
--
-- Is something required to appear in source Haskell (Required),
-- permitted by request (Specified) (visible type application), or
-- prohibited entirely from appearing in source Haskell
-- (Inferred)? See Note [VarBndrs, TyCoVarBinders, TyConBinders,
-- and visibility] in GHC.Core.TyCo.Rep
data ArgFlag
Invisible :: Specificity -> ArgFlag
Required :: ArgFlag
pattern Specified :: ArgFlag
pattern Inferred :: ArgFlag
-- | The non-dependent version of ArgFlag. See Note [AnonArgFlag]
-- Appears here partly so that it's together with its friends ArgFlag and
-- ForallVisFlag, but also because it is used in IfaceType, rather early
-- in the compilation chain
data AnonArgFlag
-- | Used for (->): an ordinary non-dependent arrow. The
-- argument is visible in source code.
VisArg :: AnonArgFlag
-- | Used for (=>): a non-dependent predicate arrow. The
-- argument is invisible in source code.
InvisArg :: AnonArgFlag
-- | Show forall flag
--
-- Unconditionally show the forall quantifier with
-- (ShowForAllMust) or when (ShowForAllWhen) the names used
-- are free in the binder or when compiling with
-- -fprint-explicit-foralls.
data ShowForAllFlag
ShowForAllMust :: ShowForAllFlag
ShowForAllWhen :: ShowForAllFlag
-- | Make an IfaceForAllBndr from an IfaceTvBndr.
mkIfaceForAllTvBndr :: ArgFlag -> IfaceTvBndr -> IfaceForAllBndr
-- | Build the tyConKind from the binders and the result kind. Keep
-- in sync with mkTyConKind in GHC.Core.TyCon.
mkIfaceTyConKind :: [IfaceTyConBinder] -> IfaceKind -> IfaceKind
ifaceForAllSpecToBndrs :: [IfaceForAllSpecBndr] -> [IfaceForAllBndr]
ifaceForAllSpecToBndr :: IfaceForAllSpecBndr -> IfaceForAllBndr
-- | Extract an IfaceBndr from an IfaceForAllBndr.
ifForAllBndrVar :: IfaceForAllBndr -> IfaceBndr
-- | Extract the variable name from an IfaceForAllBndr.
ifForAllBndrName :: IfaceForAllBndr -> IfLclName
ifaceBndrName :: IfaceBndr -> IfLclName
-- | Extract an IfaceBndr from an IfaceTyConBinder.
ifTyConBinderVar :: IfaceTyConBinder -> IfaceBndr
-- | Extract the variable name from an IfaceTyConBinder.
ifTyConBinderName :: IfaceTyConBinder -> IfLclName
-- | Given a kind K, is K of the form (TYPE ('BoxedRep 'LiftedRep))?
isIfaceLiftedTypeKind :: IfaceKind -> Bool
appArgsIfaceTypes :: IfaceAppArgs -> [IfaceType]
appArgsIfaceTypesArgFlags :: IfaceAppArgs -> [(IfaceType, ArgFlag)]
-- | Do we want to suppress kind annotations on binders? See Note
-- [Suppressing binder signatures]
newtype SuppressBndrSig
SuppressBndrSig :: Bool -> SuppressBndrSig
newtype UseBndrParens
UseBndrParens :: Bool -> UseBndrParens
newtype PrintExplicitKinds
PrintExplicitKinds :: Bool -> PrintExplicitKinds
pprIfaceType :: IfaceType -> SDoc
pprParendIfaceType :: IfaceType -> SDoc
pprPrecIfaceType :: PprPrec -> IfaceType -> SDoc
-- | Prints a context or () if empty You give it the context
-- precedence
pprIfaceContext :: PprPrec -> [IfacePredType] -> SDoc
-- | Prints "(C a, D b) =>", including the arrow. Used when we want to
-- print a context in a type, so we use funPrec to decide whether
-- to parenthesise a singleton predicate; e.g. Num a => a -> a
pprIfaceContextArr :: [IfacePredType] -> SDoc
pprIfaceIdBndr :: IfaceIdBndr -> SDoc
pprIfaceLamBndr :: IfaceLamBndr -> SDoc
pprIfaceTvBndr :: IfaceTvBndr -> SuppressBndrSig -> UseBndrParens -> SDoc
pprIfaceTyConBinders :: SuppressBndrSig -> [IfaceTyConBinder] -> SDoc
pprIfaceBndrs :: [IfaceBndr] -> SDoc
pprIfaceAppArgs :: IfaceAppArgs -> SDoc
pprParendIfaceAppArgs :: IfaceAppArgs -> SDoc
pprIfaceForAllPart :: [IfaceForAllBndr] -> [IfacePredType] -> SDoc -> SDoc
-- | Like pprIfaceForAllPart, but always uses an explicit
-- forall.
pprIfaceForAllPartMust :: [IfaceForAllBndr] -> [IfacePredType] -> SDoc -> SDoc
-- | Render the "forall ... ." or "forall ... ->" bit of a type.
pprIfaceForAll :: [IfaceForAllBndr] -> SDoc
pprIfaceSigmaType :: ShowForAllFlag -> IfaceType -> SDoc
pprIfaceTyLit :: IfaceTyLit -> SDoc
pprIfaceCoercion :: IfaceCoercion -> SDoc
pprParendIfaceCoercion :: IfaceCoercion -> SDoc
splitIfaceSigmaTy :: IfaceType -> ([IfaceForAllBndr], [IfacePredType], IfaceType)
pprIfaceTypeApp :: PprPrec -> IfaceTyCon -> IfaceAppArgs -> SDoc
pprUserIfaceForAll :: [IfaceForAllBndr] -> SDoc
pprIfaceCoTcApp :: PprPrec -> IfaceTyCon -> [IfaceCoercion] -> SDoc
pprTyTcApp :: PprPrec -> IfaceTyCon -> IfaceAppArgs -> SDoc
pprIfacePrefixApp :: PprPrec -> SDoc -> [SDoc] -> SDoc
ppr_fun_arrow :: IfaceMult -> SDoc
isIfaceTauType :: IfaceType -> Bool
suppressIfaceInvisibles :: PrintExplicitKinds -> [IfaceTyConBinder] -> [a] -> [a]
stripIfaceInvisVars :: PrintExplicitKinds -> [IfaceTyConBinder] -> [IfaceTyConBinder]
stripInvisArgs :: PrintExplicitKinds -> IfaceAppArgs -> IfaceAppArgs
mkIfaceTySubst :: [(IfLclName, IfaceType)] -> IfaceTySubst
substIfaceTyVar :: IfaceTySubst -> IfLclName -> IfaceType
substIfaceAppArgs :: IfaceTySubst -> IfaceAppArgs -> IfaceAppArgs
inDomIfaceTySubst :: IfaceTySubst -> IfaceTvBndr -> Bool
many_ty :: IfaceType
instance GHC.Classes.Eq GHC.Iface.Type.IfaceTyLit
instance GHC.Classes.Eq GHC.Iface.Type.IfaceTyConSort
instance GHC.Classes.Eq GHC.Iface.Type.IfaceTyConInfo
instance GHC.Classes.Eq GHC.Iface.Type.IfaceTyCon
instance GHC.Utils.Outputable.Outputable GHC.Iface.Type.IfaceBndr
instance GHC.Base.Semigroup GHC.Iface.Type.IfaceAppArgs
instance GHC.Base.Monoid GHC.Iface.Type.IfaceAppArgs
instance GHC.Utils.Binary.Binary GHC.Iface.Type.IfaceBndr
instance GHC.Utils.Outputable.Outputable GHC.Iface.Type.IfaceType
instance GHC.Utils.Outputable.Outputable GHC.Iface.Type.IfaceAppArgs
instance GHC.Utils.Outputable.Outputable GHC.Iface.Type.IfaceCoercion
instance GHC.Utils.Binary.Binary GHC.Iface.Type.IfaceAppArgs
instance GHC.Utils.Binary.Binary GHC.Iface.Type.IfaceType
instance GHC.Utils.Binary.Binary GHC.Iface.Type.IfaceMCoercion
instance GHC.Utils.Binary.Binary GHC.Iface.Type.IfaceCoercion
instance GHC.Utils.Binary.Binary GHC.Iface.Type.IfaceUnivCoProv
instance GHC.Utils.Binary.Binary (GHC.Types.Basic.DefMethSpec GHC.Iface.Type.IfaceType)
instance Control.DeepSeq.NFData GHC.Iface.Type.IfaceType
instance Control.DeepSeq.NFData GHC.Iface.Type.IfaceCoercion
instance Control.DeepSeq.NFData GHC.Iface.Type.IfaceUnivCoProv
instance Control.DeepSeq.NFData GHC.Iface.Type.IfaceMCoercion
instance Control.DeepSeq.NFData GHC.Iface.Type.IfaceBndr
instance Control.DeepSeq.NFData GHC.Iface.Type.IfaceAppArgs
instance GHC.Utils.Outputable.Outputable GHC.Iface.Type.IfaceTyCon
instance GHC.Utils.Binary.Binary GHC.Iface.Type.IfaceTyCon
instance Control.DeepSeq.NFData GHC.Iface.Type.IfaceTyCon
instance GHC.Utils.Outputable.Outputable GHC.Iface.Type.IfaceTyConInfo
instance GHC.Utils.Binary.Binary GHC.Iface.Type.IfaceTyConInfo
instance Control.DeepSeq.NFData GHC.Iface.Type.IfaceTyConInfo
instance GHC.Utils.Outputable.Outputable GHC.Iface.Type.IfaceTyConSort
instance GHC.Utils.Binary.Binary GHC.Iface.Type.IfaceTyConSort
instance Control.DeepSeq.NFData GHC.Iface.Type.IfaceTyConSort
instance GHC.Utils.Outputable.Outputable GHC.Iface.Type.IfaceTyLit
instance GHC.Utils.Binary.Binary GHC.Iface.Type.IfaceTyLit
instance Control.DeepSeq.NFData GHC.Iface.Type.IfaceTyLit
instance GHC.Utils.Outputable.Outputable GHC.Iface.Type.IfaceOneShot
instance GHC.Utils.Binary.Binary GHC.Iface.Type.IfaceOneShot
instance Control.DeepSeq.NFData GHC.Iface.Type.IfaceOneShot
-- | Types used in the typechecker
--
-- This module provides the Type interface for front-end parts of the
-- compiler. These parts
--
-- -- SynAny `SynFun` (SynList `SynFun` SynType Int) `SynFun` SynAny ---- -- you'll get three types back: one for the first SynAny, the -- element type of the list, and one for the last SynAny. -- You don't get anything for the SynType, because you've said -- positively that it should be an Int, and so it shall be. -- -- You'll also get three multiplicities back: one for each function -- arrow. See also Note [Linear types] in Multiplicity. -- -- This is defined here to avoid defining it in GHC.Tc.Gen.Expr -- boot file. data SyntaxOpType -- | Any type SynAny :: SyntaxOpType -- | A rho type, skolemised or instantiated as appropriate SynRho :: SyntaxOpType -- | A list type. You get back the element type of the list SynList :: SyntaxOpType -- | A function. SynFun :: SyntaxOpType -> SyntaxOpType -> SyntaxOpType -- | A known type. SynType :: ExpType -> SyntaxOpType infixr 0 `SynFun` -- | Like SynType but accepts a regular TcType synKnownType :: TcType -> SyntaxOpType -- | Like mkFunTys but for SyntaxOpType mkSynFunTys :: [SyntaxOpType] -> ExpType -> SyntaxOpType newtype TcLevel TcLevel :: Int -> TcLevel topTcLevel :: TcLevel pushTcLevel :: TcLevel -> TcLevel isTopTcLevel :: TcLevel -> Bool strictlyDeeperThan :: TcLevel -> TcLevel -> Bool deeperThanOrSame :: TcLevel -> TcLevel -> Bool sameDepthAs :: TcLevel -> TcLevel -> Bool tcTypeLevel :: TcType -> TcLevel tcTyVarLevel :: TcTyVar -> TcLevel maxTcLevel :: TcLevel -> TcLevel -> TcLevel promoteSkolem :: TcLevel -> TcTyVar -> TcTyVar -- | Change the TcLevel in a skolem, extending a substitution promoteSkolemX :: TcLevel -> TCvSubst -> TcTyVar -> (TCvSubst, TcTyVar) promoteSkolemsX :: TcLevel -> TCvSubst -> [TcTyVar] -> (TCvSubst, [TcTyVar]) data TcTyVarDetails SkolemTv :: TcLevel -> Bool -> TcTyVarDetails RuntimeUnk :: TcTyVarDetails MetaTv :: MetaInfo -> IORef MetaDetails -> TcLevel -> TcTyVarDetails [mtv_info] :: TcTyVarDetails -> MetaInfo [mtv_ref] :: TcTyVarDetails -> IORef MetaDetails [mtv_tclvl] :: TcTyVarDetails -> TcLevel pprTcTyVarDetails :: TcTyVarDetails -> SDoc vanillaSkolemTv :: TcTyVarDetails superSkolemTv :: TcTyVarDetails data MetaDetails Flexi :: MetaDetails Indirect :: TcType -> MetaDetails data MetaInfo TauTv :: MetaInfo TyVarTv :: MetaInfo RuntimeUnkTv :: MetaInfo CycleBreakerTv :: MetaInfo isImmutableTyVar :: TyVar -> Bool isSkolemTyVar :: TcTyVar -> Bool isMetaTyVar :: TcTyVar -> Bool isMetaTyVarTy :: TcType -> Bool isTyVarTy :: Type -> Bool tcIsTcTyVar :: TcTyVar -> Bool isTyVarTyVar :: Var -> Bool isOverlappableTyVar :: TcTyVar -> Bool isTyConableTyVar :: TcTyVar -> Bool isAmbiguousTyVar :: TcTyVar -> Bool isCycleBreakerTyVar :: TcTyVar -> Bool metaTyVarRef :: TyVar -> IORef MetaDetails metaTyVarInfo :: TcTyVar -> MetaInfo isFlexi :: MetaDetails -> Bool isIndirect :: MetaDetails -> Bool isRuntimeUnkSkol :: TyVar -> Bool metaTyVarTcLevel :: TcTyVar -> TcLevel setMetaTyVarTcLevel :: TcTyVar -> TcLevel -> TcTyVar metaTyVarTcLevel_maybe :: TcTyVar -> Maybe TcLevel isTouchableMetaTyVar :: TcLevel -> TcTyVar -> Bool isPromotableMetaTyVar :: TcTyVar -> Bool findDupTyVarTvs :: [(Name, TcTyVar)] -> [(Name, Name)] mkTyVarNamePairs :: [TyVar] -> [(Name, TyVar)] mkPhiTy :: [PredType] -> Type -> Type -- | Make a sigma ty where all type variables are Inferred. That is, -- they cannot be used with visible type application. mkInfSigmaTy :: [TyCoVar] -> [PredType] -> Type -> Type -- | Make a sigma ty where all type variables are "specified". That is, -- they can be used with visible type application mkSpecSigmaTy :: [TyVar] -> [PredType] -> Type -> Type mkSigmaTy :: [TyCoVarBinder] -> [PredType] -> Type -> Type mkTcAppTy :: Type -> Type -> Type mkTcAppTys :: Type -> [Type] -> Type mkTcCastTy :: Type -> Coercion -> Type -- | Attempts to obtain the type variable underlying a Type, and -- panics with the given message if this is not a type variable type. See -- also getTyVar_maybe getTyVar :: String -> Type -> TyVar tcSplitForAllTyVarBinder_maybe :: Type -> Maybe (TyVarBinder, Type) -- | Like tcSplitPiTys, but splits off only named binders, returning -- just the tyvars. tcSplitForAllTyVars :: Type -> ([TyVar], Type) -- | Like tcSplitForAllTyVars, but only splits ForAllTys with -- Invisible type variable binders. tcSplitForAllInvisTyVars :: Type -> ([TyVar], Type) -- | Like tcSplitForAllTyVars, but only splits a ForAllTy if -- argf_pred argf is True, where argf is the -- visibility of the ForAllTy's binder and argf_pred is -- a predicate over visibilities provided as an argument to this -- function. tcSplitSomeForAllTyVars :: (ArgFlag -> Bool) -> Type -> ([TyVar], Type) -- | Like tcSplitForAllTyVars, but only splits ForAllTys with -- Required type variable binders. All split tyvars are annotated -- with (). tcSplitForAllReqTVBinders :: Type -> ([TcReqTVBinder], Type) -- | Like tcSplitForAllTyVars, but only splits ForAllTys with -- Invisible type variable binders. All split tyvars are annotated -- with their Specificity. tcSplitForAllInvisTVBinders :: Type -> ([TcInvisTVBinder], Type) -- | Splits a forall type into a list of TyBinders and the inner -- type. Always succeeds, even if it returns an empty list. tcSplitPiTys :: Type -> ([TyBinder], Type) -- | Splits a type into a TyBinder and a body, if possible. Panics -- otherwise tcSplitPiTy_maybe :: Type -> Maybe (TyBinder, Type) -- | Like tcSplitForAllTyVars, but splits off only named binders. tcSplitForAllTyVarBinders :: Type -> ([TyVarBinder], Type) tcSplitPhiTy :: Type -> (ThetaType, Type) tcSplitPredFunTy_maybe :: Type -> Maybe (PredType, Type) tcSplitFunTy_maybe :: Type -> Maybe (Scaled Type, Type) tcSplitFunTys :: Type -> ([Scaled Type], Type) tcFunArgTy :: Type -> Scaled Type tcFunResultTy :: Type -> Type -- | Strips off n *visible* arguments and returns the resulting type tcFunResultTyN :: HasDebugCallStack => Arity -> Type -> Type -- | Split off exactly the specified number argument types Returns (Left m) -- if there are m missing arrows in the type (Right (tys,res)) -- if the type looks like t1 -> ... -> tn -> res tcSplitFunTysN :: Arity -> TcRhoType -> Either Arity ([Scaled TcSigmaType], TcSigmaType) tcSplitTyConApp :: Type -> (TyCon, [Type]) -- | Split a type constructor application into its type constructor and -- applied types. Note that this may fail in the case of a FunTy -- with an argument of unknown kind FunTy (e.g. FunTy (a :: k) -- Int. since the kind of a isn't of the form TYPE -- rep). Consequently, you may need to zonk your type before using -- this function. -- -- This does *not* split types headed with (=>), as that's not a TyCon -- in the type-checker. -- -- If you only need the TyCon, consider using -- tcTyConAppTyCon_maybe. tcSplitTyConApp_maybe :: HasCallStack => Type -> Maybe (TyCon, [Type]) tcTyConAppTyCon :: Type -> TyCon -- | Like tcRepSplitTyConApp_maybe, but only returns the -- TyCon. tcTyConAppTyCon_maybe :: Type -> Maybe TyCon tcTyConAppArgs :: Type -> [Type] tcSplitAppTy_maybe :: Type -> Maybe (Type, Type) tcSplitAppTy :: Type -> (Type, Type) tcSplitAppTys :: Type -> (Type, [Type]) -- | Does the AppTy split as in tcSplitAppTy_maybe, but assumes -- that any coreView stuff is already done. Refuses to look through (c -- => t) tcRepSplitAppTy_maybe :: Type -> Maybe (Type, Type) -- | Returns the number of arguments in the given type, without looking -- through synonyms. This is used only for error reporting. We don't look -- through synonyms because of #11313. tcRepGetNumAppTys :: Type -> Arity -- | If the type is a tyvar, possibly under a cast, returns it, along with -- the coercion. Thus, the co is :: kind tv ~N kind type tcGetCastedTyVar_maybe :: Type -> Maybe (TyVar, CoercionN) tcGetTyVar_maybe :: Type -> Maybe TyVar tcGetTyVar :: String -> Type -> TyVar -- | Split a sigma type into its parts. This only splits invisible -- type variable binders, as these are the only forms of binder that the -- typechecker will implicitly instantiate. tcSplitSigmaTy :: Type -> ([TyVar], ThetaType, Type) -- | Split a sigma type into its parts, going underneath as many -- ForAllTys as possible. For example, given this type synonym: -- --
-- type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t ---- -- if you called tcSplitSigmaTy on this type: -- --
-- forall s t a b. Each s t a b => Traversal s t a b ---- -- then it would return ([s,t,a,b], [Each s t a b], Traversal s t a -- b). But if you instead called tcSplitNestedSigmaTys on -- the type, it would return ([s,t,a,b,f], [Each s t a b, Applicative -- f], (a -> f b) -> s -> f t). tcSplitNestedSigmaTys :: Type -> ([TyVar], ThetaType, Type) -- | Type equality on source types. Does not look through newtypes -- or PredTypes, but it does look through type synonyms. This -- first checks that the kinds of the types are equal and then checks -- whether the types are equal, ignoring casts and coercions. (The kind -- check is a recursive call, but since all kinds have type -- Type, there is no need to check the types of kinds.) See also -- Note [Non-trivial definitional equality] in GHC.Core.TyCo.Rep. eqType :: Type -> Type -> Bool -- | Type equality on lists of types, looking through type synonyms but not -- newtypes. eqTypes :: [Type] -> [Type] -> Bool nonDetCmpType :: Type -> Type -> Ordering nonDetCmpTypes :: [Type] -> [Type] -> Ordering -- | Compare types with respect to a (presumably) non-empty RnEnv2. eqTypeX :: RnEnv2 -> Type -> Type -> Bool -- | Like pickyEqTypeVis, but returns a Bool for convenience pickyEqType :: TcType -> TcType -> Bool -- | tcEqType implements typechecker equality, as described in Note -- [Typechecker equality vs definitional equality]. tcEqType :: HasDebugCallStack => TcType -> TcType -> Bool tcEqKind :: HasDebugCallStack => TcKind -> TcKind -> Bool -- | Just like tcEqType, but will return True for types of different -- kinds as long as their non-coercion structure is identical. tcEqTypeNoKindCheck :: TcType -> TcType -> Bool -- | Like tcEqType, but returns True if the visible part of -- the types are equal, even if they are really unequal (in the invisible -- bits) tcEqTypeVis :: TcType -> TcType -> Bool -- | Check whether two TyConApps are the same; if the number of arguments -- are different, just checks the common prefix of arguments. tcEqTyConApps :: TyCon -> [Type] -> TyCon -> [Type] -> Bool isSigmaTy :: TcType -> Bool isRhoTy :: TcType -> Bool -- | Like isRhoTy, but also says True for Infer types isRhoExpTy :: ExpType -> Bool isOverloadedTy :: Type -> Bool -- | Does a type represent a floating-point number? isFloatingTy :: Type -> Bool isDoubleTy :: Type -> Bool isFloatTy :: Type -> Bool isIntTy :: Type -> Bool isWordTy :: Type -> Bool -- | Is a type String? isStringTy :: Type -> Bool isIntegerTy :: Type -> Bool isNaturalTy :: Type -> Bool isBoolTy :: Type -> Bool isUnitTy :: Type -> Bool isCharTy :: Type -> Bool -- | Is a type a CallStack? isCallStackTy :: Type -> Bool -- | Is a PredType a CallStack implicit parameter? -- -- If so, return the name of the parameter. isCallStackPred :: Class -> [Type] -> Maybe FastString isTauTy :: Type -> Bool isTauTyCon :: TyCon -> Bool tcIsTyVarTy :: Type -> Bool -- | Is this a ForAllTy with a named binder? tcIsForAllTy :: Type -> Bool isPredTy :: HasDebugCallStack => Type -> Bool isTyVarClassPred :: PredType -> Bool checkValidClsArgs :: Bool -> Class -> [KindOrType] -> Bool hasTyVarHead :: Type -> Bool isRigidTy :: TcType -> Bool deNoteType :: Type -> Type orphNamesOfType :: Type -> NameSet orphNamesOfCo :: Coercion -> NameSet orphNamesOfTypes :: [Type] -> NameSet orphNamesOfCoCon :: CoAxiom br -> NameSet getDFunTyKey :: Type -> OccName evVarPred :: EvVar -> PredType mkMinimalBySCs :: forall a. (a -> PredType) -> [a] -> [a] transSuperClasses :: PredType -> [PredType] -- | When inferring types, should we quantify over a given predicate? -- Generally true of classes; generally false of equality constraints. -- Equality constraints that mention quantified type variables and -- implicit variables complicate the story. See Notes [Inheriting -- implicit parameters] and [Quantifying over equality constraints] pickQuantifiablePreds :: TyVarSet -> TcThetaType -> TcThetaType pickCapturedPreds :: TyVarSet -> TcThetaType -> TcThetaType immSuperClasses :: Class -> [Type] -> [PredType] boxEqPred :: EqRel -> Type -> Type -> Maybe (Class, [Type]) isImprovementPred :: PredType -> Bool -- | Finds outermost type-family applications occurring in a type, after -- expanding synonyms. In the list (F, tys) that is returned we guarantee -- that tys matches F's arity. For example, given type family F a :: * -- -> * (arity 1) calling tcTyFamInsts on (Maybe (F Int Bool) will -- return (F, [Int]), not (F, [Int,Bool]) -- -- This is important for its use in deciding termination of type -- instances (see #11581). E.g. type instance G [Int] = ...(F Int <big -- type>)... we don't need to take <big type> into account when -- asking if the calls on the RHS are smaller than the LHS tcTyFamInsts :: Type -> [(TyCon, [Type])] -- | Like tcTyFamInsts, except that the output records whether the -- type family and its arguments occur as an invisible argument in -- some type application. This information is useful because it helps GHC -- know when to turn on -fprint-explicit-kinds during error -- reporting so that users can actually see the type family being -- mentioned. -- -- As an example, consider: -- --
-- class C a -- data T (a :: k) -- type family F a :: k -- instance C (T @(F Int) (F Bool)) ---- -- There are two occurrences of the type family F in that -- C instance, so tcTyFamInstsAndVis (C (T @(F Int) -- (F Bool))) will return: -- --
-- [ (True, F, [Int]) -- , (False, F, [Bool]) ] ---- -- F Int is paired with True since it appears as an -- invisible argument to C, whereas F Bool is -- paired with False since it appears an a visible argument -- to C. -- -- See also Note [Kind arguments in error messages] in -- GHC.Tc.Errors. tcTyFamInstsAndVis :: Type -> [(Bool, TyCon, [Type])] -- | In an application of a TyCon to some arguments, find the -- outermost occurrences of type family applications within the -- arguments. This function will not consider the TyCon itself -- when checking for type family applications. -- -- See tcTyFamInstsAndVis for more details on how this works (as -- this function is called inside of tcTyFamInstsAndVis). tcTyConAppTyFamInstsAndVis :: TyCon -> [Type] -> [(Bool, TyCon, [Type])] -- | Check that a type does not contain any type family applications. isTyFamFree :: Type -> Bool exactTyCoVarsOfType :: Type -> TyCoVarSet exactTyCoVarsOfTypes :: [Type] -> TyCoVarSet anyRewritableTyVar :: Bool -> EqRel -> (EqRel -> TcTyVar -> Bool) -> TcType -> Bool anyRewritableTyFamApp :: EqRel -> (EqRel -> TyCon -> [TcType] -> Bool) -> TcType -> Bool anyRewritableCanEqLHS :: EqRel -> (EqRel -> TcTyVar -> Bool) -> (EqRel -> TyCon -> [TcType] -> Bool) -> TcType -> Bool isFFIArgumentTy :: DynFlags -> Safety -> Type -> Validity isFFIImportResultTy :: DynFlags -> Type -> Validity isFFIExportResultTy :: Type -> Validity isFFIExternalTy :: Type -> Validity isFFIDynTy :: Type -> Type -> Validity isFFIPrimArgumentTy :: DynFlags -> Type -> Validity isFFIPrimResultTy :: DynFlags -> Type -> Validity isFFILabelTy :: Type -> Validity isFFITy :: Type -> Bool isFunPtrTy :: Type -> Bool tcSplitIOType_maybe :: Type -> Maybe (TyCon, Type) -- | The key type representing kinds in the compiler. type Kind = Type tcTypeKind :: HasDebugCallStack => Type -> Kind liftedTypeKind :: Kind constraintKind :: Kind -- | This version considers Constraint to be the same as *. Returns True if -- the argument is equivalent to Type/Constraint and False otherwise. See -- Note [Kind Constraint and kind Type] isLiftedTypeKind :: Kind -> Bool -- | Returns True if the kind classifies unlifted types (like 'Int#') and -- False otherwise. Note that this returns False for levity-polymorphic -- kinds, which may be specialized to a kind that classifies unlifted -- types. isUnliftedTypeKind :: Kind -> Bool -- | Does this classify a type allowed to have values? Responds True to -- things like *, #, TYPE Lifted, TYPE v, Constraint. -- -- True of any sub-kind of OpenTypeKind classifiesTypeWithValues :: Kind -> Bool data Type -- | A type of the form p of constraint kind represents a value -- whose type is the Haskell predicate p, where a predicate is -- what occurs before the => in a Haskell type. -- -- We use PredType as documentation to mark those types that we -- guarantee to have this kind. -- -- It can be expanded into its representation, but: -- --
-- f :: (Eq a) => a -> Int
-- g :: (?x :: Int -> Int) => a -> Int
-- h :: (r\l) => {r} => {l::Int | r}
--
--
-- Here the Eq a and ?x :: Int -> Int and
-- rl are all called "predicates"
type PredType = Type
-- | A collection of PredTypes
type ThetaType = [PredType]
-- | A TyCoBinder represents an argument to a function. TyCoBinders
-- can be dependent (Named) or nondependent (Anon). They
-- may also be visible or not. See Note [TyCoBinders]
data TyCoBinder
-- | Argument Flag
--
-- Is something required to appear in source Haskell (Required),
-- permitted by request (Specified) (visible type application), or
-- prohibited entirely from appearing in source Haskell
-- (Inferred)? See Note [VarBndrs, TyCoVarBinders, TyConBinders,
-- and visibility] in GHC.Core.TyCo.Rep
data ArgFlag
Invisible :: Specificity -> ArgFlag
Required :: ArgFlag
pattern Specified :: ArgFlag
pattern Inferred :: ArgFlag
-- | The non-dependent version of ArgFlag. See Note [AnonArgFlag]
-- Appears here partly so that it's together with its friends ArgFlag and
-- ForallVisFlag, but also because it is used in IfaceType, rather early
-- in the compilation chain
data AnonArgFlag
-- | Used for (->): an ordinary non-dependent arrow. The
-- argument is visible in source code.
VisArg :: AnonArgFlag
-- | Used for (=>): a non-dependent predicate arrow. The
-- argument is invisible in source code.
InvisArg :: AnonArgFlag
-- | Like mkTyCoForAllTy, but does not check the occurrence of the
-- binder See Note [Unused coercion variable in ForAllTy]
mkForAllTy :: TyCoVar -> ArgFlag -> Type -> Type
-- | Wraps foralls over the type using the provided TyCoVars from
-- left to right
mkForAllTys :: [TyCoVarBinder] -> Type -> Type
-- | Wraps foralls over the type using the provided InvisTVBinders
-- from left to right
mkInvisForAllTys :: [InvisTVBinder] -> Type -> Type
-- | Like mkForAllTys, but assumes all variables are dependent and
-- Inferred, a common case
mkTyCoInvForAllTys :: [TyCoVar] -> Type -> Type
-- | Like mkForAllTys, but assumes all variables are dependent and
-- Specified, a common case
mkSpecForAllTys :: [TyVar] -> Type -> Type
-- | Make a dependent forall over an Inferred variable
mkTyCoInvForAllTy :: TyCoVar -> Type -> Type
-- | Like mkTyCoInvForAllTy, but tv should be a tyvar
mkInfForAllTy :: TyVar -> Type -> Type
-- | Like mkTyCoInvForAllTys, but tvs should be a list of tyvar
mkInfForAllTys :: [TyVar] -> Type -> Type
mkVisFunTy :: Mult -> Type -> Type -> Type
infixr 3 `mkVisFunTy`
-- | Make nested arrow types
mkVisFunTys :: [Scaled Type] -> Type -> Type
mkInvisFunTy :: Mult -> Type -> Type -> Type
infixr 3 `mkInvisFunTy`
mkInvisFunTyMany :: Type -> Type -> Type
infixr 3 `mkInvisFunTyMany`
-- | Special, common, case: Arrow type with mult Many
mkVisFunTyMany :: Type -> Type -> Type
infixr 3 `mkVisFunTyMany`
mkVisFunTysMany :: [Type] -> Type -> Type
mkInvisFunTysMany :: [Type] -> Type -> Type
-- | A key function: builds a TyConApp or FunTy as
-- appropriate to its arguments. Applies its arguments to the constructor
-- from left to right.
mkTyConApp :: TyCon -> [Type] -> Type
-- | Applies a type to another, as in e.g. k a
mkAppTy :: Type -> Type -> Type
mkAppTys :: Type -> [Type] -> Type
-- | Create the plain type constructor type which has been applied to no
-- type arguments at all.
mkTyConTy :: TyCon -> Type
mkTyVarTy :: TyVar -> Type
mkTyVarTys :: [TyVar] -> [Type]
mkTyCoVarTy :: TyCoVar -> Type
mkTyCoVarTys :: [TyCoVar] -> [Type]
isClassPred :: PredType -> Bool
isEqPrimPred :: PredType -> Bool
isIPLikePred :: Type -> Bool
isEqPred :: PredType -> Bool
isEqPredClass :: Class -> Bool
mkClassPred :: Class -> [Type] -> PredType
tcSplitDFunTy :: Type -> ([TyVar], [Type], Class, [Type])
tcSplitDFunHead :: Type -> (Class, [Type])
tcSplitMethodTy :: Type -> ([TyVar], PredType, Type)
-- | Is a tyvar of type RuntimeRep?
isRuntimeRepVar :: TyVar -> Bool
-- | Tests whether the given kind (which should look like TYPE x)
-- is something other than a constructor tree (that is, constructors at
-- every node). E.g. True of TYPE k, TYPE (F Int) False of TYPE
-- 'LiftedRep
isKindLevPoly :: Kind -> Bool
-- | Does this binder bind a visible argument?
isVisibleBinder :: TyCoBinder -> Bool
-- | Does this binder bind an invisible argument?
isInvisibleBinder :: TyCoBinder -> Bool
-- | Type & coercion substitution
--
-- The following invariants must hold of a TCvSubst:
--
-- -- data T [a] = ... ---- -- In that case we want to print T [a], where T is the -- family TyCon pprSourceTyCon :: TyCon -> SDoc pprCo :: Coercion -> SDoc pprParendCo :: Coercion -> SDoc -- | debugPprType is a simple pretty printer that prints a type without -- going through IfaceType. It does not format as prettily as the normal -- route, but it's much more direct, and that can be useful for -- debugging. E.g. with -dppr-debug it prints the kind on type-variable -- occurrences which the normal route fundamentally cannot do. debugPprType :: Type -> SDoc -- | Functions for converting Core things to interface file things. module GHC.CoreToIface toIfaceTvBndr :: TyVar -> IfaceTvBndr toIfaceTvBndrs :: [TyVar] -> [IfaceTvBndr] toIfaceIdBndr :: Id -> IfaceIdBndr toIfaceBndr :: Var -> IfaceBndr toIfaceForAllBndr :: VarBndr TyCoVar flag -> VarBndr IfaceBndr flag toIfaceTyCoVarBinders :: [VarBndr Var vis] -> [VarBndr IfaceBndr vis] toIfaceTyVar :: TyVar -> FastString toIfaceType :: Type -> IfaceType toIfaceTypeX :: VarSet -> Type -> IfaceType toIfaceKind :: Type -> IfaceType toIfaceTcArgs :: TyCon -> [Type] -> IfaceAppArgs toIfaceTyCon :: TyCon -> IfaceTyCon toIfaceTyCon_name :: Name -> IfaceTyCon toIfaceTyLit :: TyLit -> IfaceTyLit tidyToIfaceType :: TidyEnv -> Type -> IfaceType tidyToIfaceContext :: TidyEnv -> ThetaType -> IfaceContext tidyToIfaceTcArgs :: TidyEnv -> TyCon -> [Type] -> IfaceAppArgs toIfaceCoercion :: Coercion -> IfaceCoercion toIfaceCoercionX :: VarSet -> Coercion -> IfaceCoercion patSynToIfaceDecl :: PatSyn -> IfaceDecl toIfaceExpr :: CoreExpr -> IfaceExpr toIfaceBang :: TidyEnv -> HsImplBang -> IfaceBang toIfaceSrcBang :: HsSrcBang -> IfaceSrcBang toIfaceLetBndr :: Id -> IfaceLetBndr toIfaceIdDetails :: IdDetails -> IfaceIdDetails toIfaceIdInfo :: IdInfo -> IfaceIdInfo toIfUnfolding :: Bool -> Unfolding -> Maybe IfaceInfoItem toIfaceTickish :: CoreTickish -> Maybe IfaceTickish toIfaceBind :: Bind Id -> IfaceBinding toIfaceAlt :: CoreAlt -> IfaceAlt toIfaceCon :: AltCon -> IfaceConAlt toIfaceApp :: Expr CoreBndr -> [Arg CoreBndr] -> IfaceExpr toIfaceVar :: Id -> IfaceExpr toIfaceLFInfo :: Name -> LambdaFormInfo -> IfaceLFInfo module GHC.Types.Id.Make mkDictFunId :: Name -> [TyVar] -> ThetaType -> Class -> [Type] -> Id mkDictFunTy :: [TyVar] -> ThetaType -> Class -> [Type] -> Type mkDictSelId :: Name -> Class -> Id mkDictSelRhs :: Class -> Int -> CoreExpr mkPrimOpId :: PrimOp -> Id mkFCallId :: DynFlags -> Unique -> ForeignCall -> Type -> Id unwrapNewTypeBody :: TyCon -> [Type] -> CoreExpr -> CoreExpr wrapFamInstBody :: TyCon -> [Type] -> CoreExpr -> CoreExpr -- | Data Constructor Boxer newtype DataConBoxer DCB :: ([Type] -> [Var] -> UniqSM ([Var], [CoreBind])) -> DataConBoxer vanillaDataConBoxer :: DataConBoxer mkDataConRep :: DynFlags -> FamInstEnvs -> Name -> Maybe [HsImplBang] -> DataCon -> UniqSM DataConRep mkDataConWorkId :: Name -> DataCon -> Id wiredInIds :: [Id] ghcPrimIds :: [Id] realWorldPrimId :: Id voidPrimId :: Id voidArgId :: Id nullAddrId :: Id seqId :: Id lazyId :: Id lazyIdKey :: Unique coercionTokenId :: Id magicDictId :: Id coerceId :: Id proxyHashId :: Id noinlineId :: Id noinlineIdName :: Name coerceName :: Name leftSectionName :: Name rightSectionName :: Name -- | Types for the Constructed Product Result lattice. -- GHC.Core.Opt.CprAnal and GHC.Core.Opt.WorkWrap.Utils are -- its primary customers via idCprInfo. module GHC.Types.Cpr data Cpr pattern ConCpr :: ConTag -> [Cpr] -> Cpr topCpr :: Cpr botCpr :: Cpr flatConCpr :: ConTag -> Cpr asConCpr :: Cpr -> Maybe (ConTag, [Cpr]) -- | The abstract domain <math> from the original 'CPR for Haskell' -- paper. data CprType CprType :: !Arity -> !Cpr -> CprType -- | Number of value arguments the denoted expression eats before returning -- the ct_cpr [ct_arty] :: CprType -> !Arity -- | Cpr eventually unleashed when applied to ct_arty -- arguments [ct_cpr] :: CprType -> !Cpr topCprType :: CprType botCprType :: CprType flatConCprType :: ConTag -> CprType lubCprType :: CprType -> CprType -> CprType applyCprTy :: CprType -> Arity -> CprType abstractCprTy :: CprType -> CprType trimCprTy :: CprType -> CprType -- | The result of unpackConFieldsCpr. data UnpackConFieldsResult AllFieldsSame :: !Cpr -> UnpackConFieldsResult ForeachField :: ![Cpr] -> UnpackConFieldsResult -- | Unpacks a ConCpr-shaped Cpr and returns the field -- Cprs wrapped in a ForeachField. Otherwise, it returns -- AllFieldsSame with the appropriate Cpr to assume for -- each field. -- -- The use of UnpackConFieldsResult allows O(1) space for the -- common, non-ConCpr case. unpackConFieldsCpr :: DataCon -> Cpr -> UnpackConFieldsResult -- | The arity of the wrapped CprType is the arity at which it is -- safe to unleash. See Note [Understanding DmdType and StrictSig] in -- GHC.Types.Demand newtype CprSig CprSig :: CprType -> CprSig [getCprSig] :: CprSig -> CprType topCprSig :: CprSig isTopCprSig :: CprSig -> Bool -- | Turns a CprType computed for the particular Arity into a -- CprSig unleashable at that arity. See Note [Understanding -- DmdType and StrictSig] in GHC.Types.Demand mkCprSigForArity :: Arity -> CprType -> CprSig mkCprSig :: Arity -> Cpr -> CprSig seqCprSig :: CprSig -> () instance GHC.Classes.Eq GHC.Types.Cpr.Cpr instance GHC.Utils.Binary.Binary GHC.Types.Cpr.CprSig instance GHC.Classes.Eq GHC.Types.Cpr.CprSig instance GHC.Utils.Outputable.Outputable GHC.Types.Cpr.CprSig instance GHC.Classes.Eq GHC.Types.Cpr.CprType instance GHC.Utils.Outputable.Outputable GHC.Types.Cpr.CprType instance GHC.Utils.Binary.Binary GHC.Types.Cpr.CprType instance GHC.Utils.Outputable.Outputable GHC.Types.Cpr.Cpr instance GHC.Utils.Binary.Binary GHC.Types.Cpr.Cpr module GHC.Core.DataCon -- | A data constructor -- --
-- T :: forall a b. a -> b -> T [a] ---- -- rather than: -- --
-- T :: forall a c. forall b. (c~[a]) => a -> b -> T c ---- -- The type variables are quantified in the order that the user wrote -- them. See Note [DataCon user type variable binders]. -- -- NB: If the constructor is part of a data instance, the result type -- mentions the family tycon, not the internal one. dataConWrapperType :: DataCon -> Type dataConNonlinearType :: DataCon -> Type dataConDisplayType :: Bool -> DataCon -> Type -- | The universally-quantified type variables of the constructor dataConUnivTyVars :: DataCon -> [TyVar] -- | The existentially-quantified type/coercion variables of the -- constructor including dependent (kind-) GADT equalities dataConExTyCoVars :: DataCon -> [TyCoVar] -- | Both the universal and existential type/coercion variables of the -- constructor dataConUnivAndExTyCoVars :: DataCon -> [TyCoVar] -- | The type variables of the constructor, in the order the user wrote -- them dataConUserTyVars :: DataCon -> [TyVar] -- | InvisTVBinders for the type variables of the constructor, in -- the order the user wrote them dataConUserTyVarBinders :: DataCon -> [InvisTVBinder] -- | Equalities derived from the result type of the data constructor, as -- written by the programmer in any GADT declaration. This includes *all* -- GADT-like equalities, including those written in by hand by the -- programmer. dataConEqSpec :: DataCon -> [EqSpec] -- | The *full* constraints on the constructor type, including dependent -- GADT equalities. dataConTheta :: DataCon -> ThetaType -- | The "stupid theta" of the DataCon, such as data Eq a -- in: -- --
-- data Eq a => T a = ... --dataConStupidTheta :: DataCon -> ThetaType -- | Returns constraints in the wrapper type, other than those in the -- dataConEqSpec dataConOtherTheta :: DataCon -> ThetaType -- | Finds the instantiated types of the arguments required to construct a -- DataCon representation NB: these INCLUDE any dictionary args -- but EXCLUDE the data-declaration context, which is discarded It's all -- post-flattening etc; this is a representation type dataConInstArgTys :: DataCon -> [Type] -> [Scaled Type] -- | Returns the argument types of the wrapper, excluding all dictionary -- arguments and without substituting for any type variables dataConOrigArgTys :: DataCon -> [Scaled Type] dataConOrigResTy :: DataCon -> Type -- | Returns just the instantiated value argument types of a -- DataCon, (excluding dictionary args) dataConInstOrigArgTys :: DataCon -> [Type] -> [Scaled Type] -- | Returns the arg types of the worker, including *all* non-dependent -- evidence, after any flattening has been done and without substituting -- for any type variables dataConRepArgTys :: DataCon -> [Scaled Type] -- | The labels for the fields of this particular DataCon dataConFieldLabels :: DataCon -> [FieldLabel] -- | Extract the type for any given labelled field of the DataCon dataConFieldType :: DataCon -> FieldLabelString -> Type -- | Extract the label and type for any given labelled field of the -- DataCon, or return Nothing if the field does not belong -- to it dataConFieldType_maybe :: DataCon -> FieldLabelString -> Maybe (FieldLabel, Type) -- | Strictness/unpack annotations, from user; or, for imported DataCons, -- from the interface file The list is in one-to-one correspondence with -- the arity of the DataCon dataConSrcBangs :: DataCon -> [HsSrcBang] -- | Source-level arity of the data constructor dataConSourceArity :: DataCon -> Arity -- | Gives the number of actual fields in the representation of the -- data constructor. This may be more than appear in the source code; the -- extra ones are the existentially quantified dictionaries dataConRepArity :: DataCon -> Arity -- | Should the DataCon be presented infix? dataConIsInfix :: DataCon -> Bool -- | Get the Id of the DataCon worker: a function that is the -- "actual" constructor and has no top level binding in the program. The -- type may be different from the obvious one written in the source -- program. Panics if there is no such Id for this DataCon dataConWorkId :: DataCon -> Id -- | Returns an Id which looks like the Haskell-source constructor by using -- the wrapper if it exists (see dataConWrapId_maybe) and failing -- over to the worker (see dataConWorkId) dataConWrapId :: DataCon -> Id -- | Get the Id of the DataCon wrapper: a function that wraps the -- "actual" constructor so it has the type visible in the source program: -- c.f. dataConWorkId. Returns Nothing if there is no wrapper, -- which occurs for an algebraic data constructor and also for a newtype -- (whose constructor is inlined compulsorily) dataConWrapId_maybe :: DataCon -> Maybe Id -- | Find all the Ids implicitly brought into scope by the data -- constructor. Currently, the union of the dataConWorkId and the -- dataConWrapId dataConImplicitTyThings :: DataCon -> [TyThing] -- | Give the demands on the arguments of a Core constructor application -- (Con dc args) dataConRepStrictness :: DataCon -> [StrictnessMark] dataConImplBangs :: DataCon -> [HsImplBang] dataConBoxer :: DataCon -> Maybe DataConBoxer -- | Extract the type constructor, type argument, data constructor and it's -- representation argument types from a type if it is a product -- type. -- -- Precisely, we return Just for any data type that is all of: -- --
-- S = [a :-> t1, b :-> t2] such that -- S( Maybe (a, b->Int ) = Maybe (Bool, Char -> Int) --matchBindFun :: TyCoVarSet -> BindFun -- | Allow the binding of any variable to any type alwaysBindFun :: BindFun type UnifyResult = UnifyResultM TCvSubst -- | See Note [Unificiation result] data UnifyResultM a Unifiable :: a -> UnifyResultM a MaybeApart :: MaybeApartReason -> a -> UnifyResultM a SurelyApart :: UnifyResultM a -- | Why are two types MaybeApart? MARTypeFamily takes -- precedence: This is used (only) in Note [Infinitary substitution in -- lookup] in GHC.Core.InstEnv data MaybeApartReason -- | matching e.g. F Int ~? Bool MARTypeFamily :: MaybeApartReason -- | matching e.g. a ~? Maybe a MARInfinite :: MaybeApartReason -- | liftCoMatch is sort of inverse to liftCoSubst. In -- particular, if liftCoMatch vars ty co == Just s, then -- liftCoSubst s ty == co, where == there means that -- the result of liftCoSubst has the same type as the original co; -- but may be different under the hood. That is, it matches a type -- against a coercion of the same "shape", and returns a lifting -- substitution which could have been used to produce the given coercion -- from the given type. Note that this function is incomplete -- it might -- return Nothing when there does indeed exist a possible lifting -- context. -- -- This function is incomplete in that it doesn't respect the equality in -- eqType. That is, it's possible that this will succeed for t1 -- and fail for t2, even when t1 eqType t2. That's because it -- depends on there being a very similar structure between the type and -- the coercion. This incompleteness shouldn't be all that surprising, -- especially because it depends on the structure of the coercion, which -- is a silly thing to do. -- -- The lifting context produced doesn't have to be exacting in the roles -- of the mappings. This is because any use of the lifting context will -- also require a desired role. Thus, this algorithm prefers mapping to -- nominal coercions where it can do so. liftCoMatch :: TyCoVarSet -> Type -> Coercion -> Maybe LiftingContext flattenTys :: InScopeSet -> [Type] -> [Type] flattenTysX :: InScopeSet -> [Type] -> ([Type], TyVarEnv (TyCon, [Type])) instance Data.Data.Data GHC.Core.Unify.RoughMatchTc instance GHC.Base.Functor GHC.Core.Unify.UnifyResultM instance GHC.Classes.Eq GHC.Core.Unify.BindFlag instance GHC.Base.Functor GHC.Core.Unify.UM instance GHC.Base.Applicative GHC.Core.Unify.UM instance GHC.Base.Monad GHC.Core.Unify.UM instance Control.Monad.Fail.MonadFail GHC.Core.Unify.UM instance GHC.Base.Applicative GHC.Core.Unify.UnifyResultM instance GHC.Base.Monad GHC.Core.Unify.UnifyResultM instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Core.Unify.UnifyResultM a) instance GHC.Utils.Outputable.Outputable GHC.Core.Unify.MaybeApartReason instance GHC.Base.Semigroup GHC.Core.Unify.MaybeApartReason module GHC.Core.TyCo.FVs shallowTyCoVarsOfType :: Type -> TyCoVarSet shallowTyCoVarsOfTypes :: [Type] -> TyCoVarSet tyCoVarsOfType :: Type -> TyCoVarSet tyCoVarsOfTypes :: [Type] -> TyCoVarSet -- | tyCoFVsOfType that returns free variables of a type in a -- deterministic set. For explanation of why using VarSet is not -- deterministic see Note [Deterministic FV] in GHC.Utils.FV. tyCoVarsOfTypeDSet :: Type -> DTyCoVarSet -- | Returns free variables of types, including kind variables as a -- deterministic set. For type synonyms it does not expand the -- synonym. tyCoVarsOfTypesDSet :: [Type] -> DTyCoVarSet tyCoFVsBndr :: TyCoVarBinder -> FV -> FV tyCoFVsVarBndr :: Var -> FV -> FV tyCoFVsVarBndrs :: [Var] -> FV -> FV -- | The worker for tyCoFVsOfType and tyCoFVsOfTypeList. -- The previous implementation used unionVarSet which is O(n+m) -- and can make the function quadratic. It's exported, so that it can be -- composed with other functions that compute free variables. See Note -- [FV naming conventions] in GHC.Utils.FV. -- -- Eta-expanded because that makes it run faster (apparently) See Note -- [FV eta expansion] in GHC.Utils.FV for explanation. tyCoFVsOfType :: Type -> FV -- | tyCoFVsOfType that returns free variables of a type in -- deterministic order. For explanation of why using VarSet is not -- deterministic see Note [Deterministic FV] in GHC.Utils.FV. tyCoVarsOfTypeList :: Type -> [TyCoVar] tyCoFVsOfTypes :: [Type] -> FV -- | Returns free variables of types, including kind variables as a -- deterministically ordered list. For type synonyms it does not -- expand the synonym. tyCoVarsOfTypesList :: [Type] -> [TyCoVar] deepTcvFolder :: TyCoFolder TyCoVarSet (Endo TyCoVarSet) -- | Returns free variables of types, including kind variables as a -- non-deterministic set. For type synonyms it does not expand the -- synonym. shallowTyCoVarsOfTyVarEnv :: TyVarEnv Type -> TyCoVarSet shallowTyCoVarsOfCoVarEnv :: CoVarEnv Coercion -> TyCoVarSet shallowTyCoVarsOfCo :: Coercion -> TyCoVarSet shallowTyCoVarsOfCos :: [Coercion] -> TyCoVarSet tyCoVarsOfCo :: Coercion -> TyCoVarSet tyCoVarsOfCos :: [Coercion] -> TyCoVarSet tyCoVarsOfMCo :: MCoercion -> TyCoVarSet coVarsOfType :: Type -> CoVarSet coVarsOfTypes :: [Type] -> CoVarSet coVarsOfCo :: Coercion -> CoVarSet coVarsOfCos :: [Coercion] -> CoVarSet -- | Get a deterministic set of the vars free in a coercion tyCoVarsOfCoDSet :: Coercion -> DTyCoVarSet tyCoFVsOfCo :: Coercion -> FV tyCoFVsOfCos :: [Coercion] -> FV tyCoVarsOfCoList :: Coercion -> [TyCoVar] -- | Given a covar and a coercion, returns True if covar is almost devoid -- in the coercion. That is, covar can only appear in Refl and GRefl. See -- last wrinkle in Note [Unused coercion variable in ForAllCo] in -- GHC.Core.Coercion almostDevoidCoVarOfCo :: CoVar -> Coercion -> Bool -- | Returns the free variables of a Type that are in injective -- positions. Specifically, it finds the free variables while: -- --
-- injectiveTyVarsOf( Either c (Maybe (a, F b c)) ) = {a,c}
--
--
-- If injectiveVarsOfType ty = itvs, then knowing
-- ty fixes itvs. More formally, if a is in
-- injectiveVarsOfType ty and S1(ty) ~ S2(ty),
-- then S1(a) ~ S2(a), where S1 and S2 are
-- arbitrary substitutions.
--
-- See Note [When does a tycon application need an explicit kind
-- signature?].
injectiveVarsOfType :: Bool -> Type -> FV
-- | Returns the free variables of a Type that are in injective
-- positions. Specifically, it finds the free variables while:
--
--
-- >>> let computation = Endo ("Hello, " ++) <> Endo (++ "!")
--
-- >>> appEndo computation "Haskell"
-- "Hello, Haskell!"
--
newtype Endo a
Endo :: (a -> a) -> Endo a
[appEndo] :: Endo a -> a -> a
runTyCoVars :: Endo TyCoVarSet -> TyCoVarSet
module GHC.Core.Map.Type
class TrieMap m where {
type Key m :: Type;
}
emptyTM :: TrieMap m => m a
lookupTM :: forall b. TrieMap m => Key m -> m b -> Maybe b
alterTM :: forall b. TrieMap m => Key m -> XT b -> m b -> m b
mapTM :: TrieMap m => (a -> b) -> m a -> m b
filterTM :: TrieMap m => (a -> Bool) -> m a -> m a
foldTM :: TrieMap m => (a -> b -> b) -> m a -> b -> b
type XT a = Maybe a -> Maybe a
-- | TypeMap a is a map from Type to a. If you are
-- a client, this is the type you want. The keys in this map may have
-- different kinds.
data TypeMap a
emptyTypeMap :: TypeMap a
extendTypeMap :: TypeMap a -> Type -> a -> TypeMap a
lookupTypeMap :: TypeMap a -> Type -> Maybe a
foldTypeMap :: (a -> b -> b) -> b -> TypeMap a -> b
-- | A LooseTypeMap doesn't do a kind-check. Thus, when lookup up (t
-- |> g), you'll find entries inserted under (t), even if (g) is
-- non-reflexive.
data LooseTypeMap a
data CmEnv
lookupCME :: CmEnv -> Var -> Maybe BoundVar
-- | Extend a TypeMap with a type in the given context.
-- extendTypeMapWithScope m (mkDeBruijnContext [a,b,c]) t v is
-- equivalent to extendTypeMap m (forall a b c. t) v, but allows
-- reuse of the context over multiple insertions.
extendTypeMapWithScope :: TypeMap a -> CmEnv -> Type -> a -> TypeMap a
lookupTypeMapWithScope :: TypeMap a -> CmEnv -> Type -> Maybe a
-- | Construct a deBruijn environment with the given variables in scope.
-- e.g. mkDeBruijnEnv [a,b,c] constructs a context forall a
-- b c.
mkDeBruijnContext :: [Var] -> CmEnv
extendCME :: CmEnv -> Var -> CmEnv
extendCMEs :: CmEnv -> [Var] -> CmEnv
emptyCME :: CmEnv
-- | TypeMapG a is a map from DeBruijn Type to
-- a. The extended key makes it suitable for recursive
-- traversal, since it can track binders, but it is strictly internal to
-- this module. If you are including a TypeMap inside another
-- TrieMap, this is the type you want. Note that this lookup does
-- not do a kind-check. Thus, all keys in this map must have the same
-- kind. Also note that this map respects the distinction between
-- Type and Constraint, despite the fact that they are
-- equivalent type synonyms in Core.
type TypeMapG = GenMap TypeMapX
type CoercionMapG = GenMap CoercionMapX
-- | DeBruijn a represents a modulo alpha-renaming. This
-- is achieved by equipping the value with a CmEnv, which tracks
-- an on-the-fly deBruijn numbering. This allows us to define an
-- Eq instance for DeBruijn a, even if this was not
-- (easily) possible for a. Note: we purposely don't export the
-- constructor. Make a helper function if you find yourself needing it.
data DeBruijn a
D :: CmEnv -> a -> DeBruijn a
-- | Synthesizes a DeBruijn a from an a, by assuming that
-- there are no bound binders (an empty CmEnv). This is usually
-- what you want if there isn't already a CmEnv in scope.
deBruijnize :: a -> DeBruijn a
-- | A BndrMap is a TypeMapG which allows us to distinguish
-- between binding forms whose binders have different types. For example,
-- if we are doing a TrieMap lookup on (x :: Int) ->
-- (), we should not pick up an entry in the TrieMap for
-- (x :: Bool) -> (): we can disambiguate this by matching on
-- the type (or kind, if this a binder in a type) of the binder.
--
-- We also need to do the same for multiplicity! Which, since
-- multiplicities are encoded simply as a Type, amounts to have a
-- Trie for a pair of types. Tries of pairs are composition.
data BndrMap a
xtBndr :: forall a. CmEnv -> Var -> XT a -> BndrMap a -> BndrMap a
lkBndr :: CmEnv -> Var -> BndrMap a -> Maybe a
data VarMap a
xtVar :: CmEnv -> Var -> XT a -> VarMap a -> VarMap a
lkVar :: CmEnv -> Var -> VarMap a -> Maybe a
lkDFreeVar :: Var -> DVarEnv a -> Maybe a
xtDFreeVar :: Var -> XT a -> DVarEnv a -> DVarEnv a
xtDNamed :: NamedThing n => n -> XT a -> DNameEnv a -> DNameEnv a
lkDNamed :: NamedThing n => n -> DNameEnv a -> Maybe a
instance GHC.Data.TrieMap.TrieMap GHC.Core.Map.Type.CoercionMap
instance GHC.Data.TrieMap.TrieMap GHC.Core.Map.Type.CoercionMapX
instance GHC.Data.TrieMap.TrieMap GHC.Core.Map.Type.TypeMap
instance GHC.Data.TrieMap.TrieMap GHC.Core.Map.Type.LooseTypeMap
instance GHC.Data.TrieMap.TrieMap GHC.Core.Map.Type.TypeMapX
instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Core.Map.Type.TypeMapG a)
instance GHC.Data.TrieMap.TrieMap GHC.Core.Map.Type.BndrMap
instance GHC.Data.TrieMap.TrieMap GHC.Core.Map.Type.VarMap
instance GHC.Classes.Eq (GHC.Core.Map.Type.DeBruijn GHC.Core.TyCo.Rep.Coercion)
instance GHC.Classes.Eq (GHC.Core.Map.Type.DeBruijn GHC.Core.TyCo.Rep.Type)
instance GHC.Classes.Eq (GHC.Core.Map.Type.DeBruijn a) => GHC.Classes.Eq (GHC.Core.Map.Type.DeBruijn [a])
instance GHC.Classes.Eq (GHC.Core.Map.Type.DeBruijn a) => GHC.Classes.Eq (GHC.Core.Map.Type.DeBruijn (GHC.Maybe.Maybe a))
instance GHC.Data.TrieMap.TrieMap GHC.Core.Map.Type.TyLitMap
module GHC.Data.TrieMap
data MaybeMap m a
data ListMap m a
type LiteralMap a = Map Literal a
class TrieMap m where {
type Key m :: Type;
}
emptyTM :: TrieMap m => m a
lookupTM :: forall b. TrieMap m => Key m -> m b -> Maybe b
alterTM :: forall b. TrieMap m => Key m -> XT b -> m b -> m b
mapTM :: TrieMap m => (a -> b) -> m a -> m b
filterTM :: TrieMap m => (a -> Bool) -> m a -> m a
foldTM :: TrieMap m => (a -> b -> b) -> m a -> b -> b
insertTM :: TrieMap m => Key m -> a -> m a -> m a
deleteTM :: TrieMap m => Key m -> m a -> m a
foldMapTM :: (TrieMap m, Monoid r) => (a -> r) -> m a -> r
isEmptyTM :: TrieMap m => m a -> Bool
(>.>) :: (a -> b) -> (b -> c) -> a -> c
infixr 1 >.>
(|>) :: a -> (a -> b) -> b
infixr 1 |>
(|>>) :: TrieMap m2 => (XT (m2 a) -> m1 (m2 a) -> m1 (m2 a)) -> (m2 a -> m2 a) -> m1 (m2 a) -> m1 (m2 a)
infixr 1 |>>
type XT a = Maybe a -> Maybe a
foldMaybe :: (a -> b -> b) -> Maybe a -> b -> b
filterMaybe :: (a -> Bool) -> Maybe a -> Maybe a
data GenMap m a
lkG :: (Eq (Key m), TrieMap m) => Key m -> GenMap m a -> Maybe a
xtG :: (Eq (Key m), TrieMap m) => Key m -> XT a -> GenMap m a -> GenMap m a
mapG :: TrieMap m => (a -> b) -> GenMap m a -> GenMap m b
fdG :: TrieMap m => (a -> b -> b) -> GenMap m a -> b -> b
xtList :: TrieMap m => (forall b. k -> XT b -> m b -> m b) -> [k] -> XT a -> ListMap m a -> ListMap m a
lkList :: TrieMap m => (forall b. k -> m b -> Maybe b) -> [k] -> ListMap m a -> Maybe a
instance (GHC.Utils.Outputable.Outputable a, GHC.Utils.Outputable.Outputable (m a)) => GHC.Utils.Outputable.Outputable (GHC.Data.TrieMap.GenMap m a)
instance (GHC.Classes.Eq (GHC.Data.TrieMap.Key m), GHC.Data.TrieMap.TrieMap m) => GHC.Data.TrieMap.TrieMap (GHC.Data.TrieMap.GenMap m)
instance (GHC.Classes.Eq (GHC.Data.TrieMap.Key m), GHC.Data.TrieMap.TrieMap m) => Data.Foldable.Foldable (GHC.Data.TrieMap.GenMap m)
instance GHC.Data.TrieMap.TrieMap m => GHC.Data.TrieMap.TrieMap (GHC.Data.TrieMap.ListMap m)
instance GHC.Data.TrieMap.TrieMap m => Data.Foldable.Foldable (GHC.Data.TrieMap.ListMap m)
instance (GHC.Data.TrieMap.TrieMap m, GHC.Utils.Outputable.Outputable a) => GHC.Utils.Outputable.Outputable (GHC.Data.TrieMap.ListMap m a)
instance GHC.Data.TrieMap.TrieMap m => GHC.Data.TrieMap.TrieMap (GHC.Data.TrieMap.MaybeMap m)
instance GHC.Data.TrieMap.TrieMap m => Data.Foldable.Foldable (GHC.Data.TrieMap.MaybeMap m)
instance GHC.Data.TrieMap.TrieMap Data.IntMap.Internal.IntMap
instance GHC.Classes.Ord k => GHC.Data.TrieMap.TrieMap (Data.Map.Internal.Map k)
instance GHC.Types.Unique.Uniquable key => GHC.Data.TrieMap.TrieMap (GHC.Types.Unique.DFM.UniqDFM key)
-- | Module for (a) type kinds and (b) type coercions, as used in System
-- FC. See Expr for more on System FC and how coercions fit into
-- it.
module GHC.Core.Coercion
-- | A Coercion is concrete evidence of the equality/convertibility
-- of two types.
data Coercion
type CoercionN = Coercion
type CoercionR = Coercion
type CoercionP = Coercion
-- | A semantically more meaningful type to represent what may or may not
-- be a useful Coercion.
data MCoercion
MRefl :: MCoercion
MCo :: Coercion -> MCoercion
type MCoercionN = MCoercion
type MCoercionR = MCoercion
-- | For simplicity, we have just one UnivCo that represents a coercion
-- from some type to some other type, with (in general) no restrictions
-- on the type. The UnivCoProvenance specifies more exactly what the
-- coercion really is and why a program should (or shouldn't!) trust the
-- coercion. It is reasonable to consider each constructor of
-- UnivCoProvenance as a totally independent coercion form; their
-- only commonality is that they don't tell you what types they coercion
-- between. (That info is in the UnivCo constructor of
-- Coercion.
data UnivCoProvenance
-- | A coercion to be filled in by the type-checker. See Note [Coercion
-- holes]
data CoercionHole
CoercionHole :: CoVar -> IORef (Maybe Coercion) -> CoercionHole
[ch_co_var] :: CoercionHole -> CoVar
[ch_ref] :: CoercionHole -> IORef (Maybe Coercion)
coHoleCoVar :: CoercionHole -> CoVar
setCoHoleCoVar :: CoercionHole -> CoVar -> CoercionHole
data LeftOrRight
CLeft :: LeftOrRight
CRight :: LeftOrRight
-- | Variable
--
-- Essentially a typed Name, that may also contain some additional
-- information about the Var and its use sites.
data Var
-- | Coercion Variable
type CoVar = Id
-- | Type or Coercion Variable
type TyCoVar = Id
data Role
Nominal :: Role
Representational :: Role
Phantom :: Role
ltRole :: Role -> Role -> Bool
coVarTypes :: HasDebugCallStack => CoVar -> Pair Type
coVarKind :: CoVar -> Type
coVarKindsTypesRole :: HasDebugCallStack => CoVar -> (Kind, Kind, Type, Type, Role)
coVarRole :: CoVar -> Role
coercionType :: Coercion -> Type
-- | Makes a coercion type from two types: the types whose equality is
-- proven by the relevant Coercion
mkCoercionType :: Role -> Type -> Type -> Type
-- | If it is the case that
--
-- -- c :: (t1 ~ t2) ---- -- i.e. the kind of c relates t1 and t2, then -- coercionKind c = Pair t1 t2. coercionKind :: Coercion -> Pair Type coercionLKind :: Coercion -> Type coercionRKind :: Coercion -> Type -- | Apply coercionKind to multiple Coercions coercionKinds :: [Coercion] -> Pair [Type] -- | Retrieve the role from a coercion. coercionRole :: Coercion -> Role -- | Get a coercion's kind and role. coercionKindRole :: Coercion -> (Pair Type, Role) -- | Make a generalized reflexive coercion mkGReflCo :: Role -> Type -> MCoercionN -> Coercion -- | Make a reflexive coercion mkReflCo :: Role -> Type -> Coercion -- | Make a representational reflexive coercion mkRepReflCo :: Type -> Coercion -- | Make a nominal reflexive coercion mkNomReflCo :: Type -> Coercion mkCoVarCo :: CoVar -> Coercion mkCoVarCos :: [CoVar] -> [Coercion] mkAxInstCo :: Role -> CoAxiom br -> BranchIndex -> [Type] -> [Coercion] -> Coercion mkUnbranchedAxInstCo :: Role -> CoAxiom Unbranched -> [Type] -> [Coercion] -> Coercion mkAxInstRHS :: CoAxiom br -> BranchIndex -> [Type] -> [Coercion] -> Type mkUnbranchedAxInstRHS :: CoAxiom Unbranched -> [Type] -> [Coercion] -> Type -- | Return the left-hand type of the axiom, when the axiom is instantiated -- at the types given. mkAxInstLHS :: CoAxiom br -> BranchIndex -> [Type] -> [Coercion] -> Type -- | Instantiate the left-hand side of an unbranched axiom mkUnbranchedAxInstLHS :: CoAxiom Unbranched -> [Type] -> [Coercion] -> Type -- | Make a forall Coercion, where both types related by the -- coercion are quantified over the same variable. mkPiCo :: Role -> Var -> Coercion -> Coercion mkPiCos :: Role -> [Var] -> Coercion -> Coercion mkCoCast :: Coercion -> CoercionR -> Coercion -- | Create a symmetric version of the given Coercion that asserts -- equality between the same types but in the other "direction", so a -- kind of t1 ~ t2 becomes the kind t2 ~ t1. mkSymCo :: Coercion -> Coercion -- | Create a new Coercion by composing the two given -- Coercions transitively. (co1 ; co2) mkTransCo :: Coercion -> Coercion -> Coercion mkNthCo :: HasDebugCallStack => Role -> Int -> Coercion -> Coercion -- | Extract the nth field of a FunCo mkNthCoFunCo :: Int -> CoercionN -> Coercion -> Coercion -> Coercion -- | If you're about to call mkNthCo r n co, then r -- should be whatever nthCoRole n co returns. nthCoRole :: Int -> Coercion -> Role mkLRCo :: LeftOrRight -> Coercion -> Coercion -- | Instantiates a Coercion. mkInstCo :: Coercion -> Coercion -> Coercion -- | Apply a Coercion to another Coercion. The second -- coercion must be Nominal, unless the first is Phantom. If the first is -- Phantom, then the second can be either Phantom or Nominal. mkAppCo :: Coercion -> Coercion -> Coercion -- | Applies multiple Coercions to another Coercion, from -- left to right. See also mkAppCo. mkAppCos :: Coercion -> [Coercion] -> Coercion -- | Apply a type constructor to a list of coercions. It is the caller's -- responsibility to get the roles correct on argument coercions. mkTyConAppCo :: HasDebugCallStack => Role -> TyCon -> [Coercion] -> Coercion -- | Build a function Coercion from two other Coercions. That -- is, given co1 :: a ~ b and co2 :: x ~ y produce -- co :: (a -> x) ~ (b -> y). mkFunCo :: Role -> CoercionN -> Coercion -> Coercion -> Coercion mkFunResCo :: Role -> Scaled Type -> Coercion -> Coercion -- | Make a Coercion from a tycovar, a kind coercion, and a body coercion. -- The kind of the tycovar should be the left-hand kind of the kind -- coercion. See Note [Unused coercion variable in ForAllCo] mkForAllCo :: TyCoVar -> CoercionN -> Coercion -> Coercion -- | Make nested ForAllCos mkForAllCos :: [(TyCoVar, CoercionN)] -> Coercion -> Coercion -- | Make a Coercion quantified over a type/coercion variable; the variable -- has the same type in both sides of the coercion mkHomoForAllCos :: [TyCoVar] -> Coercion -> Coercion -- | Make a phantom coercion between two types. The coercion passed in must -- be a nominal coercion between the kinds of the types. mkPhantomCo :: Coercion -> Type -> Type -> Coercion -- | Make a coercion from a coercion hole mkHoleCo :: CoercionHole -> Coercion -- | Make a universal coercion between two arbitrary types. mkUnivCo :: UnivCoProvenance -> Role -> Type -> Type -> Coercion mkSubCo :: HasDebugCallStack => Coercion -> Coercion mkAxiomInstCo :: CoAxiom Branched -> BranchIndex -> [Coercion] -> Coercion -- | Make a "coercion between coercions". mkProofIrrelCo :: Role -> Coercion -> Coercion -> Coercion -> Coercion -- | Like downgradeRole_maybe, but panics if the change isn't a -- downgrade. See Note [Role twiddling functions] downgradeRole :: Role -> Role -> Coercion -> Coercion mkAxiomRuleCo :: CoAxiomRule -> [Coercion] -> Coercion -- | Given ty :: k1, co :: k1 ~ k2, produces co' :: -- ty ~r (ty |> co) mkGReflRightCo :: Role -> Type -> CoercionN -> Coercion -- | Given ty :: k1, co :: k1 ~ k2, produces co' :: -- (ty |> co) ~r ty mkGReflLeftCo :: Role -> Type -> CoercionN -> Coercion -- | Given ty :: k1, co :: k1 ~ k2, co2:: ty ~r -- ty', produces @co' :: (ty |> co) ~r ty' It is not only a -- utility function, but it saves allocation when co is a GRefl coercion. mkCoherenceLeftCo :: Role -> Type -> CoercionN -> Coercion -> Coercion -- | Given ty :: k1, co :: k1 ~ k2, co2:: ty' ~r -- ty, produces @co' :: ty' ~r (ty |> co) It is not only a -- utility function, but it saves allocation when co is a GRefl coercion. mkCoherenceRightCo :: Role -> Type -> CoercionN -> Coercion -> Coercion -- | Given co :: (a :: k) ~ (b :: k') produce co' :: k ~ -- k'. mkKindCo :: Coercion -> Coercion -- | Creates a new coercion with both of its types casted by different -- casts castCoercionKind g h1 h2, where g :: t1 ~r t2, -- has type (t1 |> h1) ~r (t2 |> h2). h1 and -- h2 must be nominal. It calls coercionKindRole, so -- it's quite inefficient (which I stands for) Use -- castCoercionKind2 instead if t1, t2, and -- r are known beforehand. castCoercionKind :: Coercion -> CoercionN -> CoercionN -> Coercion -- | castCoercionKind1 g r t1 t2 h = coercionKind g r t1 t2 h -- h That is, it's a specialised form of castCoercionKind, where the -- two kind coercions are identical castCoercionKind1 g r t1 t2 -- h, where g :: t1 ~r t2, has type (t1 |> h) ~r (t2 -- |> h). h must be nominal. See Note -- [castCoercionKind1] castCoercionKind1 :: Coercion -> Role -> Type -> Type -> CoercionN -> Coercion -- | Creates a new coercion with both of its types casted by different -- casts castCoercionKind2 g r t1 t2 h1 h2, where g :: t1 ~r -- t2, has type (t1 |> h1) ~r (t2 |> h2). h1 -- and h2 must be nominal. castCoercionKind2 :: Coercion -> Role -> Type -> Type -> CoercionN -> CoercionN -> Coercion -- | Given a family instance TyCon and its arg Coercions, -- return the corresponding family Coercion. E.g: -- --
-- data family T a -- data instance T (Maybe b) = MkT b ---- -- Where the instance TyCon is :RTL, so: -- --
-- mkFamilyTyConAppCo :RTL (co :: a ~# Int) = T (Maybe a) ~# T (Maybe Int) ---- -- cf. mkFamilyTyConApp mkFamilyTyConAppCo :: TyCon -> [CoercionN] -> CoercionN mkHeteroCoercionType :: Role -> Kind -> Kind -> Type -> Type -> Type -- | Creates a primitive type equality predicate. Invariant: the types are -- not Coercions mkPrimEqPred :: Type -> Type -> Type mkReprPrimEqPred :: Type -> Type -> Type -- | Makes a lifted equality predicate at the given role mkPrimEqPredRole :: Role -> Type -> Type -> PredType -- | Creates a primitive type equality predicate with explicit kinds mkHeteroPrimEqPred :: Kind -> Kind -> Type -> Type -> Type -- | Creates a primitive representational type equality predicate with -- explicit kinds mkHeteroReprPrimEqPred :: Kind -> Kind -> Type -> Type -> Type -- | If co :: T ts ~ rep_ty then: -- --
-- instNewTyCon_maybe T ts = Just (rep_ty, co) ---- -- Checks for a newtype, and for being saturated instNewTyCon_maybe :: TyCon -> [Type] -> Maybe (Type, Coercion) -- | A function to check if we can reduce a type by one step. Used with -- topNormaliseTypeX. type NormaliseStepper ev = RecTcChecker -> TyCon -> [Type] -> NormaliseStepResult ev -- | The result of stepping in a normalisation function. See -- topNormaliseTypeX. data NormaliseStepResult ev -- | Nothing more to do NS_Done :: NormaliseStepResult ev -- | Utter failure. The outer function should fail too. NS_Abort :: NormaliseStepResult ev -- | We stepped, yielding new bits; ^ ev is evidence; Usually a co :: old -- type ~ new type NS_Step :: RecTcChecker -> Type -> ev -> NormaliseStepResult ev -- | Try one stepper and then try the next, if the first doesn't make -- progress. So if it returns NS_Done, it means that both steppers are -- satisfied composeSteppers :: NormaliseStepper ev -> NormaliseStepper ev -> NormaliseStepper ev mapStepResult :: (ev1 -> ev2) -> NormaliseStepResult ev1 -> NormaliseStepResult ev2 -- | A NormaliseStepper that unwraps newtypes, careful not to fall -- into a loop. If it would fall into a loop, it produces -- NS_Abort. unwrapNewTypeStepper :: NormaliseStepper Coercion -- | Sometimes we want to look through a newtype and get its -- associated coercion. This function strips off newtype layers -- enough to reveal something that isn't a newtype. -- Specifically, here's the invariant: -- --
-- topNormaliseNewType_maybe rec_nts ty = Just (co, ty') ---- -- then (a) co : ty ~ ty'. (b) ty' is not a newtype. -- -- The function returns Nothing for non-newtypes, or -- unsaturated applications -- -- This function does *not* look through type families, because it has no -- access to the type family environment. If you do have that at hand, -- consider to use topNormaliseType_maybe, which should be a drop-in -- replacement for topNormaliseNewType_maybe If topNormliseNewType_maybe -- ty = Just (co, ty'), then co : ty ~R ty' topNormaliseNewType_maybe :: Type -> Maybe (Coercion, Type) -- | A general function for normalising the top-level of a type. It -- continues to use the provided NormaliseStepper until that -- function fails, and then this function returns. The roles of the -- coercions produced by the NormaliseStepper must all be the -- same, which is the role returned from the call to -- topNormaliseTypeX. -- -- Typically ev is Coercion. -- -- If topNormaliseTypeX step plus ty = Just (ev, ty') then ty ~ev1~ t1 -- ~ev2~ t2 ... ~evn~ ty' and ev = ev1 plus ev2 plus -- ... plus evn If it returns Nothing then no newtype unwrapping -- could happen topNormaliseTypeX :: NormaliseStepper ev -> (ev -> ev -> ev) -> Type -> Maybe (ev, Type) -- | This breaks a Coercion with type T A B C ~ T D E F -- into a list of Coercions of kinds A ~ D, B ~ -- E and E ~ F. Hence: -- --
-- decomposeCo 3 c [r1, r2, r3] = [nth r1 0 c, nth r2 1 c, nth r3 2 c] --decomposeCo :: Arity -> Coercion -> [Role] -> [Coercion] decomposeFunCo :: HasDebugCallStack => Role -> Coercion -> (CoercionN, Coercion, Coercion) decomposePiCos :: HasDebugCallStack => CoercionN -> Pair Type -> [Type] -> ([CoercionN], CoercionN) -- | Attempts to obtain the type variable underlying a Coercion getCoVar_maybe :: Coercion -> Maybe CoVar -- | Attempts to tease a coercion apart into a type constructor and the -- application of a number of coercion arguments to that constructor splitTyConAppCo_maybe :: Coercion -> Maybe (TyCon, [Coercion]) -- | Attempt to take a coercion application apart. splitAppCo_maybe :: Coercion -> Maybe (Coercion, Coercion) splitFunCo_maybe :: Coercion -> Maybe (Coercion, Coercion) splitForAllCo_maybe :: Coercion -> Maybe (TyCoVar, Coercion, Coercion) -- | Like splitForAllCo_maybe, but only returns Just for tyvar -- binder splitForAllCo_ty_maybe :: Coercion -> Maybe (TyVar, Coercion, Coercion) -- | Like splitForAllCo_maybe, but only returns Just for covar -- binder splitForAllCo_co_maybe :: Coercion -> Maybe (CoVar, Coercion, Coercion) nthRole :: Role -> TyCon -> Int -> Role tyConRolesX :: Role -> TyCon -> [Role] tyConRolesRepresentational :: TyCon -> [Role] -- | Converts a coercion to be nominal, if possible. See Note [Role -- twiddling functions] setNominalRole_maybe :: Role -> Coercion -> Maybe Coercion pickLR :: LeftOrRight -> (a, a) -> a -- | Tests if this coercion is obviously a generalized reflexive coercion. -- Guaranteed to work very quickly. isGReflCo :: Coercion -> Bool -- | Tests if this coercion is obviously reflexive. Guaranteed to work very -- quickly. Sometimes a coercion can be reflexive, but not obviously so. -- c.f. isReflexiveCo isReflCo :: Coercion -> Bool -- | Returns the type coerced if this coercion is reflexive. Guaranteed to -- work very quickly. Sometimes a coercion can be reflexive, but not -- obviously so. c.f. isReflexiveCo_maybe isReflCo_maybe :: Coercion -> Maybe (Type, Role) -- | Returns the type coerced if this coercion is a generalized reflexive -- coercion. Guaranteed to work very quickly. isGReflCo_maybe :: Coercion -> Maybe (Type, Role) -- | Slowly checks if the coercion is reflexive. Don't call this in a loop, -- as it walks over the entire coercion. isReflexiveCo :: Coercion -> Bool -- | Extracts the coerced type from a reflexive coercion. This potentially -- walks over the entire coercion, so avoid doing this in a loop. isReflexiveCo_maybe :: Coercion -> Maybe (Type, Role) isReflCoVar_maybe :: Var -> Maybe Coercion -- | Tests if this MCoercion is obviously generalized reflexive Guaranteed -- to work very quickly. isGReflMCo :: MCoercion -> Bool mkGReflLeftMCo :: Role -> Type -> MCoercionN -> Coercion mkGReflRightMCo :: Role -> Type -> MCoercionN -> Coercion -- | Like mkCoherenceRightCo, but with an MCoercion mkCoherenceRightMCo :: Role -> Type -> MCoercionN -> Coercion -> Coercion coToMCo :: Coercion -> MCoercion -- | Compose two MCoercions via transitivity mkTransMCo :: MCoercion -> MCoercion -> MCoercion mkTransMCoL :: MCoercion -> Coercion -> MCoercion mkTransMCoR :: Coercion -> MCoercion -> MCoercion -- | Cast a type by an MCoercion mkCastTyMCo :: Type -> MCoercion -> Type -- | Get the reverse of an MCoercion mkSymMCo :: MCoercion -> MCoercion mkHomoForAllMCo :: TyCoVar -> MCoercion -> MCoercion mkFunResMCo :: Scaled Type -> MCoercionR -> MCoercionR mkPiMCos :: [Var] -> MCoercion -> MCoercion checkReflexiveMCo :: MCoercion -> MCoercion isReflMCo :: MCoercion -> Bool mkCoVar :: Name -> Type -> CoVar -- | Is this a coercion variable? Satisfies isId v ==> -- isCoVar v == not (isNonCoVarId v). isCoVar :: Var -> Bool coVarName :: CoVar -> Name setCoVarName :: CoVar -> Name -> CoVar setCoVarUnique :: CoVar -> Unique -> CoVar -- | Extract a covar, if possible. This check is dirty. Be ashamed of -- yourself. (It's dirty because it cares about the structure of a -- coercion, which is morally reprehensible.) isCoVar_maybe :: Coercion -> Maybe CoVar tyCoVarsOfCo :: Coercion -> TyCoVarSet tyCoVarsOfCos :: [Coercion] -> TyCoVarSet coVarsOfCo :: Coercion -> CoVarSet tyCoFVsOfCo :: Coercion -> FV tyCoFVsOfCos :: [Coercion] -> FV -- | Get a deterministic set of the vars free in a coercion tyCoVarsOfCoDSet :: Coercion -> DTyCoVarSet coercionSize :: Coercion -> Int anyFreeVarsOfCo :: (TyCoVar -> Bool) -> Coercion -> Bool -- | A substitution of Coercions for CoVars type CvSubstEnv = CoVarEnv Coercion emptyCvSubstEnv :: CvSubstEnv lookupCoVar :: TCvSubst -> Var -> Maybe Coercion -- | Substitute within a Coercion The substitution has to satisfy -- the invariants described in Note [The substitution invariant]. substCo :: HasCallStack => TCvSubst -> Coercion -> Coercion -- | Substitute within several Coercions The substitution has to -- satisfy the invariants described in Note [The substitution invariant]. substCos :: HasCallStack => TCvSubst -> [Coercion] -> [Coercion] substCoVar :: TCvSubst -> CoVar -> Coercion substCoVars :: TCvSubst -> [CoVar] -> [Coercion] -- | Coercion substitution, see zipTvSubst substCoWith :: HasCallStack => [TyVar] -> [Type] -> Coercion -> Coercion substCoVarBndr :: HasCallStack => TCvSubst -> CoVar -> (TCvSubst, CoVar) extendTvSubstAndInScope :: TCvSubst -> TyVar -> Type -> TCvSubst getCvSubstEnv :: TCvSubst -> CvSubstEnv -- | liftCoSubst role lc ty produces a coercion (at role -- role) that coerces between lc_left(ty) and -- lc_right(ty), where lc_left is a substitution -- mapping type variables to the left-hand types of the mapped coercions -- in lc, and similar for lc_right. liftCoSubst :: HasDebugCallStack => Role -> LiftingContext -> Type -> Coercion liftCoSubstTyVar :: LiftingContext -> Role -> TyVar -> Maybe Coercion liftCoSubstWith :: Role -> [TyCoVar] -> [Coercion] -> Type -> Coercion liftCoSubstWithEx :: Role -> [TyVar] -> [Coercion] -> [TyCoVar] -> [Type] -> (Type -> Coercion, [Type]) emptyLiftingContext :: InScopeSet -> LiftingContext -- | Extend a lifting context with a new mapping. extendLiftingContext :: LiftingContext -> TyCoVar -> Coercion -> LiftingContext -- | Extend a lifting context with a new mapping, and extend the in-scope -- set extendLiftingContextAndInScope :: LiftingContext -> TyCoVar -> Coercion -> LiftingContext liftCoSubstVarBndrUsing :: (LiftingContext -> Type -> (CoercionN, a)) -> LiftingContext -> TyCoVar -> (LiftingContext, TyCoVar, CoercionN, a) -- | Is a var in the domain of a lifting context? isMappedByLC :: TyCoVar -> LiftingContext -> Bool mkSubstLiftingContext :: TCvSubst -> LiftingContext -- | Erase the environments in a lifting context zapLiftingContext :: LiftingContext -> LiftingContext -- | Like substForAllCoBndr, but works on a lifting context substForAllCoBndrUsingLC :: Bool -> (Coercion -> Coercion) -> LiftingContext -> TyCoVar -> Coercion -> (LiftingContext, TyCoVar, Coercion) -- | Extract the underlying substitution from the LiftingContext lcTCvSubst :: LiftingContext -> TCvSubst -- | Get the InScopeSet from a LiftingContext lcInScopeSet :: LiftingContext -> InScopeSet type LiftCoEnv = VarEnv Coercion data LiftingContext LC :: TCvSubst -> LiftCoEnv -> LiftingContext liftEnvSubstLeft :: TCvSubst -> LiftCoEnv -> TCvSubst liftEnvSubstRight :: TCvSubst -> LiftCoEnv -> TCvSubst substRightCo :: LiftingContext -> Coercion -> Coercion substLeftCo :: LiftingContext -> Coercion -> Coercion -- | Apply "sym" to all coercions in a LiftCoEnv swapLiftCoEnv :: LiftCoEnv -> LiftCoEnv lcSubstLeft :: LiftingContext -> TCvSubst lcSubstRight :: LiftingContext -> TCvSubst -- | Syntactic equality of coercions eqCoercion :: Coercion -> Coercion -> Bool -- | Compare two Coercions, with respect to an RnEnv2 eqCoercionX :: RnEnv2 -> Coercion -> Coercion -> Bool seqCo :: Coercion -> () pprCo :: Coercion -> SDoc pprParendCo :: Coercion -> SDoc pprCoAxiom :: CoAxiom br -> SDoc pprCoAxBranch :: TyCon -> CoAxBranch -> SDoc pprCoAxBranchLHS :: TyCon -> CoAxBranch -> SDoc pprCoAxBranchUser :: TyCon -> CoAxBranch -> SDoc tidyCoAxBndrsForUser :: TidyEnv -> [Var] -> (TidyEnv, [Var]) etaExpandCoAxBranch :: CoAxBranch -> ([TyVar], [Type], Type) -- | Tidy a Coercion -- -- See Note [Strictness in tidyType and friends] tidyCo :: TidyEnv -> Coercion -> Coercion tidyCos :: TidyEnv -> [Coercion] -> [Coercion] -- | like mkKindCo, but aggressively & recursively optimizes to avoid -- using a KindCo constructor. The output role is nominal. promoteCoercion :: Coercion -> CoercionN -- | Assuming that two types are the same, ignoring coercions, find a -- nominal coercion between the types. This is useful when optimizing -- transitivity over coercion applications, where splitting two AppCos -- might yield different kinds. See Note [EtaAppCo] in -- GHC.Core.Coercion.Opt. buildCoercion :: Type -> Type -> CoercionN multToCo :: Mult -> Coercion simplifyArgsWorker :: [TyCoBinder] -> Kind -> TyCoVarSet -> [Role] -> [(Type, Coercion)] -> ([Type], [Coercion], MCoercionN) -- | Is there a coercion hole in this type? hasCoercionHoleTy :: Type -> Bool -- | Is there a coercion hole in this coercion? hasCoercionHoleCo :: Coercion -> Bool -- | A set of CoercionHoles type HoleSet = UniqSet CoercionHole -- | Extract out all the coercion holes from a given type coercionHolesOfType :: Type -> UniqSet CoercionHole coercionHolesOfCo :: Coercion -> UniqSet CoercionHole instance GHC.Utils.Outputable.Outputable GHC.Core.Coercion.LiftingContext instance GHC.Utils.Outputable.Outputable ev => GHC.Utils.Outputable.Outputable (GHC.Core.Coercion.NormaliseStepResult ev) -- | Commonly useful utilities for manipulating the Core language module GHC.Core.Utils -- | Wrap the given expression in the coercion safely, dropping identity -- coercions and coalescing nested coercions mkCast :: CoreExpr -> CoercionR -> CoreExpr mkCastMCo :: CoreExpr -> MCoercionR -> CoreExpr mkPiMCo :: Var -> MCoercionR -> MCoercionR -- | Wraps the given expression in the source annotation, dropping the -- annotation if possible. mkTick :: CoreTickish -> CoreExpr -> CoreExpr mkTicks :: [CoreTickish] -> CoreExpr -> CoreExpr mkTickNoHNF :: CoreTickish -> CoreExpr -> CoreExpr tickHNFArgs :: CoreTickish -> CoreExpr -> CoreExpr -- | bindNonRec x r b produces either: -- --
-- let x = r in b ---- -- or: -- --
-- case r of x { _DEFAULT_ -> b }
--
--
-- depending on whether we have to use a case or let
-- binding for the expression (see needsCaseBinding). It's used by
-- the desugarer to avoid building bindings that give Core Lint a heart
-- attack, although actually the simplifier deals with them perfectly
-- well. See also mkCoreLet
bindNonRec :: Id -> CoreExpr -> CoreExpr -> CoreExpr
-- | Tests whether we have to use a case rather than let
-- binding for this expression as per the invariants of CoreExpr:
-- see GHC.Core#let_app_invariant
needsCaseBinding :: Type -> CoreExpr -> Bool
-- | This guy constructs the value that the scrutinee must have given that
-- you are in one particular branch of a case
mkAltExpr :: AltCon -> [CoreBndr] -> [Type] -> CoreExpr
mkDefaultCase :: CoreExpr -> Id -> CoreExpr -> CoreExpr
mkSingleAltCase :: CoreExpr -> Id -> AltCon -> [Var] -> CoreExpr -> CoreExpr
-- | Extract the default case alternative
findDefault :: [Alt b] -> ([Alt b], Maybe (Expr b))
addDefault :: [Alt b] -> Maybe (Expr b) -> [Alt b]
-- | Find the case alternative corresponding to a particular constructor:
-- panics if no such constructor exists
findAlt :: AltCon -> [Alt b] -> Maybe (Alt b)
isDefaultAlt :: Alt b -> Bool
-- | Merge alternatives preserving order; alternatives in the first
-- argument shadow ones in the second
mergeAlts :: [Alt a] -> [Alt a] -> [Alt a]
-- | Given:
--
-- -- case (C a b x y) of -- C b x y -> ... ---- -- We want to drop the leading type argument of the scrutinee leaving the -- arguments to match against the pattern trimConArgs :: AltCon -> [CoreArg] -> [CoreArg] filterAlts :: TyCon -> [Type] -> [AltCon] -> [Alt b] -> ([AltCon], [Alt b]) combineIdenticalAlts :: [AltCon] -> [CoreAlt] -> (Bool, [AltCon], [CoreAlt]) -- | Refine the default alternative to a DataAlt, if there is a -- unique way to do so. See Note [Refine DEFAULT case alternatives] refineDefaultAlt :: [Unique] -> Mult -> TyCon -> [Type] -> [AltCon] -> [CoreAlt] -> (Bool, [CoreAlt]) scaleAltsBy :: Mult -> [CoreAlt] -> [CoreAlt] -- | Recover the type of a well-typed Core expression. Fails when applied -- to the actual Type expression as it cannot really be said to -- have a type exprType :: CoreExpr -> Type -- | Returns the type of the alternatives right hand side coreAltType :: CoreAlt -> Type -- | Returns the type of the first alternative, which should be the same as -- for all alternatives coreAltsType :: [CoreAlt] -> Type -- | Makes a (->) type or an implicit forall type, depending on -- whether it is given a type variable or a term variable. This is used, -- for example, when producing the type of a lambda. Always uses Inferred -- binders. mkLamType :: Var -> Type -> Type -- | mkLamType for multiple type or value arguments mkLamTypes :: [Var] -> Type -> Type mkFunctionType :: Mult -> Type -> Type -> Type -- | Is this expression levity polymorphic? This should be the same as -- saying (isKindLevPoly . typeKind . exprType) but much faster. isExprLevPoly :: CoreExpr -> Bool exprIsDupable :: Platform -> CoreExpr -> Bool exprIsTrivial :: CoreExpr -> Bool getIdFromTrivialExpr :: HasDebugCallStack => CoreExpr -> Id exprIsDeadEnd :: CoreExpr -> Bool getIdFromTrivialExpr_maybe :: CoreExpr -> Maybe Id exprIsCheap :: CoreExpr -> Bool exprIsExpandable :: CoreExpr -> Bool exprIsCheapX :: CheapAppFun -> CoreExpr -> Bool type CheapAppFun = Id -> Arity -> Bool -- | exprIsHNF returns true for expressions that are certainly -- already evaluated to head normal form. This is used to -- decide whether it's ok to change: -- --
-- case x of _ -> e ---- -- into: -- --
-- e ---- -- and to decide whether it's safe to discard a seq. -- -- So, it does not treat variables as evaluated, unless they say -- they are. However, it does treat partial applications and -- constructor applications as values, even if their arguments are -- non-trivial, provided the argument type is lifted. For example, both -- of these are values: -- --
-- (:) (f x) (map f xs) -- map (...redex...) ---- -- because seq on such things completes immediately. -- -- For unlifted argument types, we have to be careful: -- --
-- C (f x :: Int#) ---- -- Suppose f x diverges; then C (f x) is not a value. -- However this can't happen: see GHC.Core#let_app_invariant. This -- invariant states that arguments of unboxed type must be -- ok-for-speculation (or trivial). exprIsHNF :: CoreExpr -> Bool -- | exprOkForSpeculation returns True of an expression that is: -- --
-- let x = case y# +# 1# of { r# -> I# r# }
-- in E
--
--
-- being translated to:
--
--
-- case y# +# 1# of { r# ->
-- let x = I# r#
-- in E
-- }
--
--
-- We can only do this if the y + 1 is ok for speculation: it
-- has no side effects, and can't diverge or raise an exception.
exprOkForSpeculation :: CoreExpr -> Bool
-- | exprOkForSpeculation returns True of an expression that is:
--
--
-- let x = case y# +# 1# of { r# -> I# r# }
-- in E
--
--
-- being translated to:
--
--
-- case y# +# 1# of { r# ->
-- let x = I# r#
-- in E
-- }
--
--
-- We can only do this if the y + 1 is ok for speculation: it
-- has no side effects, and can't diverge or raise an exception.
exprOkForSideEffects :: CoreExpr -> Bool
exprIsWorkFree :: CoreExpr -> Bool
-- | Similar to exprIsHNF but includes CONLIKE functions as well as
-- data constructors. Conlike arguments are considered interesting by the
-- inliner.
exprIsConLike :: CoreExpr -> Bool
isCheapApp :: CheapAppFun
isExpandableApp :: CheapAppFun
-- | Check if the expression is zero or more Ticks wrapped around a literal
-- string.
exprIsTickedString :: CoreExpr -> Bool
-- | Extract a literal string from an expression that is zero or more Ticks
-- wrapped around a literal string. Returns Nothing if the expression has
-- a different shape. Used to "look through" Ticks in places that need to
-- handle literal strings.
exprIsTickedString_maybe :: CoreExpr -> Maybe ByteString
-- | Can we bind this CoreExpr at the top level?
exprIsTopLevelBindable :: CoreExpr -> Type -> Bool
altsAreExhaustive :: [Alt b] -> Bool
-- | A cheap equality test which bales out fast! If it returns
-- True the arguments are definitely equal, otherwise, they may
-- or may not be equal.
cheapEqExpr :: Expr b -> Expr b -> Bool
-- | Cheap expression equality test, can ignore ticks by type.
cheapEqExpr' :: (CoreTickish -> Bool) -> Expr b -> Expr b -> Bool
eqExpr :: InScopeSet -> CoreExpr -> CoreExpr -> Bool
-- | Finds differences between core expressions, modulo alpha and renaming.
-- Setting top means that the IdInfo of bindings will
-- be checked for differences as well.
diffExpr :: Bool -> RnEnv2 -> CoreExpr -> CoreExpr -> [SDoc]
-- | Finds differences between core bindings, see diffExpr.
--
-- The main problem here is that while we expect the binds to have the
-- same order in both lists, this is not guaranteed. To do this properly
-- we'd either have to do some sort of unification or check all possible
-- mappings, which would be seriously expensive. So instead we simply
-- match single bindings as far as we can. This leaves us just with
-- mutually recursive and/or mismatching bindings, which we then
-- speculatively match by ordering them. It's by no means perfect, but
-- gets the job done well enough.
diffBinds :: Bool -> RnEnv2 -> [(Var, CoreExpr)] -> [(Var, CoreExpr)] -> ([SDoc], RnEnv2)
tryEtaReduce :: [Var] -> CoreExpr -> Maybe CoreExpr
zapLamBndrs :: FullArgCount -> [Var] -> [Var]
-- | If the expression is a Expr, converts. Otherwise, panics. NB:
-- This does not convert Expr to CoercionTy.
exprToType :: CoreExpr -> Type
-- | If the expression is a Expr, converts.
exprToCoercion_maybe :: CoreExpr -> Maybe Coercion
-- | A more efficient version of applyTypeToArg when we have several
-- arguments. The first argument is just for debugging, and gives some
-- context
applyTypeToArgs :: SDoc -> Type -> [CoreExpr] -> Type
-- | Determines the type resulting from applying an expression with given
-- type to a given argument expression
applyTypeToArg :: Type -> CoreExpr -> Type
dataConRepInstPat :: [Unique] -> Mult -> DataCon -> [Type] -> ([TyCoVar], [Id])
dataConRepFSInstPat :: [FastString] -> [Unique] -> Mult -> DataCon -> [Type] -> ([TyCoVar], [Id])
-- | True if the type has no non-bottom elements, e.g. when it is an empty
-- datatype, or a GADT with non-satisfiable type parameters, e.g. Int :~:
-- Bool. See Note [Bottoming expressions]
--
-- See Note [No alternatives lint check] for another use of this
-- function.
isEmptyTy :: Type -> Bool
-- | Strip ticks satisfying a predicate from top of an expression
stripTicksTop :: (CoreTickish -> Bool) -> Expr b -> ([CoreTickish], Expr b)
-- | Strip ticks satisfying a predicate from top of an expression,
-- returning the remaining expression
stripTicksTopE :: (CoreTickish -> Bool) -> Expr b -> Expr b
-- | Strip ticks satisfying a predicate from top of an expression,
-- returning the ticks
stripTicksTopT :: (CoreTickish -> Bool) -> Expr b -> [CoreTickish]
-- | Completely strip ticks satisfying a predicate from an expression. Note
-- this is O(n) in the size of the expression!
stripTicksE :: (CoreTickish -> Bool) -> Expr b -> Expr b
stripTicksT :: (CoreTickish -> Bool) -> Expr b -> [CoreTickish]
-- | collectMakeStaticArgs (makeStatic t srcLoc e) yields Just
-- (makeStatic, t, srcLoc, e).
--
-- Returns Nothing for every other expression.
collectMakeStaticArgs :: CoreExpr -> Maybe (CoreExpr, Type, CoreExpr, CoreExpr)
-- | Does this binding bind a join point (or a recursive group of join
-- points)?
isJoinBind :: CoreBind -> Bool
isUnsafeEqualityProof :: CoreExpr -> Bool
dumpIdInfoOfProgram :: (IdInfo -> SDoc) -> CoreProgram -> SDoc
module GHC.Core.Predicate
-- | A predicate in the solver. The solver tries to prove Wanted predicates
-- from Given ones.
data Pred
ClassPred :: Class -> [Type] -> Pred
EqPred :: EqRel -> Type -> Type -> Pred
IrredPred :: PredType -> Pred
ForAllPred :: [TyVar] -> [PredType] -> PredType -> Pred
classifyPredType :: PredType -> Pred
isPredTy :: HasDebugCallStack => Type -> Bool
isEvVarType :: Type -> Bool
-- | A choice of equality relation. This is separate from the type
-- Role because Phantom does not define a (non-trivial)
-- equality relation.
data EqRel
NomEq :: EqRel
ReprEq :: EqRel
eqRelRole :: EqRel -> Role
isEqPrimPred :: PredType -> Bool
isEqPred :: PredType -> Bool
getEqPredTys :: PredType -> (Type, Type)
getEqPredTys_maybe :: PredType -> Maybe (Role, Type, Type)
getEqPredRole :: PredType -> Role
-- | Get the equality relation relevant for a pred type.
predTypeEqRel :: PredType -> EqRel
-- | Creates a primitive type equality predicate. Invariant: the types are
-- not Coercions
mkPrimEqPred :: Type -> Type -> Type
mkReprPrimEqPred :: Type -> Type -> Type
-- | Makes a lifted equality predicate at the given role
mkPrimEqPredRole :: Role -> Type -> Type -> PredType
-- | Creates a primitive type equality predicate with explicit kinds
mkHeteroPrimEqPred :: Kind -> Kind -> Type -> Type -> Type
-- | Creates a primitive representational type equality predicate with
-- explicit kinds
mkHeteroReprPrimEqPred :: Kind -> Kind -> Type -> Type -> Type
mkClassPred :: Class -> [Type] -> PredType
isDictTy :: Type -> Bool
isClassPred :: PredType -> Bool
isEqPredClass :: Class -> Bool
isCTupleClass :: Class -> Bool
getClassPredTys :: HasDebugCallStack => PredType -> (Class, [Type])
getClassPredTys_maybe :: PredType -> Maybe (Class, [Type])
classMethodTy :: Id -> Type
classMethodInstTy :: Id -> [Type] -> Type
isIPLikePred :: Type -> Bool
hasIPSuperClasses :: Class -> [Type] -> Bool
isIPTyCon :: TyCon -> Bool
isIPClass :: Class -> Bool
-- | Dictionary Identifier
type DictId = EvId
isEvVar :: Var -> Bool
isDictId :: Id -> Bool
instance GHC.Classes.Ord GHC.Core.Predicate.EqRel
instance GHC.Classes.Eq GHC.Core.Predicate.EqRel
instance GHC.Utils.Outputable.Outputable GHC.Core.Predicate.EqRel
module GHC.Core.TyCon.RecWalk
data RecTcChecker
-- | Initialise a RecTcChecker with defaultRecTcMaxBound.
initRecTc :: RecTcChecker
-- | The default upper bound (100) for the number of times a
-- RecTcChecker is allowed to encounter each TyCon.
defaultRecTcMaxBound :: Int
-- | Change the upper bound for the number of times a RecTcChecker
-- is allowed to encounter each TyCon.
setRecTcMaxBound :: Int -> RecTcChecker -> RecTcChecker
checkRecTc :: RecTcChecker -> TyCon -> Maybe RecTcChecker
instance GHC.Utils.Outputable.Outputable GHC.Core.TyCon.RecWalk.RecTcChecker
module GHC.Core.TyCon.Env
-- | TyCon Environment
type TyConEnv a = UniqFM TyCon a
mkTyConEnv :: [(TyCon, a)] -> TyConEnv a
mkTyConEnvWith :: (a -> TyCon) -> [a] -> TyConEnv a
emptyTyConEnv :: TyConEnv a
isEmptyTyConEnv :: TyConEnv a -> Bool
unitTyConEnv :: TyCon -> a -> TyConEnv a
nameEnvElts :: TyConEnv a -> [a]
extendTyConEnv_C :: (a -> a -> a) -> TyConEnv a -> TyCon -> a -> TyConEnv a
extendTyConEnv_Acc :: (a -> b -> b) -> (a -> b) -> TyConEnv b -> TyCon -> a -> TyConEnv b
extendTyConEnv :: TyConEnv a -> TyCon -> a -> TyConEnv a
extendTyConEnvList :: TyConEnv a -> [(TyCon, a)] -> TyConEnv a
extendTyConEnvList_C :: (a -> a -> a) -> TyConEnv a -> [(TyCon, a)] -> TyConEnv a
filterTyConEnv :: (elt -> Bool) -> TyConEnv elt -> TyConEnv elt
anyTyConEnv :: (elt -> Bool) -> TyConEnv elt -> Bool
plusTyConEnv :: TyConEnv a -> TyConEnv a -> TyConEnv a
plusTyConEnv_C :: (a -> a -> a) -> TyConEnv a -> TyConEnv a -> TyConEnv a
plusTyConEnv_CD :: (a -> a -> a) -> TyConEnv a -> a -> TyConEnv a -> a -> TyConEnv a
plusTyConEnv_CD2 :: (Maybe a -> Maybe a -> a) -> TyConEnv a -> TyConEnv a -> TyConEnv a
alterTyConEnv :: (Maybe a -> Maybe a) -> TyConEnv a -> TyCon -> TyConEnv a
lookupTyConEnv :: TyConEnv a -> TyCon -> Maybe a
lookupTyConEnv_NF :: TyConEnv a -> TyCon -> a
delFromTyConEnv :: TyConEnv a -> TyCon -> TyConEnv a
delListFromTyConEnv :: TyConEnv a -> [TyCon] -> TyConEnv a
elemTyConEnv :: TyCon -> TyConEnv a -> Bool
mapTyConEnv :: (elt1 -> elt2) -> TyConEnv elt1 -> TyConEnv elt2
disjointTyConEnv :: TyConEnv a -> TyConEnv a -> Bool
-- | Deterministic TyCon Environment
--
-- See Note [Deterministic UniqFM] in GHC.Types.Unique.DFM for
-- explanation why we need DTyConEnv.
type DTyConEnv a = UniqDFM TyCon a
emptyDTyConEnv :: DTyConEnv a
isEmptyDTyConEnv :: DTyConEnv a -> Bool
lookupDTyConEnv :: DTyConEnv a -> TyCon -> Maybe a
delFromDTyConEnv :: DTyConEnv a -> TyCon -> DTyConEnv a
filterDTyConEnv :: (a -> Bool) -> DTyConEnv a -> DTyConEnv a
mapDTyConEnv :: (a -> b) -> DTyConEnv a -> DTyConEnv b
mapMaybeDTyConEnv :: (a -> Maybe b) -> DTyConEnv a -> DTyConEnv b
adjustDTyConEnv :: (a -> a) -> DTyConEnv a -> TyCon -> DTyConEnv a
alterDTyConEnv :: (Maybe a -> Maybe a) -> DTyConEnv a -> TyCon -> DTyConEnv a
extendDTyConEnv :: DTyConEnv a -> TyCon -> a -> DTyConEnv a
foldDTyConEnv :: (elt -> a -> a) -> a -> DTyConEnv elt -> a
-- | This module defines the semi-ring of multiplicities, and associated
-- functions. Multiplicities annotate arrow types to indicate the
-- linearity of the arrow (in the sense of linear types).
--
-- Mult is a type synonym for Type, used only when its kind is
-- Multiplicity. To simplify dealing with multiplicities, functions such
-- as mkMultMul perform simplifications such as Many * x = Many on the
-- fly.
module GHC.Core.Multiplicity
-- | Mult is a type alias for Type.
--
-- Mult must contain Type because multiplicity variables are mere type
-- variables (of kind Multiplicity) in Haskell. So the simplest
-- implementation is to make Mult be Type.
--
-- Multiplicities can be formed with: - One: GHC.Types.One (= oneDataCon)
-- - Many: GHC.Types.Many (= manyDataCon) - Multiplication:
-- GHC.Types.MultMul (= multMulTyCon)
--
-- So that Mult feels a bit more structured, we provide pattern synonyms
-- and smart constructors for these.
type Mult = Type
pattern One :: Mult
pattern Many :: Mult
isMultMul :: Mult -> Maybe (Mult, Mult)
mkMultAdd :: Mult -> Mult -> Mult
mkMultMul :: Mult -> Mult -> Mult
-- | mkMultSup w1 w2 returns a multiplicity such that
-- mkMultSup w1 w2 >= w1 and mkMultSup w1 w2 >=
-- w2. See Note [Overapproximating multiplicities].
mkMultSup :: Mult -> Mult -> Mult
-- | A shorthand for data with an attached Mult element (the
-- multiplicity).
data Scaled a
Scaled :: !Mult -> a -> Scaled a
scaledMult :: Scaled a -> Mult
scaledThing :: Scaled a -> a
-- | Scale a payload by Many
unrestricted :: a -> Scaled a
-- | Scale a payload by One
linear :: a -> Scaled a
-- | Scale a payload by Many; used for type arguments in core
tymult :: a -> Scaled a
irrelevantMult :: Scaled a -> a
mkScaled :: Mult -> a -> Scaled a
scaledSet :: Scaled a -> b -> Scaled b
scaleScaled :: Mult -> Scaled a -> Scaled a
data IsSubmult
Submult :: IsSubmult
Unknown :: IsSubmult
-- | submult w1 w2 check whether a value of multiplicity
-- w1 is allowed where a value of multiplicity w2 is
-- expected. This is a partial order.
submult :: Mult -> Mult -> IsSubmult
-- | Apply a function to both the Mult and the Type in a 'Scaled Type'
mapScaledType :: (Type -> Type) -> Scaled Type -> Scaled Type
instance GHC.Classes.Eq GHC.Core.Multiplicity.IsSubmult
instance GHC.Show.Show GHC.Core.Multiplicity.IsSubmult
instance GHC.Utils.Outputable.Outputable GHC.Core.Multiplicity.IsSubmult
-- | This module is about types that can be defined in Haskell, but which
-- must be wired into the compiler nonetheless. C.f module
-- GHC.Builtin.Types.Prim
module GHC.Builtin.Types
mkWiredInTyConName :: BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
mkWiredInIdName :: Module -> FastString -> Unique -> Id -> Name
wiredInTyCons :: [TyCon]
-- | Built-in syntax isn't "in scope" so these OccNames map to wired-in
-- Names with BuiltInSyntax. However, this should only be necessary while
-- resolving names produced by Template Haskell splices since we take
-- care to encode built-in syntax names specially in interface files. See
-- Note [Symbol table representation of names].
--
-- Moreover, there is no need to include names of things that the user
-- can't write (e.g. type representation bindings like $tc(,,,)).
isBuiltInOcc_maybe :: OccName -> Maybe Name
boolTy :: Type
boolTyCon :: TyCon
boolTyCon_RDR :: RdrName
boolTyConName :: Name
trueDataCon :: DataCon
trueDataConId :: Id
true_RDR :: RdrName
falseDataCon :: DataCon
falseDataConId :: Id
false_RDR :: RdrName
promotedFalseDataCon :: TyCon
promotedTrueDataCon :: TyCon
orderingTyCon :: TyCon
ordLTDataCon :: DataCon
ordLTDataConId :: Id
ordEQDataCon :: DataCon
ordEQDataConId :: Id
ordGTDataCon :: DataCon
ordGTDataConId :: Id
promotedLTDataCon :: TyCon
promotedEQDataCon :: TyCon
promotedGTDataCon :: TyCon
boxingDataCon_maybe :: TyCon -> Maybe DataCon
charTyCon :: TyCon
charDataCon :: DataCon
charTyCon_RDR :: RdrName
charTy :: Type
stringTy :: Type
charTyConName :: Name
stringTyCon_RDR :: RdrName
doubleTyCon :: TyCon
doubleDataCon :: DataCon
doubleTy :: Type
doubleTyConName :: Name
floatTyCon :: TyCon
floatDataCon :: DataCon
floatTy :: Type
floatTyConName :: Name
intTyCon :: TyCon
intDataCon :: DataCon
intTyCon_RDR :: RdrName
intDataCon_RDR :: RdrName
intTyConName :: Name
intTy :: Type
wordTyCon :: TyCon
wordDataCon :: DataCon
wordTyConName :: Name
wordTy :: Type
word8TyCon :: TyCon
word8DataCon :: DataCon
word8Ty :: Type
listTyCon :: TyCon
listTyCon_RDR :: RdrName
listTyConName :: Name
listTyConKey :: Unique
nilDataCon :: DataCon
nilDataConName :: Name
nilDataConKey :: Unique
consDataCon_RDR :: RdrName
consDataCon :: DataCon
consDataConName :: Name
promotedNilDataCon :: TyCon
promotedConsDataCon :: TyCon
mkListTy :: Type -> Type
-- | Make a *promoted* list.
mkPromotedListTy :: Kind -> [Type] -> Type
nonEmptyTyCon :: TyCon
nonEmptyTyConName :: Name
nonEmptyDataCon :: DataCon
nonEmptyDataConName :: Name
maybeTyCon :: TyCon
maybeTyConName :: Name
nothingDataCon :: DataCon
nothingDataConName :: Name
promotedNothingDataCon :: TyCon
justDataCon :: DataCon
justDataConName :: Name
promotedJustDataCon :: TyCon
mkPromotedMaybeTy :: Kind -> Maybe Type -> Type
mkMaybeTy :: Type -> Kind
isPromotedMaybeTy :: Type -> Maybe (Maybe Type)
-- | Make a tuple type. The list of types should not include any
-- RuntimeRep specifications. Boxed 1-tuples are flattened. See Note
-- [One-tuples]
mkTupleTy :: Boxity -> [Type] -> Type
-- | Make a tuple type. The list of types should not include any
-- RuntimeRep specifications. Boxed 1-tuples are *not* flattened. See
-- Note [One-tuples] and Note [Don't flatten tuples from HsSyn] in
-- GHC.Core.Make
mkTupleTy1 :: Boxity -> [Type] -> Type
-- | Build the type of a small tuple that holds the specified type of thing
-- Flattens 1-tuples. See Note [One-tuples].
mkBoxedTupleTy :: [Type] -> Type
mkTupleStr :: Boxity -> Arity -> String
tupleTyCon :: Boxity -> Arity -> TyCon
tupleDataCon :: Boxity -> Arity -> DataCon
tupleTyConName :: TupleSort -> Arity -> Name
tupleDataConName :: Boxity -> Arity -> Name
promotedTupleDataCon :: Boxity -> Arity -> TyCon
unitTyCon :: TyCon
unitDataCon :: DataCon
unitDataConId :: Id
unitTy :: Type
unitTyConKey :: Unique
soloTyCon :: TyCon
pairTyCon :: TyCon
mkPromotedPairTy :: Kind -> Kind -> Type -> Type -> Type
isPromotedPairType :: Type -> Maybe (Type, Type)
unboxedUnitTy :: Type
unboxedUnitTyCon :: TyCon
unboxedUnitDataCon :: DataCon
-- | Specialization of unboxedTupleSumKind for tuples
unboxedTupleKind :: [Type] -> Kind
-- | Specialization of unboxedTupleSumKind for sums
unboxedSumKind :: [Type] -> Kind
-- | Replaces constraint tuple names with corresponding boxed ones.
filterCTuple :: RdrName -> RdrName
cTupleTyCon :: Arity -> TyCon
cTupleTyConName :: Arity -> Name
cTupleTyConNames :: [Name]
isCTupleTyConName :: Name -> Bool
-- | If the given name is that of a constraint tuple, return its arity.
cTupleTyConNameArity_maybe :: Name -> Maybe Arity
cTupleDataCon :: Arity -> DataCon
cTupleDataConName :: Arity -> Name
cTupleDataConNames :: [Name]
cTupleSelId :: ConTag -> Arity -> Id
cTupleSelIdName :: ConTag -> Arity -> Name
anyTyCon :: TyCon
anyTy :: Type
anyTypeOfKind :: Kind -> Type
-- | Make a fake, recovery TyCon from an existing one. Used when
-- recovering from errors in type declarations
makeRecoveryTyCon :: TyCon -> TyCon
mkSumTy :: [Type] -> Type
-- | Type constructor for n-ary unboxed sum.
sumTyCon :: Arity -> TyCon
-- | Data constructor for i-th alternative of a n-ary unboxed sum.
sumDataCon :: ConTag -> Arity -> DataCon
typeSymbolKindCon :: TyCon
typeSymbolKind :: Kind
isLiftedTypeKindTyConName :: Name -> Bool
typeToTypeKind :: Kind
-- | -- type LiftedRep = 'BoxedRep 'Lifted --liftedRepTyCon :: TyCon -- |
-- type UnliftedRep = 'BoxedRep 'Unlifted --unliftedRepTyCon :: TyCon constraintKind :: Kind liftedTypeKind :: Kind unliftedTypeKind :: Kind constraintKindTyCon :: TyCon liftedTypeKindTyCon :: TyCon -- |
-- type UnliftedType = TYPE ('BoxedRep 'Unlifted)
--
unliftedTypeKindTyCon :: TyCon
constraintKindTyConName :: Name
liftedTypeKindTyConName :: Name
unliftedTypeKindTyConName :: Name
liftedRepTyConName :: Name
unliftedRepTyConName :: Name
heqTyCon :: TyCon
heqTyConName :: Name
heqClass :: Class
heqDataCon :: DataCon
eqTyCon :: TyCon
eqTyConName :: Name
eqClass :: Class
eqDataCon :: DataCon
eqTyCon_RDR :: RdrName
coercibleTyCon :: TyCon
coercibleTyConName :: Name
coercibleDataCon :: DataCon
coercibleClass :: Class
runtimeRepTyCon :: TyCon
levityTyCon :: TyCon
vecCountTyCon :: TyCon
vecElemTyCon :: TyCon
boxedRepDataConTyCon :: TyCon
runtimeRepTy :: Type
liftedRepTy :: Type
unliftedRepTy :: Type
vecRepDataConTyCon :: TyCon
tupleRepDataConTyCon :: TyCon
sumRepDataConTyCon :: TyCon
liftedDataConTyCon :: TyCon
unliftedDataConTyCon :: TyCon
liftedDataConTy :: Type
unliftedDataConTy :: Type
intRepDataConTy :: Type
int8RepDataConTy :: Type
int16RepDataConTy :: Type
int32RepDataConTy :: Type
int64RepDataConTy :: Type
wordRepDataConTy :: Type
word8RepDataConTy :: Type
word16RepDataConTy :: Type
word32RepDataConTy :: Type
word64RepDataConTy :: Type
addrRepDataConTy :: Type
floatRepDataConTy :: Type
doubleRepDataConTy :: Type
vec2DataConTy :: Type
vec4DataConTy :: Type
vec8DataConTy :: Type
vec16DataConTy :: Type
vec32DataConTy :: Type
vec64DataConTy :: Type
int8ElemRepDataConTy :: Type
int16ElemRepDataConTy :: Type
int32ElemRepDataConTy :: Type
int64ElemRepDataConTy :: Type
word8ElemRepDataConTy :: Type
word16ElemRepDataConTy :: Type
word32ElemRepDataConTy :: Type
word64ElemRepDataConTy :: Type
floatElemRepDataConTy :: Type
doubleElemRepDataConTy :: Type
multiplicityTyConName :: Name
oneDataConName :: Name
manyDataConName :: Name
multiplicityTy :: Type
multiplicityTyCon :: TyCon
oneDataCon :: DataCon
manyDataCon :: DataCon
oneDataConTy :: Type
manyDataConTy :: Type
oneDataConTyCon :: TyCon
manyDataConTyCon :: TyCon
multMulTyCon :: TyCon
unrestrictedFunTyCon :: TyCon
unrestrictedFunTyConName :: Name
integerTy :: Type
integerTyCon :: TyCon
integerTyConName :: Name
integerISDataCon :: DataCon
integerISDataConName :: Name
integerIPDataCon :: DataCon
integerIPDataConName :: Name
integerINDataCon :: DataCon
integerINDataConName :: Name
naturalTy :: Type
naturalTyCon :: TyCon
naturalTyConName :: Name
naturalNSDataCon :: DataCon
naturalNSDataConName :: Name
naturalNBDataCon :: DataCon
naturalNBDataConName :: Name
-- | GHC uses several kinds of name internally:
--
-- -- `bar` -- ( ~ ) ---- --
-- import C( T(..) ) ---- -- Here the constructors of T are not named explicitly; only -- T is named explicitly. ImpSome :: Bool -> SrcSpan -> ImpItemSpec [is_explicit] :: ImpItemSpec -> Bool [is_iloc] :: ImpItemSpec -> SrcSpan importSpecLoc :: ImportSpec -> SrcSpan importSpecModule :: ImportSpec -> ModuleName isExplicitItem :: ImpItemSpec -> Bool bestImport :: [ImportSpec] -> ImportSpec -- | Display info about the treatment of * under NoStarIsType. -- -- With StarIsType, three properties of * hold: -- -- (a) it is not an infix operator (b) it is always in scope (c) it is a -- synonym for Data.Kind.Type -- -- However, the user might not know that they are working on a module -- with NoStarIsType and write code that still assumes (a), (b), and (c), -- which actually do not hold in that module. -- -- Violation of (a) shows up in the parser. For instance, in the -- following examples, we have * not applied to enough arguments: -- -- data A :: * data F :: * -> * -- -- Violation of (b) or (c) show up in the renamer and the typechecker -- respectively. For instance: -- -- type K = Either * Bool -- -- This will parse differently depending on whether StarIsType is -- enabled, but it will parse nonetheless. With NoStarIsType it is parsed -- as a type operator, thus we have ((*) Either Bool). Now there are two -- cases to consider: -- --
-- AvailTC Eq [Eq, ==, \/=] --AvailTC :: Name -> [GreName] -> AvailInfo avail :: Name -> AvailInfo availField :: FieldLabel -> AvailInfo availTC :: Name -> [Name] -> [FieldLabel] -> AvailInfo availsToNameSet :: [AvailInfo] -> NameSet availsToNameSetWithSelectors :: [AvailInfo] -> NameSet availsToNameEnv :: [AvailInfo] -> NameEnv AvailInfo -- | Does this AvailInfo export the parent decl? This depends on the -- invariant that the parent is first if it appears at all. availExportsDecl :: AvailInfo -> Bool -- | Just the main name made available, i.e. not the available pieces of -- type or class brought into scope by the AvailInfo availName :: AvailInfo -> Name availGreName :: AvailInfo -> GreName -- | All names made available by the availability information (excluding -- overloaded selectors) availNames :: AvailInfo -> [Name] -- | Names for non-fields made available by the availability information availNonFldNames :: AvailInfo -> [Name] -- | All names made available by the availability information (including -- overloaded selectors) availNamesWithSelectors :: AvailInfo -> [Name] -- | Fields made available by the availability information availFlds :: AvailInfo -> [FieldLabel] -- | Names and fields made available by the availability information. availGreNames :: AvailInfo -> [GreName] -- | Names and fields made available by the availability information, other -- than the main decl itself. availSubordinateGreNames :: AvailInfo -> [GreName] -- | Compare lexicographically stableAvailCmp :: AvailInfo -> AvailInfo -> Ordering plusAvail :: AvailInfo -> AvailInfo -> AvailInfo -- | trims an AvailInfo to keep only a single name trimAvail :: AvailInfo -> Name -> AvailInfo -- | filters an AvailInfo by the given predicate filterAvail :: (Name -> Bool) -> AvailInfo -> [AvailInfo] -> [AvailInfo] -- | filters AvailInfos by the given predicate filterAvails :: (Name -> Bool) -> [AvailInfo] -> [AvailInfo] -- | Combines AvailInfos from the same family avails may -- have several items with the same availName E.g import Ix( Ix(..), -- index ) will give Ix(Ix,index,range) and Ix(index) We want to combine -- these; addAvail does that nubAvails :: [AvailInfo] -> [AvailInfo] -- | Used where we may have an ordinary name or a record field label. See -- Note [GreNames] in GHC.Types.Name.Reader. data GreName NormalGreName :: Name -> GreName FieldGreName :: FieldLabel -> GreName -- | A Name for internal use, but not for output to the user. For -- fields, the OccName will be the selector. See Note [GreNames] -- in GHC.Types.Name.Reader. greNameMangledName :: GreName -> Name -- | A Name suitable for output to the user. For fields, the -- OccName will be the field label. See Note [GreNames] in -- GHC.Types.Name.Reader. greNamePrintableName :: GreName -> Name greNameSrcSpan :: GreName -> SrcSpan greNameFieldLabel :: GreName -> Maybe FieldLabel partitionGreNames :: [GreName] -> ([Name], [FieldLabel]) stableGreNameCmp :: GreName -> GreName -> Ordering instance GHC.Classes.Eq GHC.Types.Avail.GreName instance Data.Data.Data GHC.Types.Avail.GreName instance Data.Data.Data GHC.Types.Avail.AvailInfo instance GHC.Classes.Eq GHC.Types.Avail.AvailInfo instance GHC.Utils.Outputable.Outputable GHC.Types.Avail.AvailInfo instance GHC.Utils.Binary.Binary GHC.Types.Avail.AvailInfo instance GHC.Utils.Outputable.Outputable GHC.Types.Avail.GreName instance GHC.Types.Name.Occurrence.HasOccName GHC.Types.Avail.GreName instance GHC.Utils.Binary.Binary GHC.Types.Avail.GreName -- | Boolean formulas without quantifiers and without negation. Such a -- formula consists of variables, conjunctions (and), and disjunctions -- (or). -- -- This module is used to represent minimal complete definitions for -- classes. module GHC.Data.BooleanFormula data BooleanFormula a Var :: a -> BooleanFormula a And :: [LBooleanFormula a] -> BooleanFormula a Or :: [LBooleanFormula a] -> BooleanFormula a Parens :: LBooleanFormula a -> BooleanFormula a type LBooleanFormula a = LocatedL (BooleanFormula a) mkFalse :: BooleanFormula a mkTrue :: BooleanFormula a mkAnd :: Eq a => [LBooleanFormula a] -> BooleanFormula a mkOr :: Eq a => [LBooleanFormula a] -> BooleanFormula a mkVar :: a -> BooleanFormula a isFalse :: BooleanFormula a -> Bool isTrue :: BooleanFormula a -> Bool eval :: (a -> Bool) -> BooleanFormula a -> Bool simplify :: Eq a => (a -> Maybe Bool) -> BooleanFormula a -> BooleanFormula a isUnsatisfied :: Eq a => (a -> Bool) -> BooleanFormula a -> Maybe (BooleanFormula a) implies :: Uniquable a => BooleanFormula a -> BooleanFormula a -> Bool impliesAtom :: Eq a => BooleanFormula a -> a -> Bool pprBooleanFormula :: (Rational -> a -> SDoc) -> Rational -> BooleanFormula a -> SDoc pprBooleanFormulaNice :: Outputable a => BooleanFormula a -> SDoc instance Data.Traversable.Traversable GHC.Data.BooleanFormula.BooleanFormula instance Data.Foldable.Foldable GHC.Data.BooleanFormula.BooleanFormula instance GHC.Base.Functor GHC.Data.BooleanFormula.BooleanFormula instance Data.Data.Data a => Data.Data.Data (GHC.Data.BooleanFormula.BooleanFormula a) instance GHC.Classes.Eq a => GHC.Classes.Eq (GHC.Data.BooleanFormula.BooleanFormula a) instance GHC.Utils.Outputable.OutputableBndr a => GHC.Utils.Outputable.Outputable (GHC.Data.BooleanFormula.BooleanFormula a) instance GHC.Utils.Binary.Binary a => GHC.Utils.Binary.Binary (GHC.Data.BooleanFormula.BooleanFormula a) module GHC.Parser.Annotation -- | Exact print annotations exist so that tools can perform source to -- source conversions of Haskell code. They are used to keep track of the -- various syntactic keywords that are not otherwise captured in the AST. -- -- The wiki page describing this feature is -- https://gitlab.haskell.org/ghc/ghc/wikis/api-annotations -- https://gitlab.haskell.org/ghc/ghc/-/wikis/implementing-trees-that-grow/in-tree-api-annotations -- -- Note: in general the names of these are taken from the corresponding -- token, unless otherwise noted See note [exact print annotations] above -- for details of the usage data AnnKeywordId AnnAnyclass :: AnnKeywordId AnnAs :: AnnKeywordId AnnAt :: AnnKeywordId -- | ! AnnBang :: AnnKeywordId -- | '`' AnnBackquote :: AnnKeywordId AnnBy :: AnnKeywordId -- | case or lambda case AnnCase :: AnnKeywordId AnnClass :: AnnKeywordId -- | '#)' or '#-}' etc AnnClose :: AnnKeywordId -- | '|)' AnnCloseB :: AnnKeywordId -- | '|)', unicode variant AnnCloseBU :: AnnKeywordId -- | '}' AnnCloseC :: AnnKeywordId -- | '|]' AnnCloseQ :: AnnKeywordId -- | '|]', unicode variant AnnCloseQU :: AnnKeywordId -- | ')' AnnCloseP :: AnnKeywordId -- | '#)' AnnClosePH :: AnnKeywordId -- | ']' AnnCloseS :: AnnKeywordId AnnColon :: AnnKeywordId -- | as a list separator AnnComma :: AnnKeywordId -- | in a RdrName for a tuple AnnCommaTuple :: AnnKeywordId -- | '=>' AnnDarrow :: AnnKeywordId -- | '=>', unicode variant AnnDarrowU :: AnnKeywordId AnnData :: AnnKeywordId -- | '::' AnnDcolon :: AnnKeywordId -- | '::', unicode variant AnnDcolonU :: AnnKeywordId AnnDefault :: AnnKeywordId AnnDeriving :: AnnKeywordId AnnDo :: AnnKeywordId -- | . AnnDot :: AnnKeywordId -- | '..' AnnDotdot :: AnnKeywordId AnnElse :: AnnKeywordId AnnEqual :: AnnKeywordId AnnExport :: AnnKeywordId AnnFamily :: AnnKeywordId AnnForall :: AnnKeywordId -- | Unicode variant AnnForallU :: AnnKeywordId AnnForeign :: AnnKeywordId -- | for function name in matches where there are multiple equations for -- the function. AnnFunId :: AnnKeywordId AnnGroup :: AnnKeywordId -- | for CType AnnHeader :: AnnKeywordId AnnHiding :: AnnKeywordId AnnIf :: AnnKeywordId AnnImport :: AnnKeywordId AnnIn :: AnnKeywordId -- | 'infix' or 'infixl' or 'infixr' AnnInfix :: AnnKeywordId AnnInstance :: AnnKeywordId AnnLam :: AnnKeywordId -- | '<-' AnnLarrow :: AnnKeywordId -- | '<-', unicode variant AnnLarrowU :: AnnKeywordId AnnLet :: AnnKeywordId -- | The ⊸ unicode arrow AnnLollyU :: AnnKeywordId AnnMdo :: AnnKeywordId -- | - AnnMinus :: AnnKeywordId AnnModule :: AnnKeywordId AnnNewtype :: AnnKeywordId -- | where a name loses its location in the AST, this carries it AnnName :: AnnKeywordId AnnOf :: AnnKeywordId -- | '{-# DEPRECATED' etc. Opening of pragmas where the capitalisation of -- the string can be changed by the user. The actual text used is stored -- in a SourceText on the relevant pragma item. AnnOpen :: AnnKeywordId -- | '(|' AnnOpenB :: AnnKeywordId -- | '(|', unicode variant AnnOpenBU :: AnnKeywordId -- | '{' AnnOpenC :: AnnKeywordId -- | '[e|' or '[e||' AnnOpenE :: AnnKeywordId -- | '[|' AnnOpenEQ :: AnnKeywordId -- | '[|', unicode variant AnnOpenEQU :: AnnKeywordId -- | '(' AnnOpenP :: AnnKeywordId -- | '[' AnnOpenS :: AnnKeywordId -- | '(#' AnnOpenPH :: AnnKeywordId -- | prefix $ -- TemplateHaskell AnnDollar :: AnnKeywordId -- | prefix $$ -- TemplateHaskell AnnDollarDollar :: AnnKeywordId AnnPackageName :: AnnKeywordId AnnPattern :: AnnKeywordId -- | % -- for HsExplicitMult AnnPercent :: AnnKeywordId -- | '%1' -- for HsLinearArrow AnnPercentOne :: AnnKeywordId AnnProc :: AnnKeywordId AnnQualified :: AnnKeywordId -- | -> AnnRarrow :: AnnKeywordId -- | ->, unicode variant AnnRarrowU :: AnnKeywordId AnnRec :: AnnKeywordId AnnRole :: AnnKeywordId AnnSafe :: AnnKeywordId -- | ';' AnnSemi :: AnnKeywordId -- | ''' AnnSimpleQuote :: AnnKeywordId AnnSignature :: AnnKeywordId -- | static AnnStatic :: AnnKeywordId AnnStock :: AnnKeywordId AnnThen :: AnnKeywordId -- | double ''' AnnThTyQuote :: AnnKeywordId -- | ~ AnnTilde :: AnnKeywordId AnnType :: AnnKeywordId -- | () for types AnnUnit :: AnnKeywordId AnnUsing :: AnnKeywordId -- | e.g. INTEGER AnnVal :: AnnKeywordId -- | String value, will need quotes when output AnnValStr :: AnnKeywordId -- | '|' AnnVbar :: AnnKeywordId -- | via AnnVia :: AnnKeywordId AnnWhere :: AnnKeywordId -- | -< Annlarrowtail :: AnnKeywordId -- | -<, unicode variant AnnlarrowtailU :: AnnKeywordId -- | -> Annrarrowtail :: AnnKeywordId -- | ->, unicode variant AnnrarrowtailU :: AnnKeywordId -- | -<< AnnLarrowtail :: AnnKeywordId -- | -<<, unicode variant AnnLarrowtailU :: AnnKeywordId -- | >>- AnnRarrowtail :: AnnKeywordId -- | >>-, unicode variant AnnRarrowtailU :: AnnKeywordId data EpaComment EpaComment :: EpaCommentTok -> RealSrcSpan -> EpaComment [ac_tok] :: EpaComment -> EpaCommentTok -- | The location of the prior token, used in exact printing. The -- EpaComment appears as an LEpaComment containing its -- location. The difference between the end of the prior token and the -- start of this location is used for the spacing when exact printing the -- comment. [ac_prior_tok] :: EpaComment -> RealSrcSpan data EpaCommentTok -- | something beginning '-- |' EpaDocCommentNext :: String -> EpaCommentTok -- | something beginning '-- ^' EpaDocCommentPrev :: String -> EpaCommentTok -- | something beginning '-- $' EpaDocCommentNamed :: String -> EpaCommentTok -- | a section heading EpaDocSection :: Int -> String -> EpaCommentTok -- | doc options (prune, ignore-exports, etc) EpaDocOptions :: String -> EpaCommentTok -- | comment starting by "--" EpaLineComment :: String -> EpaCommentTok -- | comment in {- -} EpaBlockComment :: String -> EpaCommentTok -- | empty comment, capturing location of EOF EpaEofComment :: EpaCommentTok -- | Certain tokens can have alternate representations when unicode syntax -- is enabled. This flag is attached to those tokens in the lexer so that -- the original source representation can be reproduced in the -- corresponding EpAnnotation data IsUnicodeSyntax UnicodeSyntax :: IsUnicodeSyntax NormalSyntax :: IsUnicodeSyntax -- | Convert a normal annotation into its unicode equivalent one unicodeAnn :: AnnKeywordId -> AnnKeywordId -- | Some template haskell tokens have two variants, one with an e -- the other not: -- --
-- [| or [e| -- [|| or [e|| ---- -- This type indicates whether the e is present or not. data HasE HasE :: HasE NoE :: HasE -- | Captures an annotation, storing the AnnKeywordId and -- its location. The parser only ever inserts EpaLocation -- fields with a RealSrcSpan being the original location of the -- annotation in the source file. The EpaLocation can -- also store a delta position if the AST has been modified and needs to -- be pretty printed again. The usual way an AddEpAnn is created -- is using the mj ("make jump") function, and then it can be -- inserted into the appropriate annotation. data AddEpAnn AddEpAnn :: AnnKeywordId -> EpaLocation -> AddEpAnn -- | The anchor for an AnnKeywordId. The Parser inserts the -- EpaSpan variant, giving the exact location of the -- original item in the parsed source. This can be replaced by the -- EpaDelta version, to provide a position for the item -- relative to the end of the previous item in the source. This is useful -- when editing an AST prior to exact printing the changed one. The list -- of comments in the EpaDelta variant captures any -- comments between the prior output and the thing being marked here, -- since we cannot otherwise sort the relative order. data EpaLocation EpaSpan :: !RealSrcSpan -> EpaLocation EpaDelta :: !DeltaPos -> ![LEpaComment] -> EpaLocation -- | Used in the parser only, extract the SrcSpan from an -- EpaLocation. The parser will never insert a DeltaPos, so -- the partial function is safe. epaLocationRealSrcSpan :: EpaLocation -> RealSrcSpan epaLocationFromSrcAnn :: SrcAnn ann -> EpaLocation -- | Spacing between output items when exact printing. It captures the -- spacing from the current print position on the page to the position -- required for the thing about to be printed. This is either on the same -- line in which case is is simply the number of spaces to emit, or it is -- some number of lines down, with a given column offset. The exact -- printing algorithm keeps track of the column offset pertaining to the -- current anchor position, so the deltaColumn is the additional -- spaces to add in this case. See -- https://gitlab.haskell.org/ghc/ghc/wikis/api-annotations for -- details. data DeltaPos SameLine :: !Int -> DeltaPos [deltaColumn] :: DeltaPos -> !Int DifferentLine :: !Int -> !Int -> DeltaPos -- | deltaLine should always be > 0 [deltaLine] :: DeltaPos -> !Int [deltaColumn] :: DeltaPos -> !Int -- | Smart constructor for a DeltaPos. It preserves the invariant -- that for the DifferentLine constructor deltaLine is -- always > 0. deltaPos :: Int -> Int -> DeltaPos getDeltaLine :: DeltaPos -> Int -- | The exact print annotations (EPAs) are kept in the HsSyn AST for the -- GhcPs phase. We do not always have EPAs though, only for code that has -- been parsed as they do not exist for generated code. This type -- captures that they may be missing. -- -- A goal of the annotations is that an AST can be edited, including -- moving subtrees from one place to another, duplicating them, and so -- on. This means that each fragment must be self-contained. To this end, -- each annotated fragment keeps track of the anchor position it was -- originally captured at, being simply the start span of the topmost -- element of the ast fragment. This gives us a way to later re-calculate -- all Located items in this layer of the AST, as well as any annotations -- captured. The comments associated with the AST fragment are also -- captured here. -- -- The ann type parameter allows this general structure to be -- specialised to the specific set of locations of original exact print -- annotation elements. So for HsLet we have -- -- type instance XLet GhcPs = EpAnn AnnsLet data AnnsLet = AnnsLet { -- alLet :: EpaLocation, alIn :: EpaLocation } deriving Data -- -- The spacing between the items under the scope of a given EpAnn is -- normally derived from the original Anchor. But if a sub-element -- is not in its original position, the required spacing can be directly -- captured in the anchor_op field of the entry Anchor. -- This allows us to freely move elements around, and stitch together new -- AST fragments out of old ones, and have them still printed out in a -- precise way. data EpAnn ann EpAnn :: !Anchor -> !ann -> !EpAnnComments -> EpAnn ann -- | Base location for the start of the syntactic element holding the -- annotations. [entry] :: EpAnn ann -> !Anchor -- | Annotations added by the Parser [anns] :: EpAnn ann -> !ann -- | Comments enclosed in the SrcSpan of the element this EpAnn is -- attached to [comments] :: EpAnn ann -> !EpAnnComments -- | No Annotation for generated code, e.g. from TH, deriving, etc. EpAnnNotUsed :: EpAnn ann -- | An Anchor records the base location for the start of the -- syntactic element holding the annotations, and is used as the point of -- reference for calculating delta positions for contained annotations. -- It is also normally used as the reference point for the spacing of the -- element relative to its container. If it is moved, that relationship -- is tracked in the anchor_op instead. data Anchor Anchor :: RealSrcSpan -> AnchorOperation -> Anchor -- | Base location for the start of the syntactic element holding the -- annotations. [anchor] :: Anchor -> RealSrcSpan [anchor_op] :: Anchor -> AnchorOperation -- | If tools modify the parsed source, the MovedAnchor variant can -- directly provide the spacing for this item relative to the previous -- one when printing. This allows AST fragments with a particular anchor -- to be freely moved, without worrying about recalculating the -- appropriate anchor span. data AnchorOperation UnchangedAnchor :: AnchorOperation MovedAnchor :: DeltaPos -> AnchorOperation spanAsAnchor :: SrcSpan -> Anchor realSpanAsAnchor :: RealSrcSpan -> Anchor -- | Short form for EpAnnNotUsed noAnn :: EpAnn a -- | When we are parsing we add comments that belong a particular AST -- element, and print them together with the element, interleaving them -- into the output stream. But when editing the AST to move fragments -- around it is useful to be able to first separate the comments into -- those occuring before the AST element and those following it. The -- EpaCommentsBalanced constructor is used to do this. The GHC -- parser will only insert the EpaComments form. data EpAnnComments EpaComments :: ![LEpaComment] -> EpAnnComments [priorComments] :: EpAnnComments -> ![LEpaComment] EpaCommentsBalanced :: ![LEpaComment] -> ![LEpaComment] -> EpAnnComments [priorComments] :: EpAnnComments -> ![LEpaComment] [followingComments] :: EpAnnComments -> ![LEpaComment] type LEpaComment = GenLocated Anchor EpaComment emptyComments :: EpAnnComments getFollowingComments :: EpAnnComments -> [LEpaComment] setFollowingComments :: EpAnnComments -> [LEpaComment] -> EpAnnComments setPriorComments :: EpAnnComments -> [LEpaComment] -> EpAnnComments type EpAnnCO = EpAnn NoEpAnns " Api Annotations for comments only" type LocatedA = GenLocated SrcSpanAnnA type LocatedL = GenLocated SrcSpanAnnL type LocatedC = GenLocated SrcSpanAnnC type LocatedN = GenLocated SrcSpanAnnN -- | General representation of a GenLocated type carrying a -- parameterised annotation type. type LocatedAn an = GenLocated (SrcAnn an) type LocatedP = GenLocated SrcSpanAnnP type SrcSpanAnnA = SrcAnn AnnListItem type SrcSpanAnnL = SrcAnn AnnList type SrcSpanAnnP = SrcAnn AnnPragma type SrcSpanAnnC = SrcAnn AnnContext type SrcSpanAnnN = SrcAnn NameAnn -- | The 'SrcSpanAnn'' type wraps a normal SrcSpan, together with an -- extra annotation type. This is mapped to a specific GenLocated -- usage in the AST through the XRec and Anno type -- families. data SrcSpanAnn' a SrcSpanAnn :: !a -> !SrcSpan -> SrcSpanAnn' a [ann] :: SrcSpanAnn' a -> !a [locA] :: SrcSpanAnn' a -> !SrcSpan -- | We mostly use 'SrcSpanAnn'' with an 'EpAnn'' type SrcAnn ann = SrcSpanAnn' (EpAnn ann) -- | Annotation for items appearing in a list. They can have one or more -- trailing punctuations items, such as commas or semicolons. data AnnListItem AnnListItem :: [TrailingAnn] -> AnnListItem [lann_trailing] :: AnnListItem -> [TrailingAnn] -- | Annotation for the "container" of a list. This captures surrounding -- items such as braces if present, and introductory keywords such as -- 'where'. data AnnList AnnList :: Maybe Anchor -> Maybe AddEpAnn -> Maybe AddEpAnn -> [AddEpAnn] -> [TrailingAnn] -> AnnList -- | start point of a list having layout [al_anchor] :: AnnList -> Maybe Anchor [al_open] :: AnnList -> Maybe AddEpAnn [al_close] :: AnnList -> Maybe AddEpAnn -- | context, such as 'where' keyword [al_rest] :: AnnList -> [AddEpAnn] -- | items appearing after the list, such as '=>' for a context [al_trailing] :: AnnList -> [TrailingAnn] -- | exact print annotation for an item having surrounding "brackets", such -- as tuples or lists data AnnParen AnnParen :: ParenType -> EpaLocation -> EpaLocation -> AnnParen [ap_adornment] :: AnnParen -> ParenType [ap_open] :: AnnParen -> EpaLocation [ap_close] :: AnnParen -> EpaLocation -- | Detail of the "brackets" used in an AnnParen exact print -- annotation. data ParenType -- | '(', ')' AnnParens :: ParenType -- | '(#', '#)' AnnParensHash :: ParenType -- | '[', ']' AnnParensSquare :: ParenType -- | Maps the ParenType to the related opening and closing -- AnnKeywordId. Used when actually printing the item. parenTypeKws :: ParenType -> (AnnKeywordId, AnnKeywordId) -- | exact print annotation used for capturing the locations of annotations -- in pragmas. data AnnPragma AnnPragma :: AddEpAnn -> AddEpAnn -> [AddEpAnn] -> AnnPragma [apr_open] :: AnnPragma -> AddEpAnn [apr_close] :: AnnPragma -> AddEpAnn [apr_rest] :: AnnPragma -> [AddEpAnn] -- | Exact print annotation for the Context data type. data AnnContext AnnContext :: Maybe (IsUnicodeSyntax, EpaLocation) -> [EpaLocation] -> [EpaLocation] -> AnnContext -- | location and encoding of the '=>', if present. [ac_darrow] :: AnnContext -> Maybe (IsUnicodeSyntax, EpaLocation) -- | zero or more opening parentheses. [ac_open] :: AnnContext -> [EpaLocation] -- | zero or more closing parentheses. [ac_close] :: AnnContext -> [EpaLocation] -- | exact print annotations for a RdrName. There are many kinds -- of adornment that can be attached to a given RdrName. This -- type captures them, as detailed on the individual constructors. data NameAnn -- | Used for a name with an adornment, so `foo`, (bar) NameAnn :: NameAdornment -> EpaLocation -> EpaLocation -> EpaLocation -> [TrailingAnn] -> NameAnn [nann_adornment] :: NameAnn -> NameAdornment [nann_open] :: NameAnn -> EpaLocation [nann_name] :: NameAnn -> EpaLocation [nann_close] :: NameAnn -> EpaLocation [nann_trailing] :: NameAnn -> [TrailingAnn] -- | Used for (,,,), or @()# NameAnnCommas :: NameAdornment -> EpaLocation -> [EpaLocation] -> EpaLocation -> [TrailingAnn] -> NameAnn [nann_adornment] :: NameAnn -> NameAdornment [nann_open] :: NameAnn -> EpaLocation [nann_commas] :: NameAnn -> [EpaLocation] [nann_close] :: NameAnn -> EpaLocation [nann_trailing] :: NameAnn -> [TrailingAnn] -- | Used for (), (##), [] NameAnnOnly :: NameAdornment -> EpaLocation -> EpaLocation -> [TrailingAnn] -> NameAnn [nann_adornment] :: NameAnn -> NameAdornment [nann_open] :: NameAnn -> EpaLocation [nann_close] :: NameAnn -> EpaLocation [nann_trailing] :: NameAnn -> [TrailingAnn] -- | Used for ->, as an identifier NameAnnRArrow :: EpaLocation -> [TrailingAnn] -> NameAnn [nann_name] :: NameAnn -> EpaLocation [nann_trailing] :: NameAnn -> [TrailingAnn] -- | Used for an item with a leading '. The annotation for -- unquoted item is stored in nann_quoted. NameAnnQuote :: EpaLocation -> SrcSpanAnnN -> [TrailingAnn] -> NameAnn [nann_quote] :: NameAnn -> EpaLocation [nann_quoted] :: NameAnn -> SrcSpanAnnN [nann_trailing] :: NameAnn -> [TrailingAnn] -- | Used when adding a TrailingAnn to an existing LocatedN -- which has no Api Annotation (via the EpAnnNotUsed constructor. NameAnnTrailing :: [TrailingAnn] -> NameAnn [nann_trailing] :: NameAnn -> [TrailingAnn] -- | A NameAnn can capture the locations of surrounding adornments, -- such as parens or backquotes. This data type identifies what -- particular pair are being used. data NameAdornment -- | '(' ')' NameParens :: NameAdornment -- | '(#' '#)' NameParensHash :: NameAdornment -- | '`' NameBackquotes :: NameAdornment -- | '[' ']' NameSquare :: NameAdornment data NoEpAnns NoEpAnns :: NoEpAnns -- | Captures the sort order of sub elements. This is needed when the -- sub-elements have been split (as in a HsLocalBind which holds separate -- binds and sigs) or for infix patterns where the order has been -- re-arranged. It is captured explicitly so that after the Delta phase a -- SrcSpan is used purely as an index into the annotations, allowing -- transformations of the AST including the introduction of new Located -- items or re-arranging existing ones. data AnnSortKey NoAnnSortKey :: AnnSortKey AnnSortKey :: [RealSrcSpan] -> AnnSortKey -- | Captures the location of punctuation occuring between items, normally -- in a list. It is captured as a trailing annotation. data TrailingAnn -- | Trailing ';' AddSemiAnn :: EpaLocation -> TrailingAnn -- | Trailing ',' AddCommaAnn :: EpaLocation -> TrailingAnn -- | Trailing '|' AddVbarAnn :: EpaLocation -> TrailingAnn -- | Trailing -> AddRarrowAnn :: EpaLocation -> TrailingAnn -- | Trailing ->, unicode variant AddRarrowAnnU :: EpaLocation -> TrailingAnn -- | Trailing ⊸ AddLollyAnnU :: EpaLocation -> TrailingAnn -- | Helper function used in the parser to add a TrailingAnn items -- to an existing annotation. addTrailingAnnToA :: SrcSpan -> TrailingAnn -> EpAnnComments -> EpAnn AnnListItem -> EpAnn AnnListItem -- | Helper function used in the parser to add a TrailingAnn items -- to an existing annotation. addTrailingAnnToL :: SrcSpan -> TrailingAnn -> EpAnnComments -> EpAnn AnnList -> EpAnn AnnList -- | Helper function used in the parser to add a comma location to an -- existing annotation. addTrailingCommaToN :: SrcSpan -> EpAnn NameAnn -> EpaLocation -> EpAnn NameAnn -- | Helper function (temporary) during transition of names Discards any -- annotations la2na :: SrcSpanAnn' a -> SrcSpanAnnN -- | Helper function (temporary) during transition of names Discards any -- annotations na2la :: SrcSpanAnn' a -> SrcAnn ann n2l :: LocatedN a -> LocatedA a -- | Helper function (temporary) during transition of names Discards any -- annotations l2n :: LocatedAn a1 a2 -> LocatedN a2 l2l :: SrcSpanAnn' a -> SrcAnn ann -- | Helper function (temporary) during transition of names Discards any -- annotations la2la :: LocatedAn ann1 a2 -> LocatedAn ann2 a2 reLoc :: LocatedAn a e -> Located e reLocA :: Located e -> LocatedAn ann e reLocL :: LocatedN e -> LocatedA e reLocC :: LocatedN e -> LocatedC e reLocN :: LocatedN a -> Located a la2r :: SrcSpanAnn' a -> RealSrcSpan realSrcSpan :: SrcSpan -> RealSrcSpan extraToAnnList :: AnnList -> [AddEpAnn] -> AnnList reAnn :: [TrailingAnn] -> EpAnnComments -> Located a -> LocatedA a reAnnL :: ann -> EpAnnComments -> Located e -> GenLocated (SrcAnn ann) e reAnnC :: AnnContext -> EpAnnComments -> Located a -> LocatedC a addAnns :: EpAnn [AddEpAnn] -> [AddEpAnn] -> EpAnnComments -> EpAnn [AddEpAnn] addAnnsA :: SrcSpanAnnA -> [TrailingAnn] -> EpAnnComments -> SrcSpanAnnA -- | The annotations need to all come after the anchor. Make sure this is -- the case. widenSpan :: SrcSpan -> [AddEpAnn] -> SrcSpan widenAnchor :: Anchor -> [AddEpAnn] -> Anchor widenAnchorR :: Anchor -> RealSrcSpan -> Anchor widenLocatedAn :: SrcSpanAnn' an -> [AddEpAnn] -> SrcSpanAnn' an getLocAnn :: Located a -> SrcSpanAnnA epAnnAnns :: EpAnn [AddEpAnn] -> [AddEpAnn] epAnnAnnsL :: EpAnn a -> [a] annParen2AddEpAnn :: EpAnn AnnParen -> [AddEpAnn] epAnnComments :: EpAnn an -> EpAnnComments sortLocatedA :: [GenLocated (SrcSpanAnn' a) e] -> [GenLocated (SrcSpanAnn' a) e] mapLocA :: (a -> b) -> GenLocated SrcSpan a -> GenLocated (SrcAnn ann) b combineLocsA :: Semigroup a => GenLocated (SrcAnn a) e1 -> GenLocated (SrcAnn a) e2 -> SrcAnn a combineSrcSpansA :: Semigroup a => SrcAnn a -> SrcAnn a -> SrcAnn a -- | Combine locations from two Located things and add them to a -- third thing addCLocA :: GenLocated (SrcSpanAnn' a) e1 -> GenLocated SrcSpan e2 -> e3 -> GenLocated (SrcAnn ann) e3 addCLocAA :: GenLocated (SrcSpanAnn' a1) e1 -> GenLocated (SrcSpanAnn' a2) e2 -> e3 -> GenLocated (SrcAnn ann) e3 noLocA :: a -> LocatedAn an a getLocA :: GenLocated (SrcSpanAnn' a) e -> SrcSpan noSrcSpanA :: SrcAnn ann noAnnSrcSpan :: SrcSpan -> SrcAnn ann noComments :: EpAnnCO comment :: RealSrcSpan -> EpAnnComments -> EpAnnCO -- | Add additional comments to a SrcAnn, used for manipulating the -- AST prior to exact printing the changed one. addCommentsToSrcAnn :: Monoid ann => SrcAnn ann -> EpAnnComments -> SrcAnn ann -- | Replace any existing comments on a SrcAnn, used for -- manipulating the AST prior to exact printing the changed one. setCommentsSrcAnn :: Monoid ann => SrcAnn ann -> EpAnnComments -> SrcAnn ann -- | Add additional comments, used for manipulating the AST prior to exact -- printing the changed one. addCommentsToEpAnn :: Monoid a => SrcSpan -> EpAnn a -> EpAnnComments -> EpAnn a -- | Replace any existing comments, used for manipulating the AST prior to -- exact printing the changed one. setCommentsEpAnn :: Monoid a => SrcSpan -> EpAnn a -> EpAnnComments -> EpAnn a -- | Transfer comments and trailing items from the annotations in the first -- SrcSpanAnnA argument to those in the second. transferAnnsA :: SrcSpanAnnA -> SrcSpanAnnA -> (SrcSpanAnnA, SrcSpanAnnA) -- | Remove the exact print annotations payload, leaving only the anchor -- and comments. commentsOnlyA :: Monoid ann => SrcAnn ann -> SrcAnn ann -- | Remove the comments, leaving the exact print annotations payload removeCommentsA :: SrcAnn ann -> SrcAnn ann placeholderRealSpan :: RealSrcSpan instance GHC.Show.Show GHC.Parser.Annotation.AnnKeywordId instance Data.Data.Data GHC.Parser.Annotation.AnnKeywordId instance GHC.Classes.Ord GHC.Parser.Annotation.AnnKeywordId instance GHC.Classes.Eq GHC.Parser.Annotation.AnnKeywordId instance GHC.Show.Show GHC.Parser.Annotation.IsUnicodeSyntax instance Data.Data.Data GHC.Parser.Annotation.IsUnicodeSyntax instance GHC.Classes.Ord GHC.Parser.Annotation.IsUnicodeSyntax instance GHC.Classes.Eq GHC.Parser.Annotation.IsUnicodeSyntax instance GHC.Show.Show GHC.Parser.Annotation.HasE instance Data.Data.Data GHC.Parser.Annotation.HasE instance GHC.Classes.Ord GHC.Parser.Annotation.HasE instance GHC.Classes.Eq GHC.Parser.Annotation.HasE instance GHC.Show.Show GHC.Parser.Annotation.EpaCommentTok instance Data.Data.Data GHC.Parser.Annotation.EpaCommentTok instance GHC.Classes.Ord GHC.Parser.Annotation.EpaCommentTok instance GHC.Classes.Eq GHC.Parser.Annotation.EpaCommentTok instance GHC.Show.Show GHC.Parser.Annotation.EpaComment instance Data.Data.Data GHC.Parser.Annotation.EpaComment instance GHC.Classes.Ord GHC.Parser.Annotation.EpaComment instance GHC.Classes.Eq GHC.Parser.Annotation.EpaComment instance Data.Data.Data GHC.Parser.Annotation.DeltaPos instance GHC.Classes.Ord GHC.Parser.Annotation.DeltaPos instance GHC.Classes.Eq GHC.Parser.Annotation.DeltaPos instance GHC.Show.Show GHC.Parser.Annotation.DeltaPos instance GHC.Show.Show GHC.Parser.Annotation.AnchorOperation instance GHC.Classes.Eq GHC.Parser.Annotation.AnchorOperation instance Data.Data.Data GHC.Parser.Annotation.AnchorOperation instance GHC.Show.Show GHC.Parser.Annotation.Anchor instance GHC.Classes.Eq GHC.Parser.Annotation.Anchor instance Data.Data.Data GHC.Parser.Annotation.Anchor instance GHC.Classes.Eq GHC.Parser.Annotation.EpAnnComments instance Data.Data.Data GHC.Parser.Annotation.EpAnnComments instance GHC.Base.Functor GHC.Parser.Annotation.EpAnn instance GHC.Classes.Eq ann => GHC.Classes.Eq (GHC.Parser.Annotation.EpAnn ann) instance Data.Data.Data ann => Data.Data.Data (GHC.Parser.Annotation.EpAnn ann) instance GHC.Classes.Ord GHC.Parser.Annotation.EpaLocation instance GHC.Classes.Eq GHC.Parser.Annotation.EpaLocation instance Data.Data.Data GHC.Parser.Annotation.EpaLocation instance GHC.Classes.Eq GHC.Parser.Annotation.AddEpAnn instance Data.Data.Data GHC.Parser.Annotation.AddEpAnn instance GHC.Classes.Eq a => GHC.Classes.Eq (GHC.Parser.Annotation.SrcSpanAnn' a) instance Data.Data.Data a => Data.Data.Data (GHC.Parser.Annotation.SrcSpanAnn' a) instance GHC.Classes.Ord GHC.Parser.Annotation.TrailingAnn instance GHC.Classes.Eq GHC.Parser.Annotation.TrailingAnn instance Data.Data.Data GHC.Parser.Annotation.TrailingAnn instance GHC.Classes.Eq GHC.Parser.Annotation.AnnListItem instance Data.Data.Data GHC.Parser.Annotation.AnnListItem instance GHC.Classes.Eq GHC.Parser.Annotation.AnnList instance Data.Data.Data GHC.Parser.Annotation.AnnList instance Data.Data.Data GHC.Parser.Annotation.ParenType instance GHC.Classes.Ord GHC.Parser.Annotation.ParenType instance GHC.Classes.Eq GHC.Parser.Annotation.ParenType instance Data.Data.Data GHC.Parser.Annotation.AnnParen instance Data.Data.Data GHC.Parser.Annotation.AnnContext instance Data.Data.Data GHC.Parser.Annotation.NameAdornment instance GHC.Classes.Ord GHC.Parser.Annotation.NameAdornment instance GHC.Classes.Eq GHC.Parser.Annotation.NameAdornment instance GHC.Classes.Eq GHC.Parser.Annotation.NameAnn instance Data.Data.Data GHC.Parser.Annotation.NameAnn instance GHC.Classes.Eq GHC.Parser.Annotation.AnnPragma instance Data.Data.Data GHC.Parser.Annotation.AnnPragma instance GHC.Classes.Eq GHC.Parser.Annotation.AnnSortKey instance Data.Data.Data GHC.Parser.Annotation.AnnSortKey instance GHC.Classes.Ord GHC.Parser.Annotation.NoEpAnns instance GHC.Classes.Eq GHC.Parser.Annotation.NoEpAnns instance Data.Data.Data GHC.Parser.Annotation.NoEpAnns instance GHC.Base.Semigroup GHC.Parser.Annotation.AnnSortKey instance GHC.Base.Monoid GHC.Parser.Annotation.AnnSortKey instance GHC.Utils.Outputable.Outputable GHC.Parser.Annotation.AnnSortKey instance GHC.Utils.Outputable.Outputable GHC.Parser.Annotation.AnnPragma instance GHC.Base.Semigroup GHC.Parser.Annotation.NameAnn instance GHC.Base.Monoid GHC.Parser.Annotation.NameAnn instance GHC.Utils.Outputable.Outputable GHC.Parser.Annotation.NameAnn instance GHC.Utils.Outputable.Outputable GHC.Parser.Annotation.NameAdornment instance GHC.Utils.Outputable.Outputable GHC.Parser.Annotation.AnnContext instance GHC.Utils.Binary.Binary a => GHC.Utils.Binary.Binary (GHC.Parser.Annotation.LocatedL a) instance GHC.Base.Semigroup GHC.Parser.Annotation.AnnList instance GHC.Base.Monoid GHC.Parser.Annotation.AnnList instance GHC.Utils.Outputable.Outputable GHC.Parser.Annotation.AnnList instance GHC.Base.Semigroup GHC.Parser.Annotation.AnnListItem instance GHC.Base.Monoid GHC.Parser.Annotation.AnnListItem instance GHC.Utils.Outputable.Outputable GHC.Parser.Annotation.AnnListItem instance GHC.Utils.Outputable.Outputable GHC.Parser.Annotation.TrailingAnn instance GHC.Types.Name.NamedThing (GHC.Types.SrcLoc.Located a) => GHC.Types.Name.NamedThing (GHC.Parser.Annotation.LocatedAn an a) instance GHC.Base.Semigroup an => GHC.Base.Semigroup (GHC.Parser.Annotation.SrcSpanAnn' an) instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Parser.Annotation.SrcSpanAnn' a) instance (GHC.Utils.Outputable.Outputable a, GHC.Utils.Outputable.Outputable e) => GHC.Utils.Outputable.Outputable (GHC.Types.SrcLoc.GenLocated (GHC.Parser.Annotation.SrcSpanAnn' a) e) instance GHC.Utils.Outputable.Outputable GHC.Parser.Annotation.AddEpAnn instance GHC.Classes.Ord GHC.Parser.Annotation.AddEpAnn instance GHC.Utils.Outputable.Outputable GHC.Parser.Annotation.EpaLocation instance GHC.Base.Semigroup a => GHC.Base.Semigroup (GHC.Parser.Annotation.EpAnn a) instance GHC.Base.Monoid a => GHC.Base.Monoid (GHC.Parser.Annotation.EpAnn a) instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Parser.Annotation.EpAnn a) instance GHC.Base.Semigroup GHC.Parser.Annotation.EpAnnComments instance GHC.Utils.Outputable.Outputable GHC.Parser.Annotation.EpAnnComments instance GHC.Classes.Ord GHC.Parser.Annotation.Anchor instance GHC.Base.Semigroup GHC.Parser.Annotation.Anchor instance GHC.Utils.Outputable.Outputable GHC.Parser.Annotation.Anchor instance GHC.Utils.Outputable.Outputable (GHC.Types.SrcLoc.GenLocated GHC.Parser.Annotation.Anchor GHC.Parser.Annotation.EpaComment) instance GHC.Utils.Outputable.Outputable GHC.Parser.Annotation.AnchorOperation instance GHC.Utils.Outputable.Outputable GHC.Parser.Annotation.DeltaPos instance GHC.Utils.Outputable.Outputable GHC.Parser.Annotation.EpaComment instance GHC.Utils.Outputable.Outputable GHC.Parser.Annotation.IsUnicodeSyntax instance GHC.Utils.Outputable.Outputable GHC.Parser.Annotation.AnnKeywordId module GHC.Core.ConLike -- | A constructor-like thing data ConLike RealDataCon :: DataCon -> ConLike PatSynCon :: PatSyn -> ConLike -- | Is this a 'vanilla' constructor-like thing (no existentials, no -- provided constraints)? isVanillaConLike :: ConLike -> Bool -- | Number of arguments conLikeArity :: ConLike -> Arity -- | Names of fields used for selectors conLikeFieldLabels :: ConLike -> [FieldLabel] -- | Returns just the instantiated value argument types of a -- ConLike, (excluding dictionary args) conLikeInstOrigArgTys :: ConLike -> [Type] -> [Scaled Type] -- | TyVarBinders for the type variables of the ConLike. For -- pattern synonyms, this will always consist of the universally -- quantified variables followed by the existentially quantified type -- variables. For data constructors, the situation is slightly more -- complicated—see Note [DataCon user type variable binders] in -- GHC.Core.DataCon. conLikeUserTyVarBinders :: ConLike -> [InvisTVBinder] -- | Existentially quantified type/coercion variables conLikeExTyCoVars :: ConLike -> [TyCoVar] conLikeName :: ConLike -> Name -- | The "stupid theta" of the ConLike, such as data Eq a -- in: -- --
-- data Eq a => T a = ... ---- -- It is empty for PatSynCon as they do not allow such contexts. conLikeStupidTheta :: ConLike -> ThetaType -- | Returns the strictness information for each constructor conLikeImplBangs :: ConLike -> [HsImplBang] -- | The "full signature" of the ConLike returns, in order: -- -- 1) The universally quantified type variables -- -- 2) The existentially quantified type/coercion variables -- -- 3) The equality specification -- -- 4) The provided theta (the constraints provided by a match) -- -- 5) The required theta (the constraints required for a match) -- -- 6) The original argument types (i.e. before any change of the -- representation of the type) -- -- 7) The original result type conLikeFullSig :: ConLike -> ([TyVar], [TyCoVar], [EqSpec], ThetaType, ThetaType, [Scaled Type], Type) -- | Returns the type of the whole pattern conLikeResTy :: ConLike -> [Type] -> Type -- | Extract the type for any given labelled field of the ConLike conLikeFieldType :: ConLike -> FieldLabelString -> Type -- | The ConLikes that have *all* the given fields conLikesWithFields :: [ConLike] -> [FieldLabelString] -> [ConLike] conLikeIsInfix :: ConLike -> Bool -- | conLikeHasBuilder returns True except for uni-directional -- pattern synonyms, which have no builder conLikeHasBuilder :: ConLike -> Bool instance GHC.Classes.Eq GHC.Core.ConLike.ConLike instance GHC.Types.Unique.Uniquable GHC.Core.ConLike.ConLike instance GHC.Types.Name.NamedThing GHC.Core.ConLike.ConLike instance GHC.Utils.Outputable.Outputable GHC.Core.ConLike.ConLike instance GHC.Utils.Outputable.OutputableBndr GHC.Core.ConLike.ConLike instance Data.Data.Data GHC.Core.ConLike.ConLike module GHC.Core.PatSyn -- | Pattern Synonym -- -- See Note [Pattern synonym representation] See Note [Pattern synonym -- signature contexts] data PatSyn type PatSynMatcher = (Name, Type, Bool) type PatSynBuilder = Maybe (Name, Type, Bool) -- | Build a new pattern synonym mkPatSyn :: Name -> Bool -> ([InvisTVBinder], ThetaType) -> ([InvisTVBinder], ThetaType) -> [Type] -> Type -> PatSynMatcher -> PatSynBuilder -> [FieldLabel] -> PatSyn -- | The Name of the PatSyn, giving it a unique, rooted -- identification patSynName :: PatSyn -> Name -- | Arity of the pattern synonym patSynArity :: PatSyn -> Arity -- | Should the PatSyn be presented infix? patSynIsInfix :: PatSyn -> Bool patSynResultType :: PatSyn -> Type -- | Is this a 'vanilla' pattern synonym (no existentials, no provided -- constraints)? isVanillaPatSyn :: PatSyn -> Bool patSynArgs :: PatSyn -> [Type] patSynMatcher :: PatSyn -> PatSynMatcher patSynBuilder :: PatSyn -> PatSynBuilder patSynUnivTyVarBinders :: PatSyn -> [InvisTVBinder] patSynExTyVars :: PatSyn -> [TyVar] patSynExTyVarBinders :: PatSyn -> [InvisTVBinder] patSynSig :: PatSyn -> ([TyVar], ThetaType, [TyVar], ThetaType, [Scaled Type], Type) patSynSigBndr :: PatSyn -> ([InvisTVBinder], ThetaType, [InvisTVBinder], ThetaType, [Scaled Type], Type) patSynInstArgTys :: PatSyn -> [Type] -> [Type] patSynInstResTy :: PatSyn -> [Type] -> Type patSynFieldLabels :: PatSyn -> [FieldLabel] -- | Extract the type for any given labelled field of the DataCon patSynFieldType :: PatSyn -> FieldLabelString -> Type -- | Print the type of a pattern synonym. The foralls are printed -- explicitly pprPatSynType :: PatSyn -> SDoc instance GHC.Classes.Eq GHC.Core.PatSyn.PatSyn instance GHC.Types.Unique.Uniquable GHC.Core.PatSyn.PatSyn instance GHC.Types.Name.NamedThing GHC.Core.PatSyn.PatSyn instance GHC.Utils.Outputable.Outputable GHC.Core.PatSyn.PatSyn instance GHC.Utils.Outputable.OutputableBndr GHC.Core.PatSyn.PatSyn instance Data.Data.Data GHC.Core.PatSyn.PatSyn -- | Module for coercion axioms, used to represent type family instances -- and newtypes module GHC.Core.Coercion.Axiom data BranchFlag type Branched = 'Branched type Unbranched = 'Unbranched type BranchIndex = Int newtype Branches (br :: BranchFlag) MkBranches :: Array BranchIndex CoAxBranch -> Branches (br :: BranchFlag) [unMkBranches] :: Branches (br :: BranchFlag) -> Array BranchIndex CoAxBranch manyBranches :: [CoAxBranch] -> Branches Branched unbranched :: CoAxBranch -> Branches Unbranched fromBranches :: Branches br -> [CoAxBranch] numBranches :: Branches br -> Int -- | The [CoAxBranch] passed into the mapping function is a list -- of all previous branches, reversed mapAccumBranches :: ([CoAxBranch] -> CoAxBranch -> CoAxBranch) -> Branches br -> Branches br -- | A CoAxiom is a "coercion constructor", i.e. a named equality -- axiom. data CoAxiom br CoAxiom :: Unique -> Name -> Role -> TyCon -> Branches br -> Bool -> CoAxiom br [co_ax_unique] :: CoAxiom br -> Unique [co_ax_name] :: CoAxiom br -> Name [co_ax_role] :: CoAxiom br -> Role [co_ax_tc] :: CoAxiom br -> TyCon [co_ax_branches] :: CoAxiom br -> Branches br [co_ax_implicit] :: CoAxiom br -> Bool data CoAxBranch CoAxBranch :: SrcSpan -> [TyVar] -> [TyVar] -> [CoVar] -> [Role] -> [Type] -> Type -> [CoAxBranch] -> CoAxBranch [cab_loc] :: CoAxBranch -> SrcSpan [cab_tvs] :: CoAxBranch -> [TyVar] [cab_eta_tvs] :: CoAxBranch -> [TyVar] [cab_cvs] :: CoAxBranch -> [CoVar] [cab_roles] :: CoAxBranch -> [Role] [cab_lhs] :: CoAxBranch -> [Type] [cab_rhs] :: CoAxBranch -> Type [cab_incomps] :: CoAxBranch -> [CoAxBranch] toBranchedAxiom :: CoAxiom br -> CoAxiom Branched toUnbranchedAxiom :: CoAxiom br -> CoAxiom Unbranched coAxiomName :: CoAxiom br -> Name coAxiomArity :: CoAxiom br -> BranchIndex -> Arity coAxiomBranches :: CoAxiom br -> Branches br coAxiomTyCon :: CoAxiom br -> TyCon isImplicitCoAxiom :: CoAxiom br -> Bool coAxiomNumPats :: CoAxiom br -> Int coAxiomNthBranch :: CoAxiom br -> BranchIndex -> CoAxBranch coAxiomSingleBranch_maybe :: CoAxiom br -> Maybe CoAxBranch coAxiomRole :: CoAxiom br -> Role coAxiomSingleBranch :: CoAxiom Unbranched -> CoAxBranch coAxBranchTyVars :: CoAxBranch -> [TyVar] coAxBranchCoVars :: CoAxBranch -> [CoVar] coAxBranchRoles :: CoAxBranch -> [Role] coAxBranchLHS :: CoAxBranch -> [Type] coAxBranchRHS :: CoAxBranch -> Type coAxBranchSpan :: CoAxBranch -> SrcSpan coAxBranchIncomps :: CoAxBranch -> [CoAxBranch] placeHolderIncomps :: [CoAxBranch] data Role Nominal :: Role Representational :: Role Phantom :: Role fsFromRole :: Role -> FastString -- | For now, we work only with nominal equality. data CoAxiomRule CoAxiomRule :: FastString -> [Role] -> Role -> ([TypeEqn] -> Maybe TypeEqn) -> CoAxiomRule [coaxrName] :: CoAxiomRule -> FastString [coaxrAsmpRoles] :: CoAxiomRule -> [Role] [coaxrRole] :: CoAxiomRule -> Role -- | coaxrProves returns Nothing when it doesn't like the supplied -- arguments. When this happens in a coercion that means that the -- coercion is ill-formed, and Core Lint checks for that. [coaxrProves] :: CoAxiomRule -> [TypeEqn] -> Maybe TypeEqn -- | A more explicit representation for `t1 ~ t2`. type TypeEqn = Pair Type data BuiltInSynFamily BuiltInSynFamily :: ([Type] -> Maybe (CoAxiomRule, [Type], Type)) -> ([Type] -> Type -> [TypeEqn]) -> ([Type] -> Type -> [Type] -> Type -> [TypeEqn]) -> BuiltInSynFamily [sfMatchFam] :: BuiltInSynFamily -> [Type] -> Maybe (CoAxiomRule, [Type], Type) [sfInteractTop] :: BuiltInSynFamily -> [Type] -> Type -> [TypeEqn] [sfInteractInert] :: BuiltInSynFamily -> [Type] -> Type -> [Type] -> Type -> [TypeEqn] trivialBuiltInFamily :: BuiltInSynFamily instance Data.Data.Data GHC.Core.Coercion.Axiom.Role instance GHC.Classes.Ord GHC.Core.Coercion.Axiom.Role instance GHC.Classes.Eq GHC.Core.Coercion.Axiom.Role instance Data.Data.Data GHC.Core.Coercion.Axiom.CoAxBranch instance Data.Data.Data GHC.Core.Coercion.Axiom.CoAxiomRule instance GHC.Types.Unique.Uniquable GHC.Core.Coercion.Axiom.CoAxiomRule instance GHC.Classes.Eq GHC.Core.Coercion.Axiom.CoAxiomRule instance GHC.Classes.Ord GHC.Core.Coercion.Axiom.CoAxiomRule instance GHC.Utils.Outputable.Outputable GHC.Core.Coercion.Axiom.CoAxiomRule instance GHC.Classes.Eq (GHC.Core.Coercion.Axiom.CoAxiom br) instance GHC.Types.Unique.Uniquable (GHC.Core.Coercion.Axiom.CoAxiom br) instance GHC.Utils.Outputable.Outputable (GHC.Core.Coercion.Axiom.CoAxiom br) instance GHC.Types.Name.NamedThing (GHC.Core.Coercion.Axiom.CoAxiom br) instance Data.Typeable.Internal.Typeable br => Data.Data.Data (GHC.Core.Coercion.Axiom.CoAxiom br) instance GHC.Utils.Outputable.Outputable GHC.Core.Coercion.Axiom.CoAxBranch instance GHC.Utils.Outputable.Outputable GHC.Core.Coercion.Axiom.Role instance GHC.Utils.Binary.Binary GHC.Core.Coercion.Axiom.Role module GHC.Core.Class data Class type ClassOpItem = (Id, DefMethInfo) data ClassATItem ATI :: TyCon -> Maybe (Type, ATValidityInfo) -> ClassATItem -- | Information about an associated type family default implementation. -- This is used solely for validity checking. See Note [Type-checking -- default assoc decls] in GHC.Tc.TyCl. data ATValidityInfo NoATVI :: ATValidityInfo ATVI :: SrcSpan -> [Type] -> ATValidityInfo type ClassMinimalDef = BooleanFormula Name type DefMethInfo = Maybe (Name, DefMethSpec Type) pprDefMethInfo :: DefMethInfo -> SDoc type FunDep a = ([a], [a]) pprFundeps :: Outputable a => [FunDep a] -> SDoc pprFunDep :: Outputable a => FunDep a -> SDoc mkClass :: Name -> [TyVar] -> [FunDep TyVar] -> [PredType] -> [Id] -> [ClassATItem] -> [ClassOpItem] -> ClassMinimalDef -> TyCon -> Class mkAbstractClass :: Name -> [TyVar] -> [FunDep TyVar] -> TyCon -> Class classTyVars :: Class -> [TyVar] classArity :: Class -> Arity classKey :: Class -> Unique className :: Class -> Name classATs :: Class -> [TyCon] classATItems :: Class -> [ClassATItem] classTyCon :: Class -> TyCon classMethods :: Class -> [Id] classOpItems :: Class -> [ClassOpItem] classBigSig :: Class -> ([TyVar], [PredType], [Id], [ClassOpItem]) classExtraBigSig :: Class -> ([TyVar], [FunDep TyVar], [PredType], [Id], [ClassATItem], [ClassOpItem]) classTvsFds :: Class -> ([TyVar], [FunDep TyVar]) classSCTheta :: Class -> [PredType] classAllSelIds :: Class -> [Id] classSCSelId :: Class -> Int -> Id classSCSelIds :: Class -> [Id] classMinimalDef :: Class -> ClassMinimalDef classHasFds :: Class -> Bool isAbstractClass :: Class -> Bool instance GHC.Classes.Eq GHC.Core.Class.Class instance GHC.Types.Unique.Uniquable GHC.Core.Class.Class instance GHC.Types.Name.NamedThing GHC.Core.Class.Class instance GHC.Utils.Outputable.Outputable GHC.Core.Class.Class instance Data.Data.Data GHC.Core.Class.Class -- | This module defines TyCons that can't be expressed in Haskell. They -- are all, therefore, wired-in TyCons. C.f module -- GHC.Builtin.Types module GHC.Builtin.Types.Prim mkPrimTyConName :: FastString -> Unique -> TyCon -> Name mkTemplateKindVars :: [Kind] -> [TyVar] mkTemplateTyVars :: [Kind] -> [TyVar] mkTemplateTyVarsFrom :: Int -> [Kind] -> [TyVar] mkTemplateKiTyVars :: [Kind] -> ([Kind] -> [Kind]) -> [TyVar] mkTemplateKiTyVar :: Kind -> (Kind -> [Kind]) -> [TyVar] mkTemplateTyConBinders :: [Kind] -> ([Kind] -> [Kind]) -> [TyConBinder] mkTemplateKindTyConBinders :: [Kind] -> [TyConBinder] mkTemplateAnonTyConBinders :: [Kind] -> [TyConBinder] alphaTyVars :: [TyVar] alphaTyVar :: TyVar betaTyVar :: TyVar gammaTyVar :: TyVar deltaTyVar :: TyVar alphaTys :: [Type] alphaTy :: Type betaTy :: Type gammaTy :: Type deltaTy :: Type alphaTyVarsUnliftedRep :: [TyVar] alphaTyVarUnliftedRep :: TyVar alphaTysUnliftedRep :: [Type] alphaTyUnliftedRep :: Type runtimeRep1TyVar :: TyVar runtimeRep2TyVar :: TyVar runtimeRep3TyVar :: TyVar runtimeRep1Ty :: Type runtimeRep2Ty :: Type runtimeRep3Ty :: Type openAlphaTyVar :: TyVar openBetaTyVar :: TyVar openGammaTyVar :: TyVar openAlphaTy :: Type openBetaTy :: Type openGammaTy :: Type multiplicityTyVar1 :: TyVar multiplicityTyVar2 :: TyVar tYPETyCon :: TyCon tYPETyConName :: Name tYPE :: Type -> Type -- | Convert a PrimRep to a Type of kind RuntimeRep Defined -- here to avoid (more) module loops primRepToRuntimeRep :: PrimRep -> Type functionWithMultiplicity :: Type -> Type -- | The FUN type constructor. -- --
-- FUN :: forall (m :: Multiplicity) ->
-- forall {rep1 :: RuntimeRep} {rep2 :: RuntimeRep}.
-- TYPE rep1 -> TYPE rep2 -> *
--
--
-- The runtime representations quantification is left inferred. This
-- means they cannot be specified with -XTypeApplications.
--
-- This is a deliberate choice to allow future extensions to the function
-- arrow. To allow visible application a type synonym can be defined:
--
-- -- type Arr :: forall (rep1 :: RuntimeRep) (rep2 :: RuntimeRep). -- TYPE rep1 -> TYPE rep2 -> Type -- type Arr = FUN 'Many --funTyCon :: TyCon funTyConName :: Name -- | Primitive TyCons that are defined in GHC.Prim but not exposed. -- It's important to keep these separate as we don't want users to be -- able to write them (see #15209) or see them in GHCi's :browse -- output (see #12023). unexposedPrimTyCons :: [TyCon] -- | Primitive TyCons that are defined in, and exported from, -- GHC.Prim. exposedPrimTyCons :: [TyCon] primTyCons :: [TyCon] charPrimTyCon :: TyCon charPrimTy :: Type charPrimTyConName :: Name intPrimTyCon :: TyCon intPrimTy :: Type intPrimTyConName :: Name wordPrimTyCon :: TyCon wordPrimTy :: Type wordPrimTyConName :: Name addrPrimTyCon :: TyCon addrPrimTy :: Type addrPrimTyConName :: Name floatPrimTyCon :: TyCon floatPrimTy :: Type floatPrimTyConName :: Name doublePrimTyCon :: TyCon doublePrimTy :: Type doublePrimTyConName :: Name statePrimTyCon :: TyCon mkStatePrimTy :: Type -> Type realWorldTyCon :: TyCon realWorldTy :: Type realWorldStatePrimTy :: Type proxyPrimTyCon :: TyCon mkProxyPrimTy :: Type -> Type -> Type arrayPrimTyCon :: TyCon mkArrayPrimTy :: Type -> Type byteArrayPrimTyCon :: TyCon byteArrayPrimTy :: Type arrayArrayPrimTyCon :: TyCon mkArrayArrayPrimTy :: Type smallArrayPrimTyCon :: TyCon mkSmallArrayPrimTy :: Type -> Type mutableArrayPrimTyCon :: TyCon mkMutableArrayPrimTy :: Type -> Type -> Type mutableByteArrayPrimTyCon :: TyCon mkMutableByteArrayPrimTy :: Type -> Type mutableArrayArrayPrimTyCon :: TyCon mkMutableArrayArrayPrimTy :: Type -> Type smallMutableArrayPrimTyCon :: TyCon mkSmallMutableArrayPrimTy :: Type -> Type -> Type mutVarPrimTyCon :: TyCon mkMutVarPrimTy :: Type -> Type -> Type mVarPrimTyCon :: TyCon mkMVarPrimTy :: Type -> Type -> Type ioPortPrimTyCon :: TyCon mkIOPortPrimTy :: Type -> Type -> Type tVarPrimTyCon :: TyCon mkTVarPrimTy :: Type -> Type -> Type stablePtrPrimTyCon :: TyCon mkStablePtrPrimTy :: Type -> Type stableNamePrimTyCon :: TyCon mkStableNamePrimTy :: Type -> Type compactPrimTyCon :: TyCon compactPrimTy :: Type bcoPrimTyCon :: TyCon bcoPrimTy :: Type weakPrimTyCon :: TyCon mkWeakPrimTy :: Type -> Type threadIdPrimTyCon :: TyCon threadIdPrimTy :: Type int8PrimTyCon :: TyCon int8PrimTy :: Type int8PrimTyConName :: Name word8PrimTyCon :: TyCon word8PrimTy :: Type word8PrimTyConName :: Name int16PrimTyCon :: TyCon int16PrimTy :: Type int16PrimTyConName :: Name word16PrimTyCon :: TyCon word16PrimTy :: Type word16PrimTyConName :: Name int32PrimTyCon :: TyCon int32PrimTy :: Type int32PrimTyConName :: Name word32PrimTyCon :: TyCon word32PrimTy :: Type word32PrimTyConName :: Name int64PrimTyCon :: TyCon int64PrimTy :: Type int64PrimTyConName :: Name word64PrimTyCon :: TyCon word64PrimTy :: Type word64PrimTyConName :: Name eqPrimTyCon :: TyCon eqReprPrimTyCon :: TyCon eqPhantPrimTyCon :: TyCon -- | Given a Role, what TyCon is the type of equality predicates at that -- role? equalityTyCon :: Role -> TyCon int8X16PrimTy :: Type int8X16PrimTyCon :: TyCon int16X8PrimTy :: Type int16X8PrimTyCon :: TyCon int32X4PrimTy :: Type int32X4PrimTyCon :: TyCon int64X2PrimTy :: Type int64X2PrimTyCon :: TyCon int8X32PrimTy :: Type int8X32PrimTyCon :: TyCon int16X16PrimTy :: Type int16X16PrimTyCon :: TyCon int32X8PrimTy :: Type int32X8PrimTyCon :: TyCon int64X4PrimTy :: Type int64X4PrimTyCon :: TyCon int8X64PrimTy :: Type int8X64PrimTyCon :: TyCon int16X32PrimTy :: Type int16X32PrimTyCon :: TyCon int32X16PrimTy :: Type int32X16PrimTyCon :: TyCon int64X8PrimTy :: Type int64X8PrimTyCon :: TyCon word8X16PrimTy :: Type word8X16PrimTyCon :: TyCon word16X8PrimTy :: Type word16X8PrimTyCon :: TyCon word32X4PrimTy :: Type word32X4PrimTyCon :: TyCon word64X2PrimTy :: Type word64X2PrimTyCon :: TyCon word8X32PrimTy :: Type word8X32PrimTyCon :: TyCon word16X16PrimTy :: Type word16X16PrimTyCon :: TyCon word32X8PrimTy :: Type word32X8PrimTyCon :: TyCon word64X4PrimTy :: Type word64X4PrimTyCon :: TyCon word8X64PrimTy :: Type word8X64PrimTyCon :: TyCon word16X32PrimTy :: Type word16X32PrimTyCon :: TyCon word32X16PrimTy :: Type word32X16PrimTyCon :: TyCon word64X8PrimTy :: Type word64X8PrimTyCon :: TyCon floatX4PrimTy :: Type floatX4PrimTyCon :: TyCon doubleX2PrimTy :: Type doubleX2PrimTyCon :: TyCon floatX8PrimTy :: Type floatX8PrimTyCon :: TyCon doubleX4PrimTy :: Type doubleX4PrimTyCon :: TyCon floatX16PrimTy :: Type floatX16PrimTyCon :: TyCon doubleX8PrimTy :: Type doubleX8PrimTyCon :: TyCon module GHC.Builtin.Names -- | Unique identifier. -- -- The type of unique identifiers that are used in many places in GHC for -- fast ordering and equality tests. You should generate these with the -- functions from the UniqSupply module -- -- These are sometimes also referred to as "keys" in comments in GHC. data Unique -- | Class of things that we can obtain a Unique from class Uniquable a getUnique :: Uniquable a => a -> Unique hasKey :: Uniquable a => a -> Unique -> Bool aRROW :: Module absentErrorIdKey :: Unique absentSumFieldErrorIdKey :: Unique addrPrimTyConKey :: Unique allNameStrings :: [String] all_RDR :: RdrName alt_RDR :: RdrName alternativeClassKey :: Unique alternativeClassName :: Name and_RDR :: RdrName anyBoxConKey :: Unique anyTyConKey :: Unique apAClassOpKey :: Unique apAName :: Name ap_RDR :: RdrName appAIdKey :: Unique appAName :: Name appendIdKey :: Unique appendName :: Name append_RDR :: RdrName applicativeClassKey :: Unique applicativeClassName :: Name arrAIdKey :: Unique arrAName :: Name arrayArrayPrimTyConKey :: Unique arrayPrimTyConKey :: Unique assertErrorIdKey :: Unique assertErrorName :: Name assertIdKey :: Unique assertName :: Name augmentIdKey :: Unique augmentName :: Name basicKnownKeyNames :: [Name] bcoPrimTyConKey :: Unique bignatFromWordListIdKey :: Unique bignatFromWordListName :: Name bindIOIdKey :: Unique bindIOName :: Name bindIO_RDR :: RdrName bindMClassOpKey :: Unique bindMName :: Name bindM_RDR :: RdrName bitIntegerIdKey :: Unique bnbVarQual :: String -> Unique -> Name bniVarQual :: String -> Unique -> Name bnnVarQual :: String -> Unique -> Name boolTyConKey :: Unique boundedClassKey :: Unique boundedClassName :: Name boxedRepDataConKey :: Unique boxityConKey :: Unique breakpointCondIdKey :: Unique breakpointCondName :: Name breakpointIdKey :: Unique breakpointName :: Name buildIdKey :: Unique buildName :: Name build_RDR :: RdrName byteArrayPrimTyConKey :: Unique c1TyConKey :: Unique c1TyConName :: Name cONTROL_APPLICATIVE :: Module cONTROL_EXCEPTION_BASE :: Module cTyConKey :: Unique cTyConName :: Name callStackTyConKey :: Unique callStackTyConName :: Name charDataConKey :: Unique charPrimTyConKey :: Unique charTyConKey :: Unique choiceAIdKey :: Unique choiceAName :: Name choose_RDR :: RdrName clsQual :: Module -> FastString -> Unique -> Name clsQual_RDR :: Module -> FastString -> RdrName coerceKey :: Unique coercibleDataConKey :: Unique coercibleSCSelIdKey :: Unique coercibleTyConKey :: Unique coercionTokenIdKey :: Unique comp1DataCon_RDR :: RdrName compTyConKey :: Unique compTyConName :: Name compactPrimTyConKey :: Unique compare_RDR :: RdrName composeAIdKey :: Unique composeAName :: Name compose_RDR :: RdrName conFixity_RDR :: RdrName conIsRecord_RDR :: RdrName conName_RDR :: RdrName concatIdKey :: Unique concatName :: Name consDataConKey :: Unique considerAccessibleIdKey :: Unique considerAccessibleName :: Name constraintKindTyConKey :: Unique constructorClassKey :: Unique constructorClassName :: Name crossDataConKey :: Unique cstringLengthIdKey :: Unique cstringLengthName :: Name d1TyConKey :: Unique d1TyConName :: Name dATA_ARRAY_PARALLEL_NAME :: ModuleName dATA_ARRAY_PARALLEL_PRIM_NAME :: ModuleName dATA_COERCE :: Module dATA_EITHER :: Module dATA_FOLDABLE :: Module dATA_LIST :: Module dATA_STRING :: Module dATA_TRAVERSABLE :: Module dATA_TUPLE :: Module dATA_TYPE_EQUALITY :: Module dEBUG_TRACE :: Module dTyConKey :: Unique dTyConName :: Name dYNAMIC :: Module dataClassKey :: Unique dataClassName :: Name dataQual_RDR :: Module -> FastString -> RdrName dataToTag_RDR :: RdrName datatypeClassKey :: Unique datatypeClassName :: Name datatypeName_RDR :: RdrName dcQual :: Module -> FastString -> Unique -> Name decidedLazyDataConKey :: Unique decidedLazyDataConName :: Name decidedStrictDataConKey :: Unique decidedStrictDataConName :: Name decidedUnpackDataConKey :: Unique decidedUnpackDataConName :: Name derivableClassKeys :: [Unique] divIntIdKey :: Unique divIntName :: Name dollarIdKey :: Unique dollarName :: Name doubleDataConKey :: Unique doublePrimTyConKey :: Unique doubleTyConKey :: Unique doubleX2PrimTyConKey :: Unique doubleX4PrimTyConKey :: Unique doubleX8PrimTyConKey :: Unique eitherTyConKey :: Unique eitherTyConName :: Name emptyCallStackKey :: Unique emptyCallStackName :: Name enumClassKey :: Unique enumClassName :: Name enumClass_RDR :: RdrName enumFromClassOpKey :: Unique enumFromName :: Name enumFromThenClassOpKey :: Unique enumFromThenName :: Name enumFromThenToClassOpKey :: Unique enumFromThenToName :: Name enumFromThenTo_RDR :: RdrName enumFromThen_RDR :: RdrName enumFromToClassOpKey :: Unique enumFromToName :: Name enumFromTo_RDR :: RdrName enumFrom_RDR :: RdrName eqClassKey :: Unique eqClassName :: Name eqClassOpKey :: Unique eqClass_RDR :: RdrName eqDataConKey :: Unique eqName :: Name eqPhantPrimTyConKey :: Unique eqPrimTyConKey :: Unique eqReprPrimTyConKey :: Unique eqSCSelIdKey :: Unique eqStringIdKey :: Unique eqStringName :: Name eqString_RDR :: RdrName eqTag_RDR :: RdrName eqTyConKey :: Unique eq_RDR :: RdrName errorIdKey :: Unique errorMessageTypeErrorFamKey :: Unique errorMessageTypeErrorFamName :: Name error_RDR :: RdrName expectP_RDR :: RdrName failIOIdKey :: Unique failIOName :: Name failMClassOpKey :: Unique failMName :: Name failM_RDR :: RdrName falseDataConKey :: Unique filterIdKey :: Unique filterName :: Name fingerprintDataConKey :: Unique fingerprintDataConName :: Name firstAIdKey :: Unique firstAName :: Name floatDataConKey :: Unique floatPrimTyConKey :: Unique floatTyConKey :: Unique floatX16PrimTyConKey :: Unique floatX4PrimTyConKey :: Unique floatX8PrimTyConKey :: Unique floatingClassKey :: Unique floatingClassName :: Name fmapClassOpKey :: Unique fmapName :: Name fmap_RDR :: RdrName foldMap_RDR :: RdrName foldableClassKey :: Unique foldableClassName :: Name foldable_foldr_RDR :: RdrName foldrIdKey :: Unique foldrName :: Name foldr_RDR :: RdrName foreignObjPrimTyConKey :: Unique fractionalClassKey :: Unique fractionalClassKeys :: [Unique] fractionalClassName :: Name from1_RDR :: RdrName fromEnum_RDR :: RdrName fromIntegerClassOpKey :: Unique fromIntegerName :: Name fromInteger_RDR :: RdrName fromIntegralIdKey :: Unique fromIntegralName :: Name fromIntegral_RDR :: RdrName fromLabelClassOpKey :: Unique fromLabelClassOpName :: Name fromListClassOpKey :: Unique fromListNClassOpKey :: Unique fromListNName :: Name fromListN_RDR :: RdrName fromListName :: Name fromList_RDR :: RdrName fromRationalClassOpKey :: Unique fromRationalName :: Name fromRational_RDR :: RdrName fromStaticPtrClassOpKey :: Unique fromStaticPtrName :: Name fromStringClassOpKey :: Unique fromStringName :: Name fromString_RDR :: RdrName from_RDR :: RdrName frontendPluginTyConKey :: Unique frontendPluginTyConName :: Name fstIdKey :: Unique fstName :: Name funPtrTyConKey :: Unique funPtrTyConName :: Name funTyConKey :: Unique functorClassKey :: Unique functorClassName :: Name gENERICS :: Module gHC_BASE :: Module gHC_CLASSES :: Module gHC_CONC :: Module gHC_CSTRING :: Module gHC_DESUGAR :: Module gHC_ENUM :: Module gHC_ERR :: Module gHC_EXTS :: Module gHC_FINGERPRINT_TYPE :: Module gHC_FLOAT :: Module gHC_GENERICS :: Module gHC_GHCI :: Module gHC_GHCI_HELPERS :: Module gHC_INT :: Module gHC_IO :: Module gHC_IO_Exception :: Module gHC_IX :: Module gHC_LIST :: Module gHC_MAGIC :: Module gHC_MAYBE :: Module gHC_NUM :: Module gHC_NUM_BIGNAT :: Module gHC_NUM_INTEGER :: Module gHC_NUM_NATURAL :: Module gHC_OVER_LABELS :: Module gHC_PRIM :: Module gHC_PRIMOPWRAPPERS :: Module gHC_PRIM_EXCEPTION :: Module gHC_PRIM_PANIC :: Module gHC_PTR :: Module gHC_READ :: Module gHC_REAL :: Module gHC_RECORDS :: Module gHC_SHOW :: Module gHC_SRCLOC :: Module gHC_ST :: Module gHC_STABLE :: Module gHC_STACK :: Module gHC_STACK_TYPES :: Module gHC_STATICPTR :: Module gHC_STATICPTR_INTERNAL :: Module gHC_TOP_HANDLER :: Module gHC_TUPLE :: Module gHC_TYPELITS :: Module gHC_TYPELITS_INTERNAL :: Module gHC_TYPENATS :: Module gHC_TYPENATS_INTERNAL :: Module gHC_TYPES :: Module gHC_WORD :: Module geClassOpKey :: Unique geName :: Name ge_RDR :: RdrName gen1ClassKey :: Unique gen1ClassName :: Name genClassKey :: Unique genClassName :: Name genUnitDataConKey :: Unique genericClassNames :: [Name] genericTyConNames :: [Name] getFieldClassOpKey :: Unique getFieldName :: Name getTag_RDR :: RdrName ghciIoClassKey :: Unique ghciIoClassName :: Name ghciStepIoMClassOpKey :: Unique ghciStepIoMName :: Name groupWithIdKey :: Unique groupWithName :: Name gtTag_RDR :: RdrName gt_RDR :: RdrName guardMIdKey :: Unique guardMName :: Name hasFieldClassName :: Name hasFieldClassNameKey :: Unique heqDataConKey :: Unique heqSCSelIdKey :: Unique heqTyConKey :: Unique ident_RDR :: RdrName inRange_RDR :: RdrName index_RDR :: RdrName infixDataCon_RDR :: RdrName infixIDataConKey :: Unique infixIDataConName :: Name inlDataConKey :: Unique inlineIdKey :: Unique inlineIdName :: Name inrDataConKey :: Unique int16PrimTyConKey :: Unique int16TyConKey :: Unique int16TyConName :: Name int16X16PrimTyConKey :: Unique int16X32PrimTyConKey :: Unique int16X8PrimTyConKey :: Unique int32PrimTyConKey :: Unique int32TyConKey :: Unique int32TyConName :: Name int32X16PrimTyConKey :: Unique int32X4PrimTyConKey :: Unique int32X8PrimTyConKey :: Unique int64PrimTyConKey :: Unique int64TyConKey :: Unique int64TyConName :: Name int64X2PrimTyConKey :: Unique int64X4PrimTyConKey :: Unique int64X8PrimTyConKey :: Unique int8PrimTyConKey :: Unique int8TyConKey :: Unique int8TyConName :: Name int8X16PrimTyConKey :: Unique int8X32PrimTyConKey :: Unique int8X64PrimTyConKey :: Unique intDataConKey :: Unique intPrimTyConKey :: Unique intTyConKey :: Unique integerAbsIdKey :: Unique integerAbsName :: Name integerAddIdKey :: Unique integerAddName :: Name integerAdd_RDR :: RdrName integerAndIdKey :: Unique integerAndName :: Name integerBitIdKey :: Unique integerBitName :: Name integerCompareIdKey :: Unique integerCompareName :: Name integerComplementIdKey :: Unique integerComplementName :: Name integerDivIdKey :: Unique integerDivModIdKey :: Unique integerDivModName :: Name integerDivName :: Name integerEncodeDoubleIdKey :: Unique integerEncodeDoubleName :: Name integerEncodeFloatIdKey :: Unique integerEncodeFloatName :: Name integerEqIdKey :: Unique integerEqName :: Name integerFromInt64IdKey :: Unique integerFromInt64Name :: Name integerFromNaturalIdKey :: Unique integerFromNaturalName :: Name integerFromWord64IdKey :: Unique integerFromWord64Name :: Name integerFromWordIdKey :: Unique integerFromWordName :: Name integerGcdIdKey :: Unique integerGcdName :: Name integerGeIdKey :: Unique integerGeName :: Name integerGtIdKey :: Unique integerGtName :: Name integerINDataConKey :: Unique integerIPDataConKey :: Unique integerISDataConKey :: Unique integerLcmIdKey :: Unique integerLcmName :: Name integerLeIdKey :: Unique integerLeName :: Name integerLtIdKey :: Unique integerLtName :: Name integerModIdKey :: Unique integerModName :: Name integerMulIdKey :: Unique integerMulName :: Name integerMul_RDR :: RdrName integerNeIdKey :: Unique integerNeName :: Name integerNegateIdKey :: Unique integerNegateName :: Name integerOrIdKey :: Unique integerOrName :: Name integerPopCountIdKey :: Unique integerPopCountName :: Name integerQuotIdKey :: Unique integerQuotName :: Name integerQuotRemIdKey :: Unique integerQuotRemName :: Name integerRemIdKey :: Unique integerRemName :: Name integerShiftLIdKey :: Unique integerShiftLName :: Name integerShiftRIdKey :: Unique integerShiftRName :: Name integerSignumIdKey :: Unique integerSignumName :: Name integerSubIdKey :: Unique integerSubName :: Name integerTestBitIdKey :: Unique integerTestBitName :: Name integerToDoubleIdKey :: Unique integerToDoubleName :: Name integerToFloatIdKey :: Unique integerToFloatName :: Name integerToInt64IdKey :: Unique integerToInt64Name :: Name integerToIntIdKey :: Unique integerToIntName :: Name integerToNaturalClampIdKey :: Unique integerToNaturalClampName :: Name integerToNaturalIdKey :: Unique integerToNaturalName :: Name integerToNaturalThrowIdKey :: Unique integerToNaturalThrowName :: Name integerToWord64IdKey :: Unique integerToWord64Name :: Name integerToWordIdKey :: Unique integerToWordName :: Name integerTyConKey :: Unique integerXorIdKey :: Unique integerXorName :: Name integralClassKey :: Unique integralClassName :: Name interactiveClassKeys :: [Unique] interactiveClassNames :: [Name] ioDataConKey :: Unique ioDataConName :: Name ioDataCon_RDR :: RdrName ioPortPrimTyConKey :: Unique ioTyConKey :: Unique ioTyConName :: Name ipClassKey :: Unique ipClassName :: Name isListClassKey :: Unique isListClassName :: Name isNewtypeName_RDR :: RdrName isStringClassKey :: Unique isStringClassName :: Name isUnboundName :: Name -> Bool itName :: Unique -> SrcSpan -> Name ixClassKey :: Unique ixClassName :: Name joinMIdKey :: Unique joinMName :: Name justDataConKey :: Unique k1DataCon_RDR :: RdrName k1TyConKey :: Unique k1TyConName :: Name kindConKey :: Unique kindRepAppDataConKey :: Unique kindRepAppDataConName :: Name kindRepFunDataConKey :: Unique kindRepFunDataConName :: Name kindRepTYPEDataConKey :: Unique kindRepTYPEDataConName :: Name kindRepTyConAppDataConKey :: Unique kindRepTyConAppDataConName :: Name kindRepTyConKey :: Unique kindRepTyConName :: Name kindRepTypeLitDDataConKey :: Unique kindRepTypeLitDDataConName :: Name kindRepTypeLitSDataConKey :: Unique kindRepTypeLitSDataConName :: Name kindRepVarDataConKey :: Unique kindRepVarDataConName :: Name knownCharClassName :: Name knownCharClassNameKey :: Unique knownNatClassName :: Name knownNatClassNameKey :: Unique knownSymbolClassName :: Name knownSymbolClassNameKey :: Unique l1DataCon_RDR :: RdrName lEX :: Module lazyIdKey :: Unique le_RDR :: RdrName leftAssocDataCon_RDR :: RdrName leftAssociativeDataConKey :: Unique leftAssociativeDataConName :: Name leftDataConKey :: Unique leftDataConName :: Name leftSectionKey :: Unique left_RDR :: RdrName levityTyConKey :: Unique lexP_RDR :: RdrName liftA2_RDR :: RdrName liftMIdKey :: Unique liftMName :: Name liftedDataConKey :: Unique liftedRepTyConKey :: Unique liftedTypeKindTyConKey :: Unique listTyConKey :: Unique loopAIdKey :: Unique loopAName :: Name ltTag_RDR :: RdrName lt_RDR :: RdrName m1DataCon_RDR :: RdrName m1TyConKey :: Unique m1TyConName :: Name mAIN_NAME :: ModuleName mONAD :: Module mONAD_FAIL :: Module mONAD_FIX :: Module mONAD_ZIP :: Module mVarPrimTyConKey :: Unique magicDictKey :: Unique main_RDR_Unqual :: RdrName makeStaticKey :: Unique makeStaticName :: Name manyDataConKey :: Unique mapIdKey :: Unique mapName :: Name map_RDR :: RdrName mappendClassOpKey :: Unique mappendName :: Name mappend_RDR :: RdrName maxBound_RDR :: RdrName maybeTyConKey :: Unique mconcatClassOpKey :: Unique mconcatName :: Name memptyClassOpKey :: Unique memptyName :: Name mempty_RDR :: RdrName metaConsDataConKey :: Unique metaConsDataConName :: Name metaDataDataConKey :: Unique metaDataDataConName :: Name metaSelDataConKey :: Unique metaSelDataConName :: Name mfixIdKey :: Unique mfixName :: Name minBound_RDR :: RdrName minusClassOpKey :: Unique minusName :: Name minus_RDR :: RdrName mkBaseModule :: FastString -> Module mkBaseModule_ :: ModuleName -> Module mkBignumModule :: FastString -> Module mkInteractiveModule :: Int -> Module mkMainModule :: FastString -> Module mkMainModule_ :: ModuleName -> Module mkPrimModule :: FastString -> Module mkRationalBase10IdKey :: Unique mkRationalBase10Name :: Name mkRationalBase2IdKey :: Unique mkRationalBase2Name :: Name mkThisGhcModule :: FastString -> Module mkThisGhcModule_ :: ModuleName -> Module mkTrAppKey :: Unique mkTrAppName :: Name mkTrConKey :: Unique mkTrConName :: Name mkTrFunKey :: Unique mkTrFunName :: Name mkTrTypeKey :: Unique mkTrTypeName :: Name mkTyConKey :: Unique mkUnboundName :: OccName -> Name mk_known_key_name :: NameSpace -> Module -> FastString -> Unique -> Name modIntIdKey :: Unique modIntName :: Name moduleName_RDR :: RdrName monadClassKey :: Unique monadClassName :: Name monadClass_RDR :: RdrName monadFailClassKey :: Unique monadFailClassName :: Name monadFixClassKey :: Unique monadFixClassName :: Name monadPlusClassKey :: Unique monadPlusClassName :: Name monoidClassKey :: Unique monoidClassName :: Name multMulTyConKey :: Unique multiplicityTyConKey :: Unique mutVarPrimTyConKey :: Unique mutableArrayArrayPrimTyConKey :: Unique mutableArrayPrimTyConKey :: Unique mutableByteArrayPrimTyConKey :: Unique mzipIdKey :: Unique mzipName :: Name naturalAddIdKey :: Unique naturalAddName :: Name naturalAndIdKey :: Unique naturalAndName :: Name naturalAndNotIdKey :: Unique naturalAndNotName :: Name naturalBitIdKey :: Unique naturalBitName :: Name naturalCompareIdKey :: Unique naturalCompareName :: Name naturalEqIdKey :: Unique naturalEqName :: Name naturalGcdIdKey :: Unique naturalGcdName :: Name naturalGeIdKey :: Unique naturalGeName :: Name naturalGtIdKey :: Unique naturalGtName :: Name naturalLcmIdKey :: Unique naturalLcmName :: Name naturalLeIdKey :: Unique naturalLeName :: Name naturalLog2IdKey :: Unique naturalLog2Name :: Name naturalLogBaseIdKey :: Unique naturalLogBaseName :: Name naturalLogBaseWordIdKey :: Unique naturalLogBaseWordName :: Name naturalLtIdKey :: Unique naturalLtName :: Name naturalMulIdKey :: Unique naturalMulName :: Name naturalNBDataConKey :: Unique naturalNSDataConKey :: Unique naturalNeIdKey :: Unique naturalNeName :: Name naturalNegateIdKey :: Unique naturalNegateName :: Name naturalOrIdKey :: Unique naturalOrName :: Name naturalPopCountIdKey :: Unique naturalPopCountName :: Name naturalPowModIdKey :: Unique naturalPowModName :: Name naturalQuotIdKey :: Unique naturalQuotName :: Name naturalQuotRemIdKey :: Unique naturalQuotRemName :: Name naturalRemIdKey :: Unique naturalRemName :: Name naturalShiftLIdKey :: Unique naturalShiftLName :: Name naturalShiftRIdKey :: Unique naturalShiftRName :: Name naturalSignumIdKey :: Unique naturalSignumName :: Name naturalSizeInBaseIdKey :: Unique naturalSizeInBaseName :: Name naturalSubIdKey :: Unique naturalSubName :: Name naturalSubThrowIdKey :: Unique naturalSubThrowName :: Name naturalSubUnsafeIdKey :: Unique naturalSubUnsafeName :: Name naturalTestBitIdKey :: Unique naturalTestBitName :: Name naturalToDoubleIdKey :: Unique naturalToDoubleName :: Name naturalToFloatIdKey :: Unique naturalToFloatName :: Name naturalToWordClampIdKey :: Unique naturalToWordClampName :: Name naturalToWordIdKey :: Unique naturalToWordName :: Name naturalTyConKey :: Unique naturalXorIdKey :: Unique naturalXorName :: Name negateClassOpKey :: Unique negateName :: Name newStablePtrIdKey :: Unique newStablePtrName :: Name newStablePtr_RDR :: RdrName nilDataConKey :: Unique noMethodBindingErrorIdKey :: Unique noSelTyConKey :: Unique noSelTyConName :: Name noSourceStrictnessDataConKey :: Unique noSourceStrictnessDataConName :: Name noSourceUnpackednessDataConKey :: Unique noSourceUnpackednessDataConName :: Name noinlineIdKey :: Unique nonEmptyDataConKey :: Unique nonEmptyTyConKey :: Unique nonExhaustiveGuardsErrorIdKey :: Unique notAssocDataCon_RDR :: RdrName notAssociativeDataConKey :: Unique notAssociativeDataConName :: Name not_RDR :: RdrName nothingDataConKey :: Unique nullAddrIdKey :: Unique null_RDR :: RdrName numClassKey :: Unique numClassName :: Name numClass_RDR :: RdrName numericClassKeys :: [Unique] oneDataConKey :: Unique oneShotKey :: Unique opaqueTyConKey :: Unique opaqueTyConName :: Name ordClassKey :: Unique ordClassName :: Name ordClass_RDR :: RdrName ordEQDataConKey :: Unique ordEQDataConName :: Name ordGTDataConKey :: Unique ordGTDataConName :: Name ordLTDataConKey :: Unique ordLTDataConName :: Name orderingTyConKey :: Unique orderingTyConName :: Name otherwiseIdKey :: Unique otherwiseIdName :: Name pLUGINS :: Module pRELUDE :: Module pRELUDE_NAME :: ModuleName packageName_RDR :: RdrName par1DataCon_RDR :: RdrName par1TyConKey :: Unique par1TyConName :: Name parens_RDR :: RdrName patErrorIdKey :: Unique pfail_RDR :: RdrName pluginTyConKey :: Unique pluginTyConName :: Name plus_RDR :: RdrName prec_RDR :: RdrName pred_RDR :: RdrName prefixDataCon_RDR :: RdrName prefixIDataConKey :: Unique prefixIDataConName :: Name pretendNameIsInScope :: Name -> Bool printIdKey :: Unique printName :: Name prodDataCon_RDR :: RdrName prodTyConKey :: Unique prodTyConName :: Name proxyHashKey :: Unique proxyPrimTyConKey :: Unique ptrTyConKey :: Unique ptrTyConName :: Name punc_RDR :: RdrName pureAClassOpKey :: Unique pureAName :: Name pure_RDR :: RdrName pushCallStackKey :: Unique pushCallStackName :: Name r1DataCon_RDR :: RdrName rANDOM :: Module rEAD_PREC :: Module rOOT_MAIN :: Module rTyConKey :: Unique rTyConName :: Name raiseDivZeroIdKey :: Unique raiseOverflowIdKey :: Unique raiseUnderflowIdKey :: Unique randomClassKey :: Unique randomClassName :: Name randomGenClassKey :: Unique randomGenClassName :: Name range_RDR :: RdrName ratioDataConKey :: Unique ratioDataConName :: Name ratioDataCon_RDR :: RdrName ratioTyConKey :: Unique ratioTyConName :: Name rationalToDoubleIdKey :: Unique rationalToDoubleName :: Name rationalToFloatIdKey :: Unique rationalToFloatName :: Name rationalTyConKey :: Unique rationalTyConName :: Name readClassKey :: Unique readClassName :: Name readFieldHash_RDR :: RdrName readField_RDR :: RdrName readListDefault_RDR :: RdrName readListPrecDefault_RDR :: RdrName readListPrec_RDR :: RdrName readList_RDR :: RdrName readPrec_RDR :: RdrName readSymField_RDR :: RdrName realClassKey :: Unique realClassName :: Name realFloatClassKey :: Unique realFloatClassName :: Name realFracClassKey :: Unique realFracClassName :: Name realToFracIdKey :: Unique realToFracName :: Name realWorldPrimIdKey :: Unique realWorldTyConKey :: Unique rec0TyConKey :: Unique rec0TyConName :: Name rec1DataCon_RDR :: RdrName rec1TyConKey :: Unique rec1TyConName :: Name recConErrorIdKey :: Unique recSelErrorIdKey :: Unique rep1TyConKey :: Unique rep1TyConName :: Name repTyConKey :: Unique repTyConName :: Name replace_RDR :: RdrName reset_RDR :: RdrName returnIOIdKey :: Unique returnIOName :: Name returnIO_RDR :: RdrName returnMClassOpKey :: Unique returnMName :: Name returnM_RDR :: RdrName rightAssocDataCon_RDR :: RdrName rightAssociativeDataConKey :: Unique rightAssociativeDataConName :: Name rightDataConKey :: Unique rightDataConName :: Name rightSectionKey :: Unique right_RDR :: RdrName rootMainKey :: Unique runMainIOName :: Name runMainKey :: Unique runRWKey :: Unique runRWName :: Name runtimeErrorIdKey :: Unique runtimeRepSimpleDataConKeys :: [Unique] runtimeRepTyConKey :: Unique s1TyConKey :: Unique s1TyConName :: Name sTyConKey :: Unique sTyConName :: Name sYSTEM_IO :: Module sappendClassOpKey :: Unique sappendName :: Name selName_RDR :: RdrName selectorClassKey :: Unique selectorClassName :: Name semigroupClassKey :: Unique semigroupClassName :: Name seqIdKey :: Unique setFieldClassOpKey :: Unique setFieldName :: Name showClassKey :: Unique showClassName :: Name showCommaSpace_RDR :: RdrName showParen_RDR :: RdrName showSpace_RDR :: RdrName showString_RDR :: RdrName showsPrec_RDR :: RdrName shows_RDR :: RdrName smallArrayPrimTyConKey :: Unique smallMutableArrayPrimTyConKey :: Unique sndIdKey :: Unique sndName :: Name someTypeRepDataConKey :: Unique someTypeRepDataConName :: Name someTypeRepTyConKey :: Unique someTypeRepTyConName :: Name sourceLazyDataConKey :: Unique sourceLazyDataConName :: Name sourceNoUnpackDataConKey :: Unique sourceNoUnpackDataConName :: Name sourceStrictDataConKey :: Unique sourceStrictDataConName :: Name sourceUnpackDataConKey :: Unique sourceUnpackDataConName :: Name specTyConKey :: Unique specTyConName :: Name srcLocDataConKey :: Unique srcLocDataConName :: Name stableNameDataConKey :: Unique stableNamePrimTyConKey :: Unique stableNameTyConKey :: Unique stablePtrPrimTyConKey :: Unique stablePtrTyConKey :: Unique stablePtrTyConName :: Name standardClassKeys :: [Unique] starArrStarArrStarKindRepKey :: Unique starArrStarArrStarKindRepName :: Name starArrStarKindRepKey :: Unique starArrStarKindRepName :: Name starKindRepKey :: Unique starKindRepName :: Name statePrimTyConKey :: Unique staticPtrDataConKey :: Unique staticPtrDataConName :: Name staticPtrInfoDataConKey :: Unique staticPtrInfoDataConName :: Name staticPtrInfoTyConKey :: Unique staticPtrInfoTyConName :: Name staticPtrTyConKey :: Unique staticPtrTyConName :: Name step_RDR :: RdrName stringTyConKey :: Unique succ_RDR :: RdrName sumRepDataConKey :: Unique sumTyConKey :: Unique sumTyConName :: Name symbol_RDR :: RdrName tVarPrimTyConKey :: Unique tYPEABLE :: Module tYPEABLE_INTERNAL :: Module tYPETyConKey :: Unique tcQual :: Module -> FastString -> Unique -> Name tcQual_RDR :: Module -> FastString -> RdrName thenAClassOpKey :: Unique thenAName :: Name thenIOIdKey :: Unique thenIOName :: Name thenMClassOpKey :: Unique thenMName :: Name threadIdPrimTyConKey :: Unique times_RDR :: RdrName to1_RDR :: RdrName toAnnotationWrapperIdKey :: Unique toAnnotationWrapperName :: Name toDynIdKey :: Unique toDynName :: Name toEnum_RDR :: RdrName toIntegerClassOpKey :: Unique toIntegerName :: Name toInteger_RDR :: RdrName toListClassOpKey :: Unique toListName :: Name toList_RDR :: RdrName toRationalClassOpKey :: Unique toRationalName :: Name toRational_RDR :: RdrName to_RDR :: RdrName tr'PtrRepLiftedKey :: Unique trGhcPrimModuleKey :: Unique trGhcPrimModuleName :: Name trLiftedRepKey :: Unique trModuleDataConKey :: Unique trModuleDataConName :: Name trModuleTyConKey :: Unique trModuleTyConName :: Name trNameDDataConKey :: Unique trNameDDataConName :: Name trNameSDataConKey :: Unique trNameSDataConName :: Name trNameTyConKey :: Unique trNameTyConName :: Name trRuntimeRepKey :: Unique trTYPE'PtrRepLiftedKey :: Unique trTYPEKey :: Unique trTyConDataConKey :: Unique trTyConDataConName :: Name trTyConTyConKey :: Unique trTyConTyConName :: Name traceKey :: Unique traceName :: Name traversableClassKey :: Unique traversableClassName :: Name traverse_RDR :: RdrName trueDataConKey :: Unique tupleRepDataConKey :: Unique typeCharCmpTyFamNameKey :: Unique typeCharKindConNameKey :: Unique typeCharToNatTyFamNameKey :: Unique typeCharTypeRepKey :: Unique typeCharTypeRepName :: Name typeConKey :: Unique typeConsSymbolTyFamNameKey :: Unique typeErrorAppendDataConKey :: Unique typeErrorAppendDataConName :: Name typeErrorIdKey :: Unique typeErrorShowTypeDataConKey :: Unique typeErrorShowTypeDataConName :: Name typeErrorTextDataConKey :: Unique typeErrorTextDataConName :: Name typeErrorVAppendDataConKey :: Unique typeErrorVAppendDataConName :: Name typeLeqCharTyFamNameKey :: Unique typeLitCharDataConKey :: Unique typeLitCharDataConName :: Name typeLitNatDataConKey :: Unique typeLitNatDataConName :: Name typeLitSortTyConKey :: Unique typeLitSortTyConName :: Name typeLitSymbolDataConKey :: Unique typeLitSymbolDataConName :: Name typeNatAddTyFamNameKey :: Unique typeNatCmpTyFamNameKey :: Unique typeNatDivTyFamNameKey :: Unique typeNatExpTyFamNameKey :: Unique typeNatLogTyFamNameKey :: Unique typeNatModTyFamNameKey :: Unique typeNatMulTyFamNameKey :: Unique typeNatSubTyFamNameKey :: Unique typeNatToCharTyFamNameKey :: Unique typeNatTypeRepKey :: Unique typeNatTypeRepName :: Name typeRepIdKey :: Unique typeRepIdName :: Name typeRepTyConKey :: Unique typeRepTyConName :: Name typeSymbolAppendFamNameKey :: Unique typeSymbolCmpTyFamNameKey :: Unique typeSymbolKindConNameKey :: Unique typeSymbolTypeRepKey :: Unique typeSymbolTypeRepName :: Name typeUnconsSymbolTyFamNameKey :: Unique typeableClassKey :: Unique typeableClassName :: Name u1DataCon_RDR :: RdrName u1TyConKey :: Unique u1TyConName :: Name uAddrDataCon_RDR :: RdrName uAddrHash_RDR :: RdrName uAddrTyConKey :: Unique uAddrTyConName :: Name uCharDataCon_RDR :: RdrName uCharHash_RDR :: RdrName uCharTyConKey :: Unique uCharTyConName :: Name uDoubleDataCon_RDR :: RdrName uDoubleHash_RDR :: RdrName uDoubleTyConKey :: Unique uDoubleTyConName :: Name uFloatDataCon_RDR :: RdrName uFloatHash_RDR :: RdrName uFloatTyConKey :: Unique uFloatTyConName :: Name uIntDataCon_RDR :: RdrName uIntHash_RDR :: RdrName uIntTyConKey :: Unique uIntTyConName :: Name uNSAFE_COERCE :: Module uRecTyConKey :: Unique uRecTyConName :: Name uWordDataCon_RDR :: RdrName uWordHash_RDR :: RdrName uWordTyConKey :: Unique uWordTyConName :: Name unComp1_RDR :: RdrName unK1_RDR :: RdrName unPar1_RDR :: RdrName unRec1_RDR :: RdrName unboundKey :: Unique unknown1TyConKey :: Unique unknown2TyConKey :: Unique unknown3TyConKey :: Unique unknownTyConKey :: Unique unliftedDataConKey :: Unique unliftedRepTyConKey :: Unique unliftedTypeKindTyConKey :: Unique unpackCStringAppendIdKey :: Unique unpackCStringFoldrIdKey :: Unique unpackCStringFoldrName :: Name unpackCStringFoldrUtf8IdKey :: Unique unpackCStringFoldrUtf8Name :: Name unpackCStringFoldrUtf8_RDR :: RdrName unpackCStringFoldr_RDR :: RdrName unpackCStringIdKey :: Unique unpackCStringName :: Name unpackCStringUtf8IdKey :: Unique unpackCStringUtf8Name :: Name unpackCStringUtf8_RDR :: RdrName unpackCString_RDR :: RdrName unrestrictedFunTyConKey :: Unique unsafeCoercePrimIdKey :: Unique unsafeCoercePrimName :: Name unsafeEqualityProofIdKey :: Unique unsafeEqualityProofName :: Name unsafeEqualityTyConKey :: Unique unsafeEqualityTyConName :: Name unsafeIndex_RDR :: RdrName unsafeRangeSize_RDR :: RdrName unsafeReflDataConKey :: Unique unsafeReflDataConName :: Name v1TyConKey :: Unique v1TyConName :: Name varQual :: Module -> FastString -> Unique -> Name varQual_RDR :: Module -> FastString -> RdrName vecCountDataConKeys :: [Unique] vecCountTyConKey :: Unique vecElemDataConKeys :: [Unique] vecElemTyConKey :: Unique vecRepDataConKey :: Unique voidArgIdKey :: Unique voidPrimIdKey :: Unique weakPrimTyConKey :: Unique wildCardKey :: Unique wildCardName :: Name word16PrimTyConKey :: Unique word16TyConKey :: Unique word16TyConName :: Name word16X16PrimTyConKey :: Unique word16X32PrimTyConKey :: Unique word16X8PrimTyConKey :: Unique word32PrimTyConKey :: Unique word32TyConKey :: Unique word32TyConName :: Name word32X16PrimTyConKey :: Unique word32X4PrimTyConKey :: Unique word32X8PrimTyConKey :: Unique word64PrimTyConKey :: Unique word64TyConKey :: Unique word64TyConName :: Name word64X2PrimTyConKey :: Unique word64X4PrimTyConKey :: Unique word64X8PrimTyConKey :: Unique word8DataConKey :: Unique word8PrimTyConKey :: Unique word8TyConKey :: Unique word8TyConName :: Name word8X16PrimTyConKey :: Unique word8X32PrimTyConKey :: Unique word8X64PrimTyConKey :: Unique wordDataConKey :: Unique wordPrimTyConKey :: Unique wordTyConKey :: Unique zipIdKey :: Unique zipName :: Name module GHC.Core.Ppr pprCoreExpr :: OutputableBndr b => Expr b -> SDoc pprParendExpr :: OutputableBndr b => Expr b -> SDoc pprCoreBinding :: OutputableBndr b => Bind b -> SDoc pprCoreBindings :: OutputableBndr b => [Bind b] -> SDoc pprCoreAlt :: OutputableBndr a => Alt a -> SDoc pprCoreBindingWithSize :: CoreBind -> SDoc pprCoreBindingsWithSize :: [CoreBind] -> SDoc pprCoreBinder :: BindingSite -> Var -> SDoc pprCoreBinders :: [Var] -> SDoc pprRules :: [CoreRule] -> SDoc pprOptCo :: Coercion -> SDoc instance GHC.Utils.Outputable.OutputableBndr b => GHC.Utils.Outputable.Outputable (GHC.Core.Bind b) instance GHC.Utils.Outputable.OutputableBndr b => GHC.Utils.Outputable.Outputable (GHC.Core.Expr b) instance GHC.Utils.Outputable.OutputableBndr b => GHC.Utils.Outputable.Outputable (GHC.Core.Alt b) instance GHC.Utils.Outputable.OutputableBndr GHC.Types.Var.Var instance GHC.Utils.Outputable.Outputable b => GHC.Utils.Outputable.OutputableBndr (GHC.Core.TaggedBndr b) instance GHC.Utils.Outputable.Outputable GHC.Types.Id.Info.IdInfo instance GHC.Utils.Outputable.Outputable GHC.Core.UnfoldingGuidance instance GHC.Utils.Outputable.Outputable GHC.Core.UnfoldingSource instance GHC.Utils.Outputable.Outputable GHC.Core.Unfolding instance GHC.Utils.Outputable.Outputable GHC.Core.CoreRule instance GHC.Utils.Outputable.Outputable (GHC.Types.Tickish.XTickishId pass) => GHC.Utils.Outputable.Outputable (GHC.Types.Tickish.GenTickish pass) -- | Functions to computing the statistics reflective of the "size" of a -- Core expression module GHC.Core.Stats coreBindsSize :: [CoreBind] -> Int -- | A measure of the size of the expressions, strictly greater than 0 -- Counts *leaves*, not internal nodes. Types and coercions are not -- counted. exprSize :: CoreExpr -> Int data CoreStats CS :: !Int -> !Int -> !Int -> !Int -> !Int -> CoreStats [cs_tm] :: CoreStats -> !Int [cs_ty] :: CoreStats -> !Int [cs_co] :: CoreStats -> !Int [cs_vb] :: CoreStats -> !Int [cs_jb] :: CoreStats -> !Int coreBindsStats :: [CoreBind] -> CoreStats exprStats :: CoreExpr -> CoreStats instance GHC.Utils.Outputable.Outputable GHC.Core.Stats.CoreStats -- | GHC.Core holds all the main data types for use by for the Glasgow -- Haskell Compiler midsection module GHC.Core -- | This is the data type that represents GHCs core intermediate language. -- Currently GHC uses System FC -- https://www.microsoft.com/en-us/research/publication/system-f-with-type-equality-coercions/ -- for this purpose, which is closely related to the simpler and better -- known System F http://en.wikipedia.org/wiki/System_F. -- -- We get from Haskell source to this Core language in a number of -- stages: -- --
-- f x = let f x = x + 1 -- in f (x - 2) ---- -- Would be renamed by having Uniques attached so it looked -- something like this: -- --
-- f_1 x_2 = let f_3 x_4 = x_4 + 1 -- in f_3 (x_2 - 2) ---- -- But see Note [Shadowing] below. -- --
-- data C = C !(Int -> Int)
-- case x of { C f -> ... }
--
--
-- Here, f gets an OtherCon [] unfolding.
OtherCon :: [AltCon] -> Unfolding
DFunUnfolding :: [Var] -> DataCon -> [CoreExpr] -> Unfolding
[df_bndrs] :: Unfolding -> [Var]
[df_con] :: Unfolding -> DataCon
[df_args] :: Unfolding -> [CoreExpr]
-- | An unfolding with redundant cached information. Parameters:
--
-- uf_tmpl: Template used to perform unfolding; NB: Occurrence info is
-- guaranteed correct: see Note [OccInfo in unfoldings and rules]
--
-- uf_is_top: Is this a top level binding?
--
-- uf_is_value: exprIsHNF template (cached); it is ok to discard
-- a seq on this variable
--
-- uf_is_work_free: Does this waste only a little work if we expand it
-- inside an inlining? Basically this is a cached version of
-- exprIsWorkFree
--
-- uf_guidance: Tells us about the size of the unfolding template
CoreUnfolding :: CoreExpr -> UnfoldingSource -> Bool -> Bool -> Bool -> Bool -> Bool -> UnfoldingGuidance -> Unfolding
[uf_tmpl] :: Unfolding -> CoreExpr
[uf_src] :: Unfolding -> UnfoldingSource
[uf_is_top] :: Unfolding -> Bool
[uf_is_value] :: Unfolding -> Bool
[uf_is_conlike] :: Unfolding -> Bool
[uf_is_work_free] :: Unfolding -> Bool
[uf_expandable] :: Unfolding -> Bool
[uf_guidance] :: Unfolding -> UnfoldingGuidance
-- | UnfoldingGuidance says when unfolding should take place
data UnfoldingGuidance
UnfWhen :: Arity -> Bool -> Bool -> UnfoldingGuidance
[ug_arity] :: UnfoldingGuidance -> Arity
[ug_unsat_ok] :: UnfoldingGuidance -> Bool
[ug_boring_ok] :: UnfoldingGuidance -> Bool
UnfIfGoodArgs :: [Int] -> Int -> Int -> UnfoldingGuidance
[ug_args] :: UnfoldingGuidance -> [Int]
[ug_size] :: UnfoldingGuidance -> Int
[ug_res] :: UnfoldingGuidance -> Int
UnfNever :: UnfoldingGuidance
data UnfoldingSource
InlineRhs :: UnfoldingSource
InlineStable :: UnfoldingSource
InlineCompulsory :: UnfoldingSource
-- | There is no known Unfolding
noUnfolding :: Unfolding
-- | There is no known Unfolding, because this came from an hi-boot
-- file.
bootUnfolding :: Unfolding
-- | This unfolding marks the associated thing as being evaluated
evaldUnfolding :: Unfolding
mkOtherCon :: [AltCon] -> Unfolding
unSaturatedOk :: Bool
needSaturated :: Bool
boringCxtOk :: Bool
boringCxtNotOk :: Bool
-- | Retrieves the template of an unfolding: panics if none is known
unfoldingTemplate :: Unfolding -> CoreExpr
expandUnfolding_maybe :: Unfolding -> Maybe CoreExpr
-- | Retrieves the template of an unfolding if possible
-- maybeUnfoldingTemplate is used mainly wnen specialising, and we do
-- want to specialise DFuns, so it's important to return a template for
-- DFunUnfoldings
maybeUnfoldingTemplate :: Unfolding -> Maybe CoreExpr
-- | The constructors that the unfolding could never be: returns
-- [] if no information is available
otherCons :: Unfolding -> [AltCon]
-- | Determines if it is certainly the case that the unfolding will yield a
-- value (something in HNF): returns False if unsure
isValueUnfolding :: Unfolding -> Bool
-- | Determines if it possibly the case that the unfolding will yield a
-- value. Unlike isValueUnfolding it returns True for
-- OtherCon
isEvaldUnfolding :: Unfolding -> Bool
-- | Is the thing we will unfold into certainly cheap?
isCheapUnfolding :: Unfolding -> Bool
isExpandableUnfolding :: Unfolding -> Bool
-- | True if the unfolding is a constructor application, the
-- application of a CONLIKE function or OtherCon
isConLikeUnfolding :: Unfolding -> Bool
isCompulsoryUnfolding :: Unfolding -> Bool
isStableUnfolding :: Unfolding -> Bool
hasCoreUnfolding :: Unfolding -> Bool
-- | Only returns False if there is no unfolding information available at
-- all
hasSomeUnfolding :: Unfolding -> Bool
isBootUnfolding :: Unfolding -> Bool
canUnfold :: Unfolding -> Bool
neverUnfoldGuidance :: UnfoldingGuidance -> Bool
isStableSource :: UnfoldingSource -> Bool
-- | Annotated core: allows annotation at every node in the tree
type AnnExpr bndr annot = (annot, AnnExpr' bndr annot)
-- | A clone of the Expr type but allowing annotation at every tree
-- node
data AnnExpr' bndr annot
AnnVar :: Id -> AnnExpr' bndr annot
AnnLit :: Literal -> AnnExpr' bndr annot
AnnLam :: bndr -> AnnExpr bndr annot -> AnnExpr' bndr annot
AnnApp :: AnnExpr bndr annot -> AnnExpr bndr annot -> AnnExpr' bndr annot
AnnCase :: AnnExpr bndr annot -> bndr -> Type -> [AnnAlt bndr annot] -> AnnExpr' bndr annot
AnnLet :: AnnBind bndr annot -> AnnExpr bndr annot -> AnnExpr' bndr annot
AnnCast :: AnnExpr bndr annot -> (annot, Coercion) -> AnnExpr' bndr annot
AnnTick :: CoreTickish -> AnnExpr bndr annot -> AnnExpr' bndr annot
AnnType :: Type -> AnnExpr' bndr annot
AnnCoercion :: Coercion -> AnnExpr' bndr annot
-- | A clone of the Bind type but allowing annotation at every tree
-- node
data AnnBind bndr annot
AnnNonRec :: bndr -> AnnExpr bndr annot -> AnnBind bndr annot
AnnRec :: [(bndr, AnnExpr bndr annot)] -> AnnBind bndr annot
-- | A clone of the Alt type but allowing annotation at every tree
-- node
data AnnAlt bndr annot
AnnAlt :: AltCon -> [bndr] -> AnnExpr bndr annot -> AnnAlt bndr annot
-- | Takes a nested application expression and returns the function being
-- applied and the arguments to which it is applied
collectAnnArgs :: AnnExpr b a -> (AnnExpr b a, [AnnExpr b a])
collectAnnArgsTicks :: (CoreTickish -> Bool) -> AnnExpr b a -> (AnnExpr b a, [AnnExpr b a], [CoreTickish])
deAnnotate :: AnnExpr bndr annot -> Expr bndr
deAnnotate' :: AnnExpr' bndr annot -> Expr bndr
deAnnAlt :: AnnAlt bndr annot -> Alt bndr
deAnnBind :: AnnBind b annot -> Bind b
-- | As collectBinders but for AnnExpr rather than
-- Expr
collectAnnBndrs :: AnnExpr bndr annot -> ([bndr], AnnExpr bndr annot)
-- | As collectNBinders but for AnnExpr rather than
-- Expr
collectNAnnBndrs :: Int -> AnnExpr bndr annot -> ([bndr], AnnExpr bndr annot)
-- | Is this instance an orphan? If it is not an orphan, contains an
-- OccName witnessing the instance's non-orphanhood. See Note
-- [Orphans]
data IsOrphan
IsOrphan :: IsOrphan
NotOrphan :: OccName -> IsOrphan
-- | Returns true if IsOrphan is orphan.
isOrphan :: IsOrphan -> Bool
-- | Returns true if IsOrphan is not an orphan.
notOrphan :: IsOrphan -> Bool
chooseOrphanAnchor :: NameSet -> IsOrphan
-- | A CoreRule is:
--
-- -- widthFromBytes (widthInBytes w) === w --widthInBytes :: Width -> Int -- | log_2 of the width in bytes, useful for generating shifts. widthInLog :: Width -> Int -- |
-- >>> narrowU W8 256 == 256 -- -- >>> narrowU W8 255 == 255 -- -- >>> narrowU W8 128 == 128 -- -- >>> narrowU W8 127 == 127 -- -- >>> narrowU W8 0 == 0 -- -- >>> narrowU W8 (-127) == 129 -- -- >>> narrowU W8 (-128) == 128 -- -- >>> narrowU W8 (-129) == 127 -- -- >>> narrowU W8 (-255) == 1 -- -- >>> narrowU W8 (-256) == 0 --narrowU :: Width -> Integer -> Integer -- | Narrow a signed value to the given width. The result will reside in -- [-2^(width-1), +2^(width-1)). -- --
-- >>> narrowS W8 256 == 0 -- -- >>> narrowS W8 255 == -1 -- -- >>> narrowS W8 128 == -128 -- -- >>> narrowS W8 127 == 127 -- -- >>> narrowS W8 0 == 0 -- -- >>> narrowS W8 (-127) == -127 -- -- >>> narrowS W8 (-128) == -128 -- -- >>> narrowS W8 (-129) == 127 -- -- >>> narrowS W8 (-255) == 1 -- -- >>> narrowS W8 (-256) == 0 --narrowS :: Width -> Integer -> Integer rEP_CostCentreStack_mem_alloc :: Platform -> CmmType rEP_CostCentreStack_scc_count :: Platform -> CmmType rEP_StgEntCounter_allocs :: Platform -> CmmType rEP_StgEntCounter_allocd :: Platform -> CmmType data ForeignHint NoHint :: ForeignHint AddrHint :: ForeignHint SignedHint :: ForeignHint type Length = Int vec :: Length -> CmmType -> CmmType vec2 :: CmmType -> CmmType vec4 :: CmmType -> CmmType vec8 :: CmmType -> CmmType vec16 :: CmmType -> CmmType vec2f64 :: CmmType vec2b64 :: CmmType vec4f32 :: CmmType vec4b32 :: CmmType vec8b16 :: CmmType vec16b8 :: CmmType cmmVec :: Int -> CmmType -> CmmType vecLength :: CmmType -> Length vecElemType :: CmmType -> CmmType isVecType :: CmmType -> Bool instance GHC.Show.Show GHC.Cmm.Type.Width instance GHC.Classes.Ord GHC.Cmm.Type.Width instance GHC.Classes.Eq GHC.Cmm.Type.Width instance GHC.Show.Show GHC.Cmm.Type.CmmCat instance GHC.Classes.Eq GHC.Cmm.Type.CmmCat instance GHC.Show.Show GHC.Cmm.Type.CmmType instance GHC.Classes.Eq GHC.Cmm.Type.ForeignHint instance GHC.Utils.Outputable.Outputable GHC.Cmm.Type.CmmType instance GHC.Utils.Outputable.Outputable GHC.Cmm.Type.CmmCat instance GHC.Utils.Outputable.Outputable GHC.Cmm.Type.Width -- | Tidying types and coercions for printing in error messages. module GHC.Core.TyCo.Tidy -- | Tidy a Type -- -- See Note [Strictness in tidyType and friends] tidyType :: TidyEnv -> Type -> Type -- | Tidy a list of Types -- -- See Note [Strictness in tidyType and friends] tidyTypes :: TidyEnv -> [Type] -> [Type] tidyOpenType :: TidyEnv -> Type -> (TidyEnv, Type) -- | Grabs the free type variables, tidies them and then uses -- tidyType to work over the type itself tidyOpenTypes :: TidyEnv -> [Type] -> (TidyEnv, [Type]) tidyOpenKind :: TidyEnv -> Kind -> (TidyEnv, Kind) tidyVarBndr :: TidyEnv -> TyCoVar -> (TidyEnv, TyCoVar) -- | This tidies up a type for printing in an error message, or in an -- interface file. -- -- It doesn't change the uniques at all, just the print names. tidyVarBndrs :: TidyEnv -> [TyCoVar] -> (TidyEnv, [TyCoVar]) -- | Add the free TyVars to the env in tidy form, so that we can -- tidy the type they are free in tidyFreeTyCoVars :: TidyEnv -> [TyCoVar] -> TidyEnv avoidNameClashes :: [TyCoVar] -> TidyEnv -> TidyEnv -- | Treat a new TyCoVar as a binder, and give it a fresh tidy name -- using the environment if one has not already been allocated. See also -- tidyVarBndr tidyOpenTyCoVar :: TidyEnv -> TyCoVar -> (TidyEnv, TyCoVar) tidyOpenTyCoVars :: TidyEnv -> [TyCoVar] -> (TidyEnv, [TyCoVar]) tidyTyCoVarOcc :: TidyEnv -> TyCoVar -> TyCoVar -- | Calls tidyType on a top-level type (i.e. with an empty tidying -- environment) tidyTopType :: Type -> Type tidyKind :: TidyEnv -> Kind -> Kind -- | Tidy a Coercion -- -- See Note [Strictness in tidyType and friends] tidyCo :: TidyEnv -> Coercion -> Coercion tidyCos :: TidyEnv -> [Coercion] -> [Coercion] tidyTyCoVarBinder :: TidyEnv -> VarBndr TyCoVar vis -> (TidyEnv, VarBndr TyCoVar vis) tidyTyCoVarBinders :: TidyEnv -> [VarBndr TyCoVar vis] -> (TidyEnv, [VarBndr TyCoVar vis]) -- | Unfolding creation module GHC.Core.Unfold.Make -- | There is no known Unfolding noUnfolding :: Unfolding mkUnfolding :: UnfoldingOpts -> UnfoldingSource -> Bool -> Bool -> CoreExpr -> Unfolding mkCoreUnfolding :: UnfoldingSource -> Bool -> CoreExpr -> UnfoldingGuidance -> Unfolding mkFinalUnfolding :: UnfoldingOpts -> UnfoldingSource -> StrictSig -> CoreExpr -> Unfolding mkSimpleUnfolding :: UnfoldingOpts -> CoreExpr -> Unfolding mkWorkerUnfolding :: SimpleOpts -> (CoreExpr -> CoreExpr) -> Unfolding -> Unfolding -- | Make an unfolding that may be used unsaturated (ug_unsat_ok = -- unSaturatedOk) and that is reported as having its manifest arity (the -- number of outer lambdas applications will resolve before doing any -- work). mkInlineUnfolding :: SimpleOpts -> CoreExpr -> Unfolding -- | Make an unfolding that will be used once the RHS has been saturated to -- the given arity. mkInlineUnfoldingWithArity :: Arity -> SimpleOpts -> CoreExpr -> Unfolding mkInlinableUnfolding :: SimpleOpts -> CoreExpr -> Unfolding mkWwInlineRule :: SimpleOpts -> CoreExpr -> Arity -> Unfolding -- | Used for things that absolutely must be unfolded mkCompulsoryUnfolding :: SimpleOpts -> CoreExpr -> Unfolding -- | Same as mkCompulsoryUnfolding but no simple optimiser pass is -- performed on the unfolding. mkCompulsoryUnfolding' :: CoreExpr -> Unfolding mkDFunUnfolding :: [Var] -> DataCon -> [CoreExpr] -> Unfolding specUnfolding :: SimpleOpts -> [Var] -> (CoreExpr -> CoreExpr) -> [CoreArg] -> Unfolding -> Unfolding module GHC.Core.SimpleOpt -- | Simple optimiser options data SimpleOpts SimpleOpts :: !UnfoldingOpts -> !OptCoercionOpts -> SimpleOpts -- | Unfolding options [so_uf_opts] :: SimpleOpts -> !UnfoldingOpts -- | Coercion optimiser options [so_co_opts] :: SimpleOpts -> !OptCoercionOpts -- | Default options for the Simple optimiser. defaultSimpleOpts :: SimpleOpts simpleOptPgm :: SimpleOpts -> Module -> CoreProgram -> [CoreRule] -> (CoreProgram, [CoreRule], CoreProgram) simpleOptExpr :: HasDebugCallStack => SimpleOpts -> CoreExpr -> CoreExpr simpleOptExprWith :: HasDebugCallStack => SimpleOpts -> Subst -> InExpr -> OutExpr -- | Returns Just (bndr,rhs) if the binding is a join point: If it's a -- JoinId, just return it If it's not yet a JoinId but is always -- tail-called, make it into a JoinId and return it. In the latter case, -- eta-expand the RHS if necessary, to make the lambdas explicit, as is -- required for join points -- -- Precondition: the InBndr has been occurrence-analysed, so its OccInfo -- is valid joinPointBinding_maybe :: InBndr -> InExpr -> Maybe (InBndr, InExpr) joinPointBindings_maybe :: [(InBndr, InExpr)] -> Maybe [(InBndr, InExpr)] -- | Returns Just ([b1..bp], dc, [t1..tk], [x1..xn]) if the -- argument expression is a *saturated* constructor application of the -- form let b1 in .. let bp in dc t1..tk x1 .. xn, where t1..tk -- are the *universally-quantified* type args of dc. Floats can -- also be (and most likely are) single-alternative case expressions. Why -- does exprIsConApp_maybe return floats? We may have to look -- through lets and cases to detect that we are in the presence of a data -- constructor wrapper. In this case, we need to return the lets and -- cases that we traversed. See Note [exprIsConApp_maybe on data -- constructors with wrappers]. Data constructor wrappers are unfolded -- late, but we really want to trigger case-of-known-constructor as early -- as possible. See also Note [Activation for data constructor wrappers] -- in GHC.Types.Id.Make. -- -- We also return the incoming InScopeSet, augmented with the binders -- from any [FloatBind] that we return exprIsConApp_maybe :: HasDebugCallStack => InScopeEnv -> CoreExpr -> Maybe (InScopeSet, [FloatBind], DataCon, [Type], [CoreExpr]) exprIsLiteral_maybe :: InScopeEnv -> CoreExpr -> Maybe Literal exprIsLambda_maybe :: HasDebugCallStack => InScopeEnv -> CoreExpr -> Maybe (Var, CoreExpr, [CoreTickish]) instance GHC.Utils.Outputable.Outputable GHC.Core.SimpleOpt.SimpleOptEnv module GHC.Core.Subst -- | A substitution environment, containing Id, TyVar, and -- CoVar substitutions. -- -- Some invariants apply to how you use the substitution: -- --
-- e' = etaExpand n e ---- -- We should have that: -- --
-- ty = exprType e = exprType e' --etaExpand :: Arity -> CoreExpr -> CoreExpr etaExpandAT :: ArityType -> CoreExpr -> CoreExpr exprBotStrictness_maybe :: CoreExpr -> Maybe (Arity, StrictSig) -- | The analysis lattice of arity analysis. It is isomorphic to -- --
-- data ArityType' -- = AEnd Divergence -- | ALam OneShotInfo ArityType' ---- -- Which is easier to display the Hasse diagram for: -- --
-- ALam OneShotLam at -- | -- AEnd topDiv -- | -- ALam NoOneShotInfo at -- | -- AEnd exnDiv -- | -- AEnd botDiv ---- -- where the at fields of ALam are inductively subject -- to the same order. That is, ALam os at1 < ALam os at2 iff -- at1 < at2. -- -- Why the strange Top element? See Note [Combining case branches]. -- -- We rely on this lattice structure for fixed-point iteration in -- findRhsArity. For the semantics of ArityType, see Note -- [ArityType]. data ArityType -- | AT oss div means this value can safely be eta-expanded -- length oss times, provided use sites respect the -- OneShotInfos in oss. A OneShotLam annotation -- can come from two sources: * The user annotated a lambda as one-shot -- with oneShot * It's from a lambda binder of a type affected by -- `-fstate-hack`. See idStateHackOneShotInfo. In both cases, -- OneShotLam should win over NoOneShotInfo, see Note -- [Combining case branches]. -- -- If div is dead-ending (isDeadEndDiv), then application -- to length os arguments will surely diverge, similar to the -- situation with DmdType. AT :: ![OneShotInfo] -> !Divergence -> ArityType mkBotArityType :: [OneShotInfo] -> ArityType mkTopArityType :: [OneShotInfo] -> ArityType -- | True = eta-expansion will add at least one lambda expandableArityType :: ArityType -> Bool -- | The number of value args for the arity type arityTypeArity :: ArityType -> Arity -- | Expand a non-bottoming arity type so that it has at least the given -- arity. maxWithArity :: ArityType -> Arity -> ArityType idArityType :: Id -> ArityType -- | Split an expression into the given number of binders and a body, -- eta-expanding if necessary. Counts value *and* type binders. etaExpandToJoinPoint :: JoinArity -> CoreExpr -> ([CoreBndr], CoreExpr) etaExpandToJoinPointRule :: JoinArity -> CoreRule -> CoreRule pushCoArg :: CoercionR -> CoreArg -> Maybe (CoreArg, MCoercion) pushCoArgs :: CoercionR -> [CoreArg] -> Maybe ([CoreArg], MCoercion) pushCoValArg :: CoercionR -> Maybe (MCoercionR, MCoercionR) pushCoTyArg :: CoercionR -> Type -> Maybe (Type, MCoercionR) pushCoercionIntoLambda :: HasDebugCallStack => InScopeSet -> Var -> CoreExpr -> CoercionR -> Maybe (Var, CoreExpr) pushCoDataCon :: DataCon -> [CoreExpr] -> Coercion -> Maybe (DataCon, [Type], [CoreExpr]) collectBindersPushingCo :: CoreExpr -> ([Var], CoreExpr) instance GHC.Classes.Eq GHC.Core.Opt.Arity.ArityType instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Arity.ArityType -- | Handy functions for creating much Core syntax module GHC.Core.Make -- | Bind a binding group over an expression, using a let or -- case as appropriate (see GHC.Core#let_app_invariant) mkCoreLet :: CoreBind -> CoreExpr -> CoreExpr -- | Bind a list of binding groups over an expression. The leftmost binding -- group becomes the outermost group in the resulting expression mkCoreLets :: [CoreBind] -> CoreExpr -> CoreExpr -- | Construct an expression which represents the application of one -- expression to the other Respects the let/app invariant by building a -- case expression where necessary See Note [Core let/app invariant] in -- GHC.Core mkCoreApp :: SDoc -> CoreExpr -> CoreExpr -> CoreExpr infixl 4 `mkCoreApp` -- | Construct an expression which represents the application of a number -- of expressions to another. The leftmost expression in the list is -- applied first Respects the let/app invariant by building a case -- expression where necessary See Note [Core let/app invariant] in -- GHC.Core mkCoreApps :: CoreExpr -> [CoreExpr] -> CoreExpr infixl 4 `mkCoreApps` -- | Construct an expression which represents the application of a number -- of expressions to that of a data constructor expression. The leftmost -- expression in the list is applied first mkCoreConApps :: DataCon -> [CoreExpr] -> CoreExpr -- | Create a lambda where the given expression has a number of variables -- bound over it. The leftmost binder is that bound by the outermost -- lambda in the result mkCoreLams :: [CoreBndr] -> CoreExpr -> CoreExpr mkWildCase :: CoreExpr -> Scaled Type -> Type -> [CoreAlt] -> CoreExpr mkIfThenElse :: CoreExpr -> CoreExpr -> CoreExpr -> CoreExpr -- | Make a wildcard binder. This is typically used when you need a -- binder that you expect to use only at a *binding* site. Do not use it -- at occurrence sites because it has a single, fixed unique, and it's -- very easy to get into difficulties with shadowing. That's why it is -- used so little. See Note [WildCard binders] in -- GHC.Core.Opt.Simplify.Env mkWildValBinder :: Mult -> Type -> Id mkWildEvBinder :: PredType -> EvVar mkSingleAltCase :: CoreExpr -> Id -> AltCon -> [Var] -> CoreExpr -> CoreExpr sortQuantVars :: [Var] -> [Var] castBottomExpr :: CoreExpr -> Type -> CoreExpr -- | Create a CoreExpr which will evaluate to the a Word -- with the given value mkWordExpr :: Platform -> Integer -> CoreExpr -- | Create a CoreExpr which will evaluate to the given Int mkIntExpr :: Platform -> Integer -> CoreExpr -- | Create a CoreExpr which will evaluate to the given Int mkIntExprInt :: Platform -> Int -> CoreExpr -- | Create a CoreExpr which will evaluate to the given -- Int. Don't check that the number is in the range of the -- target platform Int mkUncheckedIntExpr :: Integer -> CoreExpr -- | Create a CoreExpr which will evaluate to the given -- Integer mkIntegerExpr :: Integer -> CoreExpr -- | Create a CoreExpr which will evaluate to the given -- Natural mkNaturalExpr :: Integer -> CoreExpr -- | Create a CoreExpr which will evaluate to the given -- Float mkFloatExpr :: Float -> CoreExpr -- | Create a CoreExpr which will evaluate to the given -- Double mkDoubleExpr :: Double -> CoreExpr -- | Create a CoreExpr which will evaluate to the given -- Char mkCharExpr :: Char -> CoreExpr -- | Create a CoreExpr which will evaluate to the given -- String mkStringExpr :: MonadThings m => String -> m CoreExpr -- | Create a CoreExpr which will evaluate to a string morally -- equivalent to the given FastString mkStringExprFS :: MonadThings m => FastString -> m CoreExpr mkStringExprFSWith :: Monad m => (Name -> m Id) -> FastString -> m CoreExpr data FloatBind FloatLet :: CoreBind -> FloatBind FloatCase :: CoreExpr -> Id -> AltCon -> [Var] -> FloatBind wrapFloat :: FloatBind -> CoreExpr -> CoreExpr -- | Applies the floats from right to left. That is wrapFloats [b1, b2, -- …, bn] u = let b1 in let b2 in … in let bn in u wrapFloats :: [FloatBind] -> CoreExpr -> CoreExpr floatBindings :: FloatBind -> [Var] -- | Build the type of a small tuple that holds the specified variables -- One-tuples are flattened; see Note [Flattening one-tuples] mkCoreVarTupTy :: [Id] -> Type -- | Build a small tuple holding the specified expressions One-tuples are -- flattened; see Note [Flattening one-tuples] mkCoreTup :: [CoreExpr] -> CoreExpr -- | Build a small unboxed tuple holding the specified expressions, with -- the given types. The types must be the types of the expressions. Do -- not include the RuntimeRep specifiers; this function calculates them -- for you. Does not flatten one-tuples; see Note [Flattening -- one-tuples] mkCoreUbxTup :: [Type] -> [CoreExpr] -> CoreExpr -- | Build an unboxed sum. -- -- Alternative number ("alt") starts from 1. mkCoreUbxSum :: Int -> Int -> [Type] -> CoreExpr -> CoreExpr -- | Make a core tuple of the given boxity; don't flatten 1-tuples mkCoreTupBoxity :: Boxity -> [CoreExpr] -> CoreExpr -- | The unit expression unitExpr :: CoreExpr -- | Build a big tuple holding the specified variables One-tuples are -- flattened; see Note [Flattening one-tuples] mkBigCoreVarTup :: [Id] -> CoreExpr mkBigCoreVarTup1 :: [Id] -> CoreExpr -- | Build the type of a big tuple that holds the specified variables -- One-tuples are flattened; see Note [Flattening one-tuples] mkBigCoreVarTupTy :: [Id] -> Type -- | Build the type of a big tuple that holds the specified type of thing -- One-tuples are flattened; see Note [Flattening one-tuples] mkBigCoreTupTy :: [Type] -> Type -- | Build a big tuple holding the specified expressions One-tuples are -- flattened; see Note [Flattening one-tuples] mkBigCoreTup :: [CoreExpr] -> CoreExpr -- | mkSmallTupleSelector1 is like mkSmallTupleSelector but -- one-tuples are NOT flattened (see Note [Flattening one-tuples]) -- -- Like mkTupleSelector but for tuples that are guaranteed never -- to be "big". -- --
-- mkSmallTupleSelector [x] x v e = [| e |]
-- mkSmallTupleSelector [x,y,z] x v e = [| case e of v { (x,y,z) -> x } |]
--
mkSmallTupleSelector :: [Id] -> Id -> Id -> CoreExpr -> CoreExpr
-- | As mkTupleCase, but for a tuple that is small enough to be
-- guaranteed not to need nesting.
mkSmallTupleCase :: [Id] -> CoreExpr -> Id -> CoreExpr -> CoreExpr
-- | mkTupleSelector1 is like mkTupleSelector but one-tuples
-- are NOT flattened (see Note [Flattening one-tuples])
--
-- Builds a selector which scrutises the given expression and extracts
-- the one name from the list given. If you want the no-shadowing rule to
-- apply, the caller is responsible for making sure that none of these
-- names are in scope.
--
-- If there is just one Id in the tuple, then the selector is just
-- the identity.
--
-- If necessary, we pattern match on a "big" tuple.
--
-- A tuple selector is not linear in its argument. Consequently, the case
-- expression built by mkTupleSelector must consume its scrutinee
-- Many times. And all the argument variables must have
-- multiplicity Many.
mkTupleSelector :: [Id] -> Id -> Id -> CoreExpr -> CoreExpr
-- | Builds a selector which scrutises the given expression and extracts
-- the one name from the list given. If you want the no-shadowing rule to
-- apply, the caller is responsible for making sure that none of these
-- names are in scope.
--
-- If there is just one Id in the tuple, then the selector is just
-- the identity.
--
-- If necessary, we pattern match on a "big" tuple.
--
-- A tuple selector is not linear in its argument. Consequently, the case
-- expression built by mkTupleSelector must consume its scrutinee
-- Many times. And all the argument variables must have
-- multiplicity Many.
mkTupleSelector1 :: [Id] -> Id -> Id -> CoreExpr -> CoreExpr
-- | A generalization of mkTupleSelector, allowing the body of the
-- case to be an arbitrary expression.
--
-- To avoid shadowing, we use uniques to invent new variables.
--
-- If necessary we pattern match on a "big" tuple.
mkTupleCase :: UniqSupply -> [Id] -> CoreExpr -> Id -> CoreExpr -> CoreExpr
-- | Makes a list [] for lists of the specified type
mkNilExpr :: Type -> CoreExpr
-- | Makes a list (:) for lists of the specified type
mkConsExpr :: Type -> CoreExpr -> CoreExpr -> CoreExpr
-- | Make a list containing the given expressions, where the list has the
-- given type
mkListExpr :: Type -> [CoreExpr] -> CoreExpr
-- | Make a fully applied foldr expression
mkFoldrExpr :: MonadThings m => Type -> Type -> CoreExpr -> CoreExpr -> CoreExpr -> m CoreExpr
-- | Make a build expression applied to a locally-bound worker
-- function
mkBuildExpr :: (MonadFail m, MonadThings m, MonadUnique m) => Type -> ((Id, Type) -> (Id, Type) -> m CoreExpr) -> m CoreExpr
mkNonEmptyListExpr :: Type -> CoreExpr -> [CoreExpr] -> CoreExpr
-- | Makes a Nothing for the specified type
mkNothingExpr :: Type -> CoreExpr
-- | Makes a Just from a value of the specified type
mkJustExpr :: Type -> CoreExpr -> CoreExpr
mkRuntimeErrorApp :: Id -> Type -> String -> CoreExpr
mkImpossibleExpr :: Type -> CoreExpr
mkAbsentErrorApp :: Type -> String -> CoreExpr
errorIds :: [Id]
rEC_CON_ERROR_ID :: Id
rUNTIME_ERROR_ID :: Id
nON_EXHAUSTIVE_GUARDS_ERROR_ID :: Id
nO_METHOD_BINDING_ERROR_ID :: Id
pAT_ERROR_ID :: Id
rEC_SEL_ERROR_ID :: Id
aBSENT_ERROR_ID :: Id
tYPE_ERROR_ID :: Id
aBSENT_SUM_FIELD_ERROR_ID :: Id
instance GHC.Utils.Outputable.Outputable GHC.Core.Make.FloatBind
-- | Here we collect a variety of helper functions that construct or
-- analyse HsSyn. All these functions deal with generic HsSyn; functions
-- which deal with the instantiated versions are located elsewhere:
--
-- Parameterised by Module ---------------- ------------- GhcPs/RdrName
-- GHC.Parser.PostProcess GhcRn/Name GHC.Rename.* GhcTc/Id
-- GHC.Tc.Utils.Zonk
--
-- The mk* functions attempt to construct a
-- not-completely-useless SrcSpan from their components, compared with
-- the nl* functions which just attach noSrcSpan to everything.
module GHC.Hs.Utils
-- | -- e => (e) --mkHsPar :: LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) mkHsApp :: LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) mkHsAppWith :: (LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -> HsExpr (GhcPass id) -> LHsExpr (GhcPass id)) -> LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) mkHsApps :: LHsExpr (GhcPass id) -> [LHsExpr (GhcPass id)] -> LHsExpr (GhcPass id) mkHsAppsWith :: (LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -> HsExpr (GhcPass id) -> LHsExpr (GhcPass id)) -> LHsExpr (GhcPass id) -> [LHsExpr (GhcPass id)] -> LHsExpr (GhcPass id) mkHsAppType :: LHsExpr GhcRn -> LHsWcType GhcRn -> LHsExpr GhcRn mkHsAppTypes :: LHsExpr GhcRn -> [LHsWcType GhcRn] -> LHsExpr GhcRn -- | A simple case alternative with a single pattern, no binds, no guards; -- pre-typechecking mkHsCaseAlt :: (Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p)))) ~ SrcSpan, Anno (Match (GhcPass p) (LocatedA (body (GhcPass p)))) ~ SrcSpanAnnA) => LPat (GhcPass p) -> LocatedA (body (GhcPass p)) -> LMatch (GhcPass p) (LocatedA (body (GhcPass p))) mkSimpleMatch :: (Anno (Match (GhcPass p) (LocatedA (body (GhcPass p)))) ~ SrcSpanAnnA, Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p)))) ~ SrcSpan) => HsMatchContext (NoGhcTc (GhcPass p)) -> [LPat (GhcPass p)] -> LocatedA (body (GhcPass p)) -> LMatch (GhcPass p) (LocatedA (body (GhcPass p))) unguardedGRHSs :: Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p)))) ~ SrcSpan => SrcSpan -> LocatedA (body (GhcPass p)) -> EpAnn GrhsAnn -> GRHSs (GhcPass p) (LocatedA (body (GhcPass p))) unguardedRHS :: Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p)))) ~ SrcSpan => EpAnn GrhsAnn -> SrcSpan -> LocatedA (body (GhcPass p)) -> [LGRHS (GhcPass p) (LocatedA (body (GhcPass p)))] mkMatchGroup :: AnnoBody p body => Origin -> LocatedL [LocatedA (Match (GhcPass p) (LocatedA (body (GhcPass p))))] -> MatchGroup (GhcPass p) (LocatedA (body (GhcPass p))) mkMatch :: forall p. IsPass p => HsMatchContext (NoGhcTc (GhcPass p)) -> [LPat (GhcPass p)] -> LHsExpr (GhcPass p) -> HsLocalBinds (GhcPass p) -> LMatch (GhcPass p) (LHsExpr (GhcPass p)) -- | Make a prefix, non-strict function HsMatchContext mkPrefixFunRhs :: LIdP p -> HsMatchContext p mkHsLam :: (IsPass p, XMG (GhcPass p) (LHsExpr (GhcPass p)) ~ NoExtField) => [LPat (GhcPass p)] -> LHsExpr (GhcPass p) -> LHsExpr (GhcPass p) mkHsIf :: LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs -> EpAnn AnnsIf -> HsExpr GhcPs -- | Avoid HsWrap co1 (HsWrap co2 _) and -- HsWrap co1 (HsPar _ _) See Note [Detecting -- forced eta expansion] in GHC.HsToCore.Expr mkHsWrap :: HsWrapper -> HsExpr GhcTc -> HsExpr GhcTc mkLHsWrap :: HsWrapper -> LHsExpr GhcTc -> LHsExpr GhcTc mkHsWrapCo :: TcCoercionN -> HsExpr GhcTc -> HsExpr GhcTc mkHsWrapCoR :: TcCoercionR -> HsExpr GhcTc -> HsExpr GhcTc mkLHsWrapCo :: TcCoercionN -> LHsExpr GhcTc -> LHsExpr GhcTc mkHsDictLet :: TcEvBinds -> LHsExpr GhcTc -> LHsExpr GhcTc mkHsLams :: [TyVar] -> [EvVar] -> LHsExpr GhcTc -> LHsExpr GhcTc -- | A useful function for building OpApps. The operator is always -- a variable, and we don't know the fixity yet. mkHsOpApp :: LHsExpr GhcPs -> IdP GhcPs -> LHsExpr GhcPs -> HsExpr GhcPs mkHsDo :: HsStmtContext GhcRn -> LocatedL [ExprLStmt GhcPs] -> HsExpr GhcPs mkHsDoAnns :: HsStmtContext GhcRn -> LocatedL [ExprLStmt GhcPs] -> EpAnn AnnList -> HsExpr GhcPs mkHsComp :: HsStmtContext GhcRn -> [ExprLStmt GhcPs] -> LHsExpr GhcPs -> HsExpr GhcPs mkHsCompAnns :: HsStmtContext GhcRn -> [ExprLStmt GhcPs] -> LHsExpr GhcPs -> EpAnn AnnList -> HsExpr GhcPs mkHsWrapPat :: HsWrapper -> Pat GhcTc -> Type -> Pat GhcTc mkHsWrapPatCo :: TcCoercionN -> Pat GhcTc -> Type -> Pat GhcTc -- | Wrap in parens if hsExprNeedsParens appPrec says it -- needs them So f x becomes (f x), but 3 -- stays as 3. mkLHsPar :: IsPass id => LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) mkHsCmdWrap :: HsWrapper -> HsCmd GhcTc -> HsCmd GhcTc mkLHsCmdWrap :: HsWrapper -> LHsCmd GhcTc -> LHsCmd GhcTc mkHsCmdIf :: LHsExpr GhcPs -> LHsCmd GhcPs -> LHsCmd GhcPs -> EpAnn AnnsIf -> HsCmd GhcPs nlHsTyApp :: Id -> [Type] -> LHsExpr GhcTc nlHsTyApps :: Id -> [Type] -> [LHsExpr GhcTc] -> LHsExpr GhcTc nlHsVar :: IsSrcSpanAnn p a => IdP (GhcPass p) -> LHsExpr (GhcPass p) nl_HsVar :: IsSrcSpanAnn p a => IdP (GhcPass p) -> HsExpr (GhcPass p) -- | NB: Only for LHsExpr Id. nlHsDataCon :: DataCon -> LHsExpr GhcTc nlHsLit :: HsLit (GhcPass p) -> LHsExpr (GhcPass p) nlHsApp :: IsPass id => LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) nlHsApps :: IsSrcSpanAnn p a => IdP (GhcPass p) -> [LHsExpr (GhcPass p)] -> LHsExpr (GhcPass p) nlHsSyntaxApps :: SyntaxExprTc -> [LHsExpr GhcTc] -> LHsExpr GhcTc nlHsIntLit :: Integer -> LHsExpr (GhcPass p) nlHsVarApps :: IsSrcSpanAnn p a => IdP (GhcPass p) -> [IdP (GhcPass p)] -> LHsExpr (GhcPass p) nlHsDo :: HsStmtContext GhcRn -> [LStmt GhcPs (LHsExpr GhcPs)] -> LHsExpr GhcPs nlHsOpApp :: LHsExpr GhcPs -> IdP GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs nlHsLam :: LMatch GhcPs (LHsExpr GhcPs) -> LHsExpr GhcPs nlHsPar :: LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) nlHsIf :: LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs nlHsCase :: LHsExpr GhcPs -> [LMatch GhcPs (LHsExpr GhcPs)] -> LHsExpr GhcPs nlList :: [LHsExpr GhcPs] -> LHsExpr GhcPs mkLHsTupleExpr :: [LHsExpr (GhcPass p)] -> XExplicitTuple (GhcPass p) -> LHsExpr (GhcPass p) mkLHsVarTuple :: IsSrcSpanAnn p a => [IdP (GhcPass p)] -> XExplicitTuple (GhcPass p) -> LHsExpr (GhcPass p) missingTupArg :: EpAnn EpaLocation -> HsTupArg GhcPs mkLocatedList :: Semigroup a => [GenLocated (SrcAnn a) e2] -> LocatedAn an [GenLocated (SrcAnn a) e2] -- | Lifts a "small" constructor into a "big" constructor by recursive -- decomposition mkChunkified :: ([a] -> a) -> [a] -> a -- | Split a list into lists that are small enough to have a corresponding -- tuple arity. The sub-lists of the result all have length <= -- mAX_TUPLE_SIZE But there may be more than mAX_TUPLE_SIZE -- sub-lists chunkify :: [a] -> [[a]] -- | Not infix, with place holders for coercion and free vars mkFunBind :: Origin -> LocatedN RdrName -> [LMatch GhcPs (LHsExpr GhcPs)] -> HsBind GhcPs mkVarBind :: IdP (GhcPass p) -> LHsExpr (GhcPass p) -> LHsBind (GhcPass p) mkHsVarBind :: SrcSpan -> RdrName -> LHsExpr GhcPs -> LHsBind GhcPs -- | Convenience function using mkFunBind. This is for generated -- bindings only, do not use for user-written code. mkSimpleGeneratedFunBind :: SrcSpan -> RdrName -> [LPat GhcPs] -> LHsExpr GhcPs -> LHsBind GhcPs -- | In Name-land, with empty bind_fvs mkTopFunBind :: Origin -> LocatedN Name -> [LMatch GhcRn (LHsExpr GhcRn)] -> HsBind GhcRn mkPatSynBind :: LocatedN RdrName -> HsPatSynDetails GhcPs -> LPat GhcPs -> HsPatSynDir GhcPs -> EpAnn [AddEpAnn] -> HsBind GhcPs -- | If any of the matches in the FunBind are infix, the -- FunBind is considered infix. isInfixFunBind :: forall id1 id2. UnXRec id2 => HsBindLR id1 id2 -> Bool -- | Return the SrcSpan encompassing the contents of any enclosed -- binds spanHsLocaLBinds :: Data (HsLocalBinds (GhcPass p)) => HsLocalBinds (GhcPass p) -> SrcSpan mkHsIntegral :: IntegralLit -> HsOverLit GhcPs mkHsFractional :: FractionalLit -> HsOverLit GhcPs mkHsIsString :: SourceText -> FastString -> HsOverLit GhcPs mkHsString :: String -> HsLit (GhcPass p) mkHsStringPrimLit :: FastString -> HsLit (GhcPass p) mkHsCharPrimLit :: Char -> HsLit (GhcPass p) mkNPat :: Located (HsOverLit GhcPs) -> Maybe (SyntaxExpr GhcPs) -> EpAnn [AddEpAnn] -> Pat GhcPs mkNPlusKPat :: LocatedN RdrName -> Located (HsOverLit GhcPs) -> EpAnn EpaLocation -> Pat GhcPs nlVarPat :: IsSrcSpanAnn p a => IdP (GhcPass p) -> LPat (GhcPass p) nlLitPat :: HsLit GhcPs -> LPat GhcPs nlConVarPat :: RdrName -> [RdrName] -> LPat GhcPs nlConVarPatName :: Name -> [Name] -> LPat GhcRn nlConPat :: RdrName -> [LPat GhcPs] -> LPat GhcPs nlConPatName :: Name -> [LPat GhcRn] -> LPat GhcRn nlInfixConPat :: RdrName -> LPat GhcPs -> LPat GhcPs -> LPat GhcPs nlNullaryConPat :: RdrName -> LPat GhcPs nlWildConPat :: DataCon -> LPat GhcPs -- | Wildcard pattern - after parsing nlWildPat :: LPat GhcPs -- | Wildcard pattern - after renaming nlWildPatName :: LPat GhcRn nlTuplePat :: [LPat GhcPs] -> Boxity -> LPat GhcPs mkParPat :: IsPass p => LPat (GhcPass p) -> LPat (GhcPass p) nlParPat :: LPat (GhcPass name) -> LPat (GhcPass name) -- | The Big equivalents for the source tuple expressions mkBigLHsVarTup :: IsSrcSpanAnn p a => [IdP (GhcPass p)] -> XExplicitTuple (GhcPass p) -> LHsExpr (GhcPass p) mkBigLHsTup :: [LHsExpr (GhcPass id)] -> XExplicitTuple (GhcPass id) -> LHsExpr (GhcPass id) -- | The Big equivalents for the source tuple patterns mkBigLHsVarPatTup :: [IdP GhcRn] -> LPat GhcRn mkBigLHsPatTup :: [LPat GhcRn] -> LPat GhcRn mkHsAppTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) mkHsAppKindTy :: XAppKindTy (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) -- | Convert an LHsType to an LHsSigType. hsTypeToHsSigType :: LHsType GhcPs -> LHsSigType GhcPs -- | Convert an LHsType to an LHsSigWcType. hsTypeToHsSigWcType :: LHsType GhcPs -> LHsSigWcType GhcPs -- | Convert TypeSig to ClassOpSig. The former is what is -- parsed, but the latter is what we need in class/instance declarations mkClassOpSigs :: [LSig GhcPs] -> [LSig GhcPs] mkHsSigEnv :: forall a. (LSig GhcRn -> Maybe ([LocatedN Name], a)) -> [LSig GhcRn] -> NameEnv a nlHsAppTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsAppKindTy :: LHsType (GhcPass p) -> LHsKind (GhcPass p) -> LHsType (GhcPass p) nlHsTyVar :: IsSrcSpanAnn p a => IdP (GhcPass p) -> LHsType (GhcPass p) nlHsFunTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsParTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsTyConApp :: IsSrcSpanAnn p a => LexicalFixity -> IdP (GhcPass p) -> [LHsTypeArg (GhcPass p)] -> LHsType (GhcPass p) mkTransformStmt :: EpAnn [AddEpAnn] -> [ExprLStmt GhcPs] -> LHsExpr GhcPs -> StmtLR GhcPs GhcPs (LHsExpr GhcPs) mkTransformByStmt :: EpAnn [AddEpAnn] -> [ExprLStmt GhcPs] -> LHsExpr GhcPs -> LHsExpr GhcPs -> StmtLR GhcPs GhcPs (LHsExpr GhcPs) mkBodyStmt :: LocatedA (bodyR GhcPs) -> StmtLR (GhcPass idL) GhcPs (LocatedA (bodyR GhcPs)) mkPsBindStmt :: EpAnn [AddEpAnn] -> LPat GhcPs -> LocatedA (bodyR GhcPs) -> StmtLR GhcPs GhcPs (LocatedA (bodyR GhcPs)) mkRnBindStmt :: LPat GhcRn -> LocatedA (bodyR GhcRn) -> StmtLR GhcRn GhcRn (LocatedA (bodyR GhcRn)) mkTcBindStmt :: LPat GhcTc -> LocatedA (bodyR GhcTc) -> StmtLR GhcTc GhcTc (LocatedA (bodyR GhcTc)) mkLastStmt :: IsPass idR => LocatedA (bodyR (GhcPass idR)) -> StmtLR (GhcPass idL) (GhcPass idR) (LocatedA (bodyR (GhcPass idR))) emptyTransStmt :: EpAnn [AddEpAnn] -> StmtLR GhcPs GhcPs (LHsExpr GhcPs) mkGroupUsingStmt :: EpAnn [AddEpAnn] -> [ExprLStmt GhcPs] -> LHsExpr GhcPs -> StmtLR GhcPs GhcPs (LHsExpr GhcPs) mkGroupByUsingStmt :: EpAnn [AddEpAnn] -> [ExprLStmt GhcPs] -> LHsExpr GhcPs -> LHsExpr GhcPs -> StmtLR GhcPs GhcPs (LHsExpr GhcPs) emptyRecStmt :: Anno [GenLocated (Anno (StmtLR (GhcPass idL) GhcPs bodyR)) (StmtLR (GhcPass idL) GhcPs bodyR)] ~ SrcSpanAnnL => StmtLR (GhcPass idL) GhcPs bodyR emptyRecStmtName :: Anno [GenLocated (Anno (StmtLR GhcRn GhcRn bodyR)) (StmtLR GhcRn GhcRn bodyR)] ~ SrcSpanAnnL => StmtLR GhcRn GhcRn bodyR emptyRecStmtId :: Stmt GhcTc (LocatedA (HsCmd GhcTc)) mkRecStmt :: Anno [GenLocated (Anno (StmtLR (GhcPass idL) GhcPs bodyR)) (StmtLR (GhcPass idL) GhcPs bodyR)] ~ SrcSpanAnnL => EpAnn AnnList -> LocatedL [LStmtLR (GhcPass idL) GhcPs bodyR] -> StmtLR (GhcPass idL) GhcPs bodyR unitRecStmtTc :: RecStmtTc mkLetStmt :: EpAnn [AddEpAnn] -> HsLocalBinds GhcPs -> StmtLR GhcPs GhcPs (LocatedA b) mkUntypedSplice :: EpAnn [AddEpAnn] -> SpliceDecoration -> LHsExpr GhcPs -> HsSplice GhcPs mkTypedSplice :: EpAnn [AddEpAnn] -> SpliceDecoration -> LHsExpr GhcPs -> HsSplice GhcPs mkHsQuasiQuote :: RdrName -> SrcSpan -> FastString -> HsSplice GhcPs -- | Should we treat this as an unlifted bind? This will be true for any -- bind that binds an unlifted variable, but we must be careful around -- AbsBinds. See Note [Unlifted id check in isUnliftedHsBind]. For usage -- information, see Note [Strict binds checks] is GHC.HsToCore.Binds. isUnliftedHsBind :: HsBind GhcTc -> Bool -- | Is a binding a strict variable or pattern bind (e.g. !x = -- ...)? isBangedHsBind :: HsBind GhcTc -> Bool collectLocalBinders :: CollectPass (GhcPass idL) => CollectFlag (GhcPass idL) -> HsLocalBindsLR (GhcPass idL) (GhcPass idR) -> [IdP (GhcPass idL)] collectHsValBinders :: CollectPass (GhcPass idL) => CollectFlag (GhcPass idL) -> HsValBindsLR (GhcPass idL) (GhcPass idR) -> [IdP (GhcPass idL)] -- | Same as collectHsBindsBinders, but works over a list of -- bindings collectHsBindListBinders :: forall p idR. CollectPass p => CollectFlag p -> [LHsBindLR p idR] -> [IdP p] -- | Collect Id binders only, or Ids + pattern synonyms, -- respectively collectHsIdBinders :: CollectPass (GhcPass idL) => CollectFlag (GhcPass idL) -> HsValBindsLR (GhcPass idL) (GhcPass idR) -> [IdP (GhcPass idL)] collectHsBindsBinders :: CollectPass p => CollectFlag p -> LHsBindsLR p idR -> [IdP p] -- | Collect both Ids and pattern-synonym binders collectHsBindBinders :: CollectPass p => CollectFlag p -> HsBindLR p idR -> [IdP p] -- | Used exclusively for the bindings of an instance decl which are all -- FunBinds collectMethodBinders :: forall idL idR. UnXRec idL => LHsBindsLR idL idR -> [LIdP idL] collectPatBinders :: CollectPass p => CollectFlag p -> LPat p -> [IdP p] collectPatsBinders :: CollectPass p => CollectFlag p -> [LPat p] -> [IdP p] collectLStmtsBinders :: CollectPass (GhcPass idL) => CollectFlag (GhcPass idL) -> [LStmtLR (GhcPass idL) (GhcPass idR) body] -> [IdP (GhcPass idL)] collectStmtsBinders :: CollectPass (GhcPass idL) => CollectFlag (GhcPass idL) -> [StmtLR (GhcPass idL) (GhcPass idR) body] -> [IdP (GhcPass idL)] collectLStmtBinders :: CollectPass (GhcPass idL) => CollectFlag (GhcPass idL) -> LStmtLR (GhcPass idL) (GhcPass idR) body -> [IdP (GhcPass idL)] collectStmtBinders :: CollectPass (GhcPass idL) => CollectFlag (GhcPass idL) -> StmtLR (GhcPass idL) (GhcPass idR) body -> [IdP (GhcPass idL)] -- | This class specifies how to collect variable identifiers from -- extension patterns in the given pass. Consumers of the GHC API that -- define their own passes should feel free to implement instances in -- order to make use of functions which depend on it. -- -- In particular, Haddock already makes use of this, with an instance for -- its DocNameI pass so that it can reuse the code in GHC for -- collecting binders. class UnXRec p => CollectPass p collectXXPat :: CollectPass p => Proxy p -> CollectFlag p -> XXPat p -> [IdP p] -> [IdP p] -- | Indicate if evidence binders have to be collected. -- -- This type is used as a boolean (should we collect evidence binders or -- not?) but also to pass an evidence that the AST has been typechecked -- when we do want to collect evidence binders, otherwise these binders -- are not available. -- -- See Note [Dictionary binders in ConPatOut] data CollectFlag p -- | Don't collect evidence binders [CollNoDictBinders] :: CollectFlag p -- | Collect evidence binders [CollWithDictBinders] :: CollectFlag GhcTc -- | Returns all the binding names of the decl. The first one is -- guaranteed to be the name of the decl. The first component represents -- all binding names except record fields; the second represents field -- occurrences. For record fields mentioned in multiple constructors, the -- SrcLoc will be from the first occurrence. -- -- Each returned (Located name) has a SrcSpan for the whole -- declaration. See Note [SrcSpan for binders] hsLTyClDeclBinders :: IsPass p => LocatedA (TyClDecl (GhcPass p)) -> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)]) hsTyClForeignBinders :: [TyClGroup GhcRn] -> [LForeignDecl GhcRn] -> [Name] -- | Collects record pattern-synonym selectors only; the pattern synonym -- names are collected by collectHsValBinders. hsPatSynSelectors :: IsPass p => HsValBinds (GhcPass p) -> [FieldOcc (GhcPass p)] getPatSynBinds :: forall id. UnXRec id => [(RecFlag, LHsBinds id)] -> [PatSynBind id id] -- | See Note [SrcSpan for binders] hsForeignDeclsBinders :: forall p a. (UnXRec (GhcPass p), IsSrcSpanAnn p a) => [LForeignDecl (GhcPass p)] -> [LIdP (GhcPass p)] hsGroupBinders :: HsGroup GhcRn -> [Name] -- | the SrcLoc returned are for the whole declarations, not just -- the names hsDataFamInstBinders :: IsPass p => DataFamInstDecl (GhcPass p) -> ([LocatedA (IdP (GhcPass p))], [LFieldOcc (GhcPass p)]) lStmtsImplicits :: [LStmtLR GhcRn (GhcPass idR) (LocatedA (body (GhcPass idR)))] -> [(SrcSpan, [Name])] hsValBindsImplicits :: HsValBindsLR GhcRn (GhcPass idR) -> [(SrcSpan, [Name])] lPatImplicits :: LPat GhcRn -> [(SrcSpan, [Name])] instance GHC.Hs.Extension.IsPass p => GHC.Hs.Utils.CollectPass (GHC.Hs.Extension.GhcPass p) module GHC.Tc.Types.Evidence data HsWrapper WpHole :: HsWrapper WpCompose :: HsWrapper -> HsWrapper -> HsWrapper WpFun :: HsWrapper -> HsWrapper -> Scaled TcType -> SDoc -> HsWrapper WpCast :: TcCoercionR -> HsWrapper WpEvLam :: EvVar -> HsWrapper WpEvApp :: EvTerm -> HsWrapper WpTyLam :: TyVar -> HsWrapper WpTyApp :: KindOrType -> HsWrapper WpLet :: TcEvBinds -> HsWrapper WpMultCoercion :: Coercion -> HsWrapper (<.>) :: HsWrapper -> HsWrapper -> HsWrapper mkWpTyApps :: [Type] -> HsWrapper mkWpEvApps :: [EvTerm] -> HsWrapper mkWpEvVarApps :: [EvVar] -> HsWrapper mkWpTyLams :: [TyVar] -> HsWrapper mkWpLams :: [Var] -> HsWrapper mkWpLet :: TcEvBinds -> HsWrapper mkWpCastN :: TcCoercionN -> HsWrapper mkWpCastR :: TcCoercionR -> HsWrapper collectHsWrapBinders :: HsWrapper -> ([Var], HsWrapper) mkWpFun :: HsWrapper -> HsWrapper -> Scaled TcType -> TcType -> SDoc -> HsWrapper idHsWrapper :: HsWrapper isIdHsWrapper :: HsWrapper -> Bool pprHsWrapper :: HsWrapper -> (Bool -> SDoc) -> SDoc -- | Identifies the lambda-bound dictionaries of an -- HsWrapper. This is used (only) to allow the pattern-match -- overlap checker to know what Given dictionaries are in scope. -- -- We specifically do not collect dictionaries bound in a WpLet. -- These are either superclasses of lambda-bound ones, or (extremely -- numerous) results of binding Wanted dictionaries. We definitely don't -- want all those cluttering up the Given dictionaries for pattern-match -- overlap checking! hsWrapDictBinders :: HsWrapper -> Bag DictId data TcEvBinds TcEvBinds :: EvBindsVar -> TcEvBinds EvBinds :: Bag EvBind -> TcEvBinds data EvBindsVar EvBindsVar :: Unique -> IORef EvBindMap -> IORef CoVarSet -> EvBindsVar [ebv_uniq] :: EvBindsVar -> Unique [ebv_binds] :: EvBindsVar -> IORef EvBindMap [ebv_tcvs] :: EvBindsVar -> IORef CoVarSet CoEvBindsVar :: Unique -> IORef CoVarSet -> EvBindsVar [ebv_uniq] :: EvBindsVar -> Unique [ebv_tcvs] :: EvBindsVar -> IORef CoVarSet newtype EvBindMap EvBindMap :: DVarEnv EvBind -> EvBindMap [ev_bind_varenv] :: EvBindMap -> DVarEnv EvBind emptyEvBindMap :: EvBindMap extendEvBinds :: EvBindMap -> EvBind -> EvBindMap lookupEvBind :: EvBindMap -> EvVar -> Maybe EvBind evBindMapBinds :: EvBindMap -> Bag EvBind foldEvBindMap :: (EvBind -> a -> a) -> a -> EvBindMap -> a nonDetStrictFoldEvBindMap :: (EvBind -> a -> a) -> a -> EvBindMap -> a filterEvBindMap :: (EvBind -> Bool) -> EvBindMap -> EvBindMap isEmptyEvBindMap :: EvBindMap -> Bool evBindMapToVarSet :: EvBindMap -> VarSet varSetMinusEvBindMap :: VarSet -> EvBindMap -> VarSet data EvBind EvBind :: EvVar -> EvTerm -> Bool -> EvBind [eb_lhs] :: EvBind -> EvVar [eb_rhs] :: EvBind -> EvTerm [eb_is_given] :: EvBind -> Bool emptyTcEvBinds :: TcEvBinds isEmptyTcEvBinds :: TcEvBinds -> Bool mkGivenEvBind :: EvVar -> EvTerm -> EvBind mkWantedEvBind :: EvVar -> EvTerm -> EvBind evBindVar :: EvBind -> EvVar isCoEvBindsVar :: EvBindsVar -> Bool data EvTerm EvExpr :: EvExpr -> EvTerm EvTypeable :: Type -> EvTypeable -> EvTerm EvFun :: [TyVar] -> [EvVar] -> TcEvBinds -> EvVar -> EvTerm [et_tvs] :: EvTerm -> [TyVar] [et_given] :: EvTerm -> [EvVar] [et_binds] :: EvTerm -> TcEvBinds [et_body] :: EvTerm -> EvVar type EvExpr = CoreExpr -- | Any sort of evidence Id, including coercions evId :: EvId -> EvExpr evCoercion :: TcCoercion -> EvTerm -- | d |> co evCast :: EvExpr -> TcCoercion -> EvTerm evDFunApp :: DFunId -> [Type] -> [EvExpr] -> EvTerm evDataConApp :: DataCon -> [Type] -> [EvExpr] -> EvTerm evSelector :: Id -> [Type] -> [EvExpr] -> EvExpr mkEvCast :: EvExpr -> TcCoercion -> EvTerm evVarsOfTerm :: EvTerm -> VarSet mkEvScSelectors :: Class -> [TcType] -> [(TcPredType, EvExpr)] evTypeable :: Type -> EvTypeable -> EvTerm findNeededEvVars :: EvBindMap -> VarSet -> VarSet evTermCoercion :: EvTerm -> TcCoercion evTermCoercion_maybe :: EvTerm -> Maybe TcCoercion -- | Evidence for CallStack implicit parameters. data EvCallStack EvCsEmpty :: EvCallStack -- | EvCsPushCall name loc stk represents a call to name, -- occurring at loc, in a calling context stk. EvCsPushCall :: Name -> RealSrcSpan -> EvExpr -> EvCallStack -- | Instructions on how to make a Typeable dictionary. See Note -- [Typeable evidence terms] data EvTypeable -- | Dictionary for Typeable T where T is a type -- constructor with all of its kind variables saturated. The -- [EvTerm] is Typeable evidence for the applied -- kinds.. EvTypeableTyCon :: TyCon -> [EvTerm] -> EvTypeable -- | Dictionary for Typeable (s t), given a dictionaries for -- s and t. EvTypeableTyApp :: EvTerm -> EvTerm -> EvTypeable -- | Dictionary for Typeable (s # w -> t), given a dictionaries -- for w, s, and t. EvTypeableTrFun :: EvTerm -> EvTerm -> EvTerm -> EvTypeable -- | Dictionary for a type literal, e.g. Typeable "foo" or -- Typeable 3 The EvTerm is evidence of, e.g., -- KnownNat 3 (see #10348) EvTypeableTyLit :: EvTerm -> EvTypeable -- | Where to store evidence for expression holes See Note [Holes] in -- GHC.Tc.Types.Constraint data HoleExprRef HER :: IORef EvTerm -> TcType -> Unique -> HoleExprRef type TcCoercion = Coercion type TcCoercionR = CoercionR type TcCoercionN = CoercionN type TcCoercionP = CoercionP -- | A coercion to be filled in by the type-checker. See Note [Coercion -- holes] data CoercionHole type TcMCoercion = MCoercion type TcMCoercionN = MCoercionN type TcMCoercionR = MCoercionR data Role Nominal :: Role Representational :: Role Phantom :: Role data LeftOrRight CLeft :: LeftOrRight CRight :: LeftOrRight pickLR :: LeftOrRight -> (a, a) -> a mkTcReflCo :: Role -> TcType -> TcCoercion mkTcNomReflCo :: TcType -> TcCoercionN mkTcRepReflCo :: TcType -> TcCoercionR mkTcTyConAppCo :: Role -> TyCon -> [TcCoercion] -> TcCoercion mkTcAppCo :: TcCoercion -> TcCoercionN -> TcCoercion mkTcFunCo :: Role -> TcCoercion -> TcCoercion -> TcCoercion -> TcCoercion mkTcAxInstCo :: Role -> CoAxiom br -> BranchIndex -> [TcType] -> [TcCoercion] -> TcCoercion mkTcUnbranchedAxInstCo :: CoAxiom Unbranched -> [TcType] -> [TcCoercion] -> TcCoercionR mkTcForAllCo :: TyVar -> TcCoercionN -> TcCoercion -> TcCoercion mkTcForAllCos :: [(TyVar, TcCoercionN)] -> TcCoercion -> TcCoercion mkTcSymCo :: TcCoercion -> TcCoercion mkTcSymMCo :: TcMCoercion -> TcMCoercion mkTcTransCo :: TcCoercion -> TcCoercion -> TcCoercion mkTcNthCo :: Role -> Int -> TcCoercion -> TcCoercion mkTcLRCo :: LeftOrRight -> TcCoercion -> TcCoercion mkTcSubCo :: HasDebugCallStack => TcCoercionN -> TcCoercionR -- | If a SwapFlag is IsSwapped, flip the orientation of a -- coercion maybeTcSymCo :: SwapFlag -> TcCoercion -> TcCoercion -- | If the EqRel is ReprEq, makes a SubCo; otherwise, does nothing. Note -- that the input coercion should always be nominal. maybeTcSubCo :: HasDebugCallStack => EqRel -> TcCoercionN -> TcCoercion tcDowngradeRole :: Role -> Role -> TcCoercion -> TcCoercion mkTcAxiomRuleCo :: CoAxiomRule -> [TcCoercion] -> TcCoercionR mkTcGReflRightCo :: Role -> TcType -> TcCoercionN -> TcCoercion mkTcGReflRightMCo :: Role -> TcType -> TcMCoercionN -> TcCoercion mkTcGReflLeftCo :: Role -> TcType -> TcCoercionN -> TcCoercion mkTcGReflLeftMCo :: Role -> TcType -> TcMCoercionN -> TcCoercion mkTcPhantomCo :: TcCoercionN -> TcType -> TcType -> TcCoercionP mkTcCoherenceLeftCo :: Role -> TcType -> TcCoercionN -> TcCoercion -> TcCoercion mkTcCoherenceRightCo :: Role -> TcType -> TcCoercionN -> TcCoercion -> TcCoercion mkTcKindCo :: TcCoercion -> TcCoercionN tcCoercionKind :: TcCoercion -> Pair TcType mkTcCoVarCo :: CoVar -> TcCoercion mkTcFamilyTyConAppCo :: TyCon -> [TcCoercionN] -> TcCoercionN isTcReflCo :: TcCoercion -> Bool -- | This version does a slow check, calculating the related types and -- seeing if they are equal. isTcReflexiveCo :: TcCoercion -> Bool tcCoercionRole :: TcCoercion -> Role -- | Create a Expr that unwraps an implicit-parameter or -- overloaded-label dictionary to expose the underlying value. We expect -- the Expr to have the form `IP sym ty` or `IsLabel sym ty`, and -- return a Expr `co :: IP sym ty ~ ty` or `co :: IsLabel sym ty ~ -- ty`. See also Note [Type-checking overloaded labels] in -- GHC.Tc.Gen.Expr. unwrapIP :: Type -> CoercionR -- | Create a Expr that wraps a value in an implicit-parameter -- dictionary. See unwrapIP. wrapIP :: Type -> CoercionR data QuoteWrapper QuoteWrapper :: EvVar -> Type -> QuoteWrapper -- | Convert the QuoteWrapper into a normal HsWrapper which can be used to -- apply its contents. applyQuoteWrapper :: QuoteWrapper -> HsWrapper quoteWrapperTyVarTy :: QuoteWrapper -> Type instance Data.Data.Data GHC.Tc.Types.Evidence.EvTerm instance Data.Data.Data GHC.Tc.Types.Evidence.EvTypeable instance Data.Data.Data GHC.Tc.Types.Evidence.EvCallStack instance Data.Data.Data GHC.Tc.Types.Evidence.QuoteWrapper instance GHC.Utils.Outputable.Outputable GHC.Tc.Types.Evidence.HoleExprRef instance Data.Data.Data GHC.Tc.Types.Evidence.HoleExprRef instance GHC.Utils.Outputable.Outputable GHC.Tc.Types.Evidence.EvCallStack instance Data.Data.Data GHC.Tc.Types.Evidence.HsWrapper instance GHC.Utils.Outputable.Outputable GHC.Tc.Types.Evidence.HsWrapper instance Data.Data.Data GHC.Tc.Types.Evidence.TcEvBinds instance GHC.Utils.Outputable.Outputable GHC.Tc.Types.Evidence.EvBindMap instance GHC.Utils.Outputable.Outputable GHC.Tc.Types.Evidence.TcEvBinds instance GHC.Utils.Outputable.Outputable GHC.Tc.Types.Evidence.EvBindsVar instance GHC.Types.Unique.Uniquable GHC.Tc.Types.Evidence.EvBindsVar instance GHC.Utils.Outputable.Outputable GHC.Tc.Types.Evidence.EvBind instance GHC.Utils.Outputable.Outputable GHC.Tc.Types.Evidence.EvTerm instance GHC.Utils.Outputable.Outputable GHC.Tc.Types.Evidence.EvTypeable module GHC.Hs.Type -- | Mult is a type alias for Type. -- -- Mult must contain Type because multiplicity variables are mere type -- variables (of kind Multiplicity) in Haskell. So the simplest -- implementation is to make Mult be Type. -- -- Multiplicities can be formed with: - One: GHC.Types.One (= oneDataCon) -- - Many: GHC.Types.Many (= manyDataCon) - Multiplication: -- GHC.Types.MultMul (= multMulTyCon) -- -- So that Mult feels a bit more structured, we provide pattern synonyms -- and smart constructors for these. type Mult = Type -- | This is used in the syntax. In constructor declaration. It must keep -- the arrow representation. data HsScaled pass a HsScaled :: HsArrow pass -> a -> HsScaled pass a hsMult :: HsScaled pass a -> HsArrow pass hsScaledThing :: HsScaled pass a -> a -- | Denotes the type of arrows in the surface language data HsArrow pass -- | a -> b or a → b HsUnrestrictedArrow :: IsUnicodeSyntax -> HsArrow pass -- | a %1 -> b or a %1 → b, or a ⊸ b HsLinearArrow :: IsUnicodeSyntax -> Maybe AddEpAnn -> HsArrow pass -- | a %m -> b or a %m → b (very much including `a %Many -> b`! This -- is how the programmer wrote it). It is stored as an HsType so -- as to preserve the syntax as written in the program. HsExplicitMult :: IsUnicodeSyntax -> Maybe AddEpAnn -> LHsType pass -> HsArrow pass -- | Convert an arrow into its corresponding multiplicity. In essence this -- erases the information of whether the programmer wrote an explicit -- multiplicity or a shorthand. arrowToHsType :: HsArrow GhcRn -> LHsType GhcRn -- | When creating syntax we use the shorthands. It's better for printing, -- also, the shorthands work trivially at each pass. hsLinear :: a -> HsScaled pass a -- | When creating syntax we use the shorthands. It's better for printing, -- also, the shorthands work trivially at each pass. hsUnrestricted :: a -> HsScaled pass a isUnrestricted :: HsArrow GhcRn -> Bool -- | Haskell Type data HsType pass -- |
-- (?x :: ty) ---- --
-- (ty :: kind) ---- --
-- type instance forall a. F [a] = Tree a ---- -- The notion of specificity is irrelevant in type family equations, so -- we use () for the HsOuterTyVarBndrs flag. type HsOuterFamEqnTyVarBndrs = HsOuterTyVarBndrs () -- | Used for signatures, e.g., -- --
-- f :: forall a {b}. blah
--
--
-- We use Specificity for the HsOuterTyVarBndrs
-- flag to allow distinguishing between specified and inferred
-- type variables.
type HsOuterSigTyVarBndrs = HsOuterTyVarBndrs Specificity
-- | Haskell Wildcard Binders
data HsWildCardBndrs pass thing
HsWC :: XHsWC pass thing -> thing -> HsWildCardBndrs pass thing
[hswc_ext] :: HsWildCardBndrs pass thing -> XHsWC pass thing
[hswc_body] :: HsWildCardBndrs pass thing -> thing
XHsWildCardBndrs :: !XXHsWildCardBndrs pass thing -> HsWildCardBndrs pass thing
-- | Types that can appear in pattern signatures, as well as the signatures
-- for term-level binders in RULES. See Note [Pattern signature
-- binders and scoping].
--
-- This is very similar to HsSigWcType, but with slightly
-- different semantics: see Note [HsType binders]. See also
-- Note [The wildcard story for types].
data HsPatSigType pass
HsPS :: XHsPS pass -> LHsType pass -> HsPatSigType pass
-- | After renamer: HsPSRn
[hsps_ext] :: HsPatSigType pass -> XHsPS pass
-- | Main payload (the type itself)
[hsps_body] :: HsPatSigType pass -> LHsType pass
XHsPatSigType :: !XXHsPatSigType pass -> HsPatSigType pass
-- | The extension field for HsPatSigType, which is only used in the
-- renamer onwards. See Note [Pattern signature binders and
-- scoping].
data HsPSRn
HsPSRn :: [Name] -> [Name] -> HsPSRn
-- | Wildcard names
[hsps_nwcs] :: HsPSRn -> [Name]
-- | Implicitly bound variable names
[hsps_imp_tvs] :: HsPSRn -> [Name]
-- | A type signature that obeys the forall-or-nothing rule. In
-- other words, an LHsType that uses an
-- HsOuterSigTyVarBndrs to represent its outermost type variable
-- quantification. See Note [Representing type signatures].
data HsSigType pass
HsSig :: XHsSig pass -> HsOuterSigTyVarBndrs pass -> LHsType pass -> HsSigType pass
[sig_ext] :: HsSigType pass -> XHsSig pass
[sig_bndrs] :: HsSigType pass -> HsOuterSigTyVarBndrs pass
[sig_body] :: HsSigType pass -> LHsType pass
XHsSigType :: !XXHsSigType pass -> HsSigType pass
-- | Located Haskell Signature Type
type LHsSigType pass = XRec pass (HsSigType pass)
-- | Located Haskell Signature Wildcard Type
type LHsSigWcType pass = HsWildCardBndrs pass (LHsSigType pass)
-- | Located Haskell Wildcard Type
type LHsWcType pass = HsWildCardBndrs pass (LHsType pass)
-- | Haskell Tuple Sort
data HsTupleSort
HsUnboxedTuple :: HsTupleSort
HsBoxedOrConstraintTuple :: HsTupleSort
-- | Haskell Context
type HsContext pass = [LHsType pass]
-- | Located Haskell Context
type LHsContext pass = XRec pass (HsContext pass) " 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnUnit' For details on above see note [exact print annotations] in GHC.Parser.Annotation"
fromMaybeContext :: Maybe (LHsContext (GhcPass p)) -> HsContext (GhcPass p)
-- | Haskell Type Literal
data HsTyLit
HsNumTy :: SourceText -> Integer -> HsTyLit
HsStrTy :: SourceText -> FastString -> HsTyLit
HsCharTy :: SourceText -> Char -> HsTyLit
-- | These names are used early on to store the names of implicit
-- parameters. They completely disappear after type-checking.
newtype HsIPName
HsIPName :: FastString -> HsIPName
hsIPNameFS :: HsIPName -> FastString
data HsArg tm ty
HsValArg :: tm -> HsArg tm ty
HsTypeArg :: SrcSpan -> ty -> HsArg tm ty
HsArgPar :: SrcSpan -> HsArg tm ty
numVisibleArgs :: [HsArg tm ty] -> Arity
type LHsTypeArg p = HsArg (LHsType p) (LHsKind p)
-- | Compute the SrcSpan associated with an LHsTypeArg.
lhsTypeArgSrcSpan :: LHsTypeArg (GhcPass pass) -> SrcSpan
class OutputableBndrFlag flag p
-- | Located Bang Type
type LBangType pass = XRec pass (BangType pass)
-- | Bang Type
--
-- In the parser, strictness and packedness annotations bind more tightly
-- than docstrings. This means that when consuming a BangType (and
-- looking for HsBangTy) we must be ready to peer behind a
-- potential layer of HsDocTy. See #15206 for motivation and
-- getBangType for an example.
type BangType pass = HsType pass
-- | Haskell Source Bang
--
-- Bangs on data constructor arguments as the user wrote them in the
-- source code.
--
-- (HsSrcBang _ SrcUnpack SrcLazy) and (HsSrcBang _
-- SrcUnpack NoSrcStrict) (without StrictData) makes no sense, we
-- emit a warning (in checkValidDataCon) and treat it like (HsSrcBang
-- _ NoSrcUnpack SrcLazy)
data HsSrcBang
HsSrcBang :: SourceText -> SrcUnpackedness -> SrcStrictness -> HsSrcBang
-- | Haskell Implementation Bang
--
-- Bangs of data constructor arguments as generated by the compiler after
-- consulting HsSrcBang, flags, etc.
data HsImplBang
-- | Lazy field, or one with an unlifted type
HsLazy :: HsImplBang
-- | Strict but not unpacked field
HsStrict :: HsImplBang
-- | Strict and unpacked field co :: arg-ty ~ product-ty HsBang
HsUnpack :: Maybe Coercion -> HsImplBang
-- | Source Strictness
--
-- What strictness annotation the user wrote
data SrcStrictness
-- | Lazy, ie ~
SrcLazy :: SrcStrictness
-- | Strict, ie !
SrcStrict :: SrcStrictness
-- | no strictness annotation
NoSrcStrict :: SrcStrictness
-- | Source Unpackedness
--
-- What unpackedness the user requested
data SrcUnpackedness
-- | {-# UNPACK #-} specified
SrcUnpack :: SrcUnpackedness
-- | {-# NOUNPACK #-} specified
SrcNoUnpack :: SrcUnpackedness
-- | no unpack pragma
NoSrcUnpack :: SrcUnpackedness
getBangType :: LHsType (GhcPass p) -> LHsType (GhcPass p)
getBangStrictness :: LHsType (GhcPass p) -> HsSrcBang
-- | Constructor Declaration Field
data ConDeclField pass
ConDeclField :: XConDeclField pass -> [LFieldOcc pass] -> LBangType pass -> Maybe LHsDocString -> ConDeclField pass
[cd_fld_ext] :: ConDeclField pass -> XConDeclField pass
-- | See Note [ConDeclField passs]
[cd_fld_names] :: ConDeclField pass -> [LFieldOcc pass]
[cd_fld_type] :: ConDeclField pass -> LBangType pass
-- | -- syn_res_wrap $ syn_expr (syn_arg_wraps[0] arg0) -- (syn_arg_wraps[1] arg1) ... ---- -- where the actual arguments come from elsewhere in the AST. data SyntaxExprTc SyntaxExprTc :: HsExpr GhcTc -> [HsWrapper] -> HsWrapper -> SyntaxExprTc [syn_expr] :: SyntaxExprTc -> HsExpr GhcTc [syn_arg_wraps] :: SyntaxExprTc -> [HsWrapper] [syn_res_wrap] :: SyntaxExprTc -> HsWrapper NoSyntaxExprTc :: SyntaxExprTc data XBindStmtRn XBindStmtRn :: SyntaxExpr GhcRn -> FailOperator GhcRn -> XBindStmtRn [xbsrn_bindOp] :: XBindStmtRn -> SyntaxExpr GhcRn [xbsrn_failOp] :: XBindStmtRn -> FailOperator GhcRn data XBindStmtTc XBindStmtTc :: SyntaxExpr GhcTc -> Type -> Mult -> FailOperator GhcTc -> XBindStmtTc [xbstc_bindOp] :: XBindStmtTc -> SyntaxExpr GhcTc [xbstc_boundResultType] :: XBindStmtTc -> Type [xbstc_boundResultMult] :: XBindStmtTc -> Mult [xbstc_failOp] :: XBindStmtTc -> FailOperator GhcTc data XXExprGhcTc WrapExpr :: {-# UNPACK #-} !HsWrap HsExpr -> XXExprGhcTc ExpansionExpr :: {-# UNPACK #-} !HsExpansion (HsExpr GhcRn) (HsExpr GhcTc) -> XXExprGhcTc instance Data.Data.Data GHC.Hs.Expr.EpAnnHsCase instance Data.Data.Data GHC.Hs.Expr.EpAnnUnboundVar instance Data.Data.Data GHC.Hs.Expr.AnnExplicitSum instance Data.Data.Data GHC.Hs.Expr.AnnsLet instance Data.Data.Data GHC.Hs.Expr.AnnFieldLabel instance Data.Data.Data GHC.Hs.Expr.AnnProjection instance Data.Data.Data GHC.Hs.Expr.AnnsIf instance (Data.Data.Data a, Data.Data.Data b) => Data.Data.Data (GHC.Hs.Expr.HsExpansion a b) instance Data.Data.Data GHC.Hs.Expr.GrhsAnn instance Data.Data.Data GHC.Hs.Expr.HsSplicedT instance (Data.Data.Data (hs_syn GHC.Hs.Extension.GhcTc), Data.Typeable.Internal.Typeable hs_syn) => Data.Data.Data (GHC.Hs.Expr.HsWrap hs_syn) instance GHC.Utils.Outputable.Outputable GHC.Hs.Expr.PendingTcSplice instance GHC.Utils.Outputable.Outputable GHC.Hs.Expr.PendingRnSplice instance Data.Data.Data GHC.Hs.Expr.DelayedSplice instance GHC.Utils.Outputable.Outputable GHC.Hs.Expr.GrhsAnn instance (GHC.Utils.Outputable.Outputable a, GHC.Utils.Outputable.Outputable b) => GHC.Utils.Outputable.Outputable (GHC.Hs.Expr.HsExpansion a b) instance GHC.Utils.Outputable.Outputable GHC.Hs.Expr.SyntaxExprTc instance GHC.Utils.Outputable.Outputable GHC.Hs.Expr.SyntaxExprRn instance GHC.Hs.Extension.OutputableBndrId p => GHC.Utils.Outputable.Outputable (Language.Haskell.Syntax.Expr.HsExpr (GHC.Hs.Extension.GhcPass p)) instance GHC.Utils.Outputable.Outputable (Language.Haskell.Syntax.Expr.HsPragE (GHC.Hs.Extension.GhcPass p)) instance GHC.Hs.Extension.OutputableBndrId p => GHC.Utils.Outputable.Outputable (Language.Haskell.Syntax.Expr.HsCmd (GHC.Hs.Extension.GhcPass p)) instance GHC.Hs.Extension.OutputableBndrId p => GHC.Utils.Outputable.Outputable (Language.Haskell.Syntax.Expr.HsCmdTop (GHC.Hs.Extension.GhcPass p)) instance (GHC.Hs.Extension.OutputableBndrId pr, GHC.Utils.Outputable.Outputable body) => GHC.Utils.Outputable.Outputable (Language.Haskell.Syntax.Expr.Match (GHC.Hs.Extension.GhcPass pr) body) instance (GHC.Utils.Outputable.Outputable (Language.Haskell.Syntax.Expr.StmtLR (GHC.Hs.Extension.GhcPass idL) (GHC.Hs.Extension.GhcPass idL) (Language.Haskell.Syntax.Expr.LHsExpr (GHC.Hs.Extension.GhcPass idL))), GHC.Utils.Outputable.Outputable (Language.Haskell.Syntax.Extension.XXParStmtBlock (GHC.Hs.Extension.GhcPass idL) (GHC.Hs.Extension.GhcPass idR))) => GHC.Utils.Outputable.Outputable (Language.Haskell.Syntax.Expr.ParStmtBlock (GHC.Hs.Extension.GhcPass idL) (GHC.Hs.Extension.GhcPass idR)) instance (GHC.Hs.Extension.OutputableBndrId pl, GHC.Hs.Extension.OutputableBndrId pr, Language.Haskell.Syntax.Extension.Anno (Language.Haskell.Syntax.Expr.StmtLR (GHC.Hs.Extension.GhcPass pl) (GHC.Hs.Extension.GhcPass pr) body) GHC.Types.~ GHC.Parser.Annotation.SrcSpanAnnA, GHC.Utils.Outputable.Outputable body) => GHC.Utils.Outputable.Outputable (Language.Haskell.Syntax.Expr.StmtLR (GHC.Hs.Extension.GhcPass pl) (GHC.Hs.Extension.GhcPass pr) body) instance GHC.Hs.Extension.OutputableBndrId idL => GHC.Utils.Outputable.Outputable (Language.Haskell.Syntax.Expr.ApplicativeArg (GHC.Hs.Extension.GhcPass idL)) instance GHC.Hs.Extension.OutputableBndrId p => GHC.Utils.Outputable.Outputable (Language.Haskell.Syntax.Expr.HsSplicedThing (GHC.Hs.Extension.GhcPass p)) instance GHC.Hs.Extension.OutputableBndrId p => GHC.Utils.Outputable.Outputable (Language.Haskell.Syntax.Expr.HsSplice (GHC.Hs.Extension.GhcPass p)) instance GHC.Hs.Extension.OutputableBndrId p => GHC.Utils.Outputable.Outputable (Language.Haskell.Syntax.Expr.HsBracket (GHC.Hs.Extension.GhcPass p)) instance GHC.Hs.Extension.OutputableBndrId p => GHC.Utils.Outputable.Outputable (Language.Haskell.Syntax.Expr.ArithSeqInfo (GHC.Hs.Extension.GhcPass p)) instance GHC.Hs.Extension.OutputableBndrId p => GHC.Utils.Outputable.Outputable (Language.Haskell.Syntax.Expr.HsMatchContext (GHC.Hs.Extension.GhcPass p)) instance GHC.Utils.Outputable.Outputable Language.Haskell.Syntax.Expr.HsArrowMatchContext instance GHC.Hs.Extension.OutputableBndrId p => GHC.Utils.Outputable.Outputable (Language.Haskell.Syntax.Expr.HsStmtContext (GHC.Hs.Extension.GhcPass p)) instance (Language.Haskell.Syntax.Extension.Anno a GHC.Types.~ GHC.Parser.Annotation.SrcSpanAnn' (GHC.Parser.Annotation.EpAnn an)) => Language.Haskell.Syntax.Extension.WrapXRec (GHC.Hs.Extension.GhcPass p) a -- | Abstract Haskell syntax for expressions. module Language.Haskell.Syntax.Expr -- | RecordDotSyntax field updates newtype FieldLabelStrings p FieldLabelStrings :: [Located (HsFieldLabel p)] -> FieldLabelStrings p pprFieldLabelStrings :: FieldLabelStrings p -> SDoc type RecProj p arg = HsRecField' (FieldLabelStrings p) arg type LHsRecProj p arg = XRec p (RecProj p arg) type RecUpdProj p = RecProj p (LHsExpr p) type LHsRecUpdProj p = XRec p (RecUpdProj p) -- | Located Haskell Expression type LHsExpr p = XRec p (HsExpr p) " May have 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnComma' when in a list" -- | Syntax Expression -- -- SyntaxExpr is represents the function used in interpreting rebindable -- syntax. In the parser, we have no information to supply; in the -- renamer, we have the name of the function (but see Note [Monad fail : -- Rebindable syntax, overloaded strings] for a wrinkle) and in the -- type-checker we have a more elaborate structure SyntaxExprTc. -- -- In some contexts, rebindable syntax is not implemented, and so we have -- constructors to represent that possibility in both the renamer and -- typechecker instantiations. -- -- E.g. (>>=) is filled in before the renamer by the -- appropriate Name for (>>=), and then -- instantiated by the type checker with its type args etc type family SyntaxExpr p -- | Command Syntax Table (for Arrow syntax) type CmdSyntaxTable p = [(Name, HsExpr p)] -- | A Haskell expression. data HsExpr p -- | Variable See Note [Located RdrNames] HsVar :: XVar p -> LIdP p -> HsExpr p -- | Unbound variable; also used for "holes" (_ or _x). Turned from HsVar -- to HsUnboundVar by the renamer, when it finds an out-of-scope variable -- or hole. The (XUnboundVar p) field becomes an HoleExprRef after -- typechecking; this is where the erroring expression will be written -- after solving. See Note [Holes] in GHC.Tc.Types.Constraint. HsUnboundVar :: XUnboundVar p -> OccName -> HsExpr p -- | After typechecker only; must be different HsVar for pretty printing HsConLikeOut :: XConLikeOut p -> ConLike -> HsExpr p -- | Variable pointing to record selector The parser produces HsVars The -- renamer renames record-field selectors to HsRecFld The typechecker -- preserves HsRecFld HsRecFld :: XRecFld p -> AmbiguousFieldOcc p -> HsExpr p -- | Overloaded label (Note [Overloaded labels] in GHC.OverloadedLabels) HsOverLabel :: XOverLabel p -> FastString -> HsExpr p -- | Implicit parameter (not in use after typechecking) HsIPVar :: XIPVar p -> HsIPName -> HsExpr p -- | Overloaded literals HsOverLit :: XOverLitE p -> HsOverLit p -> HsExpr p -- | Simple (non-overloaded) literals HsLit :: XLitE p -> HsLit p -> HsExpr p -- | Lambda abstraction. Currently always a single match -- --
-- data T b = ... deriving (C [a]) ---- -- should produce a derived instance for C [a] (T b). data DerivClauseTys pass -- | A deriving clause with a single type. Moreover, that type can -- only be a type constructor without any arguments. -- -- Example: deriving Eq DctSingle :: XDctSingle pass -> LHsSigType pass -> DerivClauseTys pass -- | A deriving clause with a comma-separated list of types, -- surrounded by enclosing parentheses. -- -- Example: deriving (Eq, C a) DctMulti :: XDctMulti pass -> [LHsSigType pass] -> DerivClauseTys pass XDerivClauseTys :: !XXDerivClauseTys pass -> DerivClauseTys pass type LDerivClauseTys pass = XRec pass (DerivClauseTys pass) data NewOrData -- |
-- newtype Blah ... --NewType :: NewOrData -- |
-- data Blah ... --DataType :: NewOrData -- | Convert a NewOrData to a TyConFlavour newOrDataToFlavour :: NewOrData -> TyConFlavour data StandaloneKindSig pass StandaloneKindSig :: XStandaloneKindSig pass -> LIdP pass -> LHsSigType pass -> StandaloneKindSig pass XStandaloneKindSig :: !XXStandaloneKindSig pass -> StandaloneKindSig pass -- | Located Standalone Kind Signature type LStandaloneKindSig pass = XRec pass (StandaloneKindSig pass) -- | A type or class declaration. data TyClDecl pass -- |
-- type/data family T :: *->* ---- --
-- deriving instance _ => Eq (Foo a) ---- -- Which signifies that the context should be inferred. [deriv_type] :: DerivDecl pass -> LHsSigWcType pass [deriv_strategy] :: DerivDecl pass -> Maybe (LDerivStrategy pass) -- |
-- -XDeriveAnyClass --AnyclassStrategy :: XAnyClassStrategy pass -> DerivStrategy pass -- |
-- -XGeneralizedNewtypeDeriving --NewtypeStrategy :: XNewtypeStrategy pass -> DerivStrategy pass -- |
-- -XDerivingVia --ViaStrategy :: XViaStrategy pass -> DerivStrategy pass -- | A Located DerivStrategy. type LDerivStrategy pass = XRec pass (DerivStrategy pass) -- | A short description of a DerivStrategy'. derivStrategyName :: DerivStrategy a -> SDoc -- | Located Rule Declarations type LRuleDecls pass = XRec pass (RuleDecls pass) -- | Rule Declarations data RuleDecls pass HsRules :: XCRuleDecls pass -> SourceText -> [LRuleDecl pass] -> RuleDecls pass [rds_ext] :: RuleDecls pass -> XCRuleDecls pass [rds_src] :: RuleDecls pass -> SourceText [rds_rules] :: RuleDecls pass -> [LRuleDecl pass] XRuleDecls :: !XXRuleDecls pass -> RuleDecls pass -- | Rule Declaration data RuleDecl pass HsRule :: XHsRule pass -> XRec pass (SourceText, RuleName) -> Activation -> Maybe [LHsTyVarBndr () (NoGhcTc pass)] -> [LRuleBndr pass] -> XRec pass (HsExpr pass) -> XRec pass (HsExpr pass) -> RuleDecl pass -- | After renamer, free-vars from the LHS and RHS [rd_ext] :: RuleDecl pass -> XHsRule pass -- | Note [Pragma source text] in GHC.Types.Basic [rd_name] :: RuleDecl pass -> XRec pass (SourceText, RuleName) [rd_act] :: RuleDecl pass -> Activation -- | Forall'd type vars [rd_tyvs] :: RuleDecl pass -> Maybe [LHsTyVarBndr () (NoGhcTc pass)] -- | Forall'd term vars, before typechecking; after typechecking this -- includes all forall'd vars [rd_tmvs] :: RuleDecl pass -> [LRuleBndr pass] [rd_lhs] :: RuleDecl pass -> XRec pass (HsExpr pass) -- | [rd_rhs] :: RuleDecl pass -> XRec pass (HsExpr pass) XRuleDecl :: !XXRuleDecl pass -> RuleDecl pass -- | Located Rule Declaration type LRuleDecl pass = XRec pass (RuleDecl pass) data HsRuleRn HsRuleRn :: NameSet -> NameSet -> HsRuleRn -- | Rule Binder data RuleBndr pass RuleBndr :: XCRuleBndr pass -> LIdP pass -> RuleBndr pass RuleBndrSig :: XRuleBndrSig pass -> LIdP pass -> HsPatSigType pass -> RuleBndr pass -- |
-- data T b = forall a. Eq a => MkT a b -- MkT :: forall b a. Eq a => MkT a b -- -- data T b where -- MkT1 :: Int -> T Int -- -- data T = Int MkT Int -- | MkT2 -- -- data T a where -- Int MkT Int :: T Int ---- --
-- f :: Int -> forall a. a -> a -- f x y = y ---- -- Then the MatchGroup will have type (Int -> a' -> a') (with a -- free type variable a'). The coercion will take a CoreExpr of this type -- and convert it to a CoreExpr of type Int -> forall a'. a' -> a' -- Notice that the coercion captures the free a'. [fun_ext] :: HsBindLR idL idR -> XFunBind idL idR [fun_id] :: HsBindLR idL idR -> LIdP idL -- | The payload [fun_matches] :: HsBindLR idL idR -> MatchGroup idR (LHsExpr idR) -- | Ticks to put on the rhs, if any [fun_tick] :: HsBindLR idL idR -> [CoreTickish] -- | Pattern Binding -- -- The pattern is never a simple variable; That case is done by FunBind. -- See Note [FunBind vs PatBind] for details about the relationship -- between FunBind and PatBind. PatBind :: XPatBind idL idR -> LPat idL -> GRHSs idR (LHsExpr idR) -> ([CoreTickish], [[CoreTickish]]) -> HsBindLR idL idR -- | See Note [Bind free vars] [pat_ext] :: HsBindLR idL idR -> XPatBind idL idR [pat_lhs] :: HsBindLR idL idR -> LPat idL [pat_rhs] :: HsBindLR idL idR -> GRHSs idR (LHsExpr idR) -- | Ticks to put on the rhs, if any, and ticks to put on the bound -- variables. [pat_ticks] :: HsBindLR idL idR -> ([CoreTickish], [[CoreTickish]]) -- | Variable Binding -- -- Dictionary binding and suchlike. All VarBinds are introduced by the -- type checker VarBind :: XVarBind idL idR -> IdP idL -> LHsExpr idR -> HsBindLR idL idR [var_ext] :: HsBindLR idL idR -> XVarBind idL idR [var_id] :: HsBindLR idL idR -> IdP idL -- | Located only for consistency [var_rhs] :: HsBindLR idL idR -> LHsExpr idR -- | Abstraction Bindings AbsBinds :: XAbsBinds idL idR -> [TyVar] -> [EvVar] -> [ABExport idL] -> [TcEvBinds] -> LHsBinds idL -> Bool -> HsBindLR idL idR [abs_ext] :: HsBindLR idL idR -> XAbsBinds idL idR [abs_tvs] :: HsBindLR idL idR -> [TyVar] -- | Includes equality constraints [abs_ev_vars] :: HsBindLR idL idR -> [EvVar] -- | AbsBinds only gets used when idL = idR after renaming, but these need -- to be idL's for the collect... code in HsUtil to have the right type [abs_exports] :: HsBindLR idL idR -> [ABExport idL] -- | Evidence bindings Why a list? See GHC.Tc.TyCl.Instance Note -- [Typechecking plan for instance declarations] [abs_ev_binds] :: HsBindLR idL idR -> [TcEvBinds] -- | Typechecked user bindings [abs_binds] :: HsBindLR idL idR -> LHsBinds idL [abs_sig] :: HsBindLR idL idR -> Bool -- | Patterns Synonym Binding PatSynBind :: XPatSynBind idL idR -> PatSynBind idL idR -> HsBindLR idL idR XHsBindsLR :: !XXHsBindsLR idL idR -> HsBindLR idL idR -- | Abstraction Bindings Export data ABExport p ABE :: XABE p -> IdP p -> IdP p -> HsWrapper -> TcSpecPrags -> ABExport p [abe_ext] :: ABExport p -> XABE p -- | Any INLINE pragma is attached to this Id [abe_poly] :: ABExport p -> IdP p [abe_mono] :: ABExport p -> IdP p -- | See Note [ABExport wrapper] Shape: (forall abs_tvs. abs_ev_vars => -- abe_mono) ~ abe_poly [abe_wrap] :: ABExport p -> HsWrapper -- | SPECIALISE pragmas [abe_prags] :: ABExport p -> TcSpecPrags XABExport :: !XXABExport p -> ABExport p -- |
-- f :: Num a => a -> a ---- -- After renaming, this list of Names contains the named wildcards -- brought into scope by this signature. For a signature _ -> _a -- -> Bool, the renamer will leave the unnamed wildcard -- _ untouched, and the named wildcard _a is then -- replaced with fresh meta vars in the type. Their names are stored in -- the type signature that brought them into scope, in this third field -- to be more specific. -- --
-- pattern Single :: () => (Show a) => a -> [a] ---- --
-- infixl 8 *** ---- --
-- {#- INLINE f #-}
--
--
--
-- {-# SPECIALISE f :: Int -> Int #-}
--
--
--
-- {-# SPECIALISE instance Eq [Int] #-}
--
--
-- (Class tys); should be a specialisation of the current instance
-- declaration
--
--
-- {-# MINIMAL a | (b, c | (d | e)) #-}
--
--
--
-- {-# SCC funName #-}
--
--
-- or
--
--
-- {-# SCC funName "cost_centre_name" #-}
--
SCCFunSig :: XSCCFunSig pass -> SourceText -> LIdP pass -> Maybe (XRec pass StringLiteral) -> Sig pass
-- | A complete match pragma
--
--
-- {-# COMPLETE C, D [:: T] #-}
--
--
-- Used to inform the pattern match checker about additional complete
-- matchings which, for example, arise from pattern synonym definitions.
CompleteMatchSig :: XCompleteMatchSig pass -> SourceText -> XRec pass [LIdP pass] -> Maybe (LIdP pass) -> Sig pass
XSig :: !XXSig pass -> Sig pass
-- | Located Fixity Signature
type LFixitySig pass = XRec pass (FixitySig pass)
-- | Fixity Signature
data FixitySig pass
FixitySig :: XFixitySig pass -> [LIdP pass] -> Fixity -> FixitySig pass
XFixitySig :: !XXFixitySig pass -> FixitySig pass
-- | Type checker Specialisation Pragmas
--
-- TcSpecPrags conveys SPECIALISE pragmas from the type
-- checker to the desugarer
data TcSpecPrags
-- | Super-specialised: a default method should be macro-expanded at every
-- call site
IsDefaultMethod :: TcSpecPrags
SpecPrags :: [LTcSpecPrag] -> TcSpecPrags
-- | Located Type checker Specification Pragmas
type LTcSpecPrag = Located TcSpecPrag
-- | Type checker Specification Pragma
data TcSpecPrag
-- | The Id to be specialised, a wrapper that specialises the polymorphic
-- function, and inlining spec for the specialised function
SpecPrag :: Id -> HsWrapper -> InlinePragma -> TcSpecPrag
noSpecPrags :: TcSpecPrags
hasSpecPrags :: TcSpecPrags -> Bool
isDefaultMethod :: TcSpecPrags -> Bool
isFixityLSig :: forall p. UnXRec p => LSig p -> Bool
isTypeLSig :: forall p. UnXRec p => LSig p -> Bool
isSpecLSig :: forall p. UnXRec p => LSig p -> Bool
isSpecInstLSig :: forall p. UnXRec p => LSig p -> Bool
isPragLSig :: forall p. UnXRec p => LSig p -> Bool
isInlineLSig :: forall p. UnXRec p => LSig p -> Bool
isMinimalLSig :: forall p. UnXRec p => LSig p -> Bool
isSCCFunSig :: forall p. UnXRec p => LSig p -> Bool
isCompleteMatchSig :: forall p. UnXRec p => LSig p -> Bool
hsSigDoc :: Sig name -> SDoc
-- | Haskell Pattern Synonym Details
type HsPatSynDetails pass = HsConDetails Void (LIdP pass) [RecordPatSynField pass]
-- | Record Pattern Synonym Field
data RecordPatSynField pass
RecordPatSynField :: FieldOcc pass -> LIdP pass -> RecordPatSynField pass
-- | Field label visible in rest of the file
[recordPatSynField] :: RecordPatSynField pass -> FieldOcc pass
-- | Filled in by renamer, the name used internally by the pattern
[recordPatSynPatVar] :: RecordPatSynField pass -> LIdP pass
-- | Haskell Pattern Synonym Direction
data HsPatSynDir id
Unidirectional :: HsPatSynDir id
ImplicitBidirectional :: HsPatSynDir id
ExplicitBidirectional :: MatchGroup id (LHsExpr id) -> HsPatSynDir id
instance Data.Data.Data Language.Haskell.Syntax.Binds.TcSpecPrag
instance Data.Data.Data Language.Haskell.Syntax.Binds.TcSpecPrags
instance GHC.Utils.Outputable.Outputable (Language.Haskell.Syntax.Binds.RecordPatSynField a)
-- | Warnings for a module
module GHC.Unit.Module.Warnings
-- | Warning information for a module
data Warnings
-- | Nothing deprecated
NoWarnings :: Warnings
-- | Whole module deprecated
WarnAll :: WarningTxt -> Warnings
-- | Some specific things deprecated
WarnSome :: [(OccName, WarningTxt)] -> Warnings
-- | Warning Text
--
-- reason/explanation from a WARNING or DEPRECATED pragma
data WarningTxt
WarningTxt :: Located SourceText -> [Located StringLiteral] -> WarningTxt
DeprecatedTxt :: Located SourceText -> [Located StringLiteral] -> WarningTxt
pprWarningTxtForMsg :: WarningTxt -> SDoc
-- | Constructs the cache for the mi_warn_fn field of a
-- ModIface
mkIfaceWarnCache :: Warnings -> OccName -> Maybe WarningTxt
emptyIfaceWarnCache :: OccName -> Maybe WarningTxt
plusWarns :: Warnings -> Warnings -> Warnings
instance Data.Data.Data GHC.Unit.Module.Warnings.WarningTxt
instance GHC.Classes.Eq GHC.Unit.Module.Warnings.WarningTxt
instance GHC.Classes.Eq GHC.Unit.Module.Warnings.Warnings
instance GHC.Utils.Binary.Binary GHC.Unit.Module.Warnings.Warnings
instance GHC.Utils.Outputable.Outputable GHC.Unit.Module.Warnings.WarningTxt
instance GHC.Utils.Binary.Binary GHC.Unit.Module.Warnings.WarningTxt
module GHC.Hs.Doc
-- | Haskell Documentation String
--
-- Internally this is a UTF8-Encoded ByteString.
data HsDocString
-- | Located Haskell Documentation String
type LHsDocString = Located HsDocString
mkHsDocString :: String -> HsDocString
-- | Create a HsDocString from a UTF8-encoded ByteString.
mkHsDocStringUtf8ByteString :: ByteString -> HsDocString
isEmptyDocString :: HsDocString -> Bool
unpackHDS :: HsDocString -> String
-- | Return the contents of a HsDocString as a UTF8-encoded
-- ByteString.
hsDocStringToByteString :: HsDocString -> ByteString
ppr_mbDoc :: Maybe LHsDocString -> SDoc
-- | Join two docstrings.
--
-- Non-empty docstrings are joined with two newlines in between,
-- resulting in separate paragraphs.
appendDocs :: HsDocString -> HsDocString -> HsDocString
-- | Concat docstrings with two newlines in between.
--
-- Empty docstrings are skipped.
--
-- If all inputs are empty, Nothing is returned.
concatDocs :: [HsDocString] -> Maybe HsDocString
-- | Docs for declarations: functions, data types, instances, methods etc.
newtype DeclDocMap
DeclDocMap :: Map Name HsDocString -> DeclDocMap
emptyDeclDocMap :: DeclDocMap
-- | Docs for arguments. E.g. function arguments, method arguments.
newtype ArgDocMap
ArgDocMap :: Map Name (IntMap HsDocString) -> ArgDocMap
emptyArgDocMap :: ArgDocMap
-- | Maps of docs that were added via Template Haskell's putDoc.
data ExtractedTHDocs
ExtractedTHDocs :: Maybe HsDocString -> DeclDocMap -> ArgDocMap -> DeclDocMap -> ExtractedTHDocs
-- | The added module header documentation, if it exists.
[ethd_mod_header] :: ExtractedTHDocs -> Maybe HsDocString
-- | The documentation added to declarations.
[ethd_decl_docs] :: ExtractedTHDocs -> DeclDocMap
-- | The documentation added to function arguments.
[ethd_arg_docs] :: ExtractedTHDocs -> ArgDocMap
-- | The documentation added to class and family instances.
[ethd_inst_docs] :: ExtractedTHDocs -> DeclDocMap
instance Data.Data.Data GHC.Hs.Doc.HsDocString
instance GHC.Show.Show GHC.Hs.Doc.HsDocString
instance GHC.Classes.Eq GHC.Hs.Doc.HsDocString
instance GHC.Utils.Binary.Binary GHC.Hs.Doc.ArgDocMap
instance GHC.Utils.Outputable.Outputable GHC.Hs.Doc.ArgDocMap
instance GHC.Utils.Binary.Binary GHC.Hs.Doc.DeclDocMap
instance GHC.Utils.Outputable.Outputable GHC.Hs.Doc.DeclDocMap
instance GHC.Utils.Binary.Binary GHC.Hs.Doc.HsDocString
instance GHC.Utils.Outputable.Outputable GHC.Hs.Doc.HsDocString
-- | Various types used during typechecking.
--
-- Please see GHC.Tc.Utils.Monad as well for operations on these
-- types. You probably want to import it, instead of this module.
--
-- All the monads exported here are built on top of the same IOEnv monad.
-- The monad functions like a Reader monad in the way it passes the
-- environment around. This is done to allow the environment to be
-- manipulated in a stack like fashion when entering expressions... etc.
--
-- For state that is global and should be returned at the end (e.g not
-- part of the stack mechanism), you should use a TcRef (= IORef) to
-- store them.
module GHC.Tc.Types
type TcRnIf a b = IOEnv (Env a b)
type TcRn = TcRnIf TcGblEnv TcLclEnv
-- | Historical "type-checking monad" (now it's just TcRn).
type TcM = TcRn
-- | Historical "renaming monad" (now it's just TcRn).
type RnM = TcRn
type IfM lcl = TcRnIf IfGblEnv lcl
type IfL = IfM IfLclEnv
type IfG = IfM ()
-- | Type alias for IORef; the convention is we'll use this for
-- mutable bits of data in TcGblEnv which are updated during
-- typechecking and returned at the end.
type TcRef a = IORef a
data Env gbl lcl
Env :: !HscEnv -> !Char -> gbl -> lcl -> Env gbl lcl
[env_top] :: Env gbl lcl -> !HscEnv
[env_um] :: Env gbl lcl -> !Char
[env_gbl] :: Env gbl lcl -> gbl
[env_lcl] :: Env gbl lcl -> lcl
-- | TcGblEnv describes the top-level of the module at the point at
-- which the typechecker is finished work. It is this structure that is
-- handed on to the desugarer For state that needs to be updated during
-- the typechecking phase and returned at end, use a TcRef (=
-- IORef).
data TcGblEnv
TcGblEnv :: Module -> Module -> HscSource -> GlobalRdrEnv -> Maybe [Type] -> FixityEnv -> RecFieldEnv -> TypeEnv -> TcRef TypeEnv -> !InstEnv -> !FamInstEnv -> AnnEnv -> [AvailInfo] -> ImportAvails -> DefUses -> TcRef [GlobalRdrElt] -> TcRef NameSet -> TcRef Bool -> TcRef Bool -> TcRef OccSet -> [(Module, Fingerprint)] -> Maybe [(LIE GhcRn, Avails)] -> [LImportDecl GhcRn] -> Maybe (HsGroup GhcRn) -> TcRef [FilePath] -> TcRef [LHsDecl GhcPs] -> TcRef [(ForeignSrcLang, FilePath)] -> TcRef NameSet -> TcRef [(TcLclEnv, ThModFinalizers)] -> TcRef [String] -> TcRef (Map TypeRep Dynamic) -> TcRef (Maybe (ForeignRef (IORef QState))) -> TcRef THDocs -> Bag EvBind -> Maybe Id -> LHsBinds GhcTc -> NameSet -> [LTcSpecPrag] -> Warnings -> [Annotation] -> [TyCon] -> NameSet -> [ClsInst] -> [FamInst] -> [LRuleDecl GhcTc] -> [LForeignDecl GhcTc] -> [PatSyn] -> Maybe LHsDocString -> !AnyHpcUsage -> SelfBootInfo -> Maybe Name -> TcRef (Bool, WarningMessages) -> [TcPluginSolver] -> [HoleFitPlugin] -> RealSrcSpan -> TcRef WantedConstraints -> !CompleteMatches -> TcRef CostCentreState -> TcGblEnv
-- | Module being compiled
[tcg_mod] :: TcGblEnv -> Module
-- | If a signature, the backing module See also Note [Identity versus
-- semantic module]
[tcg_semantic_mod] :: TcGblEnv -> Module
-- | What kind of module (regular Haskell, hs-boot, hsig)
[tcg_src] :: TcGblEnv -> HscSource
-- | Top level envt; used during renaming
[tcg_rdr_env] :: TcGblEnv -> GlobalRdrEnv
-- | Types used for defaulting. Nothing => no default
-- decl
[tcg_default] :: TcGblEnv -> Maybe [Type]
-- | Just for things in this module
[tcg_fix_env] :: TcGblEnv -> FixityEnv
-- | Just for things in this module See Note [The interactive package] in
-- GHC.Runtime.Context
[tcg_field_env] :: TcGblEnv -> RecFieldEnv
-- | Global type env for the module we are compiling now. All TyCons and
-- Classes (for this module) end up in here right away, along with their
-- derived constructors, selectors.
--
-- (Ids defined in this module start in the local envt, though they move
-- to the global envt during zonking)
--
-- NB: for what "things in this module" means, see Note [The interactive
-- package] in GHC.Runtime.Context
[tcg_type_env] :: TcGblEnv -> TypeEnv
[tcg_type_env_var] :: TcGblEnv -> TcRef TypeEnv
-- | Instance envt for all home-package modules; Includes the dfuns
-- in tcg_insts NB. BangPattern is to fix a leak, see #15111
[tcg_inst_env] :: TcGblEnv -> !InstEnv
-- | Ditto for family instances NB. BangPattern is to fix a leak, see
-- #15111
[tcg_fam_inst_env] :: TcGblEnv -> !FamInstEnv
-- | And for annotations
[tcg_ann_env] :: TcGblEnv -> AnnEnv
-- | What is exported
[tcg_exports] :: TcGblEnv -> [AvailInfo]
-- | Information about what was imported from where, including things bound
-- in this module. Also store Safe Haskell info here about transitive
-- trusted package requirements.
--
-- There are not many uses of this field, so you can grep for all them.
--
-- The ImportAvails records information about the following things:
--
-- -- data T b = ... deriving (C [a]) ---- -- should produce a derived instance for C [a] (T b). data DerivClauseTys pass -- | A deriving clause with a single type. Moreover, that type can -- only be a type constructor without any arguments. -- -- Example: deriving Eq DctSingle :: XDctSingle pass -> LHsSigType pass -> DerivClauseTys pass -- | A deriving clause with a comma-separated list of types, -- surrounded by enclosing parentheses. -- -- Example: deriving (Eq, C a) DctMulti :: XDctMulti pass -> [LHsSigType pass] -> DerivClauseTys pass XDerivClauseTys :: !XXDerivClauseTys pass -> DerivClauseTys pass type LDerivClauseTys pass = XRec pass (DerivClauseTys pass) data NewOrData -- |
-- newtype Blah ... --NewType :: NewOrData -- |
-- data Blah ... --DataType :: NewOrData -- | Convert a NewOrData to a TyConFlavour newOrDataToFlavour :: NewOrData -> TyConFlavour data StandaloneKindSig pass StandaloneKindSig :: XStandaloneKindSig pass -> LIdP pass -> LHsSigType pass -> StandaloneKindSig pass XStandaloneKindSig :: !XXStandaloneKindSig pass -> StandaloneKindSig pass -- | Located Standalone Kind Signature type LStandaloneKindSig pass = XRec pass (StandaloneKindSig pass) standaloneKindSigName :: StandaloneKindSig (GhcPass p) -> IdP (GhcPass p) -- | A type or class declaration. data TyClDecl pass -- |
-- type/data family T :: *->* ---- --
-- deriving instance _ => Eq (Foo a) ---- -- Which signifies that the context should be inferred. [deriv_type] :: DerivDecl pass -> LHsSigWcType pass [deriv_strategy] :: DerivDecl pass -> Maybe (LDerivStrategy pass) -- |
-- -XDeriveAnyClass --AnyclassStrategy :: XAnyClassStrategy pass -> DerivStrategy pass -- |
-- -XGeneralizedNewtypeDeriving --NewtypeStrategy :: XNewtypeStrategy pass -> DerivStrategy pass -- |
-- -XDerivingVia --ViaStrategy :: XViaStrategy pass -> DerivStrategy pass -- | A Located DerivStrategy. type LDerivStrategy pass = XRec pass (DerivStrategy pass) -- | A short description of a DerivStrategy'. derivStrategyName :: DerivStrategy a -> SDoc -- | Eliminate a DerivStrategy. foldDerivStrategy :: p ~ GhcPass pass => r -> (XViaStrategy p -> r) -> DerivStrategy p -> r -- | Map over the via type if dealing with ViaStrategy. -- Otherwise, return the DerivStrategy unchanged. mapDerivStrategy :: p ~ GhcPass pass => (XViaStrategy p -> XViaStrategy p) -> DerivStrategy p -> DerivStrategy p data XViaStrategyPs XViaStrategyPs :: EpAnn [AddEpAnn] -> LHsSigType GhcPs -> XViaStrategyPs -- | Located Rule Declarations type LRuleDecls pass = XRec pass (RuleDecls pass) -- | Rule Declarations data RuleDecls pass HsRules :: XCRuleDecls pass -> SourceText -> [LRuleDecl pass] -> RuleDecls pass [rds_ext] :: RuleDecls pass -> XCRuleDecls pass [rds_src] :: RuleDecls pass -> SourceText [rds_rules] :: RuleDecls pass -> [LRuleDecl pass] XRuleDecls :: !XXRuleDecls pass -> RuleDecls pass -- | Rule Declaration data RuleDecl pass HsRule :: XHsRule pass -> XRec pass (SourceText, RuleName) -> Activation -> Maybe [LHsTyVarBndr () (NoGhcTc pass)] -> [LRuleBndr pass] -> XRec pass (HsExpr pass) -> XRec pass (HsExpr pass) -> RuleDecl pass -- | After renamer, free-vars from the LHS and RHS [rd_ext] :: RuleDecl pass -> XHsRule pass -- | Note [Pragma source text] in GHC.Types.Basic [rd_name] :: RuleDecl pass -> XRec pass (SourceText, RuleName) [rd_act] :: RuleDecl pass -> Activation -- | Forall'd type vars [rd_tyvs] :: RuleDecl pass -> Maybe [LHsTyVarBndr () (NoGhcTc pass)] -- | Forall'd term vars, before typechecking; after typechecking this -- includes all forall'd vars [rd_tmvs] :: RuleDecl pass -> [LRuleBndr pass] [rd_lhs] :: RuleDecl pass -> XRec pass (HsExpr pass) -- | [rd_rhs] :: RuleDecl pass -> XRec pass (HsExpr pass) XRuleDecl :: !XXRuleDecl pass -> RuleDecl pass -- | Located Rule Declaration type LRuleDecl pass = XRec pass (RuleDecl pass) data HsRuleRn HsRuleRn :: NameSet -> NameSet -> HsRuleRn data HsRuleAnn HsRuleAnn :: Maybe (AddEpAnn, AddEpAnn) -> Maybe (AddEpAnn, AddEpAnn) -> [AddEpAnn] -> HsRuleAnn -- | The locations of forall and . for forall'd type vars -- Using AddEpAnn to capture possible unicode variants [ra_tyanns] :: HsRuleAnn -> Maybe (AddEpAnn, AddEpAnn) -- | The locations of forall and . for forall'd term vars -- Using AddEpAnn to capture possible unicode variants [ra_tmanns] :: HsRuleAnn -> Maybe (AddEpAnn, AddEpAnn) [ra_rest] :: HsRuleAnn -> [AddEpAnn] -- | Rule Binder data RuleBndr pass RuleBndr :: XCRuleBndr pass -> LIdP pass -> RuleBndr pass RuleBndrSig :: XRuleBndrSig pass -> LIdP pass -> HsPatSigType pass -> RuleBndr pass -- |
-- data T b = forall a. Eq a => MkT a b -- MkT :: forall b a. Eq a => MkT a b -- -- data T b where -- MkT1 :: Int -> T Int -- -- data T = Int MkT Int -- | MkT2 -- -- data T a where -- Int MkT Int :: T Int ---- --
-- withTempDirectory "src" "sdist." $ \tmpDir -> do ... ---- -- The tmpDir will be a new subdirectory of the given directory, -- e.g. src/sdist.342. withTempDirectory :: FilePath -> String -> (FilePath -> IO a) -> IO a instance GHC.Show.Show GHC.Utils.TmpFs.TempFileLifetime module GHC.Unit.Module.Status -- | Status of a module compilation to machine code data HscStatus -- | Nothing to do. HscNotGeneratingCode :: ModIface -> ModDetails -> HscStatus -- | Nothing to do because code already exists. HscUpToDate :: ModIface -> ModDetails -> HscStatus -- | Update boot file result. HscUpdateBoot :: ModIface -> ModDetails -> HscStatus -- | Generate signature file (backpack) HscUpdateSig :: ModIface -> ModDetails -> HscStatus -- | Recompile this module. HscRecomp :: CgGuts -> !ModLocation -> !PartialModIface -> !Maybe Fingerprint -> HscStatus -- | Information for the code generator. [hscs_guts] :: HscStatus -> CgGuts -- | Module info [hscs_mod_location] :: HscStatus -> !ModLocation -- | Partial interface [hscs_partial_iface] :: HscStatus -> !PartialModIface -- | Old interface hash for this compilation, if an old interface file -- exists. Pass to hscMaybeWriteIface when writing the interface -- to avoid updating the existing interface when the interface isn't -- changed. [hscs_old_iface_hash] :: HscStatus -> !Maybe Fingerprint module GHC.Unit.Module.ModGuts -- | A ModGuts is carried through the compiler, accumulating stuff as it -- goes There is only one ModGuts at any time, the one for the module -- being compiled right now. Once it is compiled, a ModIface and -- ModDetails are extracted and the ModGuts is discarded. data ModGuts ModGuts :: !Module -> HscSource -> SrcSpan -> ![AvailInfo] -> !Dependencies -> ![Usage] -> !Bool -> !GlobalRdrEnv -> !FixityEnv -> ![TyCon] -> ![ClsInst] -> ![FamInst] -> ![PatSyn] -> ![CoreRule] -> !CoreProgram -> !ForeignStubs -> ![(ForeignSrcLang, FilePath)] -> !Warnings -> [Annotation] -> [CompleteMatch] -> !HpcInfo -> !Maybe ModBreaks -> InstEnv -> FamInstEnv -> SafeHaskellMode -> Bool -> !Maybe HsDocString -> !DeclDocMap -> !ArgDocMap -> ModGuts -- | Module being compiled [mg_module] :: ModGuts -> !Module -- | Whether it's an hs-boot module [mg_hsc_src] :: ModGuts -> HscSource -- | For error messages from inner passes [mg_loc] :: ModGuts -> SrcSpan -- | What it exports [mg_exports] :: ModGuts -> ![AvailInfo] -- | What it depends on, directly or otherwise [mg_deps] :: ModGuts -> !Dependencies -- | What was used? Used for interfaces. [mg_usages] :: ModGuts -> ![Usage] -- | Did we run a TH splice? [mg_used_th] :: ModGuts -> !Bool -- | Top-level lexical environment [mg_rdr_env] :: ModGuts -> !GlobalRdrEnv -- | Fixities declared in this module. Used for creating interface files. [mg_fix_env] :: ModGuts -> !FixityEnv -- | TyCons declared in this module (includes TyCons for classes) [mg_tcs] :: ModGuts -> ![TyCon] -- | Class instances declared in this module [mg_insts] :: ModGuts -> ![ClsInst] -- | Family instances declared in this module [mg_fam_insts] :: ModGuts -> ![FamInst] -- | Pattern synonyms declared in this module [mg_patsyns] :: ModGuts -> ![PatSyn] -- | Before the core pipeline starts, contains See Note [Overall plumbing -- for rules] in GHC.Core.Rules [mg_rules] :: ModGuts -> ![CoreRule] -- | Bindings for this module [mg_binds] :: ModGuts -> !CoreProgram -- | Foreign exports declared in this module [mg_foreign] :: ModGuts -> !ForeignStubs -- | Files to be compiled with the C compiler [mg_foreign_files] :: ModGuts -> ![(ForeignSrcLang, FilePath)] -- | Warnings declared in the module [mg_warns] :: ModGuts -> !Warnings -- | Annotations declared in this module [mg_anns] :: ModGuts -> [Annotation] -- | Complete Matches [mg_complete_matches] :: ModGuts -> [CompleteMatch] -- | Coverage tick boxes in the module [mg_hpc_info] :: ModGuts -> !HpcInfo -- | Breakpoints for the module [mg_modBreaks] :: ModGuts -> !Maybe ModBreaks -- | Class instance environment for home-package modules (including -- this one); c.f. tcg_inst_env [mg_inst_env] :: ModGuts -> InstEnv -- | Type-family instance environment for home-package modules -- (including this one); c.f. tcg_fam_inst_env [mg_fam_inst_env] :: ModGuts -> FamInstEnv -- | Safe Haskell mode [mg_safe_haskell] :: ModGuts -> SafeHaskellMode -- | Do we need to trust our own package for Safe Haskell? See Note [Trust -- Own Package] in GHC.Rename.Names [mg_trust_pkg] :: ModGuts -> Bool -- | Module header. [mg_doc_hdr] :: ModGuts -> !Maybe HsDocString -- | Docs on declarations. [mg_decl_docs] :: ModGuts -> !DeclDocMap -- | Docs on arguments. [mg_arg_docs] :: ModGuts -> !ArgDocMap -- | A restricted form of ModGuts for code generation purposes data CgGuts CgGuts :: !Module -> [TyCon] -> CoreProgram -> !ForeignStubs -> ![(ForeignSrcLang, FilePath)] -> ![UnitId] -> !HpcInfo -> !Maybe ModBreaks -> [SptEntry] -> CgGuts -- | Module being compiled [cg_module] :: CgGuts -> !Module -- | Algebraic data types (including ones that started life as classes); -- generate constructors and info tables. Includes newtypes, just for the -- benefit of External Core [cg_tycons] :: CgGuts -> [TyCon] -- | The tidied main bindings, including previously-implicit bindings for -- record and class selectors, and data constructor wrappers. But *not* -- data constructor workers; reason: we regard them as part of the -- code-gen of tycons [cg_binds] :: CgGuts -> CoreProgram -- | Foreign export stubs [cg_foreign] :: CgGuts -> !ForeignStubs [cg_foreign_files] :: CgGuts -> ![(ForeignSrcLang, FilePath)] -- | Dependent packages, used to generate #includes for C code gen [cg_dep_pkgs] :: CgGuts -> ![UnitId] -- | Program coverage tick box information [cg_hpc_info] :: CgGuts -> !HpcInfo -- | Module breakpoints [cg_modBreaks] :: CgGuts -> !Maybe ModBreaks -- | Static pointer table entries for static forms defined in the module. -- See Note [Grand plan for static forms] in -- GHC.Iface.Tidy.StaticPtrTable [cg_spt_entries] :: CgGuts -> [SptEntry] -- | Definitions for writing plugins for GHC. Plugins can hook into -- several areas of the compiler. See the Plugin type. These -- plugins include type-checker plugins, source plugins, and core-to-core -- plugins. module GHC.Driver.Plugins -- | Plugin is the compiler plugin data type. Try to avoid -- constructing one of these directly, and just modify some fields of -- defaultPlugin instead: this is to try and preserve source-code -- compatibility when we add fields to this. -- -- Nonetheless, this API is preliminary and highly likely to change in -- the future. data Plugin Plugin :: CorePlugin -> TcPlugin -> HoleFitPlugin -> ([CommandLineOption] -> HscEnv -> IO HscEnv) -> ([CommandLineOption] -> IO PluginRecompile) -> ([CommandLineOption] -> ModSummary -> HsParsedModule -> Hsc HsParsedModule) -> ([CommandLineOption] -> TcGblEnv -> HsGroup GhcRn -> TcM (TcGblEnv, HsGroup GhcRn)) -> ([CommandLineOption] -> ModSummary -> TcGblEnv -> TcM TcGblEnv) -> ([CommandLineOption] -> LHsExpr GhcTc -> TcM (LHsExpr GhcTc)) -> (forall lcl. [CommandLineOption] -> ModIface -> IfM lcl ModIface) -> Plugin -- | Modify the Core pipeline that will be used for compilation. This is -- called as the Core pipeline is built for every module being compiled, -- and plugins get the opportunity to modify the pipeline in a -- nondeterministic order. [installCoreToDos] :: Plugin -> CorePlugin -- | An optional typechecker plugin, which may modify the behaviour of the -- constraint solver. [tcPlugin] :: Plugin -> TcPlugin -- | An optional plugin to handle hole fits, which may re-order or change -- the list of valid hole fits and refinement hole fits. [holeFitPlugin] :: Plugin -> HoleFitPlugin -- | An optional plugin to update HscEnv, right after plugin -- loading. This can be used to register hooks or tweak any field of -- DynFlags before doing actual work on a module. [driverPlugin] :: Plugin -> [CommandLineOption] -> HscEnv -> IO HscEnv -- | Specify how the plugin should affect recompilation. [pluginRecompile] :: Plugin -> [CommandLineOption] -> IO PluginRecompile -- | Modify the module when it is parsed. This is called by -- GHC.Driver.Main when the parsing is successful. [parsedResultAction] :: Plugin -> [CommandLineOption] -> ModSummary -> HsParsedModule -> Hsc HsParsedModule -- | Modify each group after it is renamed. This is called after each -- HsGroup has been renamed. [renamedResultAction] :: Plugin -> [CommandLineOption] -> TcGblEnv -> HsGroup GhcRn -> TcM (TcGblEnv, HsGroup GhcRn) -- | Modify the module when it is type checked. This is called at the very -- end of typechecking. [typeCheckResultAction] :: Plugin -> [CommandLineOption] -> ModSummary -> TcGblEnv -> TcM TcGblEnv -- | Modify the TH splice or quasiqoute before it is run. [spliceRunAction] :: Plugin -> [CommandLineOption] -> LHsExpr GhcTc -> TcM (LHsExpr GhcTc) -- | Modify an interface that have been loaded. This is called by -- GHC.Iface.Load when an interface is successfully loaded. Not -- applied to the loading of the plugin interface. Tools that rely on -- information from modules other than the currently compiled one should -- implement this function. [interfaceLoadAction] :: Plugin -> forall lcl. [CommandLineOption] -> ModIface -> IfM lcl ModIface -- | Default plugin: does nothing at all, except for marking that safe -- inference has failed unless -fplugin-trustworthy is passed. -- For compatibility reason you should base all your plugin definitions -- on this default value. defaultPlugin :: Plugin -- | Command line options gathered from the -PModule.Name:stuff syntax are -- given to you as this type type CommandLineOption = String purePlugin :: [CommandLineOption] -> IO PluginRecompile impurePlugin :: [CommandLineOption] -> IO PluginRecompile flagRecompile :: [CommandLineOption] -> IO PluginRecompile data PluginRecompile ForceRecompile :: PluginRecompile NoForceRecompile :: PluginRecompile MaybeRecompile :: Fingerprint -> PluginRecompile data FrontendPlugin FrontendPlugin :: FrontendPluginAction -> FrontendPlugin [frontend] :: FrontendPlugin -> FrontendPluginAction defaultFrontendPlugin :: FrontendPlugin type FrontendPluginAction = [String] -> [(String, Maybe Phase)] -> Ghc () type CorePlugin = [CommandLineOption] -> [CoreToDo] -> CoreM [CoreToDo] type TcPlugin = [CommandLineOption] -> Maybe TcPlugin -- | A renamer plugin which mades the renamed source available in a -- typechecker plugin. keepRenamedSource :: [CommandLineOption] -> TcGblEnv -> HsGroup GhcRn -> TcM (TcGblEnv, HsGroup GhcRn) -- | HoleFitPluginR adds a TcRef to hole fit plugins so that plugins can -- track internal state. Note the existential quantification, ensuring -- that the state cannot be modified from outside the plugin. data HoleFitPluginR data PluginWithArgs PluginWithArgs :: Plugin -> [CommandLineOption] -> PluginWithArgs -- | the actual callable plugin [paPlugin] :: PluginWithArgs -> Plugin -- | command line arguments for the plugin [paArguments] :: PluginWithArgs -> [CommandLineOption] plugins :: HscEnv -> [PluginWithArgs] pluginRecompile' :: PluginWithArgs -> IO PluginRecompile -- | A plugin with its arguments. The result of loading the plugin. data LoadedPlugin LoadedPlugin :: PluginWithArgs -> ModIface -> LoadedPlugin -- | the actual plugin together with its commandline arguments [lpPlugin] :: LoadedPlugin -> PluginWithArgs -- | the module containing the plugin [lpModule] :: LoadedPlugin -> ModIface lpModuleName :: LoadedPlugin -> ModuleName -- | A static plugin with its arguments. For registering compiled-in -- plugins through the GHC API. data StaticPlugin StaticPlugin :: PluginWithArgs -> StaticPlugin -- | the actual plugin together with its commandline arguments [spPlugin] :: StaticPlugin -> PluginWithArgs mapPlugins :: HscEnv -> (Plugin -> [CommandLineOption] -> a) -> [a] -- | Perform an operation by using all of the plugins in turn. withPlugins :: Monad m => HscEnv -> PluginOperation m a -> a -> m a -- | Perform a constant operation by using all of the plugins in turn. withPlugins_ :: Monad m => HscEnv -> ConstPluginOperation m a -> a -> m () instance GHC.Utils.Outputable.Outputable GHC.Driver.Plugins.PluginRecompile instance GHC.Base.Semigroup GHC.Driver.Plugins.PluginRecompile instance GHC.Base.Monoid GHC.Driver.Plugins.PluginRecompile module GHC.Driver.Monad -- | A monad that has all the features needed by GHC API calls. -- -- In short, a GHC monad -- --
-- libFunc :: String -> (Int -> IO a) -> IO a -- ghcFunc :: Int -> Ghc a -- -- ghcFuncUsingLibFunc :: String -> Ghc a -> Ghc a -- ghcFuncUsingLibFunc str = -- reifyGhc $ \s -> -- libFunc $ \i -> do -- reflectGhc (ghcFunc i) s --reflectGhc :: Ghc a -> Session -> IO a reifyGhc :: (Session -> IO a) -> Ghc a -- | Grabs the DynFlags from the Session getSessionDynFlags :: GhcMonad m => m DynFlags -- | Lift a computation from the IO monad. This allows us to run IO -- computations in any monadic stack, so long as it supports these kinds -- of operations (i.e. IO is the base monad for the stack). -- --
-- import Control.Monad.Trans.State -- from the "transformers" library -- -- printState :: Show s => StateT s IO () -- printState = do -- state <- get -- liftIO $ print state ---- -- Had we omitted liftIO, we would have ended up with -- this error: -- --
-- • Couldn't match type ‘IO’ with ‘StateT s IO’ -- Expected type: StateT s IO () -- Actual type: IO () ---- -- The important part here is the mismatch between StateT s IO -- () and IO (). -- -- Luckily, we know of a function that takes an IO a and -- returns an (m a): liftIO, enabling us to run -- the program and see the expected results: -- --
-- > evalStateT printState "hello" -- "hello" -- -- > evalStateT printState 3 -- 3 --liftIO :: MonadIO m => IO a -> m a -- | The Session is a handle to the complete state of a compilation -- session. A compilation session consists of a set of modules -- constituting the current program or library, the context for -- interactive evaluation, and various caches. data Session Session :: !IORef HscEnv -> Session -- | Call the argument with the current session. withSession :: GhcMonad m => (HscEnv -> m a) -> m a -- | Set the current session to the result of applying the current session -- to the argument. modifySession :: GhcMonad m => (HscEnv -> HscEnv) -> m () -- | Set the current session to the result of applying the current session -- to the argument. modifySessionM :: GhcMonad m => (HscEnv -> m HscEnv) -> m () -- | Call an action with a temporarily modified Session. withTempSession :: GhcMonad m => (HscEnv -> HscEnv) -> m a -> m a -- | Modify the logger modifyLogger :: GhcMonad m => (Logger -> Logger) -> m () -- | Push a log hook on the stack pushLogHookM :: GhcMonad m => (LogAction -> LogAction) -> m () -- | Pop a log hook from the stack popLogHookM :: GhcMonad m => m () -- | Put a log message putLogMsgM :: GhcMonad m => WarnReason -> Severity -> SrcSpan -> SDoc -> m () -- | Put a log message putMsgM :: GhcMonad m => SDoc -> m () -- | Time an action withTimingM :: GhcMonad m => SDoc -> (b -> ()) -> m b -> m b -- | A monad that allows logging of warnings. logWarnings :: GhcMonad m => WarningMessages -> m () -- | Print the error message and all warnings. Useful inside exception -- handlers. Clears warnings after printing. printException :: GhcMonad m => SourceError -> m () -- | A function called to log warnings and errors. type WarnErrLogger = forall m. GhcMonad m => Maybe SourceError -> m () defaultWarnErrLogger :: WarnErrLogger instance Control.Monad.Catch.MonadMask GHC.Driver.Monad.Ghc instance Control.Monad.Catch.MonadCatch GHC.Driver.Monad.Ghc instance Control.Monad.Catch.MonadThrow GHC.Driver.Monad.Ghc instance GHC.Base.Functor GHC.Driver.Monad.Ghc instance Control.Monad.Catch.MonadMask m => Control.Monad.Catch.MonadMask (GHC.Driver.Monad.GhcT m) instance Control.Monad.Catch.MonadCatch m => Control.Monad.Catch.MonadCatch (GHC.Driver.Monad.GhcT m) instance Control.Monad.Catch.MonadThrow m => Control.Monad.Catch.MonadThrow (GHC.Driver.Monad.GhcT m) instance GHC.Base.Functor m => GHC.Base.Functor (GHC.Driver.Monad.GhcT m) instance GHC.Base.Applicative m => GHC.Base.Applicative (GHC.Driver.Monad.GhcT m) instance GHC.Base.Monad m => GHC.Base.Monad (GHC.Driver.Monad.GhcT m) instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (GHC.Driver.Monad.GhcT m) instance Control.Monad.IO.Class.MonadIO m => GHC.Driver.Session.HasDynFlags (GHC.Driver.Monad.GhcT m) instance Control.Monad.IO.Class.MonadIO m => GHC.Utils.Logger.HasLogger (GHC.Driver.Monad.GhcT m) instance GHC.Utils.Exception.ExceptionMonad m => GHC.Driver.Monad.GhcMonad (GHC.Driver.Monad.GhcT m) instance GHC.Base.Applicative GHC.Driver.Monad.Ghc instance GHC.Base.Monad GHC.Driver.Monad.Ghc instance Control.Monad.IO.Class.MonadIO GHC.Driver.Monad.Ghc instance Control.Monad.Fix.MonadFix GHC.Driver.Monad.Ghc instance GHC.Driver.Session.HasDynFlags GHC.Driver.Monad.Ghc instance GHC.Utils.Logger.HasLogger GHC.Driver.Monad.Ghc instance GHC.Driver.Monad.GhcMonad GHC.Driver.Monad.Ghc -- | Source errors module GHC.Types.SourceError -- | A source error is an error that is caused by one or more errors in the -- source code. A SourceError is thrown by many functions in the -- compilation pipeline. Inside GHC these errors are merely printed via -- log_action, but API clients may treat them differently, for -- example, insert them into a list box. If you want the default -- behaviour, use the idiom: -- --
-- handleSourceError printExceptionAndWarnings $ do -- ... api calls that may fail ... ---- -- The SourceErrors error messages can be accessed via -- srcErrorMessages. This list may be empty if the compiler failed -- due to -Werror (Opt_WarnIsError). -- -- See printExceptionAndWarnings for more information on what to -- take care of when writing a custom error handler. newtype SourceError SourceError :: ErrorMessages -> SourceError mkSrcErr :: ErrorMessages -> SourceError srcErrorMessages :: SourceError -> ErrorMessages throwErrors :: MonadIO io => ErrorMessages -> io a throwOneError :: MonadIO io => MsgEnvelope DecoratedSDoc -> io a -- | Perform the given action and call the exception handler if the action -- throws a SourceError. See SourceError for more -- information. handleSourceError :: MonadCatch m => (SourceError -> m a) -> m a -> m a instance GHC.Show.Show GHC.Types.SourceError.SourceError instance GHC.Exception.Type.Exception GHC.Types.SourceError.SourceError module GHC.Driver.Errors -- | Converts a list of WarningMessages into a tuple where the -- second element contains only error, i.e. warnings that are considered -- fatal by GHC based on the input DynFlags. warningsToMessages :: DynFlags -> WarningMessages -> (WarningMessages, ErrorMessages) -- | Given a bag of warnings, turn them into an exception if -Werror is -- enabled, or print them out otherwise. printOrThrowWarnings :: Logger -> DynFlags -> Bag WarnMsg -> IO () printBagOfErrors :: RenderableDiagnostic a => Logger -> DynFlags -> Bag (MsgEnvelope a) -> IO () -- | Checks if given WarnMsg is a fatal warning. isWarnMsgFatal :: DynFlags -> WarnMsg -> Maybe (Maybe WarningFlag) handleFlagWarnings :: Logger -> DynFlags -> [Warn] -> IO () module GHC.Driver.Env -- | The Hsc monad: Passing an environment and warning state newtype Hsc a Hsc :: (HscEnv -> WarningMessages -> IO (a, WarningMessages)) -> Hsc a -- | HscEnv is like Session, except that some of the fields are -- immutable. An HscEnv is used to compile a single module from plain -- Haskell source code (after preprocessing) to either C, assembly or -- C--. It's also used to store the dynamic linker state to allow for -- multiple linkers in the same address space. Things like the module -- graph don't change during a single compilation. -- -- Historical note: "hsc" used to be the name of the compiler binary, -- when there was a separate driver and compiler. To compile a single -- module, the driver would invoke hsc on the source code... so nowadays -- we think of hsc as the layer of the compiler that deals with compiling -- a single module. data HscEnv HscEnv :: DynFlags -> [Target] -> ModuleGraph -> InteractiveContext -> HomePackageTable -> {-# UNPACK #-} !IORef ExternalPackageState -> {-# UNPACK #-} !IORef NameCache -> {-# UNPACK #-} !IORef FinderCache -> Maybe (Module, IORef TypeEnv) -> Maybe Interp -> ![LoadedPlugin] -> ![StaticPlugin] -> !Maybe [UnitDatabase UnitId] -> UnitEnv -> !Logger -> !Hooks -> !TmpFs -> HscEnv -- | The dynamic flag settings [hsc_dflags] :: HscEnv -> DynFlags -- | The targets (or roots) of the current session [hsc_targets] :: HscEnv -> [Target] -- | The module graph of the current session [hsc_mod_graph] :: HscEnv -> ModuleGraph -- | The context for evaluating interactive statements [hsc_IC] :: HscEnv -> InteractiveContext -- | The home package table describes already-compiled home-package -- modules, excluding the module we are compiling right now. (In -- one-shot mode the current module is the only home-package module, so -- hsc_HPT is empty. All other modules count as "external-package" -- modules. However, even in GHCi mode, hi-boot interfaces are -- demand-loaded into the external-package table.) -- -- hsc_HPT is not mutable because we only demand-load external -- packages; the home package is eagerly loaded, module by module, by the -- compilation manager. -- -- The HPT may contain modules compiled earlier by --make but -- not actually below the current module in the dependency graph. -- -- (This changes a previous invariant: changed Jan 05.) [hsc_HPT] :: HscEnv -> HomePackageTable -- | Information about the currently loaded external packages. This is -- mutable because packages will be demand-loaded during a compilation -- run as required. [hsc_EPS] :: HscEnv -> {-# UNPACK #-} !IORef ExternalPackageState -- | As with hsc_EPS, this is side-effected by compiling to reflect -- sucking in interface files. They cache the state of external interface -- files, in effect. [hsc_NC] :: HscEnv -> {-# UNPACK #-} !IORef NameCache -- | The cached result of performing finding in the file system [hsc_FC] :: HscEnv -> {-# UNPACK #-} !IORef FinderCache -- | Used for one-shot compilation only, to initialise the -- IfGblEnv. See tcg_type_env_var for TcGblEnv. -- See also Note [hsc_type_env_var hack] [hsc_type_env_var] :: HscEnv -> Maybe (Module, IORef TypeEnv) -- | target code interpreter (if any) to use for TH and GHCi. See Note -- [Target code interpreter] [hsc_interp] :: HscEnv -> Maybe Interp -- | plugins dynamically loaded after processing arguments. What will be -- loaded here is directed by DynFlags.pluginModNames. Arguments are -- loaded from DynFlags.pluginModNameOpts. -- -- The purpose of this field is to cache the plugins so they don't have -- to be loaded each time they are needed. See initializePlugins. [hsc_plugins] :: HscEnv -> ![LoadedPlugin] -- | static plugins which do not need dynamic loading. These plugins are -- intended to be added by GHC API users directly to this list. -- -- To add dynamically loaded plugins through the GHC API see -- addPluginModuleName instead. [hsc_static_plugins] :: HscEnv -> ![StaticPlugin] -- | Stack of unit databases for the target platform. -- -- This field is populated with the result of initUnits. -- -- Nothing means the databases have never been read from disk. -- -- Usually we don't reload the databases from disk if they are cached, -- even if the database flags changed! [hsc_unit_dbs] :: HscEnv -> !Maybe [UnitDatabase UnitId] -- | Unit environment (unit state, home unit, etc.). -- -- Initialized from the databases cached in hsc_unit_dbs and from -- the DynFlags. [hsc_unit_env] :: HscEnv -> UnitEnv -- | Logger [hsc_logger] :: HscEnv -> !Logger -- | Hooks [hsc_hooks] :: HscEnv -> !Hooks -- | Temporary files [hsc_tmpfs] :: HscEnv -> !TmpFs hsc_home_unit :: HscEnv -> HomeUnit hsc_units :: HscEnv -> UnitState runHsc :: HscEnv -> Hsc a -> IO a -- | Switches in the DynFlags and Plugins from the InteractiveContext mkInteractiveHscEnv :: HscEnv -> HscEnv -- | A variant of runHsc that switches in the DynFlags and Plugins from the -- InteractiveContext before running the Hsc computation. runInteractiveHsc :: HscEnv -> Hsc a -> IO a -- | Retrieve the ExternalPackageState cache. hscEPS :: HscEnv -> IO ExternalPackageState hptCompleteSigs :: HscEnv -> [CompleteMatch] -- | Find all the instance declarations (of classes and families) from the -- Home Package Table filtered by the provided predicate function. Used -- in tcRnImports, to select the instances that are in the -- transitive closure of imports from the currently compiled module. hptInstances :: HscEnv -> (ModuleName -> Bool) -> ([ClsInst], [FamInst]) -- | Get annotations from modules "below" this one (in the dependency -- sense) hptAnns :: HscEnv -> Maybe [ModuleNameWithIsBoot] -> [Annotation] hptAllThings :: (HomeModInfo -> [a]) -> HscEnv -> [a] -- | Get things from modules "below" this one (in the dependency sense) C.f -- Inst.hptInstances hptSomeThingsBelowUs :: (HomeModInfo -> [a]) -> Bool -> HscEnv -> [ModuleNameWithIsBoot] -> [a] -- | Get rules from modules "below" this one (in the dependency sense) hptRules :: HscEnv -> [ModuleNameWithIsBoot] -> [CoreRule] -- | Deal with gathering annotations in from all possible places and -- combining them into a single AnnEnv prepareAnnotations :: HscEnv -> Maybe ModGuts -> IO AnnEnv -- | Find the TyThing for the given Name by using all the -- resources at our disposal: the compiled modules in the -- HomePackageTable and the compiled modules in other packages -- that live in PackageTypeEnv. Note that this does NOT look up -- the TyThing in the module being compiled: you have to do that -- yourself, if desired lookupType :: HscEnv -> Name -> IO (Maybe TyThing) -- | Find the ModIface_ for a Module, searching in both the -- loaded home and external package module information lookupIfaceByModule :: HomePackageTable -> PackageIfaceTable -> Module -> Maybe ModIface mainModIs :: HscEnv -> Module module GHC.Unit.External -- | Information about other packages that we have slurped in by reading -- their interface files data ExternalPackageState EPS :: !ModuleNameEnv ModuleNameWithIsBoot -> !PackageIfaceTable -> InstalledModuleEnv (UniqDSet ModuleName) -> !PackageTypeEnv -> !PackageInstEnv -> !PackageFamInstEnv -> !PackageRuleBase -> !PackageAnnEnv -> !PackageCompleteMatches -> !ModuleEnv FamInstEnv -> !EpsStats -> ExternalPackageState -- | In OneShot mode (only), home-package modules accumulate in the -- external package state, and are sucked in lazily. For these home-pkg -- modules (only) we need to record which are boot modules. We set this -- field after loading all the explicitly-imported interfaces, but before -- doing anything else -- -- The ModuleName part is not necessary, but it's useful for debug -- prints, and it's convenient because this field comes direct from -- imp_dep_mods [eps_is_boot] :: ExternalPackageState -> !ModuleNameEnv ModuleNameWithIsBoot -- | The ModIface_s for modules in external packages whose -- interfaces we have opened. The declarations in these interface files -- are held in the eps_decls, eps_inst_env, -- eps_fam_inst_env and eps_rules fields of this record, -- not in the mi_decls fields of the interface we have sucked in. -- -- What is in the PIT is: -- --
-- import Control.Monad.Trans.State -- from the "transformers" library -- -- printState :: Show s => StateT s IO () -- printState = do -- state <- get -- liftIO $ print state ---- -- Had we omitted liftIO, we would have ended up with -- this error: -- --
-- • Couldn't match type ‘IO’ with ‘StateT s IO’ -- Expected type: StateT s IO () -- Actual type: IO () ---- -- The important part here is the mismatch between StateT s IO -- () and IO (). -- -- Luckily, we know of a function that takes an IO a and -- returns an (m a): liftIO, enabling us to run -- the program and see the expected results: -- --
-- > evalStateT printState "hello" -- "hello" -- -- > evalStateT printState 3 -- 3 --liftIO :: MonadIO m => IO a -> m a -- | Lift an IO operation into CoreM while consuming its -- SimplCount liftIOWithCount :: IO (SimplCount, a) -> CoreM a -- | Get all annotations of a given type. This happens lazily, that is no -- deserialization will take place until the [a] is actually demanded and -- the [a] can also be empty (the UniqFM is not filtered). -- -- This should be done once at the start of a Core-to-Core pass that uses -- annotations. -- -- See Note [Annotations] getAnnotations :: Typeable a => ([Word8] -> a) -> ModGuts -> CoreM (ModuleEnv [a], NameEnv [a]) -- | Get at most one annotation of a given type per annotatable item. getFirstAnnotations :: Typeable a => ([Word8] -> a) -> ModGuts -> CoreM (ModuleEnv a, NameEnv a) -- | Output a message to the screen putMsg :: SDoc -> CoreM () -- | Output a String message to the screen putMsgS :: String -> CoreM () -- | Output an error to the screen. Does not cause the compiler to die. errorMsg :: SDoc -> CoreM () -- | Output an error to the screen. Does not cause the compiler to die. errorMsgS :: String -> CoreM () warnMsg :: WarnReason -> SDoc -> CoreM () -- | Output a fatal error to the screen. Does not cause the compiler to -- die. fatalErrorMsg :: SDoc -> CoreM () -- | Output a fatal error to the screen. Does not cause the compiler to -- die. fatalErrorMsgS :: String -> CoreM () -- | Outputs a debugging message at verbosity level of -v or -- higher debugTraceMsg :: SDoc -> CoreM () -- | Output a string debugging message at verbosity level of -v or -- higher debugTraceMsgS :: String -> CoreM () -- | Show some labelled SDoc if a particular flag is set or at a -- verbosity level of -v -ddump-most or higher dumpIfSet_dyn :: DumpFlag -> String -> DumpFormat -> SDoc -> CoreM () instance GHC.Base.Functor GHC.Core.Opt.Monad.CoreM instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Monad.CoreToDo instance GHC.Base.Monad GHC.Core.Opt.Monad.CoreM instance GHC.Base.Applicative GHC.Core.Opt.Monad.CoreM instance GHC.Base.Alternative GHC.Core.Opt.Monad.CoreM instance GHC.Base.MonadPlus GHC.Core.Opt.Monad.CoreM instance GHC.Types.Unique.Supply.MonadUnique GHC.Core.Opt.Monad.CoreM instance Control.Monad.IO.Class.MonadIO GHC.Core.Opt.Monad.CoreM instance GHC.Driver.Session.HasDynFlags GHC.Core.Opt.Monad.CoreM instance GHC.Utils.Logger.HasLogger GHC.Core.Opt.Monad.CoreM instance GHC.Unit.Module.HasModule GHC.Core.Opt.Monad.CoreM instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Monad.Tick instance GHC.Classes.Eq GHC.Core.Opt.Monad.Tick instance GHC.Classes.Ord GHC.Core.Opt.Monad.Tick instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Monad.FloatOutSwitches instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Monad.SimplMode -- | The IO Monad with an environment -- -- The environment is passed around as a Reader monad but as its in the -- IO monad, mutable references can be used for updating state. module GHC.Data.IOEnv data IOEnv env a failM :: IOEnv env a failWithM :: String -> IOEnv env a data IOEnvFailure IOEnvFailure :: IOEnvFailure getEnv :: IOEnv env env -- | Perform a computation with a different environment setEnv :: env' -> IOEnv env' a -> IOEnv env a -- | Perform a computation with an altered environment updEnv :: (env -> env') -> IOEnv env' a -> IOEnv env a runIOEnv :: env -> IOEnv env a -> IO a unsafeInterleaveM :: IOEnv env a -> IOEnv env a uninterruptibleMaskM_ :: IOEnv env a -> IOEnv env a tryM :: IOEnv env r -> IOEnv env (Either IOEnvFailure r) tryAllM :: IOEnv env r -> IOEnv env (Either SomeException r) tryMostM :: IOEnv env r -> IOEnv env (Either SomeException r) fixM :: (a -> IOEnv env a) -> IOEnv env a -- | A mutable variable in the IO monad data IORef a newMutVar :: a -> IOEnv env (IORef a) readMutVar :: IORef a -> IOEnv env a writeMutVar :: IORef a -> a -> IOEnv env () updMutVar :: IORef a -> (a -> a) -> IOEnv env () updMutVarM :: IORef a -> (a -> IOEnv env a) -> IOEnv env () -- | Atomically update the reference. Does not force the evaluation of the -- new variable contents. For strict update, use atomicUpdMutVar'. atomicUpdMutVar :: IORef a -> (a -> (a, b)) -> IOEnv env b -- | Strict variant of atomicUpdMutVar. atomicUpdMutVar' :: IORef a -> (a -> (a, b)) -> IOEnv env b instance Control.Monad.Catch.MonadMask (GHC.Data.IOEnv.IOEnv env) instance Control.Monad.Catch.MonadCatch (GHC.Data.IOEnv.IOEnv env) instance Control.Monad.Catch.MonadThrow (GHC.Data.IOEnv.IOEnv env) instance GHC.Show.Show GHC.Data.IOEnv.IOEnvFailure instance GHC.Exception.Type.Exception GHC.Data.IOEnv.IOEnvFailure instance GHC.Base.Functor (GHC.Data.IOEnv.IOEnv env) instance Control.Monad.IO.Class.MonadIO (GHC.Data.IOEnv.IOEnv env) instance GHC.Base.Monad (GHC.Data.IOEnv.IOEnv m) instance Control.Monad.Fail.MonadFail (GHC.Data.IOEnv.IOEnv m) instance GHC.Base.Applicative (GHC.Data.IOEnv.IOEnv m) instance GHC.Driver.Session.ContainsDynFlags env => GHC.Driver.Session.HasDynFlags (GHC.Data.IOEnv.IOEnv env) instance GHC.Driver.Hooks.ContainsHooks env => GHC.Driver.Hooks.HasHooks (GHC.Data.IOEnv.IOEnv env) instance GHC.Utils.Logger.ContainsLogger env => GHC.Utils.Logger.HasLogger (GHC.Data.IOEnv.IOEnv env) instance GHC.Unit.Module.ContainsModule env => GHC.Unit.Module.HasModule (GHC.Data.IOEnv.IOEnv env) instance GHC.Base.Alternative (GHC.Data.IOEnv.IOEnv env) instance GHC.Base.MonadPlus (GHC.Data.IOEnv.IOEnv env) module GHC.Cmm type CmmProgram = [CmmGroup] -- | Cmm group before SRT generation type CmmGroup = GenCmmGroup CmmStatics CmmTopInfo CmmGraph -- | Cmm group with SRTs type CmmGroupSRTs = GenCmmGroup RawCmmStatics CmmTopInfo CmmGraph -- | Raw cmm group (TODO (osa): not sure what that means) type RawCmmGroup = GenCmmGroup RawCmmStatics (LabelMap RawCmmStatics) CmmGraph type GenCmmGroup d h g = [GenCmmDecl d h g] type CmmDecl = GenCmmDecl CmmStatics CmmTopInfo CmmGraph type CmmDeclSRTs = GenCmmDecl RawCmmStatics CmmTopInfo CmmGraph -- | A top-level chunk, abstracted over the type of the contents of the -- basic blocks (Cmm or instructions are the likely instantiations). data GenCmmDecl d h g CmmProc :: h -> CLabel -> [GlobalReg] -> g -> GenCmmDecl d h g CmmData :: Section -> d -> GenCmmDecl d h g type CmmGraph = GenCmmGraph CmmNode data GenCmmGraph n CmmGraph :: BlockId -> Graph n C C -> GenCmmGraph n [g_entry] :: GenCmmGraph n -> BlockId [g_graph] :: GenCmmGraph n -> Graph n C C type CmmBlock = Block CmmNode C C type RawCmmDecl = GenCmmDecl RawCmmStatics (LabelMap RawCmmStatics) CmmGraph data Section Section :: SectionType -> CLabel -> Section data SectionType Text :: SectionType Data :: SectionType ReadOnlyData :: SectionType RelocatableReadOnlyData :: SectionType UninitialisedData :: SectionType ReadOnlyData16 :: SectionType CString :: SectionType OtherSection :: String -> SectionType data GenCmmStatics (rawOnly :: Bool) [CmmStatics] :: CLabel -> CmmInfoTable -> CostCentreStack -> [CmmLit] -> GenCmmStatics 'False -- | Static data, after SRTs are generated [CmmStaticsRaw] :: CLabel -> [CmmStatic] -> GenCmmStatics a type CmmStatics = GenCmmStatics 'False type RawCmmStatics = GenCmmStatics 'True data CmmStatic -- | a literal value, size given by cmmLitRep of the literal. CmmStaticLit :: CmmLit -> CmmStatic -- | uninitialised data, N bytes long CmmUninitialised :: Int -> CmmStatic -- | string of 8-bit values only, not zero terminated. CmmString :: ByteString -> CmmStatic -- | an embedded binary file CmmFileEmbed :: FilePath -> CmmStatic data SectionProtection ReadWriteSection :: SectionProtection ReadOnlySection :: SectionProtection WriteProtectedSection :: SectionProtection -- | Should a data in this section be considered constant at runtime sectionProtection :: Section -> SectionProtection data GenBasicBlock i BasicBlock :: BlockId -> [i] -> GenBasicBlock i -- | The branch block id is that of the first block in the branch, which is -- that branch's entry point blockId :: GenBasicBlock i -> BlockId newtype ListGraph i ListGraph :: [GenBasicBlock i] -> ListGraph i pprBBlock :: Outputable stmt => GenBasicBlock stmt -> SDoc -- | CmmTopInfo is attached to each CmmDecl (see defn of CmmGroup), and -- contains the extra info (beyond the executable code) that belongs to -- that CmmDecl. data CmmTopInfo TopInfo :: LabelMap CmmInfoTable -> CmmStackInfo -> CmmTopInfo [info_tbls] :: CmmTopInfo -> LabelMap CmmInfoTable [stack_info] :: CmmTopInfo -> CmmStackInfo data CmmStackInfo StackInfo :: ByteOff -> Bool -> CmmStackInfo [arg_space] :: CmmStackInfo -> ByteOff [do_layout] :: CmmStackInfo -> Bool -- | Info table as a haskell data type data CmmInfoTable CmmInfoTable :: CLabel -> SMRep -> ProfilingInfo -> Maybe CLabel -> Maybe (Id, CostCentreStack) -> CmmInfoTable [cit_lbl] :: CmmInfoTable -> CLabel [cit_rep] :: CmmInfoTable -> SMRep [cit_prof] :: CmmInfoTable -> ProfilingInfo [cit_srt] :: CmmInfoTable -> Maybe CLabel [cit_clo] :: CmmInfoTable -> Maybe (Id, CostCentreStack) topInfoTable :: GenCmmDecl a CmmTopInfo (GenCmmGraph n) -> Maybe CmmInfoTable data ClosureTypeInfo Constr :: ConTagZ -> ConstrDescription -> ClosureTypeInfo Fun :: FunArity -> ArgDescr -> ClosureTypeInfo Thunk :: ClosureTypeInfo ThunkSelector :: SelectorOffset -> ClosureTypeInfo BlackHole :: ClosureTypeInfo IndStatic :: ClosureTypeInfo data ProfilingInfo NoProfilingInfo :: ProfilingInfo ProfilingInfo :: ByteString -> ByteString -> ProfilingInfo type ConstrDescription = ByteString instance GHC.Show.Show GHC.Cmm.SectionType instance GHC.Classes.Eq GHC.Cmm.SectionProtection instance GHC.Base.Functor (GHC.Cmm.GenCmmDecl d h) instance GHC.Base.Functor GHC.Cmm.GenBasicBlock instance GHC.Base.Functor GHC.Cmm.ListGraph instance GHC.Utils.Outputable.Outputable instr => GHC.Utils.Outputable.Outputable (GHC.Cmm.ListGraph instr) instance GHC.Utils.Outputable.OutputableP env instr => GHC.Utils.Outputable.OutputableP env (GHC.Cmm.ListGraph instr) instance GHC.Utils.Outputable.Outputable instr => GHC.Utils.Outputable.Outputable (GHC.Cmm.GenBasicBlock instr) instance GHC.Utils.Outputable.OutputableP env instr => GHC.Utils.Outputable.OutputableP env (GHC.Cmm.GenBasicBlock instr) instance GHC.Utils.Outputable.Outputable GHC.Cmm.CmmStatic module GHC.Runtime.Heap.Layout -- | Word offset, or word count type WordOff = Int -- | Byte offset, or byte count type ByteOff = Int -- | Convert the given number of words to a number of bytes. -- -- This function morally has type WordOff -> ByteOff, but -- uses Num a to allow for overloading. wordsToBytes :: Num a => Platform -> a -> a -- | First round the given byte count up to a multiple of the machine's -- word size and then convert the result to words. bytesToWordsRoundUp :: Platform -> ByteOff -> WordOff -- | Round up the given byte count to the next byte count that's a multiple -- of the machine's word size. roundUpToWords :: Platform -> ByteOff -> ByteOff -- | Round up base to a multiple of size. roundUpTo :: ByteOff -> ByteOff -> ByteOff data StgWord fromStgWord :: StgWord -> Integer toStgWord :: Platform -> Integer -> StgWord data StgHalfWord fromStgHalfWord :: StgHalfWord -> Integer toStgHalfWord :: Platform -> Integer -> StgHalfWord -- | Half word size in bytes halfWordSize :: Platform -> ByteOff halfWordSizeInBits :: Platform -> Int -- | A description of the layout of a closure. Corresponds directly to the -- closure types in includes/rts/storage/ClosureTypes.h. data SMRep HeapRep :: IsStatic -> !WordOff -> !WordOff -> ClosureTypeInfo -> SMRep ArrayPtrsRep :: !WordOff -> !WordOff -> SMRep SmallArrayPtrsRep :: !WordOff -> SMRep ArrayWordsRep :: !WordOff -> SMRep StackRep :: Liveness -> SMRep RTSRep :: Int -> SMRep -> SMRep -- | True <=> This is a static closure. Affects how we -- garbage-collect it. Static closure have an extra static link field at -- the end. Constructors do not have a static variant; see Note [static -- constructors] type IsStatic = Bool data ClosureTypeInfo Constr :: ConTagZ -> ConstrDescription -> ClosureTypeInfo Fun :: FunArity -> ArgDescr -> ClosureTypeInfo Thunk :: ClosureTypeInfo ThunkSelector :: SelectorOffset -> ClosureTypeInfo BlackHole :: ClosureTypeInfo IndStatic :: ClosureTypeInfo -- | An ArgDescr describes the argument pattern of a function data ArgDescr ArgSpec :: !Int -> ArgDescr ArgGen :: Liveness -> ArgDescr ArgUnknown :: ArgDescr -- | We represent liveness bitmaps as a Bitmap (whose internal -- representation really is a bitmap). These are pinned onto case return -- vectors to indicate the state of the stack for the garbage collector. -- -- In the compiled program, liveness bitmaps that fit inside a single -- word (StgWord) are stored as a single word, while larger bitmaps are -- stored as a pointer to an array of words. type Liveness = [Bool] type ConstrDescription = ByteString mkHeapRep :: Profile -> IsStatic -> WordOff -> WordOff -> ClosureTypeInfo -> SMRep blackHoleRep :: SMRep indStaticRep :: SMRep mkStackRep :: [Bool] -> SMRep mkRTSRep :: Int -> SMRep -> SMRep arrPtrsRep :: Platform -> WordOff -> SMRep smallArrPtrsRep :: WordOff -> SMRep arrWordsRep :: Platform -> ByteOff -> SMRep isStaticRep :: SMRep -> IsStatic isConRep :: SMRep -> Bool isThunkRep :: SMRep -> Bool isFunRep :: SMRep -> Bool isStaticNoCafCon :: SMRep -> Bool isStackRep :: SMRep -> Bool -- | The total size of the closure, in words. heapClosureSizeW :: Profile -> SMRep -> WordOff -- | Size of a closure header (StgHeader in -- includes/rts/storage/Closures.h) fixedHdrSizeW :: Profile -> WordOff arrWordsHdrSize :: Profile -> ByteOff arrWordsHdrSizeW :: Profile -> WordOff arrPtrsHdrSize :: Profile -> ByteOff arrPtrsHdrSizeW :: Profile -> WordOff -- | Size of the profiling part of a closure header (StgProfHeader in -- includes/rts/storage/Closures.h) profHdrSize :: Profile -> WordOff thunkHdrSize :: Profile -> WordOff nonHdrSize :: Platform -> SMRep -> ByteOff nonHdrSizeW :: SMRep -> WordOff smallArrPtrsHdrSize :: Profile -> ByteOff smallArrPtrsHdrSizeW :: Profile -> WordOff hdrSize :: Profile -> SMRep -> ByteOff hdrSizeW :: Profile -> SMRep -> WordOff fixedHdrSize :: Profile -> ByteOff -- | Derives the RTS closure type from an SMRep rtsClosureType :: SMRep -> Int rET_SMALL :: Int rET_BIG :: Int aRG_GEN :: Int aRG_GEN_BIG :: Int -- | The byte offset into the card table of the card for a given element card :: Platform -> Int -> Int -- | Convert a number of elements to a number of cards, rounding up cardRoundUp :: Platform -> Int -> Int -- | The size of a card table, in bytes cardTableSizeB :: Platform -> Int -> ByteOff -- | The size of a card table, in words cardTableSizeW :: Platform -> Int -> WordOff instance GHC.Bits.Bits GHC.Runtime.Heap.Layout.StgWord instance GHC.Classes.Eq GHC.Runtime.Heap.Layout.StgWord instance GHC.Classes.Eq GHC.Runtime.Heap.Layout.StgHalfWord instance GHC.Utils.Outputable.Outputable GHC.Runtime.Heap.Layout.SMRep instance GHC.Utils.Outputable.Outputable GHC.Runtime.Heap.Layout.ClosureTypeInfo instance GHC.Utils.Outputable.Outputable GHC.Runtime.Heap.Layout.StgHalfWord instance GHC.Utils.Outputable.Outputable GHC.Runtime.Heap.Layout.StgWord module GHC.Cmm.Node data CmmNode e x [CmmEntry] :: {-# UNPACK #-} !Label -> CmmTickScope -> CmmNode C O [CmmComment] :: FastString -> CmmNode O O [CmmTick] :: !CmmTickish -> CmmNode O O [CmmUnwind] :: [(GlobalReg, Maybe CmmExpr)] -> CmmNode O O [CmmAssign] :: !CmmReg -> !CmmExpr -> CmmNode O O [CmmStore] :: !CmmExpr -> !CmmExpr -> !AlignmentSpec -> CmmNode O O [CmmUnsafeForeignCall] :: ForeignTarget -> [CmmFormal] -> [CmmActual] -> CmmNode O O [CmmBranch] :: {-# UNPACK #-} !Label -> CmmNode O C [CmmCondBranch] :: CmmExpr -> {-# UNPACK #-} !Label -> Maybe Bool -> CmmNode O C [CmmSwitch] :: CmmExpr -> SwitchTargets -> CmmNode O C [CmmCall] :: CmmExpr -> Maybe Label -> [GlobalReg] -> ByteOff -> ByteOff -> ByteOff -> CmmNode O C [CmmForeignCall] :: ForeignTarget -> [CmmFormal] -> [CmmActual] -> {-# UNPACK #-} !Label -> ByteOff -> ByteOff -> Bool -> CmmNode O C type CmmFormal = LocalReg type CmmActual = CmmExpr -- | Tickish in Cmm context (annotations only) type CmmTickish = GenTickish 'TickishPassCmm type UpdFrameOffset = ByteOff -- | A convention maps a list of values (function arguments or return -- values) to registers or stack locations. data Convention -- | top-level Haskell functions use NativeDirectCall, which maps -- arguments to registers starting with R2, according to how many -- registers are available on the platform. This convention ignores R1, -- because for a top-level function call the function closure is -- implicit, and doesn't need to be passed. NativeDirectCall :: Convention -- | non-top-level Haskell functions, which pass the address of the -- function closure in R1 (regardless of whether R1 is a real register or -- not), and the rest of the arguments in registers or on the stack. NativeNodeCall :: Convention -- | a native return. The convention for returns depends on how many values -- are returned: for just one value returned, the appropriate register is -- used (R1, F1, etc.). regardless of whether it is a real register or -- not. For multiple values returned, they are mapped to registers or the -- stack. NativeReturn :: Convention -- | Slow entry points: all args pushed on the stack Slow :: Convention -- | Entry to the garbage collector: uses the node reg! (TODO: I don't -- think we need this --SDM) GC :: Convention data ForeignConvention ForeignConvention :: CCallConv -> [ForeignHint] -> [ForeignHint] -> CmmReturnInfo -> ForeignConvention data ForeignTarget ForeignTarget :: CmmExpr -> ForeignConvention -> ForeignTarget PrimTarget :: CallishMachOp -> ForeignTarget foreignTargetHints :: ForeignTarget -> ([ForeignHint], [ForeignHint]) data CmmReturnInfo CmmMayReturn :: CmmReturnInfo CmmNeverReturns :: CmmReturnInfo mapExp :: (CmmExpr -> CmmExpr) -> CmmNode e x -> CmmNode e x mapExpDeep :: (CmmExpr -> CmmExpr) -> CmmNode e x -> CmmNode e x wrapRecExp :: (CmmExpr -> CmmExpr) -> CmmExpr -> CmmExpr foldExp :: (CmmExpr -> z -> z) -> CmmNode e x -> z -> z foldExpDeep :: (CmmExpr -> z -> z) -> CmmNode e x -> z -> z wrapRecExpf :: (CmmExpr -> z -> z) -> CmmExpr -> z -> z mapExpM :: (CmmExpr -> Maybe CmmExpr) -> CmmNode e x -> Maybe (CmmNode e x) mapExpDeepM :: (CmmExpr -> Maybe CmmExpr) -> CmmNode e x -> Maybe (CmmNode e x) wrapRecExpM :: (CmmExpr -> Maybe CmmExpr) -> CmmExpr -> Maybe CmmExpr mapSuccessors :: (Label -> Label) -> CmmNode O C -> CmmNode O C mapCollectSuccessors :: forall a. (Label -> (Label, a)) -> CmmNode O C -> (CmmNode O C, [a]) -- | Tick scope identifier, allowing us to reason about what annotations in -- a Cmm block should scope over. We especially take care to allow -- optimisations to reorganise blocks without losing tick association in -- the process. data CmmTickScope -- | The global scope is the "root" of the scope graph. Every scope is a -- sub-scope of the global scope. It doesn't make sense to add ticks to -- this scope. On the other hand, this means that setting this scope on a -- block means no ticks apply to it. GlobalScope :: CmmTickScope -- | Constructs a new sub-scope to an existing scope. This allows us to -- translate Core-style scoping rules (see tickishScoped) into -- the Cmm world. Suppose the following code: -- -- tick1 case ... of A -> tick2 ... B -> tick3 -- ... -- -- We want the top-level tick annotation to apply to blocks generated for -- the A and B alternatives. We can achieve that by generating -- tick1 into a block with scope a, while the code for -- alternatives A and B gets generated into sub-scopes a/b and a/c -- respectively. SubScope :: !Unique -> CmmTickScope -> CmmTickScope -- | A combined scope scopes over everything that the two given scopes -- cover. It is therefore a sub-scope of either scope. This is required -- for optimisations. Consider common block elimination: -- -- A -> tick2 case ... of C -> [common] B -> tick3 -- case ... of D -> [common] -- -- We will generate code for the C and D alternatives, and figure out -- afterwards that it's actually common code. Scoping rules dictate that -- the resulting common block needs to be covered by both tick2 -- and tick3, therefore we need to construct a scope that is a -- child to *both* scope. Now we can do that - if we assign the scopes -- ac and bd to the common-ed up blocks, the new block could have -- a combined tick scope ac+bd, which both tick2 and -- tick3 apply to. CombinedScope :: CmmTickScope -> CmmTickScope -> CmmTickScope -- | Checks whether two tick scopes are sub-scopes of each other. True if -- the two scopes are equal. isTickSubScope :: CmmTickScope -> CmmTickScope -> Bool -- | Combine two tick scopes. The new scope should be sub-scope of both -- parameters. We simplify automatically if one tick scope is a sub-scope -- of the other already. combineTickScopes :: CmmTickScope -> CmmTickScope -> CmmTickScope instance GHC.Classes.Eq GHC.Cmm.Node.Convention instance GHC.Classes.Eq GHC.Cmm.Node.CmmReturnInfo instance GHC.Classes.Eq GHC.Cmm.Node.ForeignConvention instance GHC.Classes.Eq GHC.Cmm.Node.ForeignTarget instance GHC.Classes.Eq (GHC.Cmm.Node.CmmNode e x) instance GHC.Cmm.Dataflow.Graph.NonLocal GHC.Cmm.Node.CmmNode instance GHC.Cmm.Expr.UserOfRegs GHC.Cmm.Expr.LocalReg (GHC.Cmm.Node.CmmNode e x) instance GHC.Cmm.Expr.UserOfRegs GHC.Cmm.Expr.GlobalReg (GHC.Cmm.Node.CmmNode e x) instance GHC.Cmm.Expr.DefinerOfRegs GHC.Cmm.Expr.LocalReg (GHC.Cmm.Node.CmmNode e x) instance GHC.Cmm.Expr.DefinerOfRegs GHC.Cmm.Expr.GlobalReg (GHC.Cmm.Node.CmmNode e x) instance GHC.Classes.Eq GHC.Cmm.Node.CmmTickScope instance GHC.Classes.Ord GHC.Cmm.Node.CmmTickScope instance GHC.Utils.Outputable.Outputable GHC.Cmm.Node.CmmTickScope instance (GHC.Classes.Ord r, GHC.Cmm.Expr.UserOfRegs r GHC.Cmm.Expr.CmmReg) => GHC.Cmm.Expr.UserOfRegs r GHC.Cmm.Node.ForeignTarget module GHC.Platform.Regs -- | Returns True if this global register is stored in a -- caller-saves machine register. callerSaves :: Platform -> GlobalReg -> Bool -- | Here is where the STG register map is defined for each target arch. -- The order matters (for the llvm backend anyway)! We must make sure to -- maintain the order here with the order used in the LLVM calling -- conventions. Note that also, this isn't all registers, just the ones -- that are currently possibly mapped to real registers. activeStgRegs :: Platform -> [GlobalReg] haveRegBase :: Platform -> Bool globalRegMaybe :: Platform -> GlobalReg -> Maybe RealReg freeReg :: Platform -> RegNo -> Bool module GHC.Platform.X86_64 callerSaves :: GlobalReg -> Bool activeStgRegs :: [GlobalReg] haveRegBase :: Bool globalRegMaybe :: GlobalReg -> Maybe RealReg freeReg :: RegNo -> Bool freeRegBase :: RegNo -> Bool -- | An architecture independent description of a register. This needs to -- stay architecture independent because it is used by NCGMonad and the -- register allocators, which are shared by all architectures. module GHC.Platform.Reg -- | An identifier for a primitive real machine register. type RegNo = Int -- | A register, either virtual or real data Reg RegVirtual :: !VirtualReg -> Reg RegReal :: !RealReg -> Reg regPair :: RegNo -> RegNo -> Reg regSingle :: RegNo -> Reg realRegSingle :: RegNo -> RealReg isRealReg :: Reg -> Bool takeRealReg :: Reg -> Maybe RealReg isVirtualReg :: Reg -> Bool takeVirtualReg :: Reg -> Maybe VirtualReg data VirtualReg VirtualRegI :: {-# UNPACK #-} !Unique -> VirtualReg VirtualRegHi :: {-# UNPACK #-} !Unique -> VirtualReg VirtualRegF :: {-# UNPACK #-} !Unique -> VirtualReg VirtualRegD :: {-# UNPACK #-} !Unique -> VirtualReg renameVirtualReg :: Unique -> VirtualReg -> VirtualReg classOfVirtualReg :: VirtualReg -> RegClass getHiVirtualRegFromLo :: VirtualReg -> VirtualReg getHiVRegFromLo :: Reg -> Reg -- | RealRegs are machine regs which are available for allocation, in the -- usual way. We know what class they are, because that's part of the -- processor's architecture. -- -- RealRegPairs are pairs of real registers that are allocated together -- to hold a larger value, such as with Double regs on SPARC. data RealReg RealRegSingle :: {-# UNPACK #-} !RegNo -> RealReg RealRegPair :: {-# UNPACK #-} !RegNo -> {-# UNPACK #-} !RegNo -> RealReg regNosOfRealReg :: RealReg -> [RegNo] realRegsAlias :: RealReg -> RealReg -> Bool -- | The patch function supplied by the allocator maps VirtualReg to -- RealReg regs, but sometimes we want to apply it to plain old Reg. liftPatchFnToRegReg :: (VirtualReg -> RealReg) -> Reg -> Reg instance GHC.Show.Show GHC.Platform.Reg.VirtualReg instance GHC.Classes.Eq GHC.Platform.Reg.VirtualReg instance GHC.Classes.Ord GHC.Platform.Reg.RealReg instance GHC.Show.Show GHC.Platform.Reg.RealReg instance GHC.Classes.Eq GHC.Platform.Reg.RealReg instance GHC.Show.Show GHC.Platform.Reg.Reg instance GHC.Classes.Ord GHC.Platform.Reg.Reg instance GHC.Classes.Eq GHC.Platform.Reg.Reg instance GHC.Types.Unique.Uniquable GHC.Platform.Reg.Reg instance GHC.Utils.Outputable.Outputable GHC.Platform.Reg.Reg instance GHC.Types.Unique.Uniquable GHC.Platform.Reg.RealReg instance GHC.Utils.Outputable.Outputable GHC.Platform.Reg.RealReg instance GHC.Classes.Ord GHC.Platform.Reg.VirtualReg instance GHC.Types.Unique.Uniquable GHC.Platform.Reg.VirtualReg instance GHC.Utils.Outputable.Outputable GHC.Platform.Reg.VirtualReg -- | An architecture independent description of a register's class. module GHC.Platform.Reg.Class -- | The class of a register. Used in the register allocator. We treat all -- registers in a class as being interchangeable. data RegClass RcInteger :: RegClass RcFloat :: RegClass RcDouble :: RegClass instance GHC.Classes.Eq GHC.Platform.Reg.Class.RegClass instance GHC.Types.Unique.Uniquable GHC.Platform.Reg.Class.RegClass instance GHC.Utils.Outputable.Outputable GHC.Platform.Reg.Class.RegClass module GHC.Platform.X86 callerSaves :: GlobalReg -> Bool activeStgRegs :: [GlobalReg] haveRegBase :: Bool globalRegMaybe :: GlobalReg -> Maybe RealReg freeReg :: RegNo -> Bool freeRegBase :: RegNo -> Bool module GHC.Platform.SPARC callerSaves :: GlobalReg -> Bool activeStgRegs :: [GlobalReg] haveRegBase :: Bool globalRegMaybe :: GlobalReg -> Maybe RealReg freeReg :: RegNo -> Bool module GHC.Platform.S390X callerSaves :: GlobalReg -> Bool activeStgRegs :: [GlobalReg] haveRegBase :: Bool globalRegMaybe :: GlobalReg -> Maybe RealReg freeReg :: RegNo -> Bool module GHC.Platform.RISCV64 callerSaves :: GlobalReg -> Bool activeStgRegs :: [GlobalReg] haveRegBase :: Bool globalRegMaybe :: GlobalReg -> Maybe RealReg freeReg :: RegNo -> Bool module GHC.Platform.PPC callerSaves :: GlobalReg -> Bool activeStgRegs :: [GlobalReg] haveRegBase :: Bool globalRegMaybe :: GlobalReg -> Maybe RealReg freeReg :: RegNo -> Bool module GHC.Platform.NoRegs callerSaves :: GlobalReg -> Bool activeStgRegs :: [GlobalReg] haveRegBase :: Bool globalRegMaybe :: GlobalReg -> Maybe RealReg freeReg :: RegNo -> Bool module GHC.Platform.ARM callerSaves :: GlobalReg -> Bool activeStgRegs :: [GlobalReg] haveRegBase :: Bool globalRegMaybe :: GlobalReg -> Maybe RealReg freeReg :: RegNo -> Bool module GHC.Platform.AArch64 callerSaves :: GlobalReg -> Bool activeStgRegs :: [GlobalReg] haveRegBase :: Bool globalRegMaybe :: GlobalReg -> Maybe RealReg freeReg :: RegNo -> Bool module GHC.Cmm.Switch -- | A value of type SwitchTargets contains the alternatives for a -- CmmSwitch value, and knows whether the value is signed, the -- possible range, an optional default value and a map from values to -- jump labels. data SwitchTargets -- | The smart constructor mkSwitchTargets normalises the map a bit: * No -- entries outside the range * No entries equal to the default * No -- default if all elements have explicit values mkSwitchTargets :: Bool -> (Integer, Integer) -> Maybe Label -> Map Integer Label -> SwitchTargets -- | Returns the list of non-default branches of the SwitchTargets value switchTargetsCases :: SwitchTargets -> [(Integer, Label)] -- | Return the default label of the SwitchTargets value switchTargetsDefault :: SwitchTargets -> Maybe Label -- | Return the range of the SwitchTargets value switchTargetsRange :: SwitchTargets -> (Integer, Integer) -- | Return whether this is used for a signed value switchTargetsSigned :: SwitchTargets -> Bool -- | Changes all labels mentioned in the SwitchTargets value mapSwitchTargets :: (Label -> Label) -> SwitchTargets -> SwitchTargets -- | switchTargetsToTable creates a dense jump table, usable for code -- generation. -- -- Also returns an offset to add to the value; the list is 0-based on the -- result of that addition. -- -- The conversion from Integer to Int is a bit of a wart, as the actual -- scrutinee might be an unsigned word, but it just works, due to -- wrap-around arithmetic (as verified by the CmmSwitchTest test case). switchTargetsToTable :: SwitchTargets -> (Int, [Maybe Label]) -- | Groups cases with equal targets, suitable for pretty-printing to a -- c-like switch statement with fall-through semantics. switchTargetsFallThrough :: SwitchTargets -> ([([Integer], Label)], Maybe Label) -- | The list of all labels occurring in the SwitchTargets value. switchTargetsToList :: SwitchTargets -> [Label] -- | Custom equality helper, needed for GHC.Cmm.CommonBlockElim eqSwitchTargetWith :: (Label -> Label -> Bool) -> SwitchTargets -> SwitchTargets -> Bool -- | A SwitchPlan abstractly describes how a Switch statement ought to be -- implemented. See Note [createSwitchPlan] data SwitchPlan Unconditionally :: Label -> SwitchPlan IfEqual :: Integer -> Label -> SwitchPlan -> SwitchPlan IfLT :: Bool -> Integer -> SwitchPlan -> SwitchPlan -> SwitchPlan JumpTable :: SwitchTargets -> SwitchPlan -- | Does the backend support switch out of the box? Then leave this to the -- backend! backendSupportsSwitch :: Backend -> Bool -- | This function creates a SwitchPlan from a SwitchTargets value, -- breaking it down into smaller pieces suitable for code generation. createSwitchPlan :: SwitchTargets -> SwitchPlan instance GHC.Classes.Eq GHC.Cmm.Switch.SwitchTargets instance GHC.Show.Show GHC.Cmm.Switch.SwitchTargets instance GHC.Show.Show GHC.Cmm.Switch.SwitchPlan module GHC.Cmm.Dataflow.Graph -- | A (possibly empty) collection of closed/closed blocks type Body n = LabelMap (Block n C C) -- | A control-flow graph, which may take any of four shapes (O/O, OC, -- CO, C/C). A graph open at the entry has a single, distinguished, -- anonymous entry point; if a graph is closed at the entry, its entry -- point(s) are supplied by a context. type Graph = Graph' Block -- | Graph' is abstracted over the block type, so that we can -- build graphs of annotated blocks for example (Compiler.Hoopl.Dataflow -- needs this). data Graph' block (n :: Extensibility -> Extensibility -> Type) e x [GNil] :: Graph' block n O O [GUnit] :: block n O O -> Graph' block n O O [GMany] :: MaybeO e (block n O C) -> Body' block n -> MaybeO x (block n C O) -> Graph' block n e x -- | Gives access to the anchor points for nonlocal edges as well as the -- edges themselves class NonLocal thing entryLabel :: NonLocal thing => thing C x -> Label successors :: NonLocal thing => thing e C -> [Label] addBlock :: (NonLocal block, HasDebugCallStack) => block C C -> LabelMap (block C C) -> LabelMap (block C C) bodyList :: Body' block n -> [(Label, block n C C)] emptyBody :: Body' block n labelsDefined :: forall block n e x. NonLocal (block n) => Graph' block n e x -> LabelSet -- | Maps over all nodes in a graph. mapGraph :: (forall e x. n e x -> n' e x) -> Graph n e x -> Graph n' e x -- | Function mapGraphBlocks enables a change of representation of -- blocks, nodes, or both. It lifts a polymorphic block transform into a -- polymorphic graph transform. When the block representation stabilizes, -- a similar function should be provided for blocks. mapGraphBlocks :: forall block n block' n' e x. (forall e x. block n e x -> block' n' e x) -> Graph' block n e x -> Graph' block' n' e x -- | Returns a list of blocks reachable from the provided Labels in the -- reverse postorder. -- -- This is the most important traversal over this data structure. It -- drops unreachable code and puts blocks in an order that is good for -- solving forward dataflow problems quickly. The reverse order is good -- for solving backward dataflow problems quickly. The forward order is -- also reasonably good for emitting instructions, except that it will -- not usually exploit Forrest Baskett's trick of eliminating the -- unconditional branch from a loop. For that you would need a more -- serious analysis, probably based on dominators, to identify loop -- headers. -- -- For forward analyses we want reverse postorder visitation, consider: -- A -> [B,C] B -> D C -> D Postorder: [D, C, B, A] -- (or [D, B, C, A]) Reverse postorder: [A, B, C, D] (or [A, C, B, D]) -- This matters for, e.g., forward analysis, because we want to analyze -- *both* B and C before we analyze D. revPostorderFrom :: forall block. NonLocal block => LabelMap (block C C) -> Label -> [block C C] instance GHC.Cmm.Dataflow.Graph.NonLocal n => GHC.Cmm.Dataflow.Graph.NonLocal (GHC.Cmm.Dataflow.Block.Block n) module GHC.Core.UsageEnv data Usage Zero :: Usage Bottom :: Usage MUsage :: Mult -> Usage data UsageEnv addUE :: UsageEnv -> UsageEnv -> UsageEnv addUsage :: Usage -> Usage -> Usage bottomUE :: UsageEnv deleteUE :: NamedThing n => UsageEnv -> n -> UsageEnv -- | |lookupUE x env| returns the multiplicity assigned to |x| in |env|, if -- |x| is not bound in |env|, then returns |Zero| or |Bottom|. lookupUE :: NamedThing n => UsageEnv -> n -> Usage scaleUE :: Mult -> UsageEnv -> UsageEnv scaleUsage :: Mult -> Usage -> Usage supUE :: UsageEnv -> UsageEnv -> UsageEnv supUEs :: [UsageEnv] -> UsageEnv unitUE :: NamedThing n => n -> Mult -> UsageEnv zeroUE :: UsageEnv instance GHC.Utils.Outputable.Outputable GHC.Core.UsageEnv.UsageEnv instance GHC.Utils.Outputable.Outputable GHC.Core.UsageEnv.Usage module GHC.Core.Lint -- | Type-check a CoreProgram. See Note [Core Lint guarantee]. lintCoreBindings :: DynFlags -> CoreToDo -> [Var] -> CoreProgram -> WarnsAndErrs lintUnfolding :: Bool -> DynFlags -> SrcLoc -> VarSet -> CoreExpr -> Maybe (Bag SDoc) lintPassResult :: HscEnv -> CoreToDo -> CoreProgram -> IO () lintInteractiveExpr :: SDoc -> HscEnv -> CoreExpr -> IO () lintExpr :: DynFlags -> [Var] -> CoreExpr -> Maybe (Bag SDoc) -- | This checks whether a pass correctly looks through debug annotations -- (SourceNote). This works a bit different from other -- consistency checks: We check this by running the given task twice, -- noting all differences between the results. lintAnnots :: SDoc -> (ModGuts -> CoreM ModGuts) -> ModGuts -> CoreM ModGuts lintAxioms :: Logger -> DynFlags -> SDoc -> [CoAxiom Branched] -> IO () interactiveInScope :: InteractiveContext -> [Var] endPass :: CoreToDo -> CoreProgram -> [CoreRule] -> CoreM () endPassIO :: HscEnv -> PrintUnqualified -> CoreToDo -> CoreProgram -> [CoreRule] -> IO () displayLintResults :: Logger -> DynFlags -> Bool -> SDoc -> SDoc -> WarnsAndErrs -> IO () dumpPassResult :: Logger -> DynFlags -> PrintUnqualified -> Maybe DumpFlag -> SDoc -> SDoc -> CoreProgram -> [CoreRule] -> IO () dumpIfSet :: Logger -> DynFlags -> Bool -> CoreToDo -> SDoc -> SDoc -> IO () instance GHC.Classes.Eq GHC.Core.Lint.StaticPtrCheck instance GHC.Base.Functor GHC.Core.Lint.LintM instance GHC.Base.Applicative GHC.Core.Lint.LintM instance GHC.Base.Monad GHC.Core.Lint.LintM instance Control.Monad.Fail.MonadFail GHC.Core.Lint.LintM instance GHC.Driver.Session.HasDynFlags GHC.Core.Lint.LintM module GHC.Core.Coercion.Opt -- | optCoercion applies a substitution to a coercion, *and* optimises it -- to reduce its size optCoercion :: OptCoercionOpts -> TCvSubst -> Coercion -> NormalCo -- | Check to make sure that an AxInstCo is internally consistent. Returns -- the conflicting branch, if it exists See Note [Conflict checking with -- AxiomInstCo] checkAxInstCo :: Coercion -> Maybe CoAxBranch -- | Coercion optimisation options newtype OptCoercionOpts OptCoercionOpts :: Bool -> OptCoercionOpts -- | Enable coercion optimisation (reduce its size) [optCoercionEnabled] :: OptCoercionOpts -> Bool -- | Constant Folder module GHC.Core.Opt.ConstantFold primOpRules :: Name -> PrimOp -> Maybe CoreRule builtinRules :: [CoreRule] -- | Match the scrutinee of a case and potentially return a new scrutinee -- and a function to apply to each literal alternative. caseRules :: Platform -> CoreExpr -> Maybe (CoreExpr, AltCon -> Maybe AltCon, Id -> CoreExpr) instance GHC.Base.Functor GHC.Core.Opt.ConstantFold.RuleM instance GHC.Base.Applicative GHC.Core.Opt.ConstantFold.RuleM instance GHC.Base.Monad GHC.Core.Opt.ConstantFold.RuleM instance Control.Monad.Fail.MonadFail GHC.Core.Opt.ConstantFold.RuleM instance GHC.Base.Alternative GHC.Core.Opt.ConstantFold.RuleM instance GHC.Base.MonadPlus GHC.Core.Opt.ConstantFold.RuleM -- | Adds cost-centers to call sites selected with the -- -fprof-caller=... flag. module GHC.Core.Opt.CallerCC addCallerCostCentres :: ModGuts -> CoreM ModGuts data CallerCcFilter CallerCcFilter :: Maybe ModuleName -> NamePattern -> CallerCcFilter [ccfModuleName] :: CallerCcFilter -> Maybe ModuleName [ccfFuncName] :: CallerCcFilter -> NamePattern data NamePattern PChar :: Char -> NamePattern -> NamePattern PWildcard :: NamePattern -> NamePattern PEnd :: NamePattern parseCallerCcFilter :: String -> Either String CallerCcFilter instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.CallerCC.CallerCcFilter instance GHC.Utils.Binary.Binary GHC.Core.Opt.CallerCC.CallerCcFilter instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.CallerCC.NamePattern instance GHC.Utils.Binary.Binary GHC.Core.Opt.CallerCC.NamePattern module GHC.Settings.IO data SettingsError SettingsError_MissingData :: String -> SettingsError SettingsError_BadData :: String -> SettingsError initSettings :: forall m. MonadIO m => String -> ExceptT SettingsError m Settings module GHC.Parser.CharClass is_ident :: Char -> Bool is_symbol :: Char -> Bool is_any :: Char -> Bool is_space :: Char -> Bool is_lower :: Char -> Bool is_upper :: Char -> Bool is_digit :: Char -> Bool is_alphanum :: Char -> Bool is_decdigit :: Char -> Bool is_hexdigit :: Char -> Bool is_octdigit :: Char -> Bool is_bindigit :: Char -> Bool hexDigit :: Char -> Int octDecDigit :: Char -> Int -- | Bits and pieces on the bottom of the module dependency tree. Also -- import the required constants, so we know what we're using. -- -- In the interests of cross-compilation, we want to free ourselves from -- the autoconf generated modules like GHC.Settings.Constants module GHC.CmmToAsm.SPARC.Base wordLength :: Int wordLengthInBits :: Int -- | We need 8 bytes because our largest registers are 64 bit. spillSlotSize :: Int -- | We (allegedly) put the first six C-call arguments in registers; where -- do we start putting the rest of them? extraStackArgsHere :: Int -- | Check whether an offset is representable with 13 bits. fits13Bits :: Integral a => a -> Bool -- | Check whether an integer will fit in 32 bits. A CmmInt is intended to -- be truncated to the appropriate number of bits, so here we truncate it -- to Int64. This is important because e.g. -1 as a CmmInt might be -- either -1 or 18446744073709551615. is32BitInteger :: Integer -> Bool -- | Sadness. largeOffsetError :: Show a => a -> b module GHC.CmmToAsm.PPC.Cond data Cond ALWAYS :: Cond EQQ :: Cond GE :: Cond GEU :: Cond GTT :: Cond GU :: Cond LE :: Cond LEU :: Cond LTT :: Cond LU :: Cond NE :: Cond condNegate :: Cond -> Cond condUnsigned :: Cond -> Bool instance GHC.Classes.Eq GHC.CmmToAsm.PPC.Cond.Cond -- | Various utilities used in generating assembler. -- -- These are used not only by the native code generator, but also by the -- GHC.Driver.Pipeline module GHC.Utils.Asm -- | Generate a section type (e.g. @progbits). See #13937. sectionType :: Platform -> String -> SDoc -- | Types for the general graph colorer. module GHC.Data.Graph.Base -- | A fn to check if a node is trivially colorable For graphs who's color -- classes are disjoint then a node is 'trivially colorable' when it has -- less neighbors and exclusions than available colors for that node. -- -- For graph's who's color classes overlap, ie some colors alias other -- colors, then this can be a bit more tricky. There is a general way to -- calculate this, but it's likely be too slow for use in the code. The -- coloring algorithm takes a canned function which can be optimised by -- the user to be specific to the specific graph being colored. -- -- for details, see "A Generalised Algorithm for Graph-Coloring Register -- Allocation" Smith, Ramsey, Holloway - PLDI 2004. type Triv k cls color = cls -> UniqSet k -> UniqSet color -> Bool -- | The Interference graph. There used to be more fields, but they were -- turfed out in a previous revision. maybe we'll want more later.. data Graph k cls color Graph :: UniqFM k (Node k cls color) -> Graph k cls color -- | All active nodes in the graph. [graphMap] :: Graph k cls color -> UniqFM k (Node k cls color) -- | An empty graph. initGraph :: Graph k cls color -- | Modify the finite map holding the nodes in the graph. graphMapModify :: (UniqFM k (Node k cls color) -> UniqFM k (Node k cls color)) -> Graph k cls color -> Graph k cls color -- | Graph nodes. Represents a thing that can conflict with another thing. -- For the register allocater the nodes represent registers. data Node k cls color Node :: k -> cls -> Maybe color -> UniqSet k -> UniqSet color -> [color] -> UniqSet k -> Node k cls color -- | A unique identifier for this node. [nodeId] :: Node k cls color -> k -- | The class of this node, determines the set of colors that can be used. [nodeClass] :: Node k cls color -> cls -- | The color of this node, if any. [nodeColor] :: Node k cls color -> Maybe color -- | Neighbors which must be colored differently to this node. [nodeConflicts] :: Node k cls color -> UniqSet k -- | Colors that cannot be used by this node. [nodeExclusions] :: Node k cls color -> UniqSet color -- | Colors that this node would prefer to be, in descending order. [nodePreference] :: Node k cls color -> [color] -- | Neighbors that this node would like to be colored the same as. [nodeCoalesce] :: Node k cls color -> UniqSet k -- | An empty node. newNode :: k -> cls -> Node k cls color -- | Like a UniqDFM, but maintains equivalence classes of keys -- sharing the same entry. See UniqSDFM. module GHC.Types.Unique.SDFM -- | A UniqDFM whose domain is sets of Uniques, each -- of which share a common value of type ele. Every such set -- ("equivalence class") has a distinct representative Unique. -- Supports merging the entries of multiple such sets in a union-find -- like fashion. -- -- An accurate model is that of [(Set key, Maybe ele)]: A finite -- mapping from sets of keys to possibly absent entries -- ele, where the sets don't overlap. Example: m = -- [({u1,u3}, Just ele1), ({u2}, Just ele2), ({u4,u7}, Nothing)] On -- this model we support the following main operations: -- --
-- emptySubst = mkEmptySubst emptyInScopeSet --emptySubst :: Subst -- | Constructs a new Subst assuming the variables in the given -- InScopeSet are in scope. mkEmptySubst :: InScopeSet -> Subst -- | Substitutes an Id for another one according to the Subst -- given in a way that avoids shadowing the InScopeSet, returning -- the result and an updated Subst that should be used by -- subsequent substitutions. substBndr :: Id -> Subst -> (Id, Subst) -- |
-- substBndrs = runState . traverse (state . substBndr) --substBndrs :: Traversable f => f Id -> Subst -> (f Id, Subst) -- | Substitutes an occurrence of an identifier for its counterpart -- recorded in the Subst. lookupIdSubst :: HasCallStack => Id -> Subst -> Id -- | Substitutes an occurrence of an identifier for its counterpart -- recorded in the Subst. Does not generate a debug warning if the -- identifier to to substitute wasn't in scope. noWarnLookupIdSubst :: HasCallStack => Id -> Subst -> Id -- | Add the Id to the in-scope set and remove any existing -- substitutions for it. extendInScope :: Id -> Subst -> Subst -- | Add a substitution for an Id to the Subst: you must -- ensure that the in-scope set is such that TyCoSubst Note [The -- substitution invariant] holds after extending the substitution like -- this. extendSubst :: Id -> Id -> Subst -> Subst module GHC.Data.Graph.UnVar data UnVarSet emptyUnVarSet :: UnVarSet mkUnVarSet :: [Var] -> UnVarSet varEnvDom :: VarEnv a -> UnVarSet unionUnVarSet :: UnVarSet -> UnVarSet -> UnVarSet unionUnVarSets :: [UnVarSet] -> UnVarSet extendUnVarSet :: Var -> UnVarSet -> UnVarSet delUnVarSet :: UnVarSet -> Var -> UnVarSet elemUnVarSet :: Var -> UnVarSet -> Bool isEmptyUnVarSet :: UnVarSet -> Bool data UnVarGraph emptyUnVarGraph :: UnVarGraph unionUnVarGraph :: UnVarGraph -> UnVarGraph -> UnVarGraph unionUnVarGraphs :: [UnVarGraph] -> UnVarGraph completeGraph :: UnVarSet -> UnVarGraph completeBipartiteGraph :: UnVarSet -> UnVarSet -> UnVarGraph neighbors :: UnVarGraph -> Var -> UnVarSet hasLoopAt :: UnVarGraph -> Var -> Bool delNode :: UnVarGraph -> Var -> UnVarGraph instance GHC.Classes.Eq GHC.Data.Graph.UnVar.UnVarSet instance GHC.Utils.Outputable.Outputable GHC.Data.Graph.UnVar.UnVarGraph instance GHC.Utils.Outputable.Outputable GHC.Data.Graph.UnVar.UnVarSet module GHC.Core.Opt.StaticArgs doStaticArgs :: UniqSupply -> CoreProgram -> CoreProgram module GHC.Core.Tidy tidyExpr :: TidyEnv -> CoreExpr -> CoreExpr tidyRules :: TidyEnv -> [CoreRule] -> [CoreRule] tidyUnfolding :: TidyEnv -> Unfolding -> Unfolding -> Unfolding module GHC.Stg.Stats showStgStats :: [StgTopBinding] -> String instance GHC.Classes.Ord GHC.Stg.Stats.CounterType instance GHC.Classes.Eq GHC.Stg.Stats.CounterType -- | Non-global free variable analysis on STG terms. This pass annotates -- non-top-level closure bindings with captured variables. Global -- variables are not captured. For example, in a top-level binding like -- (pseudo-STG) -- -- f = [x,y] . let g = [p] . reverse (x ++ p) in g y -- -- In g, reverse and (++) are global variables so they're -- not considered free. p is an argument, so x is the -- only actual free variable here. The annotated version is thus: -- -- f = [x,y] . let g = [x] [p] . reverse (x ++ p) in g y -- -- Note that non-top-level recursive bindings are also considered free -- within the group: -- -- map = {} r [f xs0] let { Rec { go = {f, go} r [xs1] case xs1 of { [] -- -> [] []; : x xs2 -> let { xs' = {go, xs2} u [] go xs2; } in let -- { x' = {f, x} u [] f x; } in : [x' xs']; }; end Rec } } in go xs0; -- -- Here go is free in its RHS. -- -- Top-level closure bindings never capture variables as all of their -- free variables are global. module GHC.Stg.FVs -- | Annotates a top-level STG binding group with its free variables. annTopBindingsFreeVars :: [StgTopBinding] -> [CgStgTopBinding] -- | Annotates an STG binding with its free variables. annBindingFreeVars :: StgBinding -> CgStgBinding module GHC.Stg.DepAnal -- | Dependency sort a STG program so that dependencies come before uses. depSortStgPgm :: Module -> [StgTopBinding] -> [StgTopBinding] module GHC.Stg.Debug collectDebugInformation :: DynFlags -> ModLocation -> [StgTopBinding] -> ([StgTopBinding], InfoTableProvMap) module GHC.CoreToStg coreToStg :: DynFlags -> Module -> ModLocation -> CoreProgram -> ([StgTopBinding], InfoTableProvMap, CollectedCCs) instance GHC.Classes.Eq GHC.CoreToStg.LetInfo instance GHC.Classes.Eq GHC.CoreToStg.HowBound instance GHC.Base.Functor GHC.CoreToStg.CtsM instance GHC.Base.Applicative GHC.CoreToStg.CtsM instance GHC.Base.Monad GHC.CoreToStg.CtsM instance GHC.Driver.Session.HasDynFlags GHC.CoreToStg.CtsM -- | Hides away distracting bookkeeping while lambda lifting into a -- LiftM monad. module GHC.Stg.Lift.Monad -- |
-- uncurry mkStgBinding . decomposeStgBinding = id --decomposeStgBinding :: GenStgBinding pass -> (RecFlag, [(BinderP pass, GenStgRhs pass)]) mkStgBinding :: RecFlag -> [(BinderP pass, GenStgRhs pass)] -> GenStgBinding pass -- | Environment threaded around in a scoped, Reader-like fashion. data Env Env :: !DynFlags -> !Subst -> !IdEnv DIdSet -> Env -- | Read-only. [e_dflags] :: Env -> !DynFlags -- | We need to track the renamings of local InIds to their lifted -- OutId, because shadowing might make a closure's free variables -- unavailable at its call sites. Consider: let f y = x + y in let x -- = 4 in f x Here, f can't be lifted to top-level, -- because its free variable x isn't available at its call site. [e_subst] :: Env -> !Subst -- | Lifted Ids don't occur as free variables in any closure -- anymore, because they are bound at the top-level. Every occurrence -- must supply the formerly free variables of the lifted Id, so -- they in turn become free variables of the call sites. This environment -- tracks this expansion from lifted Ids to their free variables. -- -- InIds to OutIds. -- -- Invariant: Ids not present in this map won't be substituted. [e_expansions] :: Env -> !IdEnv DIdSet -- | We need to detect when we are lifting something out of the RHS of a -- recursive binding (c.f. GHC.Stg.Lift.Monad#floats), in which -- case that binding needs to be added to the same top-level recursive -- group. This requires we detect a certain nesting structure, which is -- encoded by StartBindingGroup and EndBindingGroup. -- -- Although collectFloats will only ever care if the current -- binding to be lifted (through LiftedBinding) will occur inside -- such a binding group or not, e.g. doesn't care about the nesting level -- as long as its greater than 0. data FloatLang StartBindingGroup :: FloatLang EndBindingGroup :: FloatLang PlainTopBinding :: OutStgTopBinding -> FloatLang LiftedBinding :: OutStgBinding -> FloatLang -- | Flattens an expression in [FloatLang] into an STG -- program, see GHC.Stg.Lift.Monad#floats. Important -- pre-conditions: The nesting of opening StartBindinGroups and -- closing EndBindinGroups is balanced. Also, it is crucial that -- every binding group has at least one recursive binding inside. -- Otherwise there's no point in announcing the binding group in the -- first place and an ASSERT will trigger. collectFloats :: [FloatLang] -> [OutStgTopBinding] -- | The analysis monad consists of the following RWST components: -- --
-- 1. PrefixDataConBuilder [] MkT -- 2. PrefixDataConBuilder [A] MkT -- 3. PrefixDataConBuilder [A, B] MkT -- 4. PrefixDataConBuilder [A, B, C] MkT -- ---- -- There are two reasons we have a separate builder type instead of using -- HsConDeclDetails GhcPs directly: -- --
-- (| --IToparenbar :: IsUnicodeSyntax -> Token -- |
-- |) --ITcparenbar :: IsUnicodeSyntax -> Token -- |
-- -< --ITlarrowtail :: IsUnicodeSyntax -> Token -- |
-- >- --ITrarrowtail :: IsUnicodeSyntax -> Token -- |
-- -<< --ITLarrowtail :: IsUnicodeSyntax -> Token -- |
-- >>- --ITRarrowtail :: IsUnicodeSyntax -> Token -- | Used when the lexer can't make sense of it ITunknown :: String -> Token -- | end of file token ITeof :: Token -- | something beginning -- | ITdocCommentNext :: String -> PsSpan -> Token -- | something beginning -- ^ ITdocCommentPrev :: String -> PsSpan -> Token -- | something beginning -- $ ITdocCommentNamed :: String -> PsSpan -> Token -- | a section heading ITdocSection :: Int -> String -> PsSpan -> Token -- | doc options (prune, ignore-exports, etc) ITdocOptions :: String -> PsSpan -> Token -- | comment starting by "--" ITlineComment :: String -> PsSpan -> Token -- | comment in {- -} ITblockComment :: String -> PsSpan -> Token lexer :: Bool -> (Located Token -> P a) -> P a lexerDbg :: Bool -> (Located Token -> P a) -> P a -- | Parser options. -- -- See mkParserOpts to construct this. data ParserOpts ParserOpts :: EnumSet WarningFlag -> !ExtsBitmap -> ParserOpts -- | enabled warning flags [pWarningFlags] :: ParserOpts -> EnumSet WarningFlag -- | bitmap of permitted extensions [pExtsBitmap] :: ParserOpts -> !ExtsBitmap -- | Given exactly the information needed, set up the ParserOpts mkParserOpts :: EnumSet WarningFlag -> EnumSet Extension -> Bool -> Bool -> Bool -> Bool -> ParserOpts data PState PState :: StringBuffer -> ParserOpts -> Bag PsWarning -> Bag PsError -> Maybe RealSrcSpan -> !Word -> Maybe (PsLocated Token) -> PsSpan -> PsSpan -> PsSpan -> !Int -> PsLoc -> [LayoutContext] -> [Int] -> [FastString] -> [PsLocated Token] -> Maybe (PsLocated Token) -> PsSpan -> [ALRContext] -> Maybe ALRLayout -> Bool -> Maybe (RealSrcSpan, RealSrcSpan) -> Maybe [LEpaComment] -> [LEpaComment] -> OrdList (PsLocated HdkComment) -> PState [buffer] :: PState -> StringBuffer [options] :: PState -> ParserOpts [warnings] :: PState -> Bag PsWarning [errors] :: PState -> Bag PsError [tab_first] :: PState -> Maybe RealSrcSpan [tab_count] :: PState -> !Word [last_tk] :: PState -> Maybe (PsLocated Token) [prev_loc] :: PState -> PsSpan [prev_loc2] :: PState -> PsSpan [last_loc] :: PState -> PsSpan [last_len] :: PState -> !Int [loc] :: PState -> PsLoc [context] :: PState -> [LayoutContext] [lex_state] :: PState -> [Int] [srcfiles] :: PState -> [FastString] [alr_pending_implicit_tokens] :: PState -> [PsLocated Token] [alr_next_token] :: PState -> Maybe (PsLocated Token) [alr_last_loc] :: PState -> PsSpan [alr_context] :: PState -> [ALRContext] [alr_expecting_ocurly] :: PState -> Maybe ALRLayout [alr_justClosedExplicitLetBlock] :: PState -> Bool [eof_pos] :: PState -> Maybe (RealSrcSpan, RealSrcSpan) [header_comments] :: PState -> Maybe [LEpaComment] [comment_q] :: PState -> [LEpaComment] [hdk_comments] :: PState -> OrdList (PsLocated HdkComment) -- | Creates a parse state from a ParserOpts value initParserState :: ParserOpts -> StringBuffer -> RealSrcLoc -> PState -- | Set parser options for parsing OPTIONS pragmas initPragState :: ParserOpts -> StringBuffer -> RealSrcLoc -> PState -- | The parsing monad, isomorphic to StateT PState Maybe. newtype P a P :: (PState -> ParseResult a) -> P a [unP] :: P a -> PState -> ParseResult a -- | The result of running a parser. data ParseResult a -- | The parser has consumed a (possibly empty) prefix of the input and -- produced a result. Use getMessages to check for accumulated -- warnings and non-fatal errors. POk :: PState -> a -> ParseResult a -- | The parser has consumed a (possibly empty) prefix of the input and -- failed. PFailed :: PState -> ParseResult a allocateComments :: RealSrcSpan -> [LEpaComment] -> ([LEpaComment], [LEpaComment]) allocatePriorComments :: RealSrcSpan -> [LEpaComment] -> Maybe [LEpaComment] -> (Maybe [LEpaComment], [LEpaComment], [LEpaComment]) allocateFinalComments :: RealSrcSpan -> [LEpaComment] -> Maybe [LEpaComment] -> (Maybe [LEpaComment], [LEpaComment], [LEpaComment]) -- | An mtl-style class for monads that support parsing-related operations. -- For example, sometimes we make a second pass over the parsing results -- to validate, disambiguate, or rearrange them, and we do so in the PV -- monad which cannot consume input but can report parsing errors, check -- for extension bits, and accumulate parsing annotations. Both P and PV -- are instances of MonadP. -- -- MonadP grants us convenient overloading. The other option is to have -- separate operations for each monad: addErrorP vs addErrorPV, getBitP -- vs getBitPV, and so on. class Monad m => MonadP m -- | Add a non-fatal error. Use this when the parser can produce a result -- despite the error. -- -- For example, when GHC encounters a forall in a type, but -- -XExplicitForAll is disabled, the parser constructs -- ForAllTy as if -XExplicitForAll was enabled, adding -- a non-fatal error to the accumulator. -- -- Control flow wise, non-fatal errors act like warnings: they are added -- to the accumulator and parsing continues. This allows GHC to report -- more than one parse error per file. addError :: MonadP m => PsError -> m () -- | Add a warning to the accumulator. Use getMessages to get the -- accumulated warnings. addWarning :: MonadP m => WarningFlag -> PsWarning -> m () -- | Add a fatal error. This will be the last error reported by the parser, -- and the parser will not produce any result, ending in a PFailed -- state. addFatalError :: MonadP m => PsError -> m a -- | Check if a given flag is currently set in the bitmap. getBit :: MonadP m => ExtBits -> m Bool -- | Go through the comment_q in PState and remove all -- comments that belong within the given span allocateCommentsP :: MonadP m => RealSrcSpan -> m EpAnnComments -- | Go through the comment_q in PState and remove all -- comments that come before or within the given span allocatePriorCommentsP :: MonadP m => RealSrcSpan -> m EpAnnComments -- | Go through the comment_q in PState and remove all -- comments that come after the given span allocateFinalCommentsP :: MonadP m => RealSrcSpan -> m EpAnnComments getRealSrcLoc :: P RealSrcLoc getPState :: P PState failMsgP :: (SrcSpan -> PsError) -> P a failLocMsgP :: RealSrcLoc -> RealSrcLoc -> (SrcSpan -> PsError) -> P a srcParseFail :: P a -- | Get a bag of the errors that have been accumulated so far. Does not -- take -Werror into account. getErrorMessages :: PState -> Bag PsError -- | Get the warnings and errors accumulated so far. Does not take -Werror -- into account. getMessages :: PState -> (Bag PsWarning, Bag PsError) popContext :: P () pushModuleContext :: P () setLastToken :: PsSpan -> Int -> P () setSrcLoc :: RealSrcLoc -> P () activeContext :: P Bool nextIsEOF :: P Bool getLexState :: P Int popLexState :: P Int pushLexState :: Int -> P () -- | Various boolean flags, mostly language extensions, that impact lexing -- and parsing. Note that a handful of these can change during -- lexing/parsing. data ExtBits FfiBit :: ExtBits InterruptibleFfiBit :: ExtBits CApiFfiBit :: ExtBits ArrowsBit :: ExtBits ThBit :: ExtBits ThQuotesBit :: ExtBits IpBit :: ExtBits OverloadedLabelsBit :: ExtBits ExplicitForallBit :: ExtBits BangPatBit :: ExtBits PatternSynonymsBit :: ExtBits HaddockBit :: ExtBits MagicHashBit :: ExtBits RecursiveDoBit :: ExtBits QualifiedDoBit :: ExtBits UnicodeSyntaxBit :: ExtBits UnboxedTuplesBit :: ExtBits UnboxedSumsBit :: ExtBits DatatypeContextsBit :: ExtBits MonadComprehensionsBit :: ExtBits TransformComprehensionsBit :: ExtBits QqBit :: ExtBits RawTokenStreamBit :: ExtBits AlternativeLayoutRuleBit :: ExtBits ALRTransitionalBit :: ExtBits RelaxedLayoutBit :: ExtBits NondecreasingIndentationBit :: ExtBits SafeHaskellBit :: ExtBits TraditionalRecordSyntaxBit :: ExtBits ExplicitNamespacesBit :: ExtBits LambdaCaseBit :: ExtBits BinaryLiteralsBit :: ExtBits NegativeLiteralsBit :: ExtBits HexFloatLiteralsBit :: ExtBits StaticPointersBit :: ExtBits NumericUnderscoresBit :: ExtBits StarIsTypeBit :: ExtBits BlockArgumentsBit :: ExtBits NPlusKPatternsBit :: ExtBits DoAndIfThenElseBit :: ExtBits MultiWayIfBit :: ExtBits GadtSyntaxBit :: ExtBits ImportQualifiedPostBit :: ExtBits LinearTypesBit :: ExtBits NoLexicalNegationBit :: ExtBits OverloadedRecordDotBit :: ExtBits OverloadedRecordUpdateBit :: ExtBits InRulePragBit :: ExtBits InNestedCommentBit :: ExtBits -- | If this is enabled, '{-# LINE ... -#}' and '{-# COLUMN ... #-}' update -- the internal position. Otherwise, those pragmas are lexed as tokens of -- their own. UsePosPragsBit :: ExtBits xtest :: ExtBits -> ExtsBitmap -> Bool xunset :: ExtBits -> ExtsBitmap -> ExtsBitmap xset :: ExtBits -> ExtsBitmap -> ExtsBitmap lexTokenStream :: ParserOpts -> StringBuffer -> RealSrcLoc -> ParseResult [Located Token] -- | Given a SrcSpan that surrounds a HsPar or -- HsParTy, generate AddEpAnn values for the opening and -- closing bordering on the start and end of the span mkParensEpAnn :: RealSrcSpan -> (AddEpAnn, AddEpAnn) getCommentsFor :: MonadP m => SrcSpan -> m EpAnnComments getPriorCommentsFor :: MonadP m => SrcSpan -> m EpAnnComments getFinalCommentsFor :: MonadP m => SrcSpan -> m EpAnnComments getEofPos :: P (Maybe (RealSrcSpan, RealSrcSpan)) commentToAnnotation :: RealLocated Token -> LEpaComment -- | Haddock comment as produced by the lexer. These are accumulated in -- PState and then processed in -- GHC.Parser.PostProcess.Haddock. data HdkComment HdkCommentNext :: HsDocString -> HdkComment HdkCommentPrev :: HsDocString -> HdkComment HdkCommentNamed :: String -> HsDocString -> HdkComment HdkCommentSection :: Int -> HsDocString -> HdkComment -- | Test whether a WarningFlag is set warnopt :: WarningFlag -> ParserOpts -> Bool instance GHC.Show.Show GHC.Parser.Lexer.Token instance GHC.Show.Show GHC.Parser.Lexer.LayoutContext instance GHC.Show.Show GHC.Parser.Lexer.HdkComment instance GHC.Enum.Enum GHC.Parser.Lexer.ExtBits instance GHC.Parser.Lexer.MonadP GHC.Parser.Lexer.P instance GHC.Base.Functor GHC.Parser.Lexer.P instance GHC.Base.Applicative GHC.Parser.Lexer.P instance GHC.Base.Monad GHC.Parser.Lexer.P instance GHC.Utils.Outputable.Outputable GHC.Parser.Lexer.Token -- | This module implements addHaddockToModule, which inserts -- Haddock comments accumulated during parsing into the AST (#17544). -- -- We process Haddock comments in two phases: -- --
-- data T a = T | T1 Int ---- -- we parse the data constructors as types because of parser -- ambiguities, so then we need to change the type constr to a -- data constr -- -- The exact-name case can occur when parsing: -- --
-- data [] a = [] | a : [a] ---- -- For the exact-name case we return an original name. setRdrNameSpace :: RdrName -> NameSpace -> RdrName -- | Converts LHsTyVarBndr annotated with its Specificity to -- one without annotations. Only accepts specified variables, and errors -- if the provided binder has an InferredSpec annotation. fromSpecTyVarBndr :: LHsTyVarBndr Specificity GhcPs -> P (LHsTyVarBndr () GhcPs) -- | Converts a list of LHsTyVarBndrs annotated with their -- Specificity to binders without annotations. Only accepts -- specified variables, and errors if any of the provided binders has an -- InferredSpec annotation. fromSpecTyVarBndrs :: [LHsTyVarBndr Specificity GhcPs] -> P [LHsTyVarBndr () GhcPs] -- | Add the annotation for a 'where' keyword to existing -- HsLocalBinds annBinds :: AddEpAnn -> EpAnnComments -> HsLocalBinds GhcPs -> (HsLocalBinds GhcPs, Maybe EpAnnComments) cvBindGroup :: OrdList (LHsDecl GhcPs) -> P (HsValBinds GhcPs) cvBindsAndSigs :: OrdList (LHsDecl GhcPs) -> P (LHsBinds GhcPs, [LSig GhcPs], [LFamilyDecl GhcPs], [LTyFamInstDecl GhcPs], [LDataFamInstDecl GhcPs], [LDocDecl GhcPs]) -- | Function definitions are restructured here. Each is assumed to be -- recursive initially, and non recursive definitions are discovered by -- the dependency analyser. cvTopDecls :: OrdList (LHsDecl GhcPs) -> [LHsDecl GhcPs] placeHolderPunRhs :: DisambECP b => PV (LocatedA b) mkImport :: Located CCallConv -> Located Safety -> (Located StringLiteral, LocatedN RdrName, LHsSigType GhcPs) -> P (EpAnn [AddEpAnn] -> HsDecl GhcPs) parseCImport :: Located CCallConv -> Located Safety -> FastString -> String -> Located SourceText -> Maybe ForeignImport mkExport :: Located CCallConv -> (Located StringLiteral, LocatedN RdrName, LHsSigType GhcPs) -> P (EpAnn [AddEpAnn] -> HsDecl GhcPs) mkExtName :: RdrName -> CLabelString -- | Construct a GADT-style data constructor from the constructor names and -- their type. Some interesting aspects of this function: -- --
-- (Eq a, Ord b) --> [Eq a, Ord b] -- Eq a --> [Eq a] -- (Eq a) --> [Eq a] -- (((Eq a))) --> [Eq a] --checkContext :: LHsType GhcPs -> P (LHsContext GhcPs) checkPattern :: LocatedA (PatBuilder GhcPs) -> P (LPat GhcPs) checkPattern_hints :: [Hint] -> PV (LocatedA (PatBuilder GhcPs)) -> P (LPat GhcPs) -- | Check for monad comprehensions -- -- If the flag MonadComprehensions is set, return a MonadComp -- context, otherwise use the usual ListComp context checkMonadComp :: PV (HsStmtContext GhcRn) checkValDef :: SrcSpan -> LocatedA (PatBuilder GhcPs) -> Maybe (AddEpAnn, LHsType GhcPs) -> Located (GRHSs GhcPs (LHsExpr GhcPs)) -> P (HsBind GhcPs) checkValSigLhs :: LHsExpr GhcPs -> P (LocatedN RdrName) type LRuleTyTmVar = Located RuleTyTmVar -- | Essentially a wrapper for a RuleBndr GhcPs data RuleTyTmVar RuleTyTmVar :: EpAnn [AddEpAnn] -> LocatedN RdrName -> Maybe (LHsType GhcPs) -> RuleTyTmVar mkRuleBndrs :: [LRuleTyTmVar] -> [LRuleBndr GhcPs] mkRuleTyVarBndrs :: [LRuleTyTmVar] -> [LHsTyVarBndr () GhcPs] checkRuleTyVarBndrNames :: [LHsTyVarBndr flag GhcPs] -> P () checkRecordSyntax :: (MonadP m, Outputable a) => LocatedA a -> m (LocatedA a) -- | Check if the gadt_constrlist is empty. Only raise parse error for -- `data T where` to avoid affecting existing error message, see #8258. checkEmptyGADTs :: Located ([AddEpAnn], [LConDecl GhcPs]) -> P (Located ([AddEpAnn], [LConDecl GhcPs])) -- | Add a fatal error. This will be the last error reported by the parser, -- and the parser will not produce any result, ending in a PFailed -- state. addFatalError :: MonadP m => PsError -> m a -- | Hint about bang patterns, assuming BangPatterns is off. hintBangPat :: SrcSpan -> Pat GhcPs -> PV () mkBangTy :: EpAnn [AddEpAnn] -> SrcStrictness -> LHsType GhcPs -> HsType GhcPs -- | Result of parsing {-# UNPACK #-} or {-# NOUNPACK -- #-}. data UnpackednessPragma UnpackednessPragma :: [AddEpAnn] -> SourceText -> SrcUnpackedness -> UnpackednessPragma mkMultTy :: IsUnicodeSyntax -> Located Token -> LHsType GhcPs -> HsArrow GhcPs data ImpExpSubSpec ImpExpAbs :: ImpExpSubSpec ImpExpAll :: ImpExpSubSpec ImpExpList :: [LocatedA ImpExpQcSpec] -> ImpExpSubSpec ImpExpAllWith :: [LocatedA ImpExpQcSpec] -> ImpExpSubSpec data ImpExpQcSpec ImpExpQcName :: LocatedN RdrName -> ImpExpQcSpec ImpExpQcType :: EpaLocation -> LocatedN RdrName -> ImpExpQcSpec ImpExpQcWildcard :: ImpExpQcSpec mkModuleImpExp :: [AddEpAnn] -> LocatedA ImpExpQcSpec -> ImpExpSubSpec -> P (IE GhcPs) mkTypeImpExp :: LocatedN RdrName -> P (LocatedN RdrName) mkImpExpSubSpec :: [LocatedA ImpExpQcSpec] -> P ([AddEpAnn], ImpExpSubSpec) checkImportSpec :: LocatedL [LIE GhcPs] -> P (LocatedL [LIE GhcPs]) starSym :: Bool -> String warnStarIsType :: SrcSpan -> P () warnPrepositiveQualifiedModule :: SrcSpan -> P () failOpFewArgs :: MonadP m => LocatedN RdrName -> m a failOpNotEnabledImportQualifiedPost :: SrcSpan -> P () failOpImportQualifiedTwice :: SrcSpan -> P () data SumOrTuple b -- | Last two are the locations of the '|' before and after the payload Sum :: ConTag -> Arity -> LocatedA b -> [EpaLocation] -> [EpaLocation] -> SumOrTuple b Tuple :: [Either (EpAnn EpaLocation) (LocatedA b)] -> SumOrTuple b data PV a runPV :: PV a -> P a newtype ECP ECP :: (forall b. DisambECP b => PV (LocatedA b)) -> ECP [unECP] :: ECP -> forall b. DisambECP b => PV (LocatedA b) -- | Disambiguate infix operators. See Note [Ambiguous syntactic -- categories] class DisambInfixOp b mkHsVarOpPV :: DisambInfixOp b => LocatedN RdrName -> PV (LocatedN b) mkHsConOpPV :: DisambInfixOp b => LocatedN RdrName -> PV (LocatedN b) mkHsInfixHolePV :: DisambInfixOp b => SrcSpan -> (EpAnnComments -> EpAnn EpAnnUnboundVar) -> PV (Located b) -- | Disambiguate constructs that may appear when we do not know ahead of -- time whether we are parsing an expression, a command, or a pattern. -- See Note [Ambiguous syntactic categories] class (b ~ (Body b) GhcPs, AnnoBody b) => DisambECP b where { -- | See Note [Body in DisambECP] type Body b :: Type -> Type; -- | Infix operator representation type InfixOp b; -- | Function argument representation type FunArg b; } -- | Return a command without ambiguity, or fail in a non-command context. ecpFromCmd' :: DisambECP b => LHsCmd GhcPs -> PV (LocatedA b) -- | Return an expression without ambiguity, or fail in a non-expression -- context. ecpFromExp' :: DisambECP b => LHsExpr GhcPs -> PV (LocatedA b) mkHsProjUpdatePV :: DisambECP b => SrcSpan -> Located [Located (HsFieldLabel GhcPs)] -> LocatedA b -> Bool -> [AddEpAnn] -> PV (LHsRecProj GhcPs (LocatedA b)) -- | Disambiguate "... -> ..." (lambda) mkHsLamPV :: DisambECP b => SrcSpan -> (EpAnnComments -> MatchGroup GhcPs (LocatedA b)) -> PV (LocatedA b) -- | Disambiguate "let ... in ..." mkHsLetPV :: DisambECP b => SrcSpan -> HsLocalBinds GhcPs -> LocatedA b -> AnnsLet -> PV (LocatedA b) -- | Bring superclass constraints on InfixOp into scope. See Note -- [UndecidableSuperClasses for associated types] superInfixOp :: DisambECP b => (DisambInfixOp (InfixOp b) => PV (LocatedA b)) -> PV (LocatedA b) -- | Disambiguate "f # x" (infix operator) mkHsOpAppPV :: DisambECP b => SrcSpan -> LocatedA b -> LocatedN (InfixOp b) -> LocatedA b -> PV (LocatedA b) -- | Disambiguate "case ... of ..." mkHsCasePV :: DisambECP b => SrcSpan -> LHsExpr GhcPs -> LocatedL [LMatch GhcPs (LocatedA b)] -> EpAnnHsCase -> PV (LocatedA b) mkHsLamCasePV :: DisambECP b => SrcSpan -> LocatedL [LMatch GhcPs (LocatedA b)] -> [AddEpAnn] -> PV (LocatedA b) -- | Bring superclass constraints on FunArg into scope. See Note -- [UndecidableSuperClasses for associated types] superFunArg :: DisambECP b => (DisambECP (FunArg b) => PV (LocatedA b)) -> PV (LocatedA b) -- | Disambiguate "f x" (function application) mkHsAppPV :: DisambECP b => SrcSpanAnnA -> LocatedA b -> LocatedA (FunArg b) -> PV (LocatedA b) -- | Disambiguate "f @t" (visible type application) mkHsAppTypePV :: DisambECP b => SrcSpanAnnA -> LocatedA b -> SrcSpan -> LHsType GhcPs -> PV (LocatedA b) -- | Disambiguate "if ... then ... else ..." mkHsIfPV :: DisambECP b => SrcSpan -> LHsExpr GhcPs -> Bool -> LocatedA b -> Bool -> LocatedA b -> AnnsIf -> PV (LocatedA b) -- | Disambiguate "do { ... }" (do notation) mkHsDoPV :: DisambECP b => SrcSpan -> Maybe ModuleName -> LocatedL [LStmt GhcPs (LocatedA b)] -> AnnList -> PV (LocatedA b) -- | Disambiguate "( ... )" (parentheses) mkHsParPV :: DisambECP b => SrcSpan -> LocatedA b -> AnnParen -> PV (LocatedA b) -- | Disambiguate a variable "f" or a data constructor MkF. mkHsVarPV :: DisambECP b => LocatedN RdrName -> PV (LocatedA b) -- | Disambiguate a monomorphic literal mkHsLitPV :: DisambECP b => Located (HsLit GhcPs) -> PV (Located b) -- | Disambiguate an overloaded literal mkHsOverLitPV :: DisambECP b => Located (HsOverLit GhcPs) -> PV (Located b) -- | Disambiguate a wildcard mkHsWildCardPV :: DisambECP b => SrcSpan -> PV (Located b) -- | Disambiguate "a :: t" (type annotation) mkHsTySigPV :: DisambECP b => SrcSpanAnnA -> LocatedA b -> LHsType GhcPs -> [AddEpAnn] -> PV (LocatedA b) -- | Disambiguate "[a,b,c]" (list syntax) mkHsExplicitListPV :: DisambECP b => SrcSpan -> [LocatedA b] -> AnnList -> PV (LocatedA b) -- | Disambiguate "$(...)" and "[quasi|...|]" (TH splices) mkHsSplicePV :: DisambECP b => Located (HsSplice GhcPs) -> PV (Located b) -- | Disambiguate "f { a = b, ... }" syntax (record construction and record -- updates) mkHsRecordPV :: DisambECP b => Bool -> SrcSpan -> SrcSpan -> LocatedA b -> ([Fbind b], Maybe SrcSpan) -> [AddEpAnn] -> PV (LocatedA b) -- | Disambiguate "-a" (negation) mkHsNegAppPV :: DisambECP b => SrcSpan -> LocatedA b -> [AddEpAnn] -> PV (LocatedA b) -- | Disambiguate "(# a)" (right operator section) mkHsSectionR_PV :: DisambECP b => SrcSpan -> LocatedA (InfixOp b) -> LocatedA b -> PV (Located b) -- | Disambiguate "(a -> b)" (view pattern) mkHsViewPatPV :: DisambECP b => SrcSpan -> LHsExpr GhcPs -> LocatedA b -> [AddEpAnn] -> PV (LocatedA b) -- | Disambiguate "a@b" (as-pattern) mkHsAsPatPV :: DisambECP b => SrcSpan -> LocatedN RdrName -> LocatedA b -> [AddEpAnn] -> PV (LocatedA b) -- | Disambiguate "~a" (lazy pattern) mkHsLazyPatPV :: DisambECP b => SrcSpan -> LocatedA b -> [AddEpAnn] -> PV (LocatedA b) -- | Disambiguate "!a" (bang pattern) mkHsBangPatPV :: DisambECP b => SrcSpan -> LocatedA b -> [AddEpAnn] -> PV (LocatedA b) -- | Disambiguate tuple sections and unboxed sums mkSumOrTuplePV :: DisambECP b => SrcSpanAnnA -> Boxity -> SumOrTuple b -> [AddEpAnn] -> PV (LocatedA b) -- | Validate infixexp LHS to reject unwanted {-# SCC ... #-} pragmas rejectPragmaPV :: DisambECP b => LocatedA b -> PV () ecpFromExp :: LHsExpr GhcPs -> ECP ecpFromCmd :: LHsCmd GhcPs -> ECP -- | See Note [Ambiguous syntactic categories] and Note [PatBuilder] data PatBuilder p -- | Disambiguate constructs that may appear when we do not know ahead of -- time whether we are parsing a type or a newtype/data constructor. -- -- See Note [Ambiguous syntactic categories] for the general idea. -- -- See Note [Parsing data constructors is hard] for the specific issue -- this particular class is solving. class DisambTD b -- | Process the head of a type-level function/constructor application, -- i.e. the H in H a b c. mkHsAppTyHeadPV :: DisambTD b => LHsType GhcPs -> PV (LocatedA b) -- | Disambiguate f x (function application or prefix data -- constructor). mkHsAppTyPV :: DisambTD b => LocatedA b -> LHsType GhcPs -> PV (LocatedA b) -- | Disambiguate f @t (visible kind application) mkHsAppKindTyPV :: DisambTD b => LocatedA b -> SrcSpan -> LHsType GhcPs -> PV (LocatedA b) -- | Disambiguate f # x (infix operator) mkHsOpTyPV :: DisambTD b => LHsType GhcPs -> LocatedN RdrName -> LHsType GhcPs -> PV (LocatedA b) -- | Disambiguate {-# UNPACK #-} t (unpack/nounpack pragma) mkUnpackednessPV :: DisambTD b => Located UnpackednessPragma -> LocatedA b -> PV (LocatedA b) -- | Annotate a type with either an {-# UNPACK #-} or a {-# -- NOUNPACK #-} pragma. addUnpackednessP :: MonadP m => Located UnpackednessPragma -> LHsType GhcPs -> m (LHsType GhcPs) dataConBuilderCon :: DataConBuilder -> LocatedN RdrName dataConBuilderDetails :: DataConBuilder -> HsConDeclH98Details GhcPs instance GHC.Parser.PostProcess.DisambECP (Language.Haskell.Syntax.Expr.HsCmd GHC.Hs.Extension.GhcPs) instance GHC.Parser.PostProcess.DisambECP (Language.Haskell.Syntax.Expr.HsExpr GHC.Hs.Extension.GhcPs) instance GHC.Parser.PostProcess.DisambECP (GHC.Parser.Types.PatBuilder GHC.Hs.Extension.GhcPs) instance GHC.Parser.PostProcess.DisambInfixOp (Language.Haskell.Syntax.Expr.HsExpr GHC.Hs.Extension.GhcPs) instance GHC.Parser.PostProcess.DisambInfixOp GHC.Types.Name.Reader.RdrName instance GHC.Parser.PostProcess.DisambTD (Language.Haskell.Syntax.Type.HsType GHC.Hs.Extension.GhcPs) instance GHC.Parser.PostProcess.DisambTD GHC.Parser.Types.DataConBuilder instance GHC.Base.Functor GHC.Parser.PostProcess.PV instance GHC.Base.Applicative GHC.Parser.PostProcess.PV instance GHC.Base.Monad GHC.Parser.PostProcess.PV instance GHC.Parser.Lexer.MonadP GHC.Parser.PostProcess.PV module GHC.ThToHs convertToHsExpr :: Origin -> SrcSpan -> Exp -> Either SDoc (LHsExpr GhcPs) convertToPat :: Origin -> SrcSpan -> Pat -> Either SDoc (LPat GhcPs) convertToHsDecls :: Origin -> SrcSpan -> [Dec] -> Either SDoc [LHsDecl GhcPs] convertToHsType :: Origin -> SrcSpan -> Type -> Either SDoc (LHsType GhcPs) thRdrNameGuesses :: Name -> [RdrName] instance GHC.Base.Functor GHC.ThToHs.CvtM instance GHC.ThToHs.CvtFlag () () instance GHC.ThToHs.CvtFlag Language.Haskell.TH.Syntax.Specificity GHC.Types.Var.Specificity instance GHC.Base.Applicative GHC.ThToHs.CvtM instance GHC.Base.Monad GHC.ThToHs.CvtM -- | Subsystem configuration module GHC.Driver.Config -- | Initialise coercion optimiser configuration from DynFlags initOptCoercionOpts :: DynFlags -> OptCoercionOpts -- | Initialise Simple optimiser configuration from DynFlags initSimpleOpts :: DynFlags -> SimpleOpts -- | Extracts the flag information needed for parsing initParserOpts :: DynFlags -> ParserOpts module GHC.Core.Opt.Simplify.Monad data SimplM result initSmpl :: Logger -> DynFlags -> RuleEnv -> (FamInstEnv, FamInstEnv) -> Int -> SimplM a -> IO (a, SimplCount) traceSmpl :: String -> SDoc -> SimplM () getSimplRules :: SimplM RuleEnv getFamEnvs :: SimplM (FamInstEnv, FamInstEnv) getOptCoercionOpts :: SimplM OptCoercionOpts -- | A monad for generating unique identifiers class Monad m => MonadUnique m -- | Get a new UniqueSupply getUniqueSupplyM :: MonadUnique m => m UniqSupply -- | Get a new unique identifier getUniqueM :: MonadUnique m => m Unique -- | Get an infinite list of new unique identifiers getUniquesM :: MonadUnique m => m [Unique] newId :: FastString -> Mult -> Type -> SimplM Id newJoinId :: [Var] -> Type -> SimplM Id data SimplCount tick :: Tick -> SimplM () freeTick :: Tick -> SimplM () checkedTick :: Tick -> SimplM () getSimplCount :: SimplM SimplCount zeroSimplCount :: DynFlags -> SimplCount pprSimplCount :: SimplCount -> SDoc plusSimplCount :: SimplCount -> SimplCount -> SimplCount isZeroSimplCount :: SimplCount -> Bool instance GHC.Base.Functor GHC.Core.Opt.Simplify.Monad.SimplM instance GHC.Base.Applicative GHC.Core.Opt.Simplify.Monad.SimplM instance GHC.Base.Monad GHC.Core.Opt.Simplify.Monad.SimplM instance GHC.Types.Unique.Supply.MonadUnique GHC.Core.Opt.Simplify.Monad.SimplM instance GHC.Driver.Session.HasDynFlags GHC.Core.Opt.Simplify.Monad.SimplM instance GHC.Utils.Logger.HasLogger GHC.Core.Opt.Simplify.Monad.SimplM instance Control.Monad.IO.Class.MonadIO GHC.Core.Opt.Simplify.Monad.SimplM module GHC.Parser.Errors.Ppr pprWarning :: PsWarning -> MsgEnvelope DecoratedSDoc pprError :: PsError -> MsgEnvelope DecoratedSDoc -- | Extract docs from the renamer output so they can be serialized. module GHC.HsToCore.Docs -- | Extract docs from renamer output. This is monadic since we need to be -- able to read documentation added from Template Haskell's -- putDoc, which is stored in tcg_th_docs. extractDocs :: MonadIO m => TcGblEnv -> m (Maybe HsDocString, DeclDocMap, ArgDocMap) -- | Create decl and arg doc-maps by looping through the declarations. For -- each declaration, find its names, its subordinates, and its doc -- strings. mkMaps :: [Name] -> [(LHsDecl GhcRn, [HsDocString])] -> (Map Name HsDocString, Map Name (IntMap HsDocString)) getMainDeclBinder :: (Anno (IdGhcP p) ~ SrcSpanAnnN, CollectPass (GhcPass p)) => HsDecl (GhcPass p) -> [IdP (GhcPass p)] sigNameNoLoc :: forall pass. UnXRec pass => Sig pass -> [IdP pass] getInstLoc :: Anno (IdGhcP p) ~ SrcSpanAnnN => InstDecl (GhcPass p) -> SrcSpan -- | Get all subordinate declarations inside a declaration, and their docs. -- A subordinate declaration is something like the associate type or data -- family of a type class. subordinates :: Map RealSrcSpan Name -> HsDecl GhcRn -> [(Name, [HsDocString], IntMap HsDocString)] -- | Extract constructor argument docs from inside constructor decls. conArgDocs :: ConDecl GhcRn -> IntMap HsDocString h98ConArgDocs :: HsConDeclH98Details GhcRn -> IntMap HsDocString gadtConArgDocs :: HsConDeclGADTDetails GhcRn -> HsType GhcRn -> IntMap HsDocString con_arg_docs :: Int -> [HsType GhcRn] -> IntMap HsDocString isValD :: HsDecl a -> Bool -- | All the sub declarations of a class (that we handle), ordered by -- source location, with documentation attached if it exists. classDecls :: TyClDecl GhcRn -> [(LHsDecl GhcRn, [HsDocString])] -- | Extract function argument docs from inside top-level decls. declTypeDocs :: HsDecl GhcRn -> IntMap HsDocString nubByName :: (a -> Name) -> [a] -> [a] -- | Extract function argument docs from inside types. typeDocs :: HsType GhcRn -> IntMap HsDocString -- | Extract function argument docs from inside types. sigTypeDocs :: HsSigType GhcRn -> IntMap HsDocString -- | The top-level declarations of a module that we care about, ordered by -- source location, with documentation attached if it exists. topDecls :: HsGroup GhcRn -> [(LHsDecl GhcRn, [HsDocString])] -- | Take all declarations except pragmas, infix decls, rules from an -- HsGroup. ungroup :: HsGroup GhcRn -> [LHsDecl GhcRn] -- | Collect docs and attach them to the right declarations. -- -- A declaration may have multiple doc strings attached to it. -- -- This is an example. collectDocs :: forall p. UnXRec p => [LHsDecl p] -> [(LHsDecl p, [HsDocString])] -- | Filter out declarations that we don't handle in Haddock filterDecls :: forall p doc. UnXRec p => [(LHsDecl p, doc)] -> [(LHsDecl p, doc)] -- | Go through all class declarations and filter their sub-declarations filterClasses :: forall p doc. IsPass p => [(LHsDecl (GhcPass p), doc)] -> [(LHsDecl (GhcPass p), doc)] -- | Was this signature given by the user? isUserSig :: Sig name -> Bool -- | Take a field of declarations from a data structure and create HsDecls -- using the given constructor mkDecls :: (struct -> [GenLocated l decl]) -> (decl -> hsDecl) -> struct -> [GenLocated l hsDecl] -- | Extracts out individual maps of documentation added via Template -- Haskell's putDoc. extractTHDocs :: THDocs -> ExtractedTHDocs -- | Unions together two ArgDocMaps (or ArgMaps in haddock-api), -- such that two maps with values for the same key merge the inner map as -- well. Left biased so unionArgMaps a b prefers a over -- b. unionArgMaps :: Map Name (IntMap b) -> Map Name (IntMap b) -> Map Name (IntMap b) module GHC.Tc.Types.EvTerm evDelayedError :: Type -> FastString -> EvTerm evCallStack :: (MonadThings m, HasModule m, HasDynFlags m) => EvCallStack -> m EvExpr module GHC.Stg.Unarise unarise :: UniqSupply -> [StgTopBinding] -> [StgTopBinding] instance GHC.Utils.Outputable.Outputable GHC.Stg.Unarise.UnariseVal module GHC.Core.Opt.WorkWrap.Utils mkWwBodies :: DynFlags -> FamInstEnvs -> VarSet -> Id -> [Demand] -> Cpr -> UniqSM (Maybe WwResult) mkWWstr :: DynFlags -> FamInstEnvs -> Bool -> [Var] -> UniqSM (Bool, [Var], CoreExpr -> CoreExpr, CoreExpr -> CoreExpr) mkWorkerArgs :: DynFlags -> [Var] -> Type -> ([Var], [Var]) -- | The information needed to build a pattern for a DataCon to be unboxed. -- The pattern can be generated from dcpc_dc and -- dcpc_tc_args via dataConRepInstPat. The coercion -- dcpc_co is for newtype wrappers. -- -- If we get DataConPatContext dc tys co for some type -- ty and dataConRepInstPat ... dc tys = (exs, flds), -- then -- --
co :: T tys ~ ty
-- do (b, a, (a -> True)) <- bar -- foo a ---- -- The identifier a has two scopes: in the view pattern (a -- -> True) and in the rest of the do-block in foo -- a. PatternBind :: Scope -> Scope -> Maybe Span -> ContextInfo ClassTyDecl :: Maybe Span -> ContextInfo -- | Declaration Decl :: DeclType -> Maybe Span -> ContextInfo -- | Type variable TyVarBind :: Scope -> TyVarScope -> ContextInfo -- | Record field RecField :: RecFieldContext -> Maybe Span -> ContextInfo -- | Constraint/Dictionary evidence variable binding EvidenceVarBind :: EvVarSource -> Scope -> Maybe Span -> ContextInfo -- | Usage of evidence variable EvidenceVarUse :: ContextInfo pprBindSpan :: Maybe Span -> SDoc data EvVarSource -- | bound by a pattern match EvPatternBind :: EvVarSource -- | bound by a type signature EvSigBind :: EvVarSource -- | bound by a hswrapper EvWrapperBind :: EvVarSource -- | bound by an implicit variable EvImplicitBind :: EvVarSource -- | Bound by some instance of given class EvInstBind :: Bool -> Name -> EvVarSource [isSuperInst] :: EvVarSource -> Bool [cls] :: EvVarSource -> Name -- | A direct let binding EvLetBind :: EvBindDeps -> EvVarSource -- | Eq/Ord instances compare on the converted HieName, as non-exported -- names may have different uniques after a roundtrip newtype EvBindDeps EvBindDeps :: [Name] -> EvBindDeps [getEvBindDeps] :: EvBindDeps -> [Name] -- | Types of imports and exports data IEType Import :: IEType ImportAs :: IEType ImportHiding :: IEType Export :: IEType data RecFieldContext RecFieldDecl :: RecFieldContext RecFieldAssign :: RecFieldContext RecFieldMatch :: RecFieldContext RecFieldOcc :: RecFieldContext data BindType RegularBind :: BindType InstanceBind :: BindType data DeclType -- | type or data family FamDec :: DeclType -- | type synonym SynDec :: DeclType -- | data declaration DataDec :: DeclType -- | constructor declaration ConDec :: DeclType -- | pattern synonym PatSynDec :: DeclType -- | class declaration ClassDec :: DeclType -- | instance declaration InstDec :: DeclType data Scope NoScope :: Scope LocalScope :: Span -> Scope ModuleScope :: Scope -- | Scope of a type variable. -- -- This warrants a data type apart from Scope because of -- complexities introduced by features like -- -XScopedTypeVariables and -XInstanceSigs. For -- example, consider: -- --
-- foo, bar, baz :: forall a. a -> a ---- -- Here a is in scope in all the definitions of foo, -- bar, and baz, so we need a list of scopes to keep -- track of this. Furthermore, this list cannot be computed until we -- resolve the binding sites of foo, bar, and -- baz. -- -- Consequently, a starts with an UnresolvedScope -- [foo, bar, baz] Nothing which later gets resolved into a -- ResolvedScopes. data TyVarScope ResolvedScopes :: [Scope] -> TyVarScope -- | Unresolved scopes should never show up in the final .hie file UnresolvedScope :: [Name] -> Maybe Span -> TyVarScope -- | Name's get converted into HieName's before being written -- into .hie files. See toHieName and -- fromHieName for logic on how to convert between these two -- types. data HieName ExternalName :: !Module -> !OccName -> !SrcSpan -> HieName LocalName :: !OccName -> !SrcSpan -> HieName KnownKeyName :: !Unique -> HieName hieNameOcc :: HieName -> OccName toHieName :: Name -> HieName instance GHC.Classes.Eq a => GHC.Classes.Eq (GHC.Iface.Ext.Types.HieArgs a) instance Data.Traversable.Traversable GHC.Iface.Ext.Types.HieArgs instance Data.Foldable.Foldable GHC.Iface.Ext.Types.HieArgs instance GHC.Base.Functor GHC.Iface.Ext.Types.HieArgs instance GHC.Classes.Eq a => GHC.Classes.Eq (GHC.Iface.Ext.Types.HieType a) instance Data.Traversable.Traversable GHC.Iface.Ext.Types.HieType instance Data.Foldable.Foldable GHC.Iface.Ext.Types.HieType instance GHC.Base.Functor GHC.Iface.Ext.Types.HieType instance GHC.Classes.Ord GHC.Iface.Ext.Types.NodeOrigin instance GHC.Enum.Enum GHC.Iface.Ext.Types.NodeOrigin instance GHC.Classes.Eq GHC.Iface.Ext.Types.NodeOrigin instance GHC.Classes.Eq GHC.Iface.Ext.Types.NodeAnnotation instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.EvBindDeps instance GHC.Classes.Ord GHC.Iface.Ext.Types.EvVarSource instance GHC.Classes.Eq GHC.Iface.Ext.Types.EvVarSource instance GHC.Classes.Ord GHC.Iface.Ext.Types.IEType instance GHC.Enum.Enum GHC.Iface.Ext.Types.IEType instance GHC.Classes.Eq GHC.Iface.Ext.Types.IEType instance GHC.Classes.Ord GHC.Iface.Ext.Types.RecFieldContext instance GHC.Enum.Enum GHC.Iface.Ext.Types.RecFieldContext instance GHC.Classes.Eq GHC.Iface.Ext.Types.RecFieldContext instance GHC.Enum.Enum GHC.Iface.Ext.Types.BindType instance GHC.Classes.Ord GHC.Iface.Ext.Types.BindType instance GHC.Classes.Eq GHC.Iface.Ext.Types.BindType instance GHC.Enum.Enum GHC.Iface.Ext.Types.DeclType instance GHC.Classes.Ord GHC.Iface.Ext.Types.DeclType instance GHC.Classes.Eq GHC.Iface.Ext.Types.DeclType instance Data.Data.Data GHC.Iface.Ext.Types.Scope instance GHC.Classes.Ord GHC.Iface.Ext.Types.Scope instance GHC.Classes.Eq GHC.Iface.Ext.Types.Scope instance GHC.Classes.Ord GHC.Iface.Ext.Types.TyVarScope instance GHC.Classes.Eq GHC.Iface.Ext.Types.TyVarScope instance GHC.Classes.Ord GHC.Iface.Ext.Types.ContextInfo instance GHC.Classes.Eq GHC.Iface.Ext.Types.ContextInfo instance Data.Traversable.Traversable GHC.Iface.Ext.Types.IdentifierDetails instance Data.Foldable.Foldable GHC.Iface.Ext.Types.IdentifierDetails instance GHC.Base.Functor GHC.Iface.Ext.Types.IdentifierDetails instance GHC.Classes.Eq a => GHC.Classes.Eq (GHC.Iface.Ext.Types.IdentifierDetails a) instance Data.Traversable.Traversable GHC.Iface.Ext.Types.NodeInfo instance Data.Foldable.Foldable GHC.Iface.Ext.Types.NodeInfo instance GHC.Base.Functor GHC.Iface.Ext.Types.NodeInfo instance Data.Traversable.Traversable GHC.Iface.Ext.Types.SourcedNodeInfo instance Data.Foldable.Foldable GHC.Iface.Ext.Types.SourcedNodeInfo instance GHC.Base.Functor GHC.Iface.Ext.Types.SourcedNodeInfo instance Data.Traversable.Traversable GHC.Iface.Ext.Types.HieAST instance Data.Foldable.Foldable GHC.Iface.Ext.Types.HieAST instance GHC.Base.Functor GHC.Iface.Ext.Types.HieAST instance Data.Traversable.Traversable GHC.Iface.Ext.Types.HieASTs instance Data.Foldable.Foldable GHC.Iface.Ext.Types.HieASTs instance GHC.Base.Functor GHC.Iface.Ext.Types.HieASTs instance GHC.Classes.Eq GHC.Iface.Ext.Types.HieName instance GHC.Classes.Ord GHC.Iface.Ext.Types.HieName instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.HieName instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.HieFile instance GHC.Utils.Binary.Binary (GHC.Iface.Ext.Types.HieASTs GHC.Iface.Ext.Types.TypeIndex) instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Iface.Ext.Types.HieASTs a) instance GHC.Utils.Binary.Binary (GHC.Iface.Ext.Types.HieAST GHC.Iface.Ext.Types.TypeIndex) instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Iface.Ext.Types.HieAST a) instance GHC.Utils.Binary.Binary (GHC.Iface.Ext.Types.SourcedNodeInfo GHC.Iface.Ext.Types.TypeIndex) instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Iface.Ext.Types.SourcedNodeInfo a) instance GHC.Utils.Binary.Binary (GHC.Iface.Ext.Types.NodeInfo GHC.Iface.Ext.Types.TypeIndex) instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Iface.Ext.Types.NodeInfo a) instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Iface.Ext.Types.IdentifierDetails a) instance GHC.Base.Semigroup (GHC.Iface.Ext.Types.IdentifierDetails a) instance GHC.Base.Monoid (GHC.Iface.Ext.Types.IdentifierDetails a) instance GHC.Utils.Binary.Binary (GHC.Iface.Ext.Types.IdentifierDetails GHC.Iface.Ext.Types.TypeIndex) instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.ContextInfo instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.ContextInfo instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.TyVarScope instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.TyVarScope instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.Scope instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.Scope instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.DeclType instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.DeclType instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.BindType instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.BindType instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.RecFieldContext instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.RecFieldContext instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.IEType instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.IEType instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.EvVarSource instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.EvVarSource instance GHC.Classes.Eq GHC.Iface.Ext.Types.EvBindDeps instance GHC.Classes.Ord GHC.Iface.Ext.Types.EvBindDeps instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.EvBindDeps instance GHC.Classes.Ord GHC.Iface.Ext.Types.NodeAnnotation instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.NodeAnnotation instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.NodeAnnotation instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.NodeOrigin instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.NodeOrigin instance GHC.Utils.Binary.Binary (GHC.Iface.Ext.Types.HieType GHC.Iface.Ext.Types.TypeIndex) instance GHC.Utils.Binary.Binary (GHC.Iface.Ext.Types.HieArgs GHC.Iface.Ext.Types.TypeIndex) module GHC.Iface.Ext.Utils type RefMap a = Map Identifier [(Span, IdentifierDetails a)] generateReferencesMap :: Foldable f => f (HieAST a) -> RefMap a renderHieType :: DynFlags -> HieTypeFix -> String resolveVisibility :: Type -> [Type] -> [(Bool, Type)] foldType :: (HieType a -> a) -> HieTypeFix -> a selectPoint :: HieFile -> (Int, Int) -> Maybe (HieAST Int) findEvidenceUse :: NodeIdentifiers a -> [Name] data EvidenceInfo a EvidenceInfo :: Name -> RealSrcSpan -> a -> Maybe (EvVarSource, Scope, Maybe Span) -> EvidenceInfo a [evidenceVar] :: EvidenceInfo a -> Name [evidenceSpan] :: EvidenceInfo a -> RealSrcSpan [evidenceType] :: EvidenceInfo a -> a [evidenceDetails] :: EvidenceInfo a -> Maybe (EvVarSource, Scope, Maybe Span) getEvidenceTreesAtPoint :: HieFile -> RefMap a -> (Int, Int) -> Forest (EvidenceInfo a) getEvidenceTree :: RefMap a -> Name -> Maybe (Tree (EvidenceInfo a)) hieTypeToIface :: HieTypeFix -> IfaceType data HieTypeState HTS :: !TypeMap TypeIndex -> !IntMap HieTypeFlat -> !TypeIndex -> HieTypeState [tyMap] :: HieTypeState -> !TypeMap TypeIndex [htyTable] :: HieTypeState -> !IntMap HieTypeFlat [freshIndex] :: HieTypeState -> !TypeIndex initialHTS :: HieTypeState freshTypeIndex :: State HieTypeState TypeIndex compressTypes :: HieASTs Type -> (HieASTs TypeIndex, Array TypeIndex HieTypeFlat) recoverFullType :: TypeIndex -> Array TypeIndex HieTypeFlat -> HieTypeFix getTypeIndex :: Type -> State HieTypeState TypeIndex resolveTyVarScopes :: Map HiePath (HieAST a) -> Map HiePath (HieAST a) resolveTyVarScopeLocal :: HieAST a -> Map HiePath (HieAST a) -> HieAST a getNameBinding :: Name -> Map HiePath (HieAST a) -> Maybe Span getNameScope :: Name -> Map HiePath (HieAST a) -> Maybe [Scope] getNameBindingInClass :: Name -> Span -> Map HiePath (HieAST a) -> Maybe Span getNameScopeAndBinding :: Name -> Map HiePath (HieAST a) -> Maybe ([Scope], Maybe Span) getScopeFromContext :: ContextInfo -> Maybe [Scope] getBindSiteFromContext :: ContextInfo -> Maybe Span flattenAst :: HieAST a -> [HieAST a] smallestContainingSatisfying :: Span -> (HieAST a -> Bool) -> HieAST a -> Maybe (HieAST a) selectLargestContainedBy :: Span -> HieAST a -> Maybe (HieAST a) selectSmallestContaining :: Span -> HieAST a -> Maybe (HieAST a) definedInAsts :: Map HiePath (HieAST a) -> Name -> Bool getEvidenceBindDeps :: ContextInfo -> [Name] isEvidenceBind :: ContextInfo -> Bool isEvidenceContext :: ContextInfo -> Bool isEvidenceUse :: ContextInfo -> Bool isOccurrence :: ContextInfo -> Bool scopeContainsSpan :: Scope -> Span -> Bool -- | One must contain the other. Leaf nodes cannot contain anything combineAst :: HieAST Type -> HieAST Type -> HieAST Type -- | Insert an AST in a sorted list of disjoint Asts insertAst :: HieAST Type -> [HieAST Type] -> [HieAST Type] nodeInfo :: HieAST Type -> NodeInfo Type emptyNodeInfo :: NodeInfo a sourcedNodeIdents :: SourcedNodeInfo a -> NodeIdentifiers a combineSourcedNodeInfo :: SourcedNodeInfo Type -> SourcedNodeInfo Type -> SourcedNodeInfo Type -- | Merge two nodes together. -- -- Precondition and postcondition: elements in nodeType are -- ordered. combineNodeInfo :: NodeInfo Type -> NodeInfo Type -> NodeInfo Type -- | Merge two sorted, disjoint lists of ASTs, combining when necessary. -- -- In the absence of position-altering pragmas (ex: # line "file.hs" -- 3), different nodes in an AST tree should either have disjoint -- spans (in which case you can say for sure which one comes first) or -- one span should be completely contained in the other (in which case -- the contained span corresponds to some child node). -- -- However, since Haskell does have position-altering pragmas it -- is possible for spans to be overlapping. Here is an example of -- a source file in which foozball and quuuuuux have -- overlapping spans: -- --
-- module Baz where -- -- # line 3 "Baz.hs" -- foozball :: Int -- foozball = 0 -- -- # line 3 "Baz.hs" -- bar, quuuuuux :: Int -- bar = 1 -- quuuuuux = 2 ---- -- In these cases, we just do our best to produce sensible -- HieAST's. The blame should be laid at the feet of whoever wrote -- the line pragmas in the first place (usually the C preprocessor...). mergeAsts :: [HieAST Type] -> [HieAST Type] -> [HieAST Type] rightOf :: Span -> Span -> Bool leftOf :: Span -> Span -> Bool startsRightOf :: Span -> Span -> Bool -- | combines and sorts ASTs using a merge sort mergeSortAsts :: [HieAST Type] -> [HieAST Type] simpleNodeInfo :: FastString -> FastString -> NodeInfo a locOnly :: Monad m => SrcSpan -> ReaderT NodeOrigin m [HieAST a] mkScopeA :: SrcSpanAnn' ann -> Scope mkScope :: SrcSpan -> Scope mkLScope :: Located a -> Scope mkLScopeA :: GenLocated (SrcSpanAnn' a) e -> Scope mkLScopeN :: LocatedN a -> Scope combineScopes :: Scope -> Scope -> Scope mkSourcedNodeInfo :: NodeOrigin -> NodeInfo a -> SourcedNodeInfo a makeNodeA :: (Monad m, Data a) => a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b] makeNode :: (Monad m, Data a) => a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b] makeTypeNodeA :: (Monad m, Data a) => a -> SrcSpanAnnA -> Type -> ReaderT NodeOrigin m [HieAST Type] makeTypeNode :: (Monad m, Data a) => a -> SrcSpan -> Type -> ReaderT NodeOrigin m [HieAST Type] instance GHC.Base.Functor GHC.Iface.Ext.Utils.EvidenceInfo instance GHC.Classes.Ord a => GHC.Classes.Ord (GHC.Iface.Ext.Utils.EvidenceInfo a) instance GHC.Classes.Eq a => GHC.Classes.Eq (GHC.Iface.Ext.Utils.EvidenceInfo a) instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Iface.Ext.Utils.EvidenceInfo a) module GHC.Iface.Ext.Debug type Diff a = a -> a -> [SDoc] diffFile :: Diff HieFile diffAsts :: (Outputable a, Eq a, Ord a) => Diff a -> Diff (Map HiePath (HieAST a)) diffAst :: (Outputable a, Eq a, Ord a) => Diff a -> Diff (HieAST a) type DiffIdent = Either ModuleName HieName normalizeIdents :: Ord a => NodeIdentifiers a -> [(DiffIdent, IdentifierDetails a)] diffList :: Diff a -> Diff [a] eqDiff :: (Outputable a, Eq a) => Diff a validAst :: HieAST a -> Either SDoc () -- | Look for any identifiers which occur outside of their supposed scopes. -- Returns a list of error messages. validateScopes :: Module -> Map HiePath (HieAST a) -> [SDoc] module GHC.Core.Opt.Simplify simplTopBinds :: SimplEnv -> [InBind] -> SimplM (SimplFloats, SimplEnv) simplExpr :: SimplEnv -> CoreExpr -> SimplM CoreExpr simplRules :: SimplEnv -> Maybe OutId -> [CoreRule] -> MaybeJoinCont -> SimplM [CoreRule] module GHC.Core.Opt.FloatOut floatOutwards :: Logger -> FloatOutSwitches -> DynFlags -> UniqSupply -> CoreProgram -> IO CoreProgram instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.FloatOut.FloatBinds module GHC.Core.Opt.DmdAnal -- | Options for the demand analysis newtype DmdAnalOpts DmdAnalOpts :: Bool -> DmdAnalOpts -- | Use strict dictionaries [dmd_strict_dicts] :: DmdAnalOpts -> Bool -- | Outputs a new copy of the Core program in which binders have been -- annotated with demand and strictness information. -- -- Note: use seqBinds on the result to avoid leaks due to -- lazyness (cf Note [Stamp out space leaks in demand analysis]) dmdAnalProgram :: DmdAnalOpts -> FamInstEnvs -> [CoreRule] -> CoreProgram -> CoreProgram instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.DmdAnal.AnalEnv module GHC.Core.Opt.CallArity callArityAnalProgram :: DynFlags -> CoreProgram -> CoreProgram callArityRHS :: CoreExpr -> CoreExpr -- | GHC LLVM Mangler -- -- This script processes the assembly produced by LLVM, rewriting all -- symbols of type function to object. This keeps them from -- going through the PLT, which would be bad due to tables-next-to-code. -- On x86_64, it also rewrites AVX instructions that require alignment to -- their unaligned counterparts, since the stack is only 16-byte aligned -- but these instructions require 32-byte alignment. module GHC.CmmToLlvm.Mangler -- | Read in assembly file and process llvmFixupAsm :: Logger -> DynFlags -> FilePath -> FilePath -> IO () module GHC.CmmToAsm.Instr -- | Common things that we can do with instructions, on all architectures. -- These are used by the shared parts of the native code generator, -- specifically the register allocators. class Instruction instr -- | Get the registers that are being used by this instruction. regUsage -- doesn't need to do any trickery for jumps and such. Just state -- precisely the regs read and written by that insn. The consequences of -- control flow transfers, as far as register allocation goes, are taken -- care of by the register allocator. regUsageOfInstr :: Instruction instr => Platform -> instr -> RegUsage -- | Apply a given mapping to all the register references in this -- instruction. patchRegsOfInstr :: Instruction instr => instr -> (Reg -> Reg) -> instr -- | Checks whether this instruction is a jump/branch instruction. One that -- can change the flow of control in a way that the register allocator -- needs to worry about. isJumpishInstr :: Instruction instr => instr -> Bool -- | Give the possible destinations of this jump instruction. Must be -- defined for all jumpish instructions. jumpDestsOfInstr :: Instruction instr => instr -> [BlockId] -- | Change the destination of this jump instruction. Used in the linear -- allocator when adding fixup blocks for join points. patchJumpInstr :: Instruction instr => instr -> (BlockId -> BlockId) -> instr -- | An instruction to spill a register into a spill slot. mkSpillInstr :: Instruction instr => NCGConfig -> Reg -> Int -> Int -> [instr] -- | An instruction to reload a register from a spill slot. mkLoadInstr :: Instruction instr => NCGConfig -> Reg -> Int -> Int -> [instr] -- | See if this instruction is telling us the current C stack delta takeDeltaInstr :: Instruction instr => instr -> Maybe Int -- | Check whether this instruction is some meta thing inserted into the -- instruction stream for other purposes. -- -- Not something that has to be treated as a real machine instruction and -- have its registers allocated. -- -- eg, comments, delta, ldata, etc. isMetaInstr :: Instruction instr => instr -> Bool -- | Copy the value in a register to another one. Must work for all -- register classes. mkRegRegMoveInstr :: Instruction instr => Platform -> Reg -> Reg -> instr -- | Take the source and destination from this reg -> reg move -- instruction or Nothing if it's not one takeRegRegMoveInstr :: Instruction instr => instr -> Maybe (Reg, Reg) -- | Make an unconditional jump instruction. For architectures with branch -- delay slots, its ok to put a NOP after the jump. Don't fill the delay -- slot with an instruction that references regs or you'll confuse the -- linear allocator. mkJumpInstr :: Instruction instr => BlockId -> [instr] mkStackAllocInstr :: Instruction instr => Platform -> Int -> [instr] mkStackDeallocInstr :: Instruction instr => Platform -> Int -> [instr] -- | Pretty-print an instruction pprInstr :: Instruction instr => Platform -> instr -> SDoc mkComment :: Instruction instr => SDoc -> [instr] -- | Holds a list of source and destination registers used by a particular -- instruction. -- -- Machine registers that are pre-allocated to stgRegs are filtered out, -- because they are uninteresting from a register allocation standpoint. -- (We wouldn't want them to end up on the free list!) -- -- As far as we are concerned, the fixed registers simply don't exist -- (for allocation purposes, anyway). data RegUsage RU :: [Reg] -> [Reg] -> RegUsage [reads] :: RegUsage -> [Reg] [writes] :: RegUsage -> [Reg] -- | No regs read or written to. noUsage :: RegUsage instance GHC.Show.Show GHC.CmmToAsm.Instr.RegUsage module GHC.Cmm.Ppr.Expr pprExpr :: Platform -> CmmExpr -> SDoc pprLit :: Platform -> CmmLit -> SDoc instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform GHC.Cmm.Expr.CmmExpr instance GHC.Utils.Outputable.Outputable GHC.Cmm.Expr.CmmReg instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform GHC.Cmm.Expr.CmmLit instance GHC.Utils.Outputable.Outputable GHC.Cmm.Expr.LocalReg instance GHC.Utils.Outputable.Outputable GHC.Cmm.Expr.Area instance GHC.Utils.Outputable.Outputable GHC.Cmm.Expr.GlobalReg instance GHC.Utils.Outputable.OutputableP env GHC.Cmm.Expr.GlobalReg module GHC.Cmm.LRegSet type LRegSet = IntSet type LRegKey = Int emptyLRegSet :: LRegSet nullLRegSet :: LRegSet -> Bool insertLRegSet :: LocalReg -> LRegSet -> LRegSet elemLRegSet :: LocalReg -> LRegSet -> Bool deleteFromLRegSet :: LRegSet -> LocalReg -> LRegSet sizeLRegSet :: IntSet -> Int plusLRegSet :: IntSet -> IntSet -> IntSet elemsLRegSet :: IntSet -> [Int] module GHC.Core.Opt.Specialise -- | Specialise calls to type-class overloaded functions occurring in a -- program. specProgram :: ModGuts -> CoreM ModGuts specUnfolding :: SimpleOpts -> [Var] -> (CoreExpr -> CoreExpr) -> [CoreArg] -> Unfolding -> Unfolding instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Specialise.UsageDetails instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Specialise.CallInfoSet instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Specialise.CallInfo instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Specialise.SpecArg instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Specialise.DictBind instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Specialise.SpecEnv module GHC.Core.Opt.SpecConstr specConstrProgram :: ModGuts -> CoreM ModGuts data SpecConstrAnnotation NoSpecConstr :: SpecConstrAnnotation ForceSpecConstr :: SpecConstrAnnotation instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.SpecConstr.ScUsage instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.SpecConstr.ArgOcc instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.SpecConstr.Call instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.SpecConstr.HowBound instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.SpecConstr.Value module GHC.Core.Opt.FloatIn floatInwards :: ModGuts -> CoreM ModGuts -- | Module finder module GHC.Unit.Finder -- | The result of searching for an imported module. -- -- NB: FindResult manages both user source-import lookups (which can -- result in Module) as well as direct imports for interfaces -- (which always result in InstalledModule). data FindResult -- | The module was found Found :: ModLocation -> Module -> FindResult -- | The requested unit was not found NoPackage :: Unit -> FindResult -- | _Error_: both in multiple packages FoundMultiple :: [(Module, ModuleOrigin)] -> FindResult -- | Not found NotFound :: [FilePath] -> Maybe Unit -> [Unit] -> [Unit] -> [(Unit, UnusableUnitReason)] -> [ModuleSuggestion] -> FindResult -- | Places where I looked [fr_paths] :: FindResult -> [FilePath] -- | Just p => module is in this unit's manifest, but couldn't find the -- .hi file [fr_pkg] :: FindResult -> Maybe Unit -- | Module is in these units, but the *module* is hidden [fr_mods_hidden] :: FindResult -> [Unit] -- | Module is in these units, but the *unit* is hidden [fr_pkgs_hidden] :: FindResult -> [Unit] -- | Module is in these units, but it is unusable [fr_unusables] :: FindResult -> [(Unit, UnusableUnitReason)] -- | Possible mis-spelled modules [fr_suggestions] :: FindResult -> [ModuleSuggestion] data InstalledFindResult InstalledFound :: ModLocation -> InstalledModule -> InstalledFindResult InstalledNoPackage :: UnitId -> InstalledFindResult InstalledNotFound :: [FilePath] -> Maybe UnitId -> InstalledFindResult -- | The FinderCache maps modules to the result of searching for -- that module. It records the results of searching for modules along the -- search path. On :load, we flush the entire contents of this -- cache. type FinderCache = InstalledModuleEnv InstalledFindResult flushFinderCaches :: HscEnv -> IO () -- | Locate a module that was imported by the user. We have the module's -- name, and possibly a package name. Without a package name, this -- function will use the search path and the known exposed packages to -- find the module, if a package is specified then only that package is -- searched for the module. findImportedModule :: HscEnv -> ModuleName -> Maybe FastString -> IO FindResult -- | Locate a plugin module requested by the user, for a compiler plugin. -- This consults the same set of exposed packages as -- findImportedModule, unless -hide-all-plugin-packages -- or -plugin-package are specified. findPluginModule :: HscEnv -> ModuleName -> IO FindResult -- | Locate a specific Module. The purpose of this function is to -- create a ModLocation for a given Module, that is to find -- out where the files associated with this module live. It is used when -- reading the interface for a module mentioned by another interface, for -- example (a "system import"). findExactModule :: HscEnv -> InstalledModule -> IO InstalledFindResult findHomeModule :: HscEnv -> ModuleName -> IO FindResult findExposedPackageModule :: HscEnv -> ModuleName -> Maybe FastString -> IO FindResult mkHomeModLocation :: DynFlags -> ModuleName -> FilePath -> IO ModLocation mkHomeModLocation2 :: DynFlags -> ModuleName -> FilePath -> String -> IO ModLocation mkHiOnlyModLocation :: DynFlags -> Suffix -> FilePath -> String -> IO ModLocation -- | Constructs the filename of a .hi file for a given source file. Does -- not check whether the .hi file exists mkHiPath :: DynFlags -> FilePath -> String -> FilePath -- | Constructs the filename of a .o file for a given source file. Does -- not check whether the .o file exists mkObjPath :: DynFlags -> FilePath -> String -> FilePath addHomeModuleToFinder :: HscEnv -> ModuleName -> ModLocation -> IO Module uncacheModule :: HscEnv -> ModuleName -> IO () mkStubPaths :: DynFlags -> ModuleName -> ModLocation -> FilePath findObjectLinkableMaybe :: Module -> ModLocation -> IO (Maybe Linkable) findObjectLinkable :: Module -> FilePath -> UTCTime -> IO Linkable module GHC.HsToCore.Usage mkUsageInfo :: HscEnv -> Module -> ImportedMods -> NameSet -> [FilePath] -> [(Module, Fingerprint)] -> [ModIface] -> IO [Usage] mkUsedNames :: TcGblEnv -> NameSet -- | Extract information from the rename and typecheck phases to produce a -- dependencies information for the module being compiled. -- -- The second argument is additional dependencies from plugins mkDependencies :: UnitId -> [Module] -> TcGblEnv -> IO Dependencies -- | Interacting with the iserv interpreter, whether it is running on an -- external process or in the current process. module GHC.Runtime.Interpreter -- | Execute an action of type IO [a], returning -- ForeignHValues for each of the results. evalStmt :: Interp -> DynFlags -> Bool -> EvalExpr ForeignHValue -> IO (EvalStatus_ [ForeignHValue] [HValueRef]) data EvalStatus_ a b EvalComplete :: Word64 -> EvalResult a -> EvalStatus_ a b EvalBreak :: Bool -> HValueRef -> Int -> Int -> RemoteRef (ResumeContext b) -> RemotePtr CostCentreStack -> EvalStatus_ a b type EvalStatus a = EvalStatus_ a a data EvalResult a EvalException :: SerializableException -> EvalResult a EvalSuccess :: a -> EvalResult a -- | We can pass simple expressions to EvalStmt, consisting of values and -- application. This allows us to wrap the statement to be executed in -- another function, which is used by GHCi to implement :set args and -- :set prog. It might be worthwhile to extend this little language in -- the future. data EvalExpr a EvalThis :: a -> EvalExpr a EvalApp :: EvalExpr a -> EvalExpr a -> EvalExpr a resumeStmt :: Interp -> DynFlags -> Bool -> ForeignRef (ResumeContext [HValueRef]) -> IO (EvalStatus_ [ForeignHValue] [HValueRef]) abandonStmt :: Interp -> ForeignRef (ResumeContext [HValueRef]) -> IO () -- | Execute an action of type IO () evalIO :: Interp -> ForeignHValue -> IO () -- | Execute an action of type IO String evalString :: Interp -> ForeignHValue -> IO String -- | Execute an action of type String -> IO String evalStringToIOString :: Interp -> ForeignHValue -> String -> IO String -- | Allocate and store the given bytes in memory, returning a pointer to -- the memory in the remote process. mallocData :: Interp -> ByteString -> IO (RemotePtr ()) -- | Create a set of BCOs that may be mutually recursive. createBCOs :: Interp -> DynFlags -> [ResolvedBCO] -> IO [HValueRef] addSptEntry :: Interp -> Fingerprint -> ForeignHValue -> IO () mkCostCentres :: Interp -> String -> [(String, String)] -> IO [RemotePtr CostCentre] costCentreStackInfo :: Interp -> RemotePtr CostCentreStack -> IO [String] newBreakArray :: Interp -> Int -> IO (ForeignRef BreakArray) storeBreakpoint :: Interp -> ForeignRef BreakArray -> Int -> Int -> IO () breakpointStatus :: Interp -> ForeignRef BreakArray -> Int -> IO Bool getBreakpointVar :: Interp -> ForeignHValue -> Int -> IO (Maybe ForeignHValue) getClosure :: Interp -> ForeignHValue -> IO (GenClosure ForeignHValue) getModBreaks :: HomeModInfo -> ModBreaks -- | Send a Seq message to the iserv process to force a value #2950 seqHValue :: Interp -> HscEnv -> ForeignHValue -> IO (EvalResult ()) -- | Interpreter uses Dynamic way interpreterDynamic :: Interp -> Bool -- | Interpreter uses Profiling way interpreterProfiled :: Interp -> Bool initObjLinker :: Interp -> IO () lookupSymbol :: Interp -> FastString -> IO (Maybe (Ptr ())) lookupClosure :: Interp -> String -> IO (Maybe HValueRef) -- | loadDLL loads a dynamic library using the OS's native linker (i.e. -- dlopen() on Unix, LoadLibrary() on Windows). It takes either an -- absolute pathname to the file, or a relative filename (e.g. -- "libfoo.so" or "foo.dll"). In the latter case, loadDLL searches the -- standard locations for the appropriate library. -- -- Returns: -- -- Nothing => success Just err_msg => failure loadDLL :: Interp -> String -> IO (Maybe String) loadArchive :: Interp -> String -> IO () loadObj :: Interp -> String -> IO () unloadObj :: Interp -> String -> IO () addLibrarySearchPath :: Interp -> String -> IO (Ptr ()) removeLibrarySearchPath :: Interp -> Ptr () -> IO Bool resolveObjs :: Interp -> IO SuccessFlag findSystemLibrary :: Interp -> String -> IO (Maybe String) -- | Run a command in the interpreter's context. With -- -fexternal-interpreter, the command is serialized and sent to -- an external iserv process, and the response is deserialized (hence the -- Binary constraint). With -fno-external-interpreter -- we execute the command directly here. interpCmd :: Binary a => Interp -> Message a -> IO a -- | A Message a is a message that returns a value of type -- a. These are requests sent from GHC to the server. data Message a -- | Exit the iserv process [Shutdown] :: Message () [RtsRevertCAFs] :: Message () [InitLinker] :: Message () [LookupSymbol] :: String -> Message (Maybe (RemotePtr ())) [LookupClosure] :: String -> Message (Maybe HValueRef) [LoadDLL] :: String -> Message (Maybe String) [LoadArchive] :: String -> Message () [LoadObj] :: String -> Message () [UnloadObj] :: String -> Message () [AddLibrarySearchPath] :: String -> Message (RemotePtr ()) [RemoveLibrarySearchPath] :: RemotePtr () -> Message Bool [ResolveObjs] :: Message Bool [FindSystemLibrary] :: String -> Message (Maybe String) -- | Create a set of BCO objects, and return HValueRefs to them Note: Each -- ByteString contains a Binary-encoded [ResolvedBCO], not a ResolvedBCO. -- The list is to allow us to serialise the ResolvedBCOs in parallel. See -- createBCOs in compilerGHCRuntime/Interpreter.hs. [CreateBCOs] :: [ByteString] -> Message [HValueRef] -- | Release HValueRefs [FreeHValueRefs] :: [HValueRef] -> Message () -- | Add entries to the Static Pointer Table [AddSptEntry] :: Fingerprint -> HValueRef -> Message () -- | Malloc some data and return a RemotePtr to it [MallocData] :: ByteString -> Message (RemotePtr ()) [MallocStrings] :: [ByteString] -> Message [RemotePtr ()] -- | Calls prepareForeignCall [PrepFFI] :: FFIConv -> [FFIType] -> FFIType -> Message (RemotePtr C_ffi_cif) -- | Free data previously created by PrepFFI [FreeFFI] :: RemotePtr C_ffi_cif -> Message () -- | Create an info table for a constructor [MkConInfoTable] :: Bool -> Int -> Int -> Int -> Int -> ByteString -> Message (RemotePtr StgInfoTable) -- | Evaluate a statement [EvalStmt] :: EvalOpts -> EvalExpr HValueRef -> Message (EvalStatus_ [HValueRef] [HValueRef]) -- | Resume evaluation of a statement after a breakpoint [ResumeStmt] :: EvalOpts -> RemoteRef (ResumeContext [HValueRef]) -> Message (EvalStatus_ [HValueRef] [HValueRef]) -- | Abandon evaluation of a statement after a breakpoint [AbandonStmt] :: RemoteRef (ResumeContext [HValueRef]) -> Message () -- | Evaluate something of type IO String [EvalString] :: HValueRef -> Message (EvalResult String) -- | Evaluate something of type String -> IO String [EvalStringToString] :: HValueRef -> String -> Message (EvalResult String) -- | Evaluate something of type IO () [EvalIO] :: HValueRef -> Message (EvalResult ()) -- | Create a set of CostCentres with the same module name [MkCostCentres] :: String -> [(String, String)] -> Message [RemotePtr CostCentre] -- | Show a CostCentreStack as a [String] [CostCentreStackInfo] :: RemotePtr CostCentreStack -> Message [String] -- | Create a new array of breakpoint flags [NewBreakArray] :: Int -> Message (RemoteRef BreakArray) -- | Set how many times a breakpoint should be ignored also used for -- enable/disable [SetupBreakpoint] :: RemoteRef BreakArray -> Int -> Int -> Message () -- | Query the status of a breakpoint (True = enabled) [BreakpointStatus] :: RemoteRef BreakArray -> Int -> Message Bool -- | Get a reference to a free variable at a breakpoint [GetBreakpointVar] :: HValueRef -> Int -> Message (Maybe HValueRef) -- | Start a new TH module, return a state token that should be [StartTH] :: Message (RemoteRef (IORef QState)) -- | Evaluate a TH computation. -- -- Returns a ByteString, because we have to force the result before -- returning it to ensure there are no errors lurking in it. The TH types -- don't have NFData instances, and even if they did, we have to -- serialize the value anyway, so we might as well serialize it to force -- it. [RunTH] :: RemoteRef (IORef QState) -> HValueRef -> THResultType -> Maybe Loc -> Message (QResult ByteString) -- | Run the given mod finalizers. [RunModFinalizers] :: RemoteRef (IORef QState) -> [RemoteRef (Q ())] -> Message (QResult ()) -- | Remote interface to GHC.Exts.Heap.getClosureData. This is used by the -- GHCi debugger to inspect values in the heap for :print and type -- reconstruction. [GetClosure] :: HValueRef -> Message (GenClosure HValueRef) -- | Evaluate something. This is used to support :force in GHCi. [Seq] :: HValueRef -> Message (EvalStatus_ () ()) -- | Resume forcing a free variable in a breakpoint (#2950) [ResumeSeq] :: RemoteRef (ResumeContext ()) -> Message (EvalStatus_ () ()) -- | Grab a lock on the IServ and do something with it. Overloaded -- because this is used from TcM as well as IO. withIServ :: ExceptionMonad m => IServConfig -> IServ -> (IServInstance -> m (IServInstance, a)) -> m a withIServ_ :: (MonadIO m, ExceptionMonad m) => IServConfig -> IServ -> (IServInstance -> m a) -> m a -- | Retrieve the target code interpreter -- -- Fails if no target code interpreter is available hscInterp :: HscEnv -> Interp -- | Stop the interpreter stopInterp :: Interp -> IO () -- | Send a Message and receive the response from the iserv process iservCall :: Binary a => IServInstance -> Message a -> IO a -- | Read a value from the iserv process readIServ :: IServInstance -> Get a -> IO a -- | Send a value to the iserv process writeIServ :: IServInstance -> Put -> IO () purgeLookupSymbolCache :: Interp -> IO () freeHValueRefs :: Interp -> [HValueRef] -> IO () -- | Creates a ForeignRef that will automatically release the -- RemoteRef when it is no longer referenced. mkFinalizedHValue :: Interp -> RemoteRef a -> IO (ForeignRef a) -- | Convert a ForeignRef to the value it references directly. This -- only works when the interpreter is running in the same process as the -- compiler, so it fails when -fexternal-interpreter is on. wormhole :: Interp -> ForeignRef a -> IO a -- | Convert an RemoteRef to the value it references directly. This -- only works when the interpreter is running in the same process as the -- compiler, so it fails when -fexternal-interpreter is on. wormholeRef :: Interp -> RemoteRef a -> IO a mkEvalOpts :: DynFlags -> Bool -> EvalOpts fromEvalResult :: EvalResult a -> IO a module GHC.HsToCore.Coverage addTicksToBinds :: HscEnv -> Module -> ModLocation -> NameSet -> [TyCon] -> LHsBinds GhcTc -> IO (LHsBinds GhcTc, HpcInfo, Maybe ModBreaks) hpcInitCode :: DynFlags -> Module -> HpcInfo -> CStub instance GHC.Classes.Eq GHC.HsToCore.Coverage.TickDensity instance GHC.Classes.Eq GHC.HsToCore.Coverage.TickishType instance GHC.Base.Functor GHC.HsToCore.Coverage.TM instance GHC.Base.Applicative GHC.HsToCore.Coverage.TM instance GHC.Base.Monad GHC.HsToCore.Coverage.TM instance GHC.Driver.Session.HasDynFlags GHC.HsToCore.Coverage.TM -- | Bytecode assembler and linker module GHC.ByteCode.Linker type ClosureEnv = NameEnv (Name, ForeignHValue) emptyClosureEnv :: ClosureEnv extendClosureEnv :: ClosureEnv -> [(Name, ForeignHValue)] -> ClosureEnv linkBCO :: Interp -> ItblEnv -> ClosureEnv -> NameEnv Int -> RemoteRef BreakArray -> UnlinkedBCO -> IO ResolvedBCO lookupStaticPtr :: Interp -> FastString -> IO (Ptr ()) lookupIE :: Interp -> ItblEnv -> Name -> IO (Ptr ()) nameToCLabel :: Name -> String -> FastString linkFail :: String -> String -> IO a module GHC.CmmToAsm.X86.Regs -- | regSqueeze_class reg Calculate the maximum number of register colors -- that could be denied to a node of this class due to having this reg as -- a neighbour. virtualRegSqueeze :: RegClass -> VirtualReg -> Int realRegSqueeze :: RegClass -> RealReg -> Int data Imm ImmInt :: Int -> Imm ImmInteger :: Integer -> Imm ImmCLbl :: CLabel -> Imm ImmLit :: SDoc -> Imm ImmIndex :: CLabel -> Int -> Imm ImmFloat :: Rational -> Imm ImmDouble :: Rational -> Imm ImmConstantSum :: Imm -> Imm -> Imm ImmConstantDiff :: Imm -> Imm -> Imm strImmLit :: String -> Imm litToImm :: CmmLit -> Imm data AddrMode AddrBaseIndex :: EABase -> EAIndex -> Displacement -> AddrMode ImmAddr :: Imm -> Int -> AddrMode addrOffset :: AddrMode -> Int -> Maybe AddrMode spRel :: Platform -> Int -> AddrMode argRegs :: RegNo -> [Reg] allArgRegs :: Platform -> [(Reg, Reg)] allIntArgRegs :: Platform -> [Reg] -- | these are the regs which we cannot assume stay alive over a C call. callClobberedRegs :: Platform -> [Reg] instrClobberedRegs :: Platform -> [Reg] -- | The complete set of machine registers. allMachRegNos :: Platform -> [RegNo] -- | Take the class of a register. classOfRealReg :: Platform -> RealReg -> RegClass -- | Get the name of the register with this number. NOTE: fixme, we dont -- track which "way" the XMM registers are used showReg :: Platform -> RegNo -> String data EABase EABaseNone :: EABase EABaseReg :: Reg -> EABase EABaseRip :: EABase data EAIndex EAIndexNone :: EAIndex EAIndex :: Reg -> Int -> EAIndex addrModeRegs :: AddrMode -> [Reg] eax :: Reg ebx :: Reg ecx :: Reg edx :: Reg esi :: Reg edi :: Reg ebp :: Reg esp :: Reg rax :: Reg rbx :: Reg rcx :: Reg rdx :: Reg rsi :: Reg rdi :: Reg rbp :: Reg rsp :: Reg r8 :: Reg r9 :: Reg r10 :: Reg r11 :: Reg r12 :: Reg r13 :: Reg r14 :: Reg r15 :: Reg lastint :: Platform -> RegNo xmm0 :: Reg xmm1 :: Reg xmm2 :: Reg xmm3 :: Reg xmm4 :: Reg xmm5 :: Reg xmm6 :: Reg xmm7 :: Reg xmm8 :: Reg xmm9 :: Reg xmm10 :: Reg xmm11 :: Reg xmm12 :: Reg xmm13 :: Reg xmm14 :: Reg xmm15 :: Reg xmm :: RegNo -> Reg firstxmm :: RegNo lastxmm :: Platform -> RegNo ripRel :: Displacement -> AddrMode -- | on 64bit platforms we pass the first 8 float/double arguments in the -- xmm registers. allFPArgRegs :: Platform -> [Reg] allocatableRegs :: Platform -> [RealReg] -- | Free regs map for x86_64 module GHC.CmmToAsm.Reg.Linear.X86_64 newtype FreeRegs FreeRegs :: Word64 -> FreeRegs noFreeRegs :: FreeRegs releaseReg :: RealReg -> FreeRegs -> FreeRegs initFreeRegs :: Platform -> FreeRegs getFreeRegs :: Platform -> RegClass -> FreeRegs -> [RealReg] allocateReg :: RealReg -> FreeRegs -> FreeRegs instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.Reg.Linear.X86_64.FreeRegs instance GHC.Show.Show GHC.CmmToAsm.Reg.Linear.X86_64.FreeRegs -- | Free regs map for i386 module GHC.CmmToAsm.Reg.Linear.X86 newtype FreeRegs FreeRegs :: Word32 -> FreeRegs noFreeRegs :: FreeRegs releaseReg :: RealReg -> FreeRegs -> FreeRegs initFreeRegs :: Platform -> FreeRegs getFreeRegs :: Platform -> RegClass -> FreeRegs -> [RealReg] allocateReg :: RealReg -> FreeRegs -> FreeRegs instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.Reg.Linear.X86.FreeRegs instance GHC.Show.Show GHC.CmmToAsm.Reg.Linear.X86.FreeRegs module GHC.CmmToAsm.Utils -- | Returns the info table associated with the CmmDecl's entry point, if -- any. topInfoTable :: GenCmmDecl a (LabelMap i) (ListGraph b) -> Maybe i -- | Return the list of BlockIds in a CmmDecl that are entry points for -- this proc (i.e. they may be jumped to from outside this proc). entryBlocks :: GenCmmDecl a (LabelMap i) (ListGraph b) -> [BlockId] module GHC.CmmToAsm.Types type NatCmm instr = GenCmmGroup RawCmmStatics (LabelMap RawCmmStatics) (ListGraph instr) type NatCmmDecl statics instr = GenCmmDecl statics (LabelMap RawCmmStatics) (ListGraph instr) type NatBasicBlock instr = GenBasicBlock instr data GenBasicBlock i BasicBlock :: BlockId -> [i] -> GenBasicBlock i -- | The branch block id is that of the first block in the branch, which is -- that branch's entry point blockId :: GenBasicBlock i -> BlockId newtype ListGraph i ListGraph :: [GenBasicBlock i] -> ListGraph i type RawCmmStatics = GenCmmStatics 'True type RawCmmDecl = GenCmmDecl RawCmmStatics (LabelMap RawCmmStatics) CmmGraph module GHC.CmmToAsm.SPARC.Imm -- | An immediate value. Not all of these are directly representable by the -- machine. Things like ImmLit are slurped out and put in a data segment -- instead. data Imm ImmInt :: Int -> Imm ImmInteger :: Integer -> Imm ImmCLbl :: CLabel -> Imm ImmLit :: SDoc -> Imm ImmIndex :: CLabel -> Int -> Imm ImmFloat :: Rational -> Imm ImmDouble :: Rational -> Imm ImmConstantSum :: Imm -> Imm -> Imm ImmConstantDiff :: Imm -> Imm -> Imm LO :: Imm -> Imm HI :: Imm -> Imm -- | Create a ImmLit containing this string. strImmLit :: String -> Imm -- | Convert a CmmLit to an Imm. Narrow to the width: a CmmInt might be out -- of range, but we assume that ImmInteger only contains in-range values. -- A signed value should be fine here. litToImm :: CmmLit -> Imm module GHC.CmmToAsm.SPARC.AddrMode -- | Represents a memory address in an instruction. Being a RISC machine, -- the SPARC addressing modes are very regular. data AddrMode AddrRegReg :: Reg -> Reg -> AddrMode AddrRegImm :: Reg -> Imm -> AddrMode -- | Add an integer offset to the address in an AddrMode. addrOffset :: AddrMode -> Int -> Maybe AddrMode module GHC.CmmToAsm.Ppr doubleToBytes :: Double -> [Int] pprASCII :: ByteString -> SDoc -- | Emit a ".string" directive pprString :: ByteString -> SDoc -- | Emit a ".incbin" directive -- -- A NULL byte is added after the binary data. pprFileEmbed :: FilePath -> SDoc pprSectionHeader :: NCGConfig -> Section -> SDoc -- | The LLVM Type System. module GHC.Llvm.Types -- | A global mutable variable. Maybe defined or external data LMGlobal LMGlobal :: LlvmVar -> Maybe LlvmStatic -> LMGlobal -- | Returns the variable of the LMGlobal [getGlobalVar] :: LMGlobal -> LlvmVar -- | Return the value of the LMGlobal [getGlobalValue] :: LMGlobal -> Maybe LlvmStatic -- | A String in LLVM type LMString = FastString -- | A type alias type LlvmAlias = (LMString, LlvmType) -- | Llvm Types data LlvmType -- | An integer with a given width in bits. LMInt :: Int -> LlvmType -- | 32 bit floating point LMFloat :: LlvmType -- | 64 bit floating point LMDouble :: LlvmType -- | 80 bit (x86 only) floating point LMFloat80 :: LlvmType -- | 128 bit floating point LMFloat128 :: LlvmType -- | A pointer to a LlvmType LMPointer :: LlvmType -> LlvmType -- | An array of LlvmType LMArray :: Int -> LlvmType -> LlvmType -- | A vector of LlvmType LMVector :: Int -> LlvmType -> LlvmType -- | A LlvmVar can represent a label (address) LMLabel :: LlvmType -- | Void type LMVoid :: LlvmType -- | Packed structure type LMStruct :: [LlvmType] -> LlvmType -- | Unpacked structure type LMStructU :: [LlvmType] -> LlvmType -- | A type alias LMAlias :: LlvmAlias -> LlvmType -- | LLVM Metadata LMMetadata :: LlvmType -- | Function type, used to create pointers to functions LMFunction :: LlvmFunctionDecl -> LlvmType ppType :: LlvmType -> SDoc ppParams :: LlvmParameterListType -> [LlvmParameter] -> SDoc -- | An LLVM section definition. If Nothing then let LLVM decide the -- section type LMSection = Maybe LMString type LMAlign = Maybe Int data LMConst -- | Mutable global variable Global :: LMConst -- | Constant global variable Constant :: LMConst -- | Alias of another variable Alias :: LMConst -- | LLVM Variables data LlvmVar -- | Variables with a global scope. LMGlobalVar :: LMString -> LlvmType -> LlvmLinkageType -> LMSection -> LMAlign -> LMConst -> LlvmVar -- | Variables local to a function or parameters. LMLocalVar :: Unique -> LlvmType -> LlvmVar -- | Named local variables. Sometimes we need to be able to explicitly name -- variables (e.g for function arguments). LMNLocalVar :: LMString -> LlvmType -> LlvmVar -- | A constant variable LMLitVar :: LlvmLit -> LlvmVar -- | Llvm Literal Data. -- -- These can be used inline in expressions. data LlvmLit -- | Refers to an integer constant (i64 42). LMIntLit :: Integer -> LlvmType -> LlvmLit -- | Floating point literal LMFloatLit :: Double -> LlvmType -> LlvmLit -- | Literal NULL, only applicable to pointer types LMNullLit :: LlvmType -> LlvmLit -- | Vector literal LMVectorLit :: [LlvmLit] -> LlvmLit -- | Undefined value, random bit pattern. Useful for optimisations. LMUndefLit :: LlvmType -> LlvmLit -- | Llvm Static Data. -- -- These represent the possible global level variables and constants. data LlvmStatic -- | A comment in a static section LMComment :: LMString -> LlvmStatic -- | A static variant of a literal value LMStaticLit :: LlvmLit -> LlvmStatic -- | For uninitialised data LMUninitType :: LlvmType -> LlvmStatic -- | Defines a static LMString LMStaticStr :: LMString -> LlvmType -> LlvmStatic -- | A static array LMStaticArray :: [LlvmStatic] -> LlvmType -> LlvmStatic -- | A static structure type LMStaticStruc :: [LlvmStatic] -> LlvmType -> LlvmStatic -- | A pointer to other data LMStaticPointer :: LlvmVar -> LlvmStatic -- | Truncate LMTrunc :: LlvmStatic -> LlvmType -> LlvmStatic -- | Pointer to Pointer conversion LMBitc :: LlvmStatic -> LlvmType -> LlvmStatic -- | Pointer to Integer conversion LMPtoI :: LlvmStatic -> LlvmType -> LlvmStatic -- | Constant addition operation LMAdd :: LlvmStatic -> LlvmStatic -> LlvmStatic -- | Constant subtraction operation LMSub :: LlvmStatic -> LlvmStatic -> LlvmStatic -- | LLVM code generator options data LlvmOpts LlvmOpts :: !Platform -> !Bool -> !Bool -> LlvmOpts -- | Target platform [llvmOptsPlatform] :: LlvmOpts -> !Platform -- | Fill undefined literals with garbage values [llvmOptsFillUndefWithGarbage] :: LlvmOpts -> !Bool -- | Split sections [llvmOptsSplitSections] :: LlvmOpts -> !Bool -- | Get LlvmOptions from DynFlags initLlvmOpts :: DynFlags -> LlvmOpts garbageLit :: LlvmType -> Maybe LlvmLit -- | Return the LlvmType of the LlvmVar getVarType :: LlvmVar -> LlvmType -- | Return the LlvmType of a LlvmLit getLitType :: LlvmLit -> LlvmType -- | Return the LlvmType of the LlvmStatic getStatType :: LlvmStatic -> LlvmType -- | Return the LlvmLinkageType for a LlvmVar getLink :: LlvmVar -> LlvmLinkageType -- | Add a pointer indirection to the supplied type. LMLabel and -- LMVoid cannot be lifted. pLift :: LlvmType -> LlvmType -- | Lift a variable to LMPointer type. pVarLift :: LlvmVar -> LlvmVar -- | Remove the pointer indirection of the supplied type. Only -- LMPointer constructors can be lowered. pLower :: LlvmType -> LlvmType -- | Lower a variable of LMPointer type. pVarLower :: LlvmVar -> LlvmVar -- | Test if the given LlvmType is an integer isInt :: LlvmType -> Bool -- | Test if the given LlvmType is a floating point type isFloat :: LlvmType -> Bool -- | Test if the given LlvmType is an LMPointer construct isPointer :: LlvmType -> Bool -- | Test if the given LlvmType is an LMVector construct isVector :: LlvmType -> Bool -- | Test if a LlvmVar is global. isGlobal :: LlvmVar -> Bool -- | Width in bits of an LlvmType, returns 0 if not applicable llvmWidthInBits :: Platform -> LlvmType -> Int i128 :: LlvmType i64 :: LlvmType i32 :: LlvmType i16 :: LlvmType i8 :: LlvmType i1 :: LlvmType i8Ptr :: LlvmType -- | The target architectures word size llvmWord :: Platform -> LlvmType -- | The target architectures word size llvmWordPtr :: Platform -> LlvmType -- | An LLVM Function data LlvmFunctionDecl LlvmFunctionDecl :: LMString -> LlvmLinkageType -> LlvmCallConvention -> LlvmType -> LlvmParameterListType -> [LlvmParameter] -> LMAlign -> LlvmFunctionDecl -- | Unique identifier of the function [decName] :: LlvmFunctionDecl -> LMString -- | LinkageType of the function [funcLinkage] :: LlvmFunctionDecl -> LlvmLinkageType -- | The calling convention of the function [funcCc] :: LlvmFunctionDecl -> LlvmCallConvention -- | Type of the returned value [decReturnType] :: LlvmFunctionDecl -> LlvmType -- | Indicates if this function uses varargs [decVarargs] :: LlvmFunctionDecl -> LlvmParameterListType -- | Parameter types and attributes [decParams] :: LlvmFunctionDecl -> [LlvmParameter] -- | Function align value, must be power of 2 [funcAlign] :: LlvmFunctionDecl -> LMAlign type LlvmFunctionDecls = [LlvmFunctionDecl] type LlvmParameter = (LlvmType, [LlvmParamAttr]) -- | LLVM Parameter Attributes. -- -- Parameter attributes are used to communicate additional information -- about the result or parameters of a function data LlvmParamAttr -- | This indicates to the code generator that the parameter or return -- value should be zero-extended to a 32-bit value by the caller (for a -- parameter) or the callee (for a return value). ZeroExt :: LlvmParamAttr -- | This indicates to the code generator that the parameter or return -- value should be sign-extended to a 32-bit value by the caller (for a -- parameter) or the callee (for a return value). SignExt :: LlvmParamAttr -- | This indicates that this parameter or return value should be treated -- in a special target-dependent fashion during while emitting code for a -- function call or return (usually, by putting it in a register as -- opposed to memory). InReg :: LlvmParamAttr -- | This indicates that the pointer parameter should really be passed by -- value to the function. ByVal :: LlvmParamAttr -- | This indicates that the pointer parameter specifies the address of a -- structure that is the return value of the function in the source -- program. SRet :: LlvmParamAttr -- | This indicates that the pointer does not alias any global or any other -- parameter. NoAlias :: LlvmParamAttr -- | This indicates that the callee does not make any copies of the pointer -- that outlive the callee itself NoCapture :: LlvmParamAttr -- | This indicates that the pointer parameter can be excised using the -- trampoline intrinsics. Nest :: LlvmParamAttr -- | Llvm Function Attributes. -- -- Function attributes are set to communicate additional information -- about a function. Function attributes are considered to be part of the -- function, not of the function type, so functions with different -- parameter attributes can have the same function type. Functions can -- have multiple attributes. -- -- Descriptions taken from -- http://llvm.org/docs/LangRef.html#fnattrs data LlvmFuncAttr -- | This attribute indicates that the inliner should attempt to inline -- this function into callers whenever possible, ignoring any active -- inlining size threshold for this caller. AlwaysInline :: LlvmFuncAttr -- | This attribute indicates that the source code contained a hint that -- inlining this function is desirable (such as the "inline" keyword in -- C/C++). It is just a hint; it imposes no requirements on the inliner. InlineHint :: LlvmFuncAttr -- | This attribute indicates that the inliner should never inline this -- function in any situation. This attribute may not be used together -- with the alwaysinline attribute. NoInline :: LlvmFuncAttr -- | This attribute suggests that optimization passes and code generator -- passes make choices that keep the code size of this function low, and -- otherwise do optimizations specifically to reduce code size. OptSize :: LlvmFuncAttr -- | This function attribute indicates that the function never returns -- normally. This produces undefined behavior at runtime if the function -- ever does dynamically return. NoReturn :: LlvmFuncAttr -- | This function attribute indicates that the function never returns with -- an unwind or exceptional control flow. If the function does unwind, -- its runtime behavior is undefined. NoUnwind :: LlvmFuncAttr -- | This attribute indicates that the function computes its result (or -- decides to unwind an exception) based strictly on its arguments, -- without dereferencing any pointer arguments or otherwise accessing any -- mutable state (e.g. memory, control registers, etc) visible to caller -- functions. It does not write through any pointer arguments (including -- byval arguments) and never changes any state visible to callers. This -- means that it cannot unwind exceptions by calling the C++ exception -- throwing methods, but could use the unwind instruction. ReadNone :: LlvmFuncAttr -- | This attribute indicates that the function does not write through any -- pointer arguments (including byval arguments) or otherwise modify any -- state (e.g. memory, control registers, etc) visible to caller -- functions. It may dereference pointer arguments and read state that -- may be set in the caller. A readonly function always returns the same -- value (or unwinds an exception identically) when called with the same -- set of arguments and global state. It cannot unwind an exception by -- calling the C++ exception throwing methods, but may use the unwind -- instruction. ReadOnly :: LlvmFuncAttr -- | This attribute indicates that the function should emit a stack -- smashing protector. It is in the form of a "canary"—a random value -- placed on the stack before the local variables that's checked upon -- return from the function to see if it has been overwritten. A -- heuristic is used to determine if a function needs stack protectors or -- not. -- -- If a function that has an ssp attribute is inlined into a function -- that doesn't have an ssp attribute, then the resulting function will -- have an ssp attribute. Ssp :: LlvmFuncAttr -- | This attribute indicates that the function should always emit a stack -- smashing protector. This overrides the ssp function attribute. -- -- If a function that has an sspreq attribute is inlined into a function -- that doesn't have an sspreq attribute or which has an ssp attribute, -- then the resulting function will have an sspreq attribute. SspReq :: LlvmFuncAttr -- | This attribute indicates that the code generator should not use a red -- zone, even if the target-specific ABI normally permits it. NoRedZone :: LlvmFuncAttr -- | This attributes disables implicit floating point instructions. NoImplicitFloat :: LlvmFuncAttr -- | This attribute disables prologue / epilogue emission for the function. -- This can have very system-specific consequences. Naked :: LlvmFuncAttr -- | Different types to call a function. data LlvmCallType -- | Normal call, allocate a new stack frame. StdCall :: LlvmCallType -- | Tail call, perform the call in the current stack frame. TailCall :: LlvmCallType -- | Different calling conventions a function can use. data LlvmCallConvention -- | The C calling convention. This calling convention (the default if no -- other calling convention is specified) matches the target C calling -- conventions. This calling convention supports varargs function calls -- and tolerates some mismatch in the declared prototype and implemented -- declaration of the function (as does normal C). CC_Ccc :: LlvmCallConvention -- | This calling convention attempts to make calls as fast as possible -- (e.g. by passing things in registers). This calling convention allows -- the target to use whatever tricks it wants to produce fast code for -- the target, without having to conform to an externally specified ABI -- (Application Binary Interface). Implementations of this convention -- should allow arbitrary tail call optimization to be supported. This -- calling convention does not support varargs and requires the prototype -- of al callees to exactly match the prototype of the function -- definition. CC_Fastcc :: LlvmCallConvention -- | This calling convention attempts to make code in the caller as -- efficient as possible under the assumption that the call is not -- commonly executed. As such, these calls often preserve all registers -- so that the call does not break any live ranges in the caller side. -- This calling convention does not support varargs and requires the -- prototype of all callees to exactly match the prototype of the -- function definition. CC_Coldcc :: LlvmCallConvention -- | The GHC-specific registerised calling convention. CC_Ghc :: LlvmCallConvention -- | Any calling convention may be specified by number, allowing -- target-specific calling conventions to be used. Target specific -- calling conventions start at 64. CC_Ncc :: Int -> LlvmCallConvention -- | X86 Specific StdCall convention. LLVM includes a specific alias -- for it rather than just using CC_Ncc. CC_X86_Stdcc :: LlvmCallConvention -- | Functions can have a fixed amount of parameters, or a variable amount. data LlvmParameterListType FixedArgs :: LlvmParameterListType VarArgs :: LlvmParameterListType -- | Linkage type of a symbol. -- -- The description of the constructors is copied from the Llvm Assembly -- Language Reference Manual -- http://www.llvm.org/docs/LangRef.html#linkage, because they -- correspond to the Llvm linkage types. data LlvmLinkageType -- | Global values with internal linkage are only directly accessible by -- objects in the current module. In particular, linking code into a -- module with an internal global value may cause the internal to be -- renamed as necessary to avoid collisions. Because the symbol is -- internal to the module, all references can be updated. This -- corresponds to the notion of the static keyword in C. Internal :: LlvmLinkageType -- | Globals with linkonce linkage are merged with other globals -- of the same name when linkage occurs. This is typically used to -- implement inline functions, templates, or other code which must be -- generated in each translation unit that uses it. Unreferenced linkonce -- globals are allowed to be discarded. LinkOnce :: LlvmLinkageType -- | weak linkage is exactly the same as linkonce linkage, except -- that unreferenced weak globals may not be discarded. This is used for -- globals that may be emitted in multiple translation units, but that -- are not guaranteed to be emitted into every translation unit that uses -- them. One example of this are common globals in C, such as int -- X; at global scope. Weak :: LlvmLinkageType -- | appending linkage may only be applied to global variables of -- pointer to array type. When two global variables with appending -- linkage are linked together, the two global arrays are appended -- together. This is the Llvm, typesafe, equivalent of having the system -- linker append together sections with identical names when .o -- files are linked. Appending :: LlvmLinkageType -- | The semantics of this linkage follow the ELF model: the symbol is weak -- until linked, if not linked, the symbol becomes null instead of being -- an undefined reference. ExternWeak :: LlvmLinkageType -- | The symbol participates in linkage and can be used to resolve external -- symbol references. ExternallyVisible :: LlvmLinkageType -- | Alias for ExternallyVisible but with explicit textual form in -- LLVM assembly. External :: LlvmLinkageType -- | Symbol is private to the module and should not appear in the symbol -- table Private :: LlvmLinkageType -- | Llvm binary operators machine operations. data LlvmMachOp -- | add two integer, floating point or vector values. LM_MO_Add :: LlvmMachOp -- | subtract two ... LM_MO_Sub :: LlvmMachOp -- | multiply .. LM_MO_Mul :: LlvmMachOp -- | unsigned integer or vector division. LM_MO_UDiv :: LlvmMachOp -- | signed integer .. LM_MO_SDiv :: LlvmMachOp -- | unsigned integer or vector remainder (mod) LM_MO_URem :: LlvmMachOp -- | signed ... LM_MO_SRem :: LlvmMachOp -- | add two floating point or vector values. LM_MO_FAdd :: LlvmMachOp -- | subtract two ... LM_MO_FSub :: LlvmMachOp -- | multiply ... LM_MO_FMul :: LlvmMachOp -- | divide ... LM_MO_FDiv :: LlvmMachOp -- | remainder ... LM_MO_FRem :: LlvmMachOp -- | Left shift LM_MO_Shl :: LlvmMachOp -- | Logical shift right Shift right, filling with zero LM_MO_LShr :: LlvmMachOp -- | Arithmetic shift right The most significant bits of the result will be -- equal to the sign bit of the left operand. LM_MO_AShr :: LlvmMachOp -- | AND bitwise logical operation. LM_MO_And :: LlvmMachOp -- | OR bitwise logical operation. LM_MO_Or :: LlvmMachOp -- | XOR bitwise logical operation. LM_MO_Xor :: LlvmMachOp -- | Llvm compare operations. data LlvmCmpOp -- | Equal (Signed and Unsigned) LM_CMP_Eq :: LlvmCmpOp -- | Not equal (Signed and Unsigned) LM_CMP_Ne :: LlvmCmpOp -- | Unsigned greater than LM_CMP_Ugt :: LlvmCmpOp -- | Unsigned greater than or equal LM_CMP_Uge :: LlvmCmpOp -- | Unsigned less than LM_CMP_Ult :: LlvmCmpOp -- | Unsigned less than or equal LM_CMP_Ule :: LlvmCmpOp -- | Signed greater than LM_CMP_Sgt :: LlvmCmpOp -- | Signed greater than or equal LM_CMP_Sge :: LlvmCmpOp -- | Signed less than LM_CMP_Slt :: LlvmCmpOp -- | Signed less than or equal LM_CMP_Sle :: LlvmCmpOp -- | Float equal LM_CMP_Feq :: LlvmCmpOp -- | Float not equal LM_CMP_Fne :: LlvmCmpOp -- | Float greater than LM_CMP_Fgt :: LlvmCmpOp -- | Float greater than or equal LM_CMP_Fge :: LlvmCmpOp -- | Float less than LM_CMP_Flt :: LlvmCmpOp -- | Float less than or equal LM_CMP_Fle :: LlvmCmpOp -- | Llvm cast operations. data LlvmCastOp -- | Integer truncate LM_Trunc :: LlvmCastOp -- | Integer extend (zero fill) LM_Zext :: LlvmCastOp -- | Integer extend (sign fill) LM_Sext :: LlvmCastOp -- | Float truncate LM_Fptrunc :: LlvmCastOp -- | Float extend LM_Fpext :: LlvmCastOp -- | Float to unsigned Integer LM_Fptoui :: LlvmCastOp -- | Float to signed Integer LM_Fptosi :: LlvmCastOp -- | Unsigned Integer to Float LM_Uitofp :: LlvmCastOp -- | Signed Int to Float LM_Sitofp :: LlvmCastOp -- | Pointer to Integer LM_Ptrtoint :: LlvmCastOp -- | Integer to Pointer LM_Inttoptr :: LlvmCastOp -- | Cast between types where no bit manipulation is needed LM_Bitcast :: LlvmCastOp -- | Convert a Haskell Double to an LLVM hex encoded floating point form. -- In Llvm float literals can be printed in a big-endian hexadecimal -- format, regardless of underlying architecture. -- -- See Note [LLVM Float Types]. ppDouble :: Platform -> Double -> SDoc narrowFp :: Double -> Float widenFp :: Float -> Double ppFloat :: Platform -> Float -> SDoc ppCommaJoin :: Outputable a => [a] -> SDoc ppSpaceJoin :: Outputable a => [a] -> SDoc instance GHC.Classes.Eq GHC.Llvm.Types.LMConst instance GHC.Classes.Eq GHC.Llvm.Types.LlvmParamAttr instance GHC.Classes.Eq GHC.Llvm.Types.LlvmFuncAttr instance GHC.Show.Show GHC.Llvm.Types.LlvmCallType instance GHC.Classes.Eq GHC.Llvm.Types.LlvmCallType instance GHC.Classes.Eq GHC.Llvm.Types.LlvmCallConvention instance GHC.Show.Show GHC.Llvm.Types.LlvmParameterListType instance GHC.Classes.Eq GHC.Llvm.Types.LlvmParameterListType instance GHC.Classes.Eq GHC.Llvm.Types.LlvmLinkageType instance GHC.Classes.Eq GHC.Llvm.Types.LlvmType instance GHC.Classes.Eq GHC.Llvm.Types.LlvmFunctionDecl instance GHC.Classes.Eq GHC.Llvm.Types.LlvmLit instance GHC.Classes.Eq GHC.Llvm.Types.LlvmVar instance GHC.Classes.Eq GHC.Llvm.Types.LlvmMachOp instance GHC.Classes.Eq GHC.Llvm.Types.LlvmCmpOp instance GHC.Classes.Eq GHC.Llvm.Types.LlvmCastOp instance GHC.Utils.Outputable.Outputable GHC.Llvm.Types.LlvmCastOp instance GHC.Utils.Outputable.Outputable GHC.Llvm.Types.LlvmCmpOp instance GHC.Utils.Outputable.Outputable GHC.Llvm.Types.LlvmMachOp instance GHC.Utils.Outputable.Outputable GHC.Llvm.Types.LlvmType instance GHC.Utils.Outputable.Outputable GHC.Llvm.Types.LlvmFunctionDecl instance GHC.Utils.Outputable.Outputable GHC.Llvm.Types.LlvmLinkageType instance GHC.Utils.Outputable.Outputable GHC.Llvm.Types.LlvmCallConvention instance GHC.Utils.Outputable.Outputable GHC.Llvm.Types.LlvmFuncAttr instance GHC.Utils.Outputable.Outputable GHC.Llvm.Types.LlvmParamAttr module GHC.Llvm.MetaData -- | A reference to an un-named metadata node. newtype MetaId MetaId :: Int -> MetaId -- | LLVM metadata expressions data MetaExpr MetaStr :: !LMString -> MetaExpr MetaNode :: !MetaId -> MetaExpr MetaVar :: !LlvmVar -> MetaExpr MetaStruct :: [MetaExpr] -> MetaExpr -- | Associates some metadata with a specific label for attaching to an -- instruction. data MetaAnnot MetaAnnot :: LMString -> MetaExpr -> MetaAnnot -- | Metadata declarations. Metadata can only be declared in global scope. data MetaDecl -- | Named metadata. Only used for communicating module information to -- LLVM. ('!name = !{ [!<n>] }' form). MetaNamed :: !LMString -> [MetaId] -> MetaDecl -- | Metadata node declaration. ('!0 = metadata !{ <metadata -- expression> }' form). MetaUnnamed :: !MetaId -> !MetaExpr -> MetaDecl instance GHC.Enum.Enum GHC.Llvm.MetaData.MetaId instance GHC.Classes.Ord GHC.Llvm.MetaData.MetaId instance GHC.Classes.Eq GHC.Llvm.MetaData.MetaId instance GHC.Classes.Eq GHC.Llvm.MetaData.MetaExpr instance GHC.Classes.Eq GHC.Llvm.MetaData.MetaAnnot instance GHC.Utils.Outputable.Outputable GHC.Llvm.MetaData.MetaId -- | The LLVM abstract syntax. module GHC.Llvm.Syntax -- | Block labels type LlvmBlockId = Unique -- | A block of LLVM code. data LlvmBlock LlvmBlock :: LlvmBlockId -> [LlvmStatement] -> LlvmBlock -- | The code label for this block [blockLabel] :: LlvmBlock -> LlvmBlockId -- | A list of LlvmStatement's representing the code for this block. This -- list must end with a control flow statement. [blockStmts] :: LlvmBlock -> [LlvmStatement] type LlvmBlocks = [LlvmBlock] -- | An LLVM Module. This is a top level container in LLVM. data LlvmModule LlvmModule :: [LMString] -> [LlvmAlias] -> [MetaDecl] -> [LMGlobal] -> LlvmFunctionDecls -> LlvmFunctions -> LlvmModule -- | Comments to include at the start of the module. [modComments] :: LlvmModule -> [LMString] -- | LLVM Alias type definitions. [modAliases] :: LlvmModule -> [LlvmAlias] -- | LLVM meta data. [modMeta] :: LlvmModule -> [MetaDecl] -- | Global variables to include in the module. [modGlobals] :: LlvmModule -> [LMGlobal] -- | LLVM Functions used in this module but defined in other modules. [modFwdDecls] :: LlvmModule -> LlvmFunctionDecls -- | LLVM Functions defined in this module. [modFuncs] :: LlvmModule -> LlvmFunctions -- | An LLVM Function data LlvmFunction LlvmFunction :: LlvmFunctionDecl -> [LMString] -> [LlvmFuncAttr] -> LMSection -> Maybe LlvmStatic -> LlvmBlocks -> LlvmFunction -- | The signature of this declared function. [funcDecl] :: LlvmFunction -> LlvmFunctionDecl -- | The functions arguments [funcArgs] :: LlvmFunction -> [LMString] -- | The function attributes. [funcAttrs] :: LlvmFunction -> [LlvmFuncAttr] -- | The section to put the function into, [funcSect] :: LlvmFunction -> LMSection -- | Prefix data [funcPrefix] :: LlvmFunction -> Maybe LlvmStatic -- | The body of the functions. [funcBody] :: LlvmFunction -> LlvmBlocks type LlvmFunctions = [LlvmFunction] type SingleThreaded = Bool -- | LLVM ordering types for synchronization purposes. (Introduced in LLVM -- 3.0). Please see the LLVM documentation for a better description. data LlvmSyncOrdering -- | Some partial order of operations exists. SyncUnord :: LlvmSyncOrdering -- | A single total order for operations at a single address exists. SyncMonotonic :: LlvmSyncOrdering -- | Acquire synchronization operation. SyncAcquire :: LlvmSyncOrdering -- | Release synchronization operation. SyncRelease :: LlvmSyncOrdering -- | Acquire + Release synchronization operation. SyncAcqRel :: LlvmSyncOrdering -- | Full sequential Consistency operation. SyncSeqCst :: LlvmSyncOrdering -- | LLVM atomic operations. Please see the atomicrmw instruction -- in the LLVM documentation for a complete description. data LlvmAtomicOp LAO_Xchg :: LlvmAtomicOp LAO_Add :: LlvmAtomicOp LAO_Sub :: LlvmAtomicOp LAO_And :: LlvmAtomicOp LAO_Nand :: LlvmAtomicOp LAO_Or :: LlvmAtomicOp LAO_Xor :: LlvmAtomicOp LAO_Max :: LlvmAtomicOp LAO_Min :: LlvmAtomicOp LAO_Umax :: LlvmAtomicOp LAO_Umin :: LlvmAtomicOp -- | Llvm Statements data LlvmStatement -- | Assign an expression to a variable: * dest: Variable to assign to * -- source: Source expression Assignment :: LlvmVar -> LlvmExpression -> LlvmStatement -- | Memory fence operation Fence :: Bool -> LlvmSyncOrdering -> LlvmStatement -- | Always branch to the target label Branch :: LlvmVar -> LlvmStatement -- | Branch to label targetTrue if cond is true otherwise to label -- targetFalse * cond: condition that will be tested, must be of type i1 -- * targetTrue: label to branch to if cond is true * targetFalse: label -- to branch to if cond is false BranchIf :: LlvmVar -> LlvmVar -> LlvmVar -> LlvmStatement -- | Comment Plain comment. Comment :: [LMString] -> LlvmStatement -- | Set a label on this position. * name: Identifier of this label, unique -- for this module MkLabel :: LlvmBlockId -> LlvmStatement -- | Store variable value in pointer ptr. If value is of type t then ptr -- must be of type t*. * value: Variable/Constant to store. * ptr: -- Location to store the value in Store :: LlvmVar -> LlvmVar -> LMAlign -> LlvmStatement -- | Multiway branch * scrutinee: Variable or constant which must be of -- integer type that is determines which arm is chosen. * def: The -- default label if there is no match in target. * target: A list of -- (value,label) where the value is an integer constant and label the -- corresponding label to jump to if the scrutinee matches the value. Switch :: LlvmVar -> LlvmVar -> [(LlvmVar, LlvmVar)] -> LlvmStatement -- | Return a result. * result: The variable or constant to return Return :: Maybe LlvmVar -> LlvmStatement -- | An instruction for the optimizer that the code following is not -- reachable Unreachable :: LlvmStatement -- | Raise an expression to a statement (if don't want result or want to -- use Llvm unnamed values. Expr :: LlvmExpression -> LlvmStatement -- | A nop LLVM statement. Useful as its often more efficient to use this -- then to wrap LLvmStatement in a Just or []. Nop :: LlvmStatement -- | A LLVM statement with metadata attached to it. MetaStmt :: [MetaAnnot] -> LlvmStatement -> LlvmStatement -- | Llvm Expressions data LlvmExpression -- | Allocate amount * sizeof(tp) bytes on the stack * tp: LlvmType to -- reserve room for * amount: The nr of tp's which must be allocated Alloca :: LlvmType -> Int -> LlvmExpression -- | Perform the machine operator op on the operands left and right * op: -- operator * left: left operand * right: right operand LlvmOp :: LlvmMachOp -> LlvmVar -> LlvmVar -> LlvmExpression -- | Perform a compare operation on the operands left and right * op: -- operator * left: left operand * right: right operand Compare :: LlvmCmpOp -> LlvmVar -> LlvmVar -> LlvmExpression -- | Extract a scalar element from a vector * val: The vector * idx: The -- index of the scalar within the vector Extract :: LlvmVar -> LlvmVar -> LlvmExpression -- | Extract a scalar element from a structure * val: The structure * idx: -- The index of the scalar within the structure Corresponds to -- "extractvalue" instruction. ExtractV :: LlvmVar -> Int -> LlvmExpression -- | Insert a scalar element into a vector * val: The source vector * elt: -- The scalar to insert * index: The index at which to insert the scalar Insert :: LlvmVar -> LlvmVar -> LlvmVar -> LlvmExpression -- | Allocate amount * sizeof(tp) bytes on the heap * tp: LlvmType to -- reserve room for * amount: The nr of tp's which must be allocated Malloc :: LlvmType -> Int -> LlvmExpression -- | Load the value at location ptr Load :: LlvmVar -> LMAlign -> LlvmExpression -- | Atomic load of the value at location ptr ALoad :: LlvmSyncOrdering -> SingleThreaded -> LlvmVar -> LlvmExpression -- | Navigate in a structure, selecting elements * inbound: Is the pointer -- inbounds? (computed pointer doesn't overflow) * ptr: Location of the -- structure * indexes: A list of indexes to select the correct value. GetElemPtr :: Bool -> LlvmVar -> [LlvmVar] -> LlvmExpression -- | Cast the variable from to the to type. This is an abstraction of three -- cast operators in Llvm, inttoptr, ptrtoint and bitcast. * cast: Cast -- type * from: Variable to cast * to: type to cast to Cast :: LlvmCastOp -> LlvmVar -> LlvmType -> LlvmExpression -- | Atomic read-modify-write operation * op: Atomic operation * addr: -- Address to modify * operand: Operand to operation * ordering: Ordering -- requirement AtomicRMW :: LlvmAtomicOp -> LlvmVar -> LlvmVar -> LlvmSyncOrdering -> LlvmExpression -- | Compare-and-exchange operation * addr: Address to modify * old: -- Expected value * new: New value * suc_ord: Ordering required in -- success case * fail_ord: Ordering required in failure case, can be no -- stronger than suc_ord -- -- Result is an i1, true if store was successful. CmpXChg :: LlvmVar -> LlvmVar -> LlvmVar -> LlvmSyncOrdering -> LlvmSyncOrdering -> LlvmExpression -- | Call a function. The result is the value of the expression. * -- tailJumps: CallType to signal if the function should be tail called * -- fnptrval: An LLVM value containing a pointer to a function to be -- invoked. Can be indirect. Should be LMFunction type. * args: Concrete -- arguments for the parameters * attrs: A list of function attributes -- for the call. Only NoReturn, NoUnwind, ReadOnly and ReadNone are valid -- here. Call :: LlvmCallType -> LlvmVar -> [LlvmVar] -> [LlvmFuncAttr] -> LlvmExpression -- | Call a function as above but potentially taking metadata as arguments. -- * tailJumps: CallType to signal if the function should be tail called -- * fnptrval: An LLVM value containing a pointer to a function to be -- invoked. Can be indirect. Should be LMFunction type. * args: Arguments -- that may include metadata. * attrs: A list of function attributes for -- the call. Only NoReturn, NoUnwind, ReadOnly and ReadNone are valid -- here. CallM :: LlvmCallType -> LlvmVar -> [MetaExpr] -> [LlvmFuncAttr] -> LlvmExpression -- | Merge variables from different basic blocks which are predecessors of -- this basic block in a new variable of type tp. * tp: type of the -- merged variable, must match the types of the predecessor variables. * -- predecessors: A list of variables and the basic block that they -- originate from. Phi :: LlvmType -> [(LlvmVar, LlvmVar)] -> LlvmExpression -- | Inline assembly expression. Syntax is very similar to the style used -- by GCC. * assembly: Actual inline assembly code. * constraints: -- Operand constraints. * return ty: Return type of function. * vars: Any -- variables involved in the assembly code. * sideeffect: Does the -- expression have side effects not visible from the constraints list. * -- alignstack: Should the stack be conservatively aligned before this -- expression is executed. Asm :: LMString -> LMString -> LlvmType -> [LlvmVar] -> Bool -> Bool -> LlvmExpression -- | A LLVM expression with metadata attached to it. MExpr :: [MetaAnnot] -> LlvmExpression -> LlvmExpression instance GHC.Classes.Eq GHC.Llvm.Syntax.LlvmSyncOrdering instance GHC.Show.Show GHC.Llvm.Syntax.LlvmSyncOrdering instance GHC.Classes.Eq GHC.Llvm.Syntax.LlvmAtomicOp instance GHC.Show.Show GHC.Llvm.Syntax.LlvmAtomicOp instance GHC.Classes.Eq GHC.Llvm.Syntax.LlvmExpression instance GHC.Classes.Eq GHC.Llvm.Syntax.LlvmStatement -- | Pretty print LLVM IR Code. module GHC.Llvm.Ppr -- | Print out a whole LLVM module. ppLlvmModule :: LlvmOpts -> LlvmModule -> SDoc -- | Print out a multi-line comment, can be inside a function or on its own ppLlvmComments :: [LMString] -> SDoc -- | Print out a comment, can be inside a function or on its own ppLlvmComment :: LMString -> SDoc -- | Print out a list of global mutable variable definitions ppLlvmGlobals :: LlvmOpts -> [LMGlobal] -> SDoc -- | Print out a global mutable variable definition ppLlvmGlobal :: LlvmOpts -> LMGlobal -> SDoc -- | Print out a list of LLVM type aliases. ppLlvmAliases :: [LlvmAlias] -> SDoc -- | Print out an LLVM type alias. ppLlvmAlias :: LlvmAlias -> SDoc -- | Print out a list of LLVM metadata. ppLlvmMetas :: LlvmOpts -> [MetaDecl] -> SDoc -- | Print out an LLVM metadata definition. ppLlvmMeta :: LlvmOpts -> MetaDecl -> SDoc -- | Print out a list of function declaration. ppLlvmFunctionDecls :: LlvmFunctionDecls -> SDoc -- | Print out a function declaration. Declarations define the function -- type but don't define the actual body of the function. ppLlvmFunctionDecl :: LlvmFunctionDecl -> SDoc -- | Print out a list of function definitions. ppLlvmFunctions :: LlvmOpts -> LlvmFunctions -> SDoc -- | Print out a function definition. ppLlvmFunction :: LlvmOpts -> LlvmFunction -> SDoc ppVar :: LlvmOpts -> LlvmVar -> SDoc -- | Print a literal value. No type. ppLit :: LlvmOpts -> LlvmLit -> SDoc ppTypeLit :: LlvmOpts -> LlvmLit -> SDoc -- | Return the variable name or value of the LlvmVar in Llvm IR -- textual representation (e.g. @x, %y or 42). ppName :: LlvmOpts -> LlvmVar -> SDoc -- | Return the variable name or value of the LlvmVar in a plain -- textual representation (e.g. x, y or 42). ppPlainName :: LlvmOpts -> LlvmVar -> SDoc -- | This module supplies bindings to generate Llvm IR from Haskell -- (http://www.llvm.org/docs/LangRef.html). -- -- Note: this module is developed in a demand driven way. It is no -- complete LLVM binding library in Haskell, but enough to generate code -- for GHC. -- -- This code is derived from code taken from the Essential Haskell -- Compiler (EHC) project. module GHC.Llvm -- | LLVM code generator options data LlvmOpts LlvmOpts :: !Platform -> !Bool -> !Bool -> LlvmOpts -- | Target platform [llvmOptsPlatform] :: LlvmOpts -> !Platform -- | Fill undefined literals with garbage values [llvmOptsFillUndefWithGarbage] :: LlvmOpts -> !Bool -- | Split sections [llvmOptsSplitSections] :: LlvmOpts -> !Bool -- | Get LlvmOptions from DynFlags initLlvmOpts :: DynFlags -> LlvmOpts -- | An LLVM Module. This is a top level container in LLVM. data LlvmModule LlvmModule :: [LMString] -> [LlvmAlias] -> [MetaDecl] -> [LMGlobal] -> LlvmFunctionDecls -> LlvmFunctions -> LlvmModule -- | Comments to include at the start of the module. [modComments] :: LlvmModule -> [LMString] -- | LLVM Alias type definitions. [modAliases] :: LlvmModule -> [LlvmAlias] -- | LLVM meta data. [modMeta] :: LlvmModule -> [MetaDecl] -- | Global variables to include in the module. [modGlobals] :: LlvmModule -> [LMGlobal] -- | LLVM Functions used in this module but defined in other modules. [modFwdDecls] :: LlvmModule -> LlvmFunctionDecls -- | LLVM Functions defined in this module. [modFuncs] :: LlvmModule -> LlvmFunctions -- | An LLVM Function data LlvmFunction LlvmFunction :: LlvmFunctionDecl -> [LMString] -> [LlvmFuncAttr] -> LMSection -> Maybe LlvmStatic -> LlvmBlocks -> LlvmFunction -- | The signature of this declared function. [funcDecl] :: LlvmFunction -> LlvmFunctionDecl -- | The functions arguments [funcArgs] :: LlvmFunction -> [LMString] -- | The function attributes. [funcAttrs] :: LlvmFunction -> [LlvmFuncAttr] -- | The section to put the function into, [funcSect] :: LlvmFunction -> LMSection -- | Prefix data [funcPrefix] :: LlvmFunction -> Maybe LlvmStatic -- | The body of the functions. [funcBody] :: LlvmFunction -> LlvmBlocks -- | An LLVM Function data LlvmFunctionDecl LlvmFunctionDecl :: LMString -> LlvmLinkageType -> LlvmCallConvention -> LlvmType -> LlvmParameterListType -> [LlvmParameter] -> LMAlign -> LlvmFunctionDecl -- | Unique identifier of the function [decName] :: LlvmFunctionDecl -> LMString -- | LinkageType of the function [funcLinkage] :: LlvmFunctionDecl -> LlvmLinkageType -- | The calling convention of the function [funcCc] :: LlvmFunctionDecl -> LlvmCallConvention -- | Type of the returned value [decReturnType] :: LlvmFunctionDecl -> LlvmType -- | Indicates if this function uses varargs [decVarargs] :: LlvmFunctionDecl -> LlvmParameterListType -- | Parameter types and attributes [decParams] :: LlvmFunctionDecl -> [LlvmParameter] -- | Function align value, must be power of 2 [funcAlign] :: LlvmFunctionDecl -> LMAlign type LlvmFunctions = [LlvmFunction] type LlvmFunctionDecls = [LlvmFunctionDecl] -- | Llvm Statements data LlvmStatement -- | Assign an expression to a variable: * dest: Variable to assign to * -- source: Source expression Assignment :: LlvmVar -> LlvmExpression -> LlvmStatement -- | Memory fence operation Fence :: Bool -> LlvmSyncOrdering -> LlvmStatement -- | Always branch to the target label Branch :: LlvmVar -> LlvmStatement -- | Branch to label targetTrue if cond is true otherwise to label -- targetFalse * cond: condition that will be tested, must be of type i1 -- * targetTrue: label to branch to if cond is true * targetFalse: label -- to branch to if cond is false BranchIf :: LlvmVar -> LlvmVar -> LlvmVar -> LlvmStatement -- | Comment Plain comment. Comment :: [LMString] -> LlvmStatement -- | Set a label on this position. * name: Identifier of this label, unique -- for this module MkLabel :: LlvmBlockId -> LlvmStatement -- | Store variable value in pointer ptr. If value is of type t then ptr -- must be of type t*. * value: Variable/Constant to store. * ptr: -- Location to store the value in Store :: LlvmVar -> LlvmVar -> LMAlign -> LlvmStatement -- | Multiway branch * scrutinee: Variable or constant which must be of -- integer type that is determines which arm is chosen. * def: The -- default label if there is no match in target. * target: A list of -- (value,label) where the value is an integer constant and label the -- corresponding label to jump to if the scrutinee matches the value. Switch :: LlvmVar -> LlvmVar -> [(LlvmVar, LlvmVar)] -> LlvmStatement -- | Return a result. * result: The variable or constant to return Return :: Maybe LlvmVar -> LlvmStatement -- | An instruction for the optimizer that the code following is not -- reachable Unreachable :: LlvmStatement -- | Raise an expression to a statement (if don't want result or want to -- use Llvm unnamed values. Expr :: LlvmExpression -> LlvmStatement -- | A nop LLVM statement. Useful as its often more efficient to use this -- then to wrap LLvmStatement in a Just or []. Nop :: LlvmStatement -- | A LLVM statement with metadata attached to it. MetaStmt :: [MetaAnnot] -> LlvmStatement -> LlvmStatement -- | Llvm Expressions data LlvmExpression -- | Allocate amount * sizeof(tp) bytes on the stack * tp: LlvmType to -- reserve room for * amount: The nr of tp's which must be allocated Alloca :: LlvmType -> Int -> LlvmExpression -- | Perform the machine operator op on the operands left and right * op: -- operator * left: left operand * right: right operand LlvmOp :: LlvmMachOp -> LlvmVar -> LlvmVar -> LlvmExpression -- | Perform a compare operation on the operands left and right * op: -- operator * left: left operand * right: right operand Compare :: LlvmCmpOp -> LlvmVar -> LlvmVar -> LlvmExpression -- | Extract a scalar element from a vector * val: The vector * idx: The -- index of the scalar within the vector Extract :: LlvmVar -> LlvmVar -> LlvmExpression -- | Extract a scalar element from a structure * val: The structure * idx: -- The index of the scalar within the structure Corresponds to -- "extractvalue" instruction. ExtractV :: LlvmVar -> Int -> LlvmExpression -- | Insert a scalar element into a vector * val: The source vector * elt: -- The scalar to insert * index: The index at which to insert the scalar Insert :: LlvmVar -> LlvmVar -> LlvmVar -> LlvmExpression -- | Allocate amount * sizeof(tp) bytes on the heap * tp: LlvmType to -- reserve room for * amount: The nr of tp's which must be allocated Malloc :: LlvmType -> Int -> LlvmExpression -- | Load the value at location ptr Load :: LlvmVar -> LMAlign -> LlvmExpression -- | Atomic load of the value at location ptr ALoad :: LlvmSyncOrdering -> SingleThreaded -> LlvmVar -> LlvmExpression -- | Navigate in a structure, selecting elements * inbound: Is the pointer -- inbounds? (computed pointer doesn't overflow) * ptr: Location of the -- structure * indexes: A list of indexes to select the correct value. GetElemPtr :: Bool -> LlvmVar -> [LlvmVar] -> LlvmExpression -- | Cast the variable from to the to type. This is an abstraction of three -- cast operators in Llvm, inttoptr, ptrtoint and bitcast. * cast: Cast -- type * from: Variable to cast * to: type to cast to Cast :: LlvmCastOp -> LlvmVar -> LlvmType -> LlvmExpression -- | Atomic read-modify-write operation * op: Atomic operation * addr: -- Address to modify * operand: Operand to operation * ordering: Ordering -- requirement AtomicRMW :: LlvmAtomicOp -> LlvmVar -> LlvmVar -> LlvmSyncOrdering -> LlvmExpression -- | Compare-and-exchange operation * addr: Address to modify * old: -- Expected value * new: New value * suc_ord: Ordering required in -- success case * fail_ord: Ordering required in failure case, can be no -- stronger than suc_ord -- -- Result is an i1, true if store was successful. CmpXChg :: LlvmVar -> LlvmVar -> LlvmVar -> LlvmSyncOrdering -> LlvmSyncOrdering -> LlvmExpression -- | Call a function. The result is the value of the expression. * -- tailJumps: CallType to signal if the function should be tail called * -- fnptrval: An LLVM value containing a pointer to a function to be -- invoked. Can be indirect. Should be LMFunction type. * args: Concrete -- arguments for the parameters * attrs: A list of function attributes -- for the call. Only NoReturn, NoUnwind, ReadOnly and ReadNone are valid -- here. Call :: LlvmCallType -> LlvmVar -> [LlvmVar] -> [LlvmFuncAttr] -> LlvmExpression -- | Call a function as above but potentially taking metadata as arguments. -- * tailJumps: CallType to signal if the function should be tail called -- * fnptrval: An LLVM value containing a pointer to a function to be -- invoked. Can be indirect. Should be LMFunction type. * args: Arguments -- that may include metadata. * attrs: A list of function attributes for -- the call. Only NoReturn, NoUnwind, ReadOnly and ReadNone are valid -- here. CallM :: LlvmCallType -> LlvmVar -> [MetaExpr] -> [LlvmFuncAttr] -> LlvmExpression -- | Merge variables from different basic blocks which are predecessors of -- this basic block in a new variable of type tp. * tp: type of the -- merged variable, must match the types of the predecessor variables. * -- predecessors: A list of variables and the basic block that they -- originate from. Phi :: LlvmType -> [(LlvmVar, LlvmVar)] -> LlvmExpression -- | Inline assembly expression. Syntax is very similar to the style used -- by GCC. * assembly: Actual inline assembly code. * constraints: -- Operand constraints. * return ty: Return type of function. * vars: Any -- variables involved in the assembly code. * sideeffect: Does the -- expression have side effects not visible from the constraints list. * -- alignstack: Should the stack be conservatively aligned before this -- expression is executed. Asm :: LMString -> LMString -> LlvmType -> [LlvmVar] -> Bool -> Bool -> LlvmExpression -- | A LLVM expression with metadata attached to it. MExpr :: [MetaAnnot] -> LlvmExpression -> LlvmExpression type LlvmBlocks = [LlvmBlock] -- | A block of LLVM code. data LlvmBlock LlvmBlock :: LlvmBlockId -> [LlvmStatement] -> LlvmBlock -- | The code label for this block [blockLabel] :: LlvmBlock -> LlvmBlockId -- | A list of LlvmStatement's representing the code for this block. This -- list must end with a control flow statement. [blockStmts] :: LlvmBlock -> [LlvmStatement] -- | Block labels type LlvmBlockId = Unique -- | LLVM Parameter Attributes. -- -- Parameter attributes are used to communicate additional information -- about the result or parameters of a function data LlvmParamAttr -- | This indicates to the code generator that the parameter or return -- value should be zero-extended to a 32-bit value by the caller (for a -- parameter) or the callee (for a return value). ZeroExt :: LlvmParamAttr -- | This indicates to the code generator that the parameter or return -- value should be sign-extended to a 32-bit value by the caller (for a -- parameter) or the callee (for a return value). SignExt :: LlvmParamAttr -- | This indicates that this parameter or return value should be treated -- in a special target-dependent fashion during while emitting code for a -- function call or return (usually, by putting it in a register as -- opposed to memory). InReg :: LlvmParamAttr -- | This indicates that the pointer parameter should really be passed by -- value to the function. ByVal :: LlvmParamAttr -- | This indicates that the pointer parameter specifies the address of a -- structure that is the return value of the function in the source -- program. SRet :: LlvmParamAttr -- | This indicates that the pointer does not alias any global or any other -- parameter. NoAlias :: LlvmParamAttr -- | This indicates that the callee does not make any copies of the pointer -- that outlive the callee itself NoCapture :: LlvmParamAttr -- | This indicates that the pointer parameter can be excised using the -- trampoline intrinsics. Nest :: LlvmParamAttr type LlvmParameter = (LlvmType, [LlvmParamAttr]) -- | LLVM atomic operations. Please see the atomicrmw instruction -- in the LLVM documentation for a complete description. data LlvmAtomicOp LAO_Xchg :: LlvmAtomicOp LAO_Add :: LlvmAtomicOp LAO_Sub :: LlvmAtomicOp LAO_And :: LlvmAtomicOp LAO_Nand :: LlvmAtomicOp LAO_Or :: LlvmAtomicOp LAO_Xor :: LlvmAtomicOp LAO_Max :: LlvmAtomicOp LAO_Min :: LlvmAtomicOp LAO_Umax :: LlvmAtomicOp LAO_Umin :: LlvmAtomicOp -- | LLVM ordering types for synchronization purposes. (Introduced in LLVM -- 3.0). Please see the LLVM documentation for a better description. data LlvmSyncOrdering -- | Some partial order of operations exists. SyncUnord :: LlvmSyncOrdering -- | A single total order for operations at a single address exists. SyncMonotonic :: LlvmSyncOrdering -- | Acquire synchronization operation. SyncAcquire :: LlvmSyncOrdering -- | Release synchronization operation. SyncRelease :: LlvmSyncOrdering -- | Acquire + Release synchronization operation. SyncAcqRel :: LlvmSyncOrdering -- | Full sequential Consistency operation. SyncSeqCst :: LlvmSyncOrdering -- | Different calling conventions a function can use. data LlvmCallConvention -- | The C calling convention. This calling convention (the default if no -- other calling convention is specified) matches the target C calling -- conventions. This calling convention supports varargs function calls -- and tolerates some mismatch in the declared prototype and implemented -- declaration of the function (as does normal C). CC_Ccc :: LlvmCallConvention -- | This calling convention attempts to make calls as fast as possible -- (e.g. by passing things in registers). This calling convention allows -- the target to use whatever tricks it wants to produce fast code for -- the target, without having to conform to an externally specified ABI -- (Application Binary Interface). Implementations of this convention -- should allow arbitrary tail call optimization to be supported. This -- calling convention does not support varargs and requires the prototype -- of al callees to exactly match the prototype of the function -- definition. CC_Fastcc :: LlvmCallConvention -- | This calling convention attempts to make code in the caller as -- efficient as possible under the assumption that the call is not -- commonly executed. As such, these calls often preserve all registers -- so that the call does not break any live ranges in the caller side. -- This calling convention does not support varargs and requires the -- prototype of all callees to exactly match the prototype of the -- function definition. CC_Coldcc :: LlvmCallConvention -- | The GHC-specific registerised calling convention. CC_Ghc :: LlvmCallConvention -- | Any calling convention may be specified by number, allowing -- target-specific calling conventions to be used. Target specific -- calling conventions start at 64. CC_Ncc :: Int -> LlvmCallConvention -- | X86 Specific StdCall convention. LLVM includes a specific alias -- for it rather than just using CC_Ncc. CC_X86_Stdcc :: LlvmCallConvention -- | Different types to call a function. data LlvmCallType -- | Normal call, allocate a new stack frame. StdCall :: LlvmCallType -- | Tail call, perform the call in the current stack frame. TailCall :: LlvmCallType -- | Functions can have a fixed amount of parameters, or a variable amount. data LlvmParameterListType FixedArgs :: LlvmParameterListType VarArgs :: LlvmParameterListType -- | Linkage type of a symbol. -- -- The description of the constructors is copied from the Llvm Assembly -- Language Reference Manual -- http://www.llvm.org/docs/LangRef.html#linkage, because they -- correspond to the Llvm linkage types. data LlvmLinkageType -- | Global values with internal linkage are only directly accessible by -- objects in the current module. In particular, linking code into a -- module with an internal global value may cause the internal to be -- renamed as necessary to avoid collisions. Because the symbol is -- internal to the module, all references can be updated. This -- corresponds to the notion of the static keyword in C. Internal :: LlvmLinkageType -- | Globals with linkonce linkage are merged with other globals -- of the same name when linkage occurs. This is typically used to -- implement inline functions, templates, or other code which must be -- generated in each translation unit that uses it. Unreferenced linkonce -- globals are allowed to be discarded. LinkOnce :: LlvmLinkageType -- | weak linkage is exactly the same as linkonce linkage, except -- that unreferenced weak globals may not be discarded. This is used for -- globals that may be emitted in multiple translation units, but that -- are not guaranteed to be emitted into every translation unit that uses -- them. One example of this are common globals in C, such as int -- X; at global scope. Weak :: LlvmLinkageType -- | appending linkage may only be applied to global variables of -- pointer to array type. When two global variables with appending -- linkage are linked together, the two global arrays are appended -- together. This is the Llvm, typesafe, equivalent of having the system -- linker append together sections with identical names when .o -- files are linked. Appending :: LlvmLinkageType -- | The semantics of this linkage follow the ELF model: the symbol is weak -- until linked, if not linked, the symbol becomes null instead of being -- an undefined reference. ExternWeak :: LlvmLinkageType -- | The symbol participates in linkage and can be used to resolve external -- symbol references. ExternallyVisible :: LlvmLinkageType -- | Alias for ExternallyVisible but with explicit textual form in -- LLVM assembly. External :: LlvmLinkageType -- | Symbol is private to the module and should not appear in the symbol -- table Private :: LlvmLinkageType -- | Llvm Function Attributes. -- -- Function attributes are set to communicate additional information -- about a function. Function attributes are considered to be part of the -- function, not of the function type, so functions with different -- parameter attributes can have the same function type. Functions can -- have multiple attributes. -- -- Descriptions taken from -- http://llvm.org/docs/LangRef.html#fnattrs data LlvmFuncAttr -- | This attribute indicates that the inliner should attempt to inline -- this function into callers whenever possible, ignoring any active -- inlining size threshold for this caller. AlwaysInline :: LlvmFuncAttr -- | This attribute indicates that the source code contained a hint that -- inlining this function is desirable (such as the "inline" keyword in -- C/C++). It is just a hint; it imposes no requirements on the inliner. InlineHint :: LlvmFuncAttr -- | This attribute indicates that the inliner should never inline this -- function in any situation. This attribute may not be used together -- with the alwaysinline attribute. NoInline :: LlvmFuncAttr -- | This attribute suggests that optimization passes and code generator -- passes make choices that keep the code size of this function low, and -- otherwise do optimizations specifically to reduce code size. OptSize :: LlvmFuncAttr -- | This function attribute indicates that the function never returns -- normally. This produces undefined behavior at runtime if the function -- ever does dynamically return. NoReturn :: LlvmFuncAttr -- | This function attribute indicates that the function never returns with -- an unwind or exceptional control flow. If the function does unwind, -- its runtime behavior is undefined. NoUnwind :: LlvmFuncAttr -- | This attribute indicates that the function computes its result (or -- decides to unwind an exception) based strictly on its arguments, -- without dereferencing any pointer arguments or otherwise accessing any -- mutable state (e.g. memory, control registers, etc) visible to caller -- functions. It does not write through any pointer arguments (including -- byval arguments) and never changes any state visible to callers. This -- means that it cannot unwind exceptions by calling the C++ exception -- throwing methods, but could use the unwind instruction. ReadNone :: LlvmFuncAttr -- | This attribute indicates that the function does not write through any -- pointer arguments (including byval arguments) or otherwise modify any -- state (e.g. memory, control registers, etc) visible to caller -- functions. It may dereference pointer arguments and read state that -- may be set in the caller. A readonly function always returns the same -- value (or unwinds an exception identically) when called with the same -- set of arguments and global state. It cannot unwind an exception by -- calling the C++ exception throwing methods, but may use the unwind -- instruction. ReadOnly :: LlvmFuncAttr -- | This attribute indicates that the function should emit a stack -- smashing protector. It is in the form of a "canary"—a random value -- placed on the stack before the local variables that's checked upon -- return from the function to see if it has been overwritten. A -- heuristic is used to determine if a function needs stack protectors or -- not. -- -- If a function that has an ssp attribute is inlined into a function -- that doesn't have an ssp attribute, then the resulting function will -- have an ssp attribute. Ssp :: LlvmFuncAttr -- | This attribute indicates that the function should always emit a stack -- smashing protector. This overrides the ssp function attribute. -- -- If a function that has an sspreq attribute is inlined into a function -- that doesn't have an sspreq attribute or which has an ssp attribute, -- then the resulting function will have an sspreq attribute. SspReq :: LlvmFuncAttr -- | This attribute indicates that the code generator should not use a red -- zone, even if the target-specific ABI normally permits it. NoRedZone :: LlvmFuncAttr -- | This attributes disables implicit floating point instructions. NoImplicitFloat :: LlvmFuncAttr -- | This attribute disables prologue / epilogue emission for the function. -- This can have very system-specific consequences. Naked :: LlvmFuncAttr -- | Llvm compare operations. data LlvmCmpOp -- | Equal (Signed and Unsigned) LM_CMP_Eq :: LlvmCmpOp -- | Not equal (Signed and Unsigned) LM_CMP_Ne :: LlvmCmpOp -- | Unsigned greater than LM_CMP_Ugt :: LlvmCmpOp -- | Unsigned greater than or equal LM_CMP_Uge :: LlvmCmpOp -- | Unsigned less than LM_CMP_Ult :: LlvmCmpOp -- | Unsigned less than or equal LM_CMP_Ule :: LlvmCmpOp -- | Signed greater than LM_CMP_Sgt :: LlvmCmpOp -- | Signed greater than or equal LM_CMP_Sge :: LlvmCmpOp -- | Signed less than LM_CMP_Slt :: LlvmCmpOp -- | Signed less than or equal LM_CMP_Sle :: LlvmCmpOp -- | Float equal LM_CMP_Feq :: LlvmCmpOp -- | Float not equal LM_CMP_Fne :: LlvmCmpOp -- | Float greater than LM_CMP_Fgt :: LlvmCmpOp -- | Float greater than or equal LM_CMP_Fge :: LlvmCmpOp -- | Float less than LM_CMP_Flt :: LlvmCmpOp -- | Float less than or equal LM_CMP_Fle :: LlvmCmpOp -- | Llvm binary operators machine operations. data LlvmMachOp -- | add two integer, floating point or vector values. LM_MO_Add :: LlvmMachOp -- | subtract two ... LM_MO_Sub :: LlvmMachOp -- | multiply .. LM_MO_Mul :: LlvmMachOp -- | unsigned integer or vector division. LM_MO_UDiv :: LlvmMachOp -- | signed integer .. LM_MO_SDiv :: LlvmMachOp -- | unsigned integer or vector remainder (mod) LM_MO_URem :: LlvmMachOp -- | signed ... LM_MO_SRem :: LlvmMachOp -- | add two floating point or vector values. LM_MO_FAdd :: LlvmMachOp -- | subtract two ... LM_MO_FSub :: LlvmMachOp -- | multiply ... LM_MO_FMul :: LlvmMachOp -- | divide ... LM_MO_FDiv :: LlvmMachOp -- | remainder ... LM_MO_FRem :: LlvmMachOp -- | Left shift LM_MO_Shl :: LlvmMachOp -- | Logical shift right Shift right, filling with zero LM_MO_LShr :: LlvmMachOp -- | Arithmetic shift right The most significant bits of the result will be -- equal to the sign bit of the left operand. LM_MO_AShr :: LlvmMachOp -- | AND bitwise logical operation. LM_MO_And :: LlvmMachOp -- | OR bitwise logical operation. LM_MO_Or :: LlvmMachOp -- | XOR bitwise logical operation. LM_MO_Xor :: LlvmMachOp -- | Llvm cast operations. data LlvmCastOp -- | Integer truncate LM_Trunc :: LlvmCastOp -- | Integer extend (zero fill) LM_Zext :: LlvmCastOp -- | Integer extend (sign fill) LM_Sext :: LlvmCastOp -- | Float truncate LM_Fptrunc :: LlvmCastOp -- | Float extend LM_Fpext :: LlvmCastOp -- | Float to unsigned Integer LM_Fptoui :: LlvmCastOp -- | Float to signed Integer LM_Fptosi :: LlvmCastOp -- | Unsigned Integer to Float LM_Uitofp :: LlvmCastOp -- | Signed Int to Float LM_Sitofp :: LlvmCastOp -- | Pointer to Integer LM_Ptrtoint :: LlvmCastOp -- | Integer to Pointer LM_Inttoptr :: LlvmCastOp -- | Cast between types where no bit manipulation is needed LM_Bitcast :: LlvmCastOp -- | LLVM Variables data LlvmVar -- | Variables with a global scope. LMGlobalVar :: LMString -> LlvmType -> LlvmLinkageType -> LMSection -> LMAlign -> LMConst -> LlvmVar -- | Variables local to a function or parameters. LMLocalVar :: Unique -> LlvmType -> LlvmVar -- | Named local variables. Sometimes we need to be able to explicitly name -- variables (e.g for function arguments). LMNLocalVar :: LMString -> LlvmType -> LlvmVar -- | A constant variable LMLitVar :: LlvmLit -> LlvmVar -- | Llvm Static Data. -- -- These represent the possible global level variables and constants. data LlvmStatic -- | A comment in a static section LMComment :: LMString -> LlvmStatic -- | A static variant of a literal value LMStaticLit :: LlvmLit -> LlvmStatic -- | For uninitialised data LMUninitType :: LlvmType -> LlvmStatic -- | Defines a static LMString LMStaticStr :: LMString -> LlvmType -> LlvmStatic -- | A static array LMStaticArray :: [LlvmStatic] -> LlvmType -> LlvmStatic -- | A static structure type LMStaticStruc :: [LlvmStatic] -> LlvmType -> LlvmStatic -- | A pointer to other data LMStaticPointer :: LlvmVar -> LlvmStatic -- | Truncate LMTrunc :: LlvmStatic -> LlvmType -> LlvmStatic -- | Pointer to Pointer conversion LMBitc :: LlvmStatic -> LlvmType -> LlvmStatic -- | Pointer to Integer conversion LMPtoI :: LlvmStatic -> LlvmType -> LlvmStatic -- | Constant addition operation LMAdd :: LlvmStatic -> LlvmStatic -> LlvmStatic -- | Constant subtraction operation LMSub :: LlvmStatic -> LlvmStatic -> LlvmStatic -- | Llvm Literal Data. -- -- These can be used inline in expressions. data LlvmLit -- | Refers to an integer constant (i64 42). LMIntLit :: Integer -> LlvmType -> LlvmLit -- | Floating point literal LMFloatLit :: Double -> LlvmType -> LlvmLit -- | Literal NULL, only applicable to pointer types LMNullLit :: LlvmType -> LlvmLit -- | Vector literal LMVectorLit :: [LlvmLit] -> LlvmLit -- | Undefined value, random bit pattern. Useful for optimisations. LMUndefLit :: LlvmType -> LlvmLit -- | Llvm Types data LlvmType -- | An integer with a given width in bits. LMInt :: Int -> LlvmType -- | 32 bit floating point LMFloat :: LlvmType -- | 64 bit floating point LMDouble :: LlvmType -- | 80 bit (x86 only) floating point LMFloat80 :: LlvmType -- | 128 bit floating point LMFloat128 :: LlvmType -- | A pointer to a LlvmType LMPointer :: LlvmType -> LlvmType -- | An array of LlvmType LMArray :: Int -> LlvmType -> LlvmType -- | A vector of LlvmType LMVector :: Int -> LlvmType -> LlvmType -- | A LlvmVar can represent a label (address) LMLabel :: LlvmType -- | Void type LMVoid :: LlvmType -- | Packed structure type LMStruct :: [LlvmType] -> LlvmType -- | Unpacked structure type LMStructU :: [LlvmType] -> LlvmType -- | A type alias LMAlias :: LlvmAlias -> LlvmType -- | LLVM Metadata LMMetadata :: LlvmType -- | Function type, used to create pointers to functions LMFunction :: LlvmFunctionDecl -> LlvmType -- | A type alias type LlvmAlias = (LMString, LlvmType) -- | A global mutable variable. Maybe defined or external data LMGlobal LMGlobal :: LlvmVar -> Maybe LlvmStatic -> LMGlobal -- | Returns the variable of the LMGlobal [getGlobalVar] :: LMGlobal -> LlvmVar -- | Return the value of the LMGlobal [getGlobalValue] :: LMGlobal -> Maybe LlvmStatic -- | A String in LLVM type LMString = FastString -- | An LLVM section definition. If Nothing then let LLVM decide the -- section type LMSection = Maybe LMString type LMAlign = Maybe Int data LMConst -- | Mutable global variable Global :: LMConst -- | Constant global variable Constant :: LMConst -- | Alias of another variable Alias :: LMConst i64 :: LlvmType i32 :: LlvmType i16 :: LlvmType i8 :: LlvmType i1 :: LlvmType i8Ptr :: LlvmType -- | The target architectures word size llvmWord :: Platform -> LlvmType -- | The target architectures word size llvmWordPtr :: Platform -> LlvmType -- | LLVM metadata expressions data MetaExpr MetaStr :: !LMString -> MetaExpr MetaNode :: !MetaId -> MetaExpr MetaVar :: !LlvmVar -> MetaExpr MetaStruct :: [MetaExpr] -> MetaExpr -- | Associates some metadata with a specific label for attaching to an -- instruction. data MetaAnnot MetaAnnot :: LMString -> MetaExpr -> MetaAnnot -- | Metadata declarations. Metadata can only be declared in global scope. data MetaDecl -- | Named metadata. Only used for communicating module information to -- LLVM. ('!name = !{ [!<n>] }' form). MetaNamed :: !LMString -> [MetaId] -> MetaDecl -- | Metadata node declaration. ('!0 = metadata !{ <metadata -- expression> }' form). MetaUnnamed :: !MetaId -> !MetaExpr -> MetaDecl -- | A reference to an un-named metadata node. newtype MetaId MetaId :: Int -> MetaId -- | Test if a LlvmVar is global. isGlobal :: LlvmVar -> Bool -- | Return the LlvmType of a LlvmLit getLitType :: LlvmLit -> LlvmType -- | Return the LlvmType of the LlvmVar getVarType :: LlvmVar -> LlvmType -- | Return the LlvmLinkageType for a LlvmVar getLink :: LlvmVar -> LlvmLinkageType -- | Return the LlvmType of the LlvmStatic getStatType :: LlvmStatic -> LlvmType -- | Lift a variable to LMPointer type. pVarLift :: LlvmVar -> LlvmVar -- | Lower a variable of LMPointer type. pVarLower :: LlvmVar -> LlvmVar -- | Add a pointer indirection to the supplied type. LMLabel and -- LMVoid cannot be lifted. pLift :: LlvmType -> LlvmType -- | Remove the pointer indirection of the supplied type. Only -- LMPointer constructors can be lowered. pLower :: LlvmType -> LlvmType -- | Test if the given LlvmType is an integer isInt :: LlvmType -> Bool -- | Test if the given LlvmType is a floating point type isFloat :: LlvmType -> Bool -- | Test if the given LlvmType is an LMPointer construct isPointer :: LlvmType -> Bool -- | Test if the given LlvmType is an LMVector construct isVector :: LlvmType -> Bool -- | Width in bits of an LlvmType, returns 0 if not applicable llvmWidthInBits :: Platform -> LlvmType -> Int ppVar :: LlvmOpts -> LlvmVar -> SDoc -- | Print a literal value. No type. ppLit :: LlvmOpts -> LlvmLit -> SDoc ppTypeLit :: LlvmOpts -> LlvmLit -> SDoc -- | Return the variable name or value of the LlvmVar in Llvm IR -- textual representation (e.g. @x, %y or 42). ppName :: LlvmOpts -> LlvmVar -> SDoc -- | Return the variable name or value of the LlvmVar in a plain -- textual representation (e.g. x, y or 42). ppPlainName :: LlvmOpts -> LlvmVar -> SDoc -- | Print out a whole LLVM module. ppLlvmModule :: LlvmOpts -> LlvmModule -> SDoc -- | Print out a multi-line comment, can be inside a function or on its own ppLlvmComments :: [LMString] -> SDoc -- | Print out a comment, can be inside a function or on its own ppLlvmComment :: LMString -> SDoc -- | Print out a list of global mutable variable definitions ppLlvmGlobals :: LlvmOpts -> [LMGlobal] -> SDoc -- | Print out a global mutable variable definition ppLlvmGlobal :: LlvmOpts -> LMGlobal -> SDoc -- | Print out a list of function declaration. ppLlvmFunctionDecls :: LlvmFunctionDecls -> SDoc -- | Print out a function declaration. Declarations define the function -- type but don't define the actual body of the function. ppLlvmFunctionDecl :: LlvmFunctionDecl -> SDoc -- | Print out a list of function definitions. ppLlvmFunctions :: LlvmOpts -> LlvmFunctions -> SDoc -- | Print out a function definition. ppLlvmFunction :: LlvmOpts -> LlvmFunction -> SDoc -- | Print out an LLVM type alias. ppLlvmAlias :: LlvmAlias -> SDoc -- | Print out a list of LLVM type aliases. ppLlvmAliases :: [LlvmAlias] -> SDoc -- | Print out a list of LLVM metadata. ppLlvmMetas :: LlvmOpts -> [MetaDecl] -> SDoc -- | Print out an LLVM metadata definition. ppLlvmMeta :: LlvmOpts -> MetaDecl -> SDoc -- | Deal with Cmm registers module GHC.CmmToLlvm.Regs -- | Get the LlvmVar function argument storing the real register lmGlobalRegArg :: Platform -> GlobalReg -> LlvmVar -- | Get the LlvmVar function variable storing the real register lmGlobalRegVar :: Platform -> GlobalReg -> LlvmVar -- | A list of STG Registers that should always be considered alive alwaysLive :: [GlobalReg] -- | STG Type Based Alias Analysis hierarchy stgTBAA :: [(Unique, LMString, Maybe Unique)] -- | Id values The rootN node is the root (there can be more than -- one) of the TBAA hierarchy and as of LLVM 4.0 should *only* be -- referenced by other nodes. It should never occur in any LLVM -- instruction statement. baseN :: Unique -- | Id values The rootN node is the root (there can be more than -- one) of the TBAA hierarchy and as of LLVM 4.0 should *only* be -- referenced by other nodes. It should never occur in any LLVM -- instruction statement. stackN :: Unique -- | Id values The rootN node is the root (there can be more than -- one) of the TBAA hierarchy and as of LLVM 4.0 should *only* be -- referenced by other nodes. It should never occur in any LLVM -- instruction statement. heapN :: Unique -- | Id values The rootN node is the root (there can be more than -- one) of the TBAA hierarchy and as of LLVM 4.0 should *only* be -- referenced by other nodes. It should never occur in any LLVM -- instruction statement. rxN :: Unique -- | Id values The rootN node is the root (there can be more than -- one) of the TBAA hierarchy and as of LLVM 4.0 should *only* be -- referenced by other nodes. It should never occur in any LLVM -- instruction statement. topN :: Unique -- | The TBAA metadata identifier tbaa :: LMString -- | Get the correct TBAA metadata information for this register type getTBAA :: GlobalReg -> Unique -- | Formats on this architecture A Format is a combination of width and -- class -- -- TODO: Signed vs unsigned? -- -- TODO: This module is currently shared by all architectures because -- NCGMonad need to know about it to make a VReg. It would be better to -- have architecture specific formats, and do the overloading properly. -- eg SPARC doesn't care about FF80. module GHC.CmmToAsm.Format data Format II8 :: Format II16 :: Format II32 :: Format II64 :: Format FF32 :: Format FF64 :: Format -- | Get the integer format of this width. intFormat :: Width -> Format -- | Get the float format of this width. floatFormat :: Width -> Format -- | Check if a format represent an integer value. isIntFormat :: Format -> Bool -- | Check if a format represents a floating point value. isFloatFormat :: Format -> Bool -- | Convert a Cmm type to a Format. cmmTypeFormat :: CmmType -> Format -- | Get the Width of a Format. formatToWidth :: Format -> Width formatInBytes :: Format -> Int instance GHC.Classes.Eq GHC.CmmToAsm.Format.Format instance GHC.Show.Show GHC.CmmToAsm.Format.Format module GHC.CmmToAsm.X86.RegInfo mkVirtualReg :: Unique -> Format -> VirtualReg regDotColor :: Platform -> RealReg -> SDoc module GHC.CmmToAsm.SPARC.Regs -- | Get the standard name for the register with this number. showReg :: RegNo -> String -- | regSqueeze_class reg Calculate the maximum number of register colors -- that could be denied to a node of this class due to having this reg as -- a neighbour. virtualRegSqueeze :: RegClass -> VirtualReg -> Int realRegSqueeze :: RegClass -> RealReg -> Int classOfRealReg :: RealReg -> RegClass -- | All the allocatable registers in the machine, including register -- pairs. allRealRegs :: [RealReg] -- | Get the regno for this sort of reg gReg :: Int -> RegNo -- | Get the regno for this sort of reg iReg :: Int -> RegNo -- | Get the regno for this sort of reg lReg :: Int -> RegNo -- | Get the regno for this sort of reg oReg :: Int -> RegNo -- | Get the regno for this sort of reg fReg :: Int -> RegNo -- | Some specific regs used by the code generator. fp :: Reg -- | Some specific regs used by the code generator. sp :: Reg -- | Some specific regs used by the code generator. g0 :: Reg -- | Some specific regs used by the code generator. g1 :: Reg -- | Some specific regs used by the code generator. g2 :: Reg -- | Some specific regs used by the code generator. o0 :: Reg -- | Some specific regs used by the code generator. o1 :: Reg -- | Some specific regs used by the code generator. f0 :: Reg -- | Some specific regs used by the code generator. f1 :: Reg -- | Some specific regs used by the code generator. f6 :: Reg -- | Some specific regs used by the code generator. f8 :: Reg -- | Some specific regs used by the code generator. f22 :: Reg -- | Some specific regs used by the code generator. f26 :: Reg -- | Some specific regs used by the code generator. f27 :: Reg -- | Produce the second-half-of-a-double register given the first half. -- -- All the regs that the register allocator can allocate to, with the -- fixed use regs removed. allocatableRegs :: [RealReg] -- | The registers to place arguments for function calls, for some number -- of arguments. argRegs :: RegNo -> [Reg] -- | All the regs that could possibly be returned by argRegs allArgRegs :: [Reg] callClobberedRegs :: [Reg] -- | Make a virtual reg with this format. mkVirtualReg :: Unique -> Format -> VirtualReg regDotColor :: RealReg -> SDoc module GHC.CmmToAsm.SPARC.Stack -- | Get an AddrMode relative to the address in sp. This gives us a stack -- relative addressing mode for volatile temporaries and for excess call -- arguments. spRel :: Int -> AddrMode -- | Get an address relative to the frame pointer. This doesn't work work -- for offsets greater than 13 bits; we just hope for the best fpRel :: Int -> AddrMode -- | Convert a spill slot number to a *byte* offset, with no sign. spillSlotToOffset :: NCGConfig -> Int -> Int -- | The maximum number of spill slots available on the C stack. If we use -- up all of the slots, then we're screwed. -- -- Why do we reserve 64 bytes, instead of using the whole thing?? -- BL -- 20090215 maxSpillSlots :: NCGConfig -> Int -- | Free regs map for SPARC module GHC.CmmToAsm.Reg.Linear.SPARC data FreeRegs FreeRegs :: !Word32 -> !Word32 -> !Word32 -> FreeRegs -- | A reg map where no regs are free to be allocated. noFreeRegs :: FreeRegs -- | The initial set of free regs. initFreeRegs :: Platform -> FreeRegs -- | Get all the free registers of this class. getFreeRegs :: RegClass -> FreeRegs -> [RealReg] -- | Grab a register. allocateReg :: Platform -> RealReg -> FreeRegs -> FreeRegs -- | Release a register from allocation. The register liveness information -- says that most regs die after a C call, but we still don't want to -- allocate to some of them. releaseReg :: Platform -> RealReg -> FreeRegs -> FreeRegs bitMask :: Int -> Word32 showFreeRegs :: FreeRegs -> String instance GHC.Show.Show GHC.CmmToAsm.Reg.Linear.SPARC.FreeRegs instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.Reg.Linear.SPARC.FreeRegs module GHC.CmmToAsm.PPC.Regs -- | regSqueeze_class reg Calculate the maximum number of register colors -- that could be denied to a node of this class due to having this reg as -- a neighbour. virtualRegSqueeze :: RegClass -> VirtualReg -> Int realRegSqueeze :: RegClass -> RealReg -> Int mkVirtualReg :: Unique -> Format -> VirtualReg regDotColor :: RealReg -> SDoc data Imm ImmInt :: Int -> Imm ImmInteger :: Integer -> Imm ImmCLbl :: CLabel -> Imm ImmLit :: SDoc -> Imm ImmIndex :: CLabel -> Int -> Imm ImmFloat :: Rational -> Imm ImmDouble :: Rational -> Imm ImmConstantSum :: Imm -> Imm -> Imm ImmConstantDiff :: Imm -> Imm -> Imm LO :: Imm -> Imm HI :: Imm -> Imm HA :: Imm -> Imm HIGHERA :: Imm -> Imm HIGHESTA :: Imm -> Imm strImmLit :: String -> Imm litToImm :: CmmLit -> Imm data AddrMode AddrRegReg :: Reg -> Reg -> AddrMode AddrRegImm :: Reg -> Imm -> AddrMode addrOffset :: AddrMode -> Int -> Maybe AddrMode spRel :: Platform -> Int -> AddrMode argRegs :: RegNo -> [Reg] allArgRegs :: [Reg] callClobberedRegs :: Platform -> [Reg] allMachRegNos :: [RegNo] classOfRealReg :: RealReg -> RegClass showReg :: RegNo -> String toRegNo :: Reg -> RegNo allFPArgRegs :: Platform -> [Reg] fits16Bits :: Integral a => a -> Bool makeImmediate :: Integral a => Width -> Bool -> a -> Maybe Imm fReg :: Int -> RegNo r0 :: Reg sp :: Reg toc :: Reg r3 :: Reg r4 :: Reg r11 :: Reg r12 :: Reg r30 :: Reg tmpReg :: Platform -> Reg f1 :: Reg allocatableRegs :: Platform -> [RealReg] -- | Free regs map for PowerPC module GHC.CmmToAsm.Reg.Linear.PPC data FreeRegs FreeRegs :: !Word32 -> !Word32 -> FreeRegs noFreeRegs :: FreeRegs releaseReg :: RealReg -> FreeRegs -> FreeRegs initFreeRegs :: Platform -> FreeRegs getFreeRegs :: RegClass -> FreeRegs -> [RealReg] allocateReg :: RealReg -> FreeRegs -> FreeRegs instance GHC.Show.Show GHC.CmmToAsm.Reg.Linear.PPC.FreeRegs instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.Reg.Linear.PPC.FreeRegs -- | Constants describing the DWARF format. Most of this simply mirrors -- /usr/include/dwarf.h. module GHC.CmmToAsm.Dwarf.Constants -- | Language ID used for Haskell. dW_LANG_Haskell :: Word dW_TAG_compile_unit :: Word dW_TAG_subroutine_type :: Word dW_TAG_file_type :: Word dW_TAG_subprogram :: Word dW_TAG_lexical_block :: Word dW_TAG_base_type :: Word dW_TAG_structure_type :: Word dW_TAG_pointer_type :: Word dW_TAG_array_type :: Word dW_TAG_subrange_type :: Word dW_TAG_typedef :: Word dW_TAG_variable :: Word dW_TAG_arg_variable :: Word dW_TAG_auto_variable :: Word dW_TAG_ghc_src_note :: Word dW_AT_name :: Word dW_AT_stmt_list :: Word dW_AT_low_pc :: Word dW_AT_high_pc :: Word dW_AT_language :: Word dW_AT_comp_dir :: Word dW_AT_producer :: Word dW_AT_external :: Word dW_AT_frame_base :: Word dW_AT_use_UTF8 :: Word dW_AT_linkage_name :: Word dW_AT_ghc_tick_parent :: Word dW_AT_ghc_span_file :: Word dW_AT_ghc_span_start_line :: Word dW_AT_ghc_span_start_col :: Word dW_AT_ghc_span_end_line :: Word dW_AT_ghc_span_end_col :: Word dW_CHILDREN_no :: Word8 dW_CHILDREN_yes :: Word8 dW_FORM_addr :: Word dW_FORM_data2 :: Word dW_FORM_data4 :: Word dW_FORM_string :: Word dW_FORM_flag :: Word dW_FORM_block1 :: Word dW_FORM_ref4 :: Word dW_FORM_ref_addr :: Word dW_FORM_flag_present :: Word dW_ATE_address :: Word dW_ATE_boolean :: Word dW_ATE_float :: Word dW_ATE_signed :: Word dW_ATE_signed_char :: Word dW_ATE_unsigned :: Word dW_ATE_unsigned_char :: Word dW_CFA_set_loc :: Word8 dW_CFA_undefined :: Word8 dW_CFA_same_value :: Word8 dW_CFA_def_cfa :: Word8 dW_CFA_def_cfa_offset :: Word8 dW_CFA_def_cfa_expression :: Word8 dW_CFA_expression :: Word8 dW_CFA_offset_extended_sf :: Word8 dW_CFA_def_cfa_offset_sf :: Word8 dW_CFA_def_cfa_sf :: Word8 dW_CFA_val_offset :: Word8 dW_CFA_val_expression :: Word8 dW_CFA_offset :: Word8 dW_OP_addr :: Word8 dW_OP_deref :: Word8 dW_OP_consts :: Word8 dW_OP_minus :: Word8 dW_OP_mul :: Word8 dW_OP_plus :: Word8 dW_OP_lit0 :: Word8 dW_OP_breg0 :: Word8 dW_OP_call_frame_cfa :: Word8 dwarfInfoSection :: Platform -> SDoc dwarfAbbrevSection :: Platform -> SDoc dwarfLineSection :: Platform -> SDoc dwarfFrameSection :: Platform -> SDoc dwarfGhcSection :: Platform -> SDoc dwarfARangesSection :: Platform -> SDoc dwarfSection :: Platform -> String -> SDoc dwarfInfoLabel :: PtrString dwarfAbbrevLabel :: PtrString dwarfLineLabel :: PtrString dwarfFrameLabel :: PtrString -- | Mapping of registers to DWARF register numbers dwarfRegNo :: Platform -> Reg -> Word8 -- | Virtual register number to use for return address. dwarfReturnRegNo :: Platform -> Word8 module GHC.CmmToAsm.AArch64.Regs allMachRegNos :: [RegNo] allocatableRegs :: Platform -> [RealReg] allGpArgRegs :: [Reg] allFpArgRegs :: [Reg] data AddrMode AddrRegReg :: Reg -> Reg -> AddrMode AddrRegImm :: Reg -> Imm -> AddrMode AddrReg :: Reg -> AddrMode data Imm ImmInt :: Int -> Imm ImmInteger :: Integer -> Imm ImmCLbl :: CLabel -> Imm ImmLit :: SDoc -> Imm ImmIndex :: CLabel -> Int -> Imm ImmFloat :: Rational -> Imm ImmDouble :: Rational -> Imm ImmConstantSum :: Imm -> Imm -> Imm ImmConstantDiff :: Imm -> Imm -> Imm strImmLit :: String -> Imm litToImm :: CmmLit -> Imm -- | regSqueeze_class reg Calculate the maximum number of register colors -- that could be denied to a node of this class due to having this reg as -- a neighbour. virtualRegSqueeze :: RegClass -> VirtualReg -> Int realRegSqueeze :: RegClass -> RealReg -> Int mkVirtualReg :: Unique -> Format -> VirtualReg classOfRealReg :: RealReg -> RegClass regDotColor :: RealReg -> SDoc instance GHC.Show.Show GHC.CmmToAsm.AArch64.Regs.Imm instance GHC.Classes.Eq GHC.CmmToAsm.AArch64.Regs.Imm instance GHC.Show.Show GHC.CmmToAsm.AArch64.Regs.AddrMode instance GHC.Classes.Eq GHC.CmmToAsm.AArch64.Regs.AddrMode instance GHC.Show.Show GHC.Utils.Outputable.SDoc instance GHC.Classes.Eq GHC.Utils.Outputable.SDoc -- | Hard wired things related to registers. This is module is preventing -- the native code generator being able to emit code for non-host -- architectures. -- -- TODO: Do a better job of the overloading, and eliminate this module. -- We'd probably do better with a Register type class, and hook this to -- Instruction somehow. -- -- TODO: We should also make arch specific versions of -- RegAlloc.Graph.TrivColorable module GHC.CmmToAsm.Reg.Target targetVirtualRegSqueeze :: Platform -> RegClass -> VirtualReg -> Int targetRealRegSqueeze :: Platform -> RegClass -> RealReg -> Int targetClassOfRealReg :: Platform -> RealReg -> RegClass targetMkVirtualReg :: Platform -> Unique -> Format -> VirtualReg targetRegDotColor :: Platform -> RealReg -> SDoc targetClassOfReg :: Platform -> Reg -> RegClass module GHC.CmmToAsm.SPARC.Instr -- | SPARC instruction set. Not complete. This is only the ones we need. data Instr COMMENT :: FastString -> Instr LDATA :: Section -> RawCmmStatics -> Instr NEWBLOCK :: BlockId -> Instr DELTA :: Int -> Instr LD :: Format -> AddrMode -> Reg -> Instr ST :: Format -> Reg -> AddrMode -> Instr ADD :: Bool -> Bool -> Reg -> RI -> Reg -> Instr SUB :: Bool -> Bool -> Reg -> RI -> Reg -> Instr UMUL :: Bool -> Reg -> RI -> Reg -> Instr SMUL :: Bool -> Reg -> RI -> Reg -> Instr UDIV :: Bool -> Reg -> RI -> Reg -> Instr SDIV :: Bool -> Reg -> RI -> Reg -> Instr RDY :: Reg -> Instr WRY :: Reg -> Reg -> Instr AND :: Bool -> Reg -> RI -> Reg -> Instr ANDN :: Bool -> Reg -> RI -> Reg -> Instr OR :: Bool -> Reg -> RI -> Reg -> Instr ORN :: Bool -> Reg -> RI -> Reg -> Instr XOR :: Bool -> Reg -> RI -> Reg -> Instr XNOR :: Bool -> Reg -> RI -> Reg -> Instr SLL :: Reg -> RI -> Reg -> Instr SRL :: Reg -> RI -> Reg -> Instr SRA :: Reg -> RI -> Reg -> Instr SETHI :: Imm -> Reg -> Instr NOP :: Instr FABS :: Format -> Reg -> Reg -> Instr FADD :: Format -> Reg -> Reg -> Reg -> Instr FCMP :: Bool -> Format -> Reg -> Reg -> Instr FDIV :: Format -> Reg -> Reg -> Reg -> Instr FMOV :: Format -> Reg -> Reg -> Instr FMUL :: Format -> Reg -> Reg -> Reg -> Instr FNEG :: Format -> Reg -> Reg -> Instr FSQRT :: Format -> Reg -> Reg -> Instr FSUB :: Format -> Reg -> Reg -> Reg -> Instr FxTOy :: Format -> Format -> Reg -> Reg -> Instr BI :: Cond -> Bool -> BlockId -> Instr BF :: Cond -> Bool -> BlockId -> Instr JMP :: AddrMode -> Instr JMP_TBL :: AddrMode -> [Maybe BlockId] -> CLabel -> Instr CALL :: Either Imm Reg -> Int -> Bool -> Instr -- | Register or immediate data RI RIReg :: Reg -> RI RIImm :: Imm -> RI -- | Check if a RI represents a zero value. - a literal zero - register -- %g0, which is always zero. riZero :: RI -> Bool -- | Calculate the effective address which would be used by the -- corresponding fpRel sequence. fpRelEA :: Int -> Reg -> Instr -- | Code to shift the stack pointer by n words. moveSp :: Int -> Instr -- | An instruction that will cause the one after it never to be exectuted isUnconditionalJump :: Instr -> Bool -- | The maximum number of spill slots available on the C stack. If we use -- up all of the slots, then we're screwed. -- -- Why do we reserve 64 bytes, instead of using the whole thing?? -- BL -- 20090215 maxSpillSlots :: NCGConfig -> Int -- | Apply a given mapping to tall the register references in this -- instruction. patchRegsOfInstr :: Instr -> (Reg -> Reg) -> Instr patchJumpInstr :: Instr -> (BlockId -> BlockId) -> Instr -- | Make a reg-reg move instruction. On SPARC v8 there are no instructions -- to move directly between floating point and integer regs. If we need -- to do that then we have to go via memory. mkRegRegMoveInstr :: Platform -> Reg -> Reg -> Instr -- | Make a spill reload instruction. mkLoadInstr :: NCGConfig -> Reg -> Int -> Int -> [Instr] -- | Make a spill instruction. On SPARC we spill below frame pointer -- leaving 2 words/spill mkSpillInstr :: NCGConfig -> Reg -> Int -> Int -> [Instr] -- | Make an unconditional branch instruction. mkJumpInstr :: BlockId -> [Instr] -- | See if this instruction is telling us the current C stack delta takeDeltaInstr :: Instr -> Maybe Int isMetaInstr :: Instr -> Bool isJumpishInstr :: Instr -> Bool jumpDestsOfInstr :: Instr -> [BlockId] -- | Check whether an instruction represents a reg-reg move. The register -- allocator attempts to eliminate reg->reg moves whenever it can, by -- assigning the src and dest temporaries to the same real register. takeRegRegMoveInstr :: Instr -> Maybe (Reg, Reg) -- | regUsage returns the sets of src and destination registers used by a -- particular instruction. Machine registers that are pre-allocated to -- stgRegs are filtered out, because they are uninteresting from a -- register allocation standpoint. (We wouldn't want them to end up on -- the free list!) As far as we are concerned, the fixed registers simply -- don't exist (for allocation purposes, anyway). regUsageOfInstr :: Platform -> Instr -> RegUsage module GHC.CmmToAsm.SPARC.ShortcutJump data JumpDest DestBlockId :: BlockId -> JumpDest DestImm :: Imm -> JumpDest getJumpDestBlockId :: JumpDest -> Maybe BlockId canShortcut :: Instr -> Maybe JumpDest shortcutJump :: (BlockId -> Maybe JumpDest) -> Instr -> Instr shortcutStatics :: (BlockId -> Maybe JumpDest) -> RawCmmStatics -> RawCmmStatics shortBlockId :: (BlockId -> Maybe JumpDest) -> BlockId -> CLabel instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.SPARC.ShortcutJump.JumpDest -- | Expand out synthetic instructions into single machine instrs. module GHC.CmmToAsm.SPARC.CodeGen.Expand -- | Expand out synthetic instructions in this top level thing expandTop :: NatCmmDecl RawCmmStatics Instr -> NatCmmDecl RawCmmStatics Instr module GHC.CmmToAsm.SPARC.CodeGen.Base -- | InstrBlocks are the insn sequences generated by the insn -- selectors. They are really trees of insns to facilitate fast -- appending, where a left-to-right traversal yields the insns in the -- correct order. type InstrBlock = OrdList Instr -- | Condition codes passed up the tree. data CondCode CondCode :: Bool -> Cond -> InstrBlock -> CondCode -- | a.k.a "Register64" Reg is the lower 32-bit temporary which contains -- the result. Use getHiVRegFromLo to find the other VRegUnique. -- -- Rules of this simplified insn selection game are therefore that the -- returned Reg may be modified data ChildCode64 ChildCode64 :: InstrBlock -> Reg -> ChildCode64 -- | Holds code that references a memory address. data Amode Amode :: AddrMode -> InstrBlock -> Amode -- | Code to produce a result into a register. If the result must go in a -- specific register, it comes out as Fixed. Otherwise, the parent can -- decide which register to put it in. data Register Fixed :: Format -> Reg -> InstrBlock -> Register Any :: Format -> (Reg -> InstrBlock) -> Register -- | Change the format field in a Register. setFormatOfRegister :: Register -> Format -> Register -- | Grab the Reg for a CmmReg getRegisterReg :: Platform -> CmmReg -> Reg mangleIndexTree :: Platform -> CmmExpr -> CmmExpr module GHC.CmmToAsm.Reg.Linear.AArch64 -- | Armv6 | Armv7-A | Armv8-A AArch64 | | SIMD extension | NEON | NEON | -- |===========================================================================| -- | - Operates on 32-bit | - Separate reg. bank, | - Separate reg. bank, -- | | GP ARM registers | 32x64-bit NEON regs | 32x128-bit NEON regs | | -- - 8-bit16-bit integer | - 8163264-bit int | - -- 81632/64-bit int | | | - Single percision fp | - Single -- percision fp | | | | - Double precision fp | | | | - Single/Double fp -- are | | | | IEEE compliant | | - 2x16-bit/4x8-bit ops | - Up to -- 16x8-bit ops | - Up to 16x8-bit ops | | per instruction | per -- instruction | per instruction | -- '---------------------------------------------------------------------------' data FreeRegs FreeRegs :: !Word32 -> !Word32 -> FreeRegs noFreeRegs :: FreeRegs showBits :: Word32 -> String allocateReg :: HasCallStack => RealReg -> FreeRegs -> FreeRegs getFreeRegs :: RegClass -> FreeRegs -> [RealReg] initFreeRegs :: Platform -> FreeRegs releaseReg :: HasCallStack => RealReg -> FreeRegs -> FreeRegs instance GHC.Show.Show GHC.CmmToAsm.Reg.Linear.AArch64.FreeRegs instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.Reg.Linear.AArch64.FreeRegs module GHC.CmmToAsm.AArch64.Instr -- | TODO: verify this! stackFrameHeaderSize :: Platform -> Int -- | All registers are 8 byte wide. spillSlotSize :: Int -- | The number of bytes that the stack pointer should be aligned to. stackAlign :: Int -- | The number of spill slots available without allocating more. maxSpillSlots :: NCGConfig -> Int -- | Convert a spill slot number to a *byte* offset, with no sign. spillSlotToOffset :: NCGConfig -> Int -> Int regUsageOfInstr :: Platform -> Instr -> RegUsage -- | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -- 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -- 30 | 31 | | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 42 -- | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 -- | 58 | 59 | 60 | 61 | 62 | 63 | |== General Purpose registers -- ==================================================================================================================================| -- | argument passing ------------- | IR | tmp registers -- -------- | IP0| IP1| PL | callee saved ------------ | FP | -- LR | SP | | free registers -- -------------------------------------------------------------------- -- | BR | Sp | Hp | R1 | R2 | R3 | R4 | R5 | R6 | SL | -- | -- | -- | |== -- SIMD/FP Registers -- ==========================================================================================================================================| -- | argument passing ------------- | callee saved (lower 64 -- bits) --- | caller saved ---------------------- | | free -- registers ------------- | F1 | F2 | F3 | F4 | D1 | D2 | D3 | D4 | -- free registers -- ----------------------------------------------------- | -- '---------------------------------------------------------------------------------------------------------------------------------------------------------------' -- IR: Indirect result location register, IP: Intra-procedure register, -- PL: Platform register, FP: Frame pointer, LR: Link register, SP: Stack -- pointer BR: Base, SL: SpLim callerSavedRegisters :: [Reg] -- | Apply a given mapping to all the register references in this -- instruction. patchRegsOfInstr :: Instr -> (Reg -> Reg) -> Instr -- | Checks whether this instruction is a jump/branch instruction. One that -- can change the flow of control in a way that the register allocator -- needs to worry about. isJumpishInstr :: Instr -> Bool -- | Checks whether this instruction is a jump/branch instruction. One that -- can change the flow of control in a way that the register allocator -- needs to worry about. jumpDestsOfInstr :: Instr -> [BlockId] -- | Change the destination of this jump instruction. Used in the linear -- allocator when adding fixup blocks for join points. patchJumpInstr :: Instr -> (BlockId -> BlockId) -> Instr -- | An instruction to spill a register into a spill slot. mkSpillInstr :: HasCallStack => NCGConfig -> Reg -> Int -> Int -> [Instr] mkLoadInstr :: NCGConfig -> Reg -> Int -> Int -> [Instr] -- | See if this instruction is telling us the current C stack delta takeDeltaInstr :: Instr -> Maybe Int isMetaInstr :: Instr -> Bool -- | Copy the value in a register to another one. Must work for all -- register classes. mkRegRegMoveInstr :: Reg -> Reg -> Instr -- | Take the source and destination from this reg -> reg move -- instruction or Nothing if it's not one takeRegRegMoveInstr :: Instr -> Maybe (Reg, Reg) -- | Make an unconditional jump instruction. mkJumpInstr :: BlockId -> [Instr] mkStackAllocInstr :: Platform -> Int -> [Instr] mkStackDeallocInstr :: Platform -> Int -> [Instr] allocMoreStack :: Platform -> Int -> NatCmmDecl statics Instr -> UniqSM (NatCmmDecl statics Instr, [(BlockId, BlockId)]) data Instr COMMENT :: SDoc -> Instr MULTILINE_COMMENT :: SDoc -> Instr ANN :: SDoc -> Instr -> Instr LOCATION :: Int -> Int -> Int -> String -> Instr LDATA :: Section -> RawCmmStatics -> Instr NEWBLOCK :: BlockId -> Instr DELTA :: Int -> Instr SXTB :: Operand -> Operand -> Instr UXTB :: Operand -> Operand -> Instr SXTH :: Operand -> Operand -> Instr UXTH :: Operand -> Operand -> Instr -- | SXTW Operand Operand | SXTX Operand Operand PUSH_STACK_FRAME :: Instr POP_STACK_FRAME :: Instr -- | ADC Operand Operand Operang -- rd = rn + rm + C | ADCS ... ADD :: Operand -> Operand -> Operand -> Instr -- | ADDS Operand Operand Operand -- rd = rn + rm | ADR ... | ADRP ... CMN :: Operand -> Operand -> Instr CMP :: Operand -> Operand -> Instr -- | MADD ... | MNEG ... MSUB :: Operand -> Operand -> Operand -> Operand -> Instr MUL :: Operand -> Operand -> Operand -> Instr NEG :: Operand -> Operand -> Instr -- | NEGS ... | NGC ... | NGCS ... | SBC ... | SBCS ... SDIV :: Operand -> Operand -> Operand -> Instr -- | SMADDL ... | SMNEGL ... | SMSUBL ... | SMULH ... | SMULL ... SUB :: Operand -> Operand -> Operand -> Instr -- | SUBS ... UDIV :: Operand -> Operand -> Operand -> Instr -- | UMADDL ... -- Xd = Xa + Wn × Wm | UMNEGL ... -- Xd = - Wn × Wm | -- UMSUBL ... -- Xd = Xa - Wn × Wm | UMULH ... -- Xd = (Xn × Xm)_127:64 | -- UMULL ... -- Xd = Wn × Wm SBFM :: Operand -> Operand -> Operand -> Operand -> Instr UBFM :: Operand -> Operand -> Operand -> Operand -> Instr SBFX :: Operand -> Operand -> Operand -> Operand -> Instr UBFX :: Operand -> Operand -> Operand -> Operand -> Instr AND :: Operand -> Operand -> Operand -> Instr ANDS :: Operand -> Operand -> Operand -> Instr ASR :: Operand -> Operand -> Operand -> Instr BIC :: Operand -> Operand -> Operand -> Instr BICS :: Operand -> Operand -> Operand -> Instr EON :: Operand -> Operand -> Operand -> Instr EOR :: Operand -> Operand -> Operand -> Instr LSL :: Operand -> Operand -> Operand -> Instr LSR :: Operand -> Operand -> Operand -> Instr MOV :: Operand -> Operand -> Instr MOVK :: Operand -> Operand -> Instr -- | MOVN Operand Operand | MOVZ Operand Operand MVN :: Operand -> Operand -> Instr ORN :: Operand -> Operand -> Operand -> Instr ORR :: Operand -> Operand -> Operand -> Instr ROR :: Operand -> Operand -> Operand -> Instr TST :: Operand -> Operand -> Instr STR :: Format -> Operand -> Operand -> Instr LDR :: Format -> Operand -> Operand -> Instr STP :: Format -> Operand -> Operand -> Operand -> Instr LDP :: Format -> Operand -> Operand -> Operand -> Instr CSET :: Operand -> Cond -> Instr CBZ :: Operand -> Target -> Instr CBNZ :: Operand -> Target -> Instr J :: Target -> Instr B :: Target -> Instr BL :: Target -> [Reg] -> [Reg] -> Instr BCOND :: Cond -> Target -> Instr DMBSY :: Instr FCVT :: Operand -> Operand -> Instr SCVTF :: Operand -> Operand -> Instr FCVTZS :: Operand -> Operand -> Instr FABS :: Operand -> Operand -> Instr data Target TBlock :: BlockId -> Target TLabel :: CLabel -> Target TReg :: Reg -> Target data ExtMode EUXTB :: ExtMode EUXTH :: ExtMode EUXTW :: ExtMode EUXTX :: ExtMode ESXTB :: ExtMode ESXTH :: ExtMode ESXTW :: ExtMode ESXTX :: ExtMode data ShiftMode SLSL :: ShiftMode SLSR :: ShiftMode SASR :: ShiftMode SROR :: ShiftMode type ExtShift = Int type RegShift = Int data Operand OpReg :: Width -> Reg -> Operand OpRegExt :: Width -> Reg -> ExtMode -> ExtShift -> Operand OpRegShift :: Width -> Reg -> ShiftMode -> RegShift -> Operand OpImm :: Imm -> Operand OpImmShift :: Imm -> ShiftMode -> RegShift -> Operand OpAddr :: AddrMode -> Operand opReg :: Width -> Reg -> Operand xzr :: Operand wzr :: Operand sp :: Operand ip0 :: Operand _x :: Int -> Operand x0 :: Operand x1 :: Operand x2 :: Operand x3 :: Operand x4 :: Operand x5 :: Operand x6 :: Operand x7 :: Operand x8 :: Operand x9 :: Operand x10 :: Operand x11 :: Operand x12 :: Operand x13 :: Operand x14 :: Operand x15 :: Operand x16 :: Operand x17 :: Operand x18 :: Operand x19 :: Operand x20 :: Operand x21 :: Operand x22 :: Operand x23 :: Operand x24 :: Operand x25 :: Operand x26 :: Operand x27 :: Operand x28 :: Operand x29 :: Operand x30 :: Operand x31 :: Operand _d :: Int -> Operand d0 :: Operand d1 :: Operand d2 :: Operand d3 :: Operand d4 :: Operand d5 :: Operand d6 :: Operand d7 :: Operand d8 :: Operand d9 :: Operand d10 :: Operand d11 :: Operand d12 :: Operand d13 :: Operand d14 :: Operand d15 :: Operand d16 :: Operand d17 :: Operand d18 :: Operand d19 :: Operand d20 :: Operand d21 :: Operand d22 :: Operand d23 :: Operand d24 :: Operand d25 :: Operand d26 :: Operand d27 :: Operand d28 :: Operand d29 :: Operand d30 :: Operand d31 :: Operand opRegUExt :: Width -> Reg -> Operand opRegSExt :: Width -> Reg -> Operand instance GHC.Show.Show GHC.CmmToAsm.AArch64.Instr.ExtMode instance GHC.Classes.Eq GHC.CmmToAsm.AArch64.Instr.ExtMode instance GHC.Show.Show GHC.CmmToAsm.AArch64.Instr.ShiftMode instance GHC.Classes.Eq GHC.CmmToAsm.AArch64.Instr.ShiftMode instance GHC.Show.Show GHC.CmmToAsm.AArch64.Instr.Operand instance GHC.Classes.Eq GHC.CmmToAsm.AArch64.Instr.Operand instance GHC.Show.Show GHC.CmmToAsm.AArch64.Instr.Instr instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.Instr.RegUsage module GHC.CmmToAsm.AArch64.RegInfo data JumpDest DestBlockId :: BlockId -> JumpDest getJumpDestBlockId :: JumpDest -> Maybe BlockId canShortcut :: Instr -> Maybe JumpDest shortcutStatics :: (BlockId -> Maybe JumpDest) -> RawCmmStatics -> RawCmmStatics shortcutJump :: (BlockId -> Maybe JumpDest) -> Instr -> Instr instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.AArch64.RegInfo.JumpDest module GHC.CmmToAsm.AArch64.Ppr pprNatCmmDecl :: NCGConfig -> NatCmmDecl RawCmmStatics Instr -> SDoc pprInstr :: Platform -> Instr -> SDoc instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.AArch64.Instr.Instr module GHC.Cmm.Utils primRepCmmType :: Platform -> PrimRep -> CmmType slotCmmType :: Platform -> SlotTy -> CmmType typeCmmType :: Platform -> UnaryType -> CmmType typeForeignHint :: UnaryType -> ForeignHint primRepForeignHint :: PrimRep -> ForeignHint zeroCLit :: Platform -> CmmLit mkIntCLit :: Platform -> Int -> CmmLit mkWordCLit :: Platform -> Integer -> CmmLit packHalfWordsCLit :: Platform -> StgHalfWord -> StgHalfWord -> CmmLit -- | We make a top-level decl for the string, and return a label pointing -- to it mkByteStringCLit :: CLabel -> ByteString -> (CmmLit, GenCmmDecl (GenCmmStatics raw) info stmt) -- | We make a top-level decl for the embedded binary file, and return a -- label pointing to it mkFileEmbedLit :: CLabel -> FilePath -> (CmmLit, GenCmmDecl (GenCmmStatics raw) info stmt) -- | Build a data-segment data block mkDataLits :: Section -> CLabel -> [CmmLit] -> GenCmmDecl (GenCmmStatics raw) info stmt mkRODataLits :: CLabel -> [CmmLit] -> GenCmmDecl (GenCmmStatics raw) info stmt mkStgWordCLit :: Platform -> StgWord -> CmmLit mkIntExpr :: Platform -> Int -> CmmExpr zeroExpr :: Platform -> CmmExpr mkLblExpr :: CLabel -> CmmExpr cmmRegOff :: CmmReg -> Int -> CmmExpr cmmOffset :: Platform -> CmmExpr -> Int -> CmmExpr cmmLabelOff :: CLabel -> Int -> CmmLit cmmOffsetLit :: CmmLit -> Int -> CmmLit cmmOffsetExpr :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmRegOffB :: CmmReg -> ByteOff -> CmmExpr cmmOffsetB :: Platform -> CmmExpr -> ByteOff -> CmmExpr cmmLabelOffB :: CLabel -> ByteOff -> CmmLit cmmOffsetLitB :: CmmLit -> ByteOff -> CmmLit cmmOffsetExprB :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmRegOffW :: Platform -> CmmReg -> WordOff -> CmmExpr cmmOffsetW :: Platform -> CmmExpr -> WordOff -> CmmExpr cmmLabelOffW :: Platform -> CLabel -> WordOff -> CmmLit cmmOffsetLitW :: Platform -> CmmLit -> WordOff -> CmmLit cmmOffsetExprW :: Platform -> CmmExpr -> CmmExpr -> CmmExpr -- | Useful for creating an index into an array, with a statically known -- offset. The type is the element type; used for making the multiplier cmmIndex :: Platform -> Width -> CmmExpr -> Int -> CmmExpr -- | Useful for creating an index into an array, with an unknown offset. cmmIndexExpr :: Platform -> Width -> CmmExpr -> CmmExpr -> CmmExpr cmmLoadIndex :: Platform -> CmmType -> CmmExpr -> Int -> CmmExpr cmmLoadIndexW :: Platform -> CmmExpr -> Int -> CmmType -> CmmExpr -- | Load a naturally-aligned non-pointer word. cmmLoadBWord :: Platform -> CmmExpr -> CmmExpr -- | Load a naturally-aligned GC pointer. cmmLoadGCWord :: Platform -> CmmExpr -> CmmExpr cmmNegate :: Platform -> CmmExpr -> CmmExpr cmmULtWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmUGeWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmUGtWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmUShrWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmSLtWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmNeWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmEqWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmOrWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmAndWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmSubWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmAddWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmMulWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmQuotWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmToWord :: Platform -> CmmExpr -> CmmExpr cmmMkAssign :: Platform -> CmmExpr -> Unique -> (CmmNode O O, CmmExpr) isTrivialCmmExpr :: CmmExpr -> Bool hasNoGlobalRegs :: CmmExpr -> Bool isLit :: CmmExpr -> Bool isComparisonExpr :: CmmExpr -> Bool baseExpr :: CmmExpr spExpr :: CmmExpr hpExpr :: CmmExpr spLimExpr :: CmmExpr hpLimExpr :: CmmExpr currentTSOExpr :: CmmExpr currentNurseryExpr :: CmmExpr cccsExpr :: CmmExpr cmmTagMask :: Platform -> CmmExpr cmmPointerMask :: Platform -> CmmExpr cmmUntag :: Platform -> CmmExpr -> CmmExpr cmmIsTagged :: Platform -> CmmExpr -> CmmExpr cmmConstrTag1 :: Platform -> CmmExpr -> CmmExpr mAX_PTR_TAG :: Platform -> Int tAG_MASK :: Platform -> Int -- | Returns True if the two STG registers overlap on the specified -- platform, in the sense that writing to one will clobber the other. -- This includes the case that the two registers are the same STG -- register. See Note [Overlapping global registers] for details. regsOverlap :: Platform -> CmmReg -> CmmReg -> Bool -- | Returns True if the STG register is used by the expression, in the -- sense that a store to the register might affect the value of the -- expression. -- -- We must check for overlapping registers and not just equal registers -- here, otherwise CmmSink may incorrectly reorder assignments that -- conflict due to overlap. See #10521 and Note [Overlapping global -- registers]. regUsedIn :: Platform -> CmmReg -> CmmExpr -> Bool mkLiveness :: Platform -> [LocalReg] -> Liveness modifyGraph :: (Graph n C C -> Graph n' C C) -> GenCmmGraph n -> GenCmmGraph n' ofBlockMap :: BlockId -> LabelMap CmmBlock -> CmmGraph toBlockMap :: CmmGraph -> LabelMap CmmBlock ofBlockList :: BlockId -> [CmmBlock] -> CmmGraph toBlockList :: CmmGraph -> [CmmBlock] bodyToBlockList :: Body CmmNode -> [CmmBlock] -- | like toBlockList, but the entry block always comes first toBlockListEntryFirst :: CmmGraph -> [CmmBlock] -- | Like toBlockListEntryFirst, but we strive to ensure that we -- order blocks so that the false case of a conditional jumps to the next -- block in the output list of blocks. This matches the way OldCmm blocks -- were output since in OldCmm the false case was a fallthrough, whereas -- in Cmm conditional branches have both true and false successors. Block -- ordering can make a big difference in performance in the LLVM backend. -- Note that we rely crucially on the order of successors returned for -- CmmCondBranch by the NonLocal instance for CmmNode defined in -- GHC.Cmm.Node. -GBM toBlockListEntryFirstFalseFallthrough :: CmmGraph -> [CmmBlock] foldlGraphBlocks :: (a -> CmmBlock -> a) -> a -> CmmGraph -> a mapGraphNodes :: (CmmNode C O -> CmmNode C O, CmmNode O O -> CmmNode O O, CmmNode O C -> CmmNode O C) -> CmmGraph -> CmmGraph revPostorder :: CmmGraph -> [CmmBlock] mapGraphNodes1 :: (forall e x. CmmNode e x -> CmmNode e x) -> CmmGraph -> CmmGraph -- | Extract all tick annotations from the given block blockTicks :: Block CmmNode C C -> [CmmTickish] module GHC.StgToCmm.Closure type DynTag = Int tagForCon :: Platform -> DataCon -> DynTag isSmallFamily :: Platform -> Int -> Bool -- | Assumes that there is precisely one PrimRep of the type. This -- assumption holds after unarise. See Note [Post-unarisation invariants] idPrimRep :: Id -> PrimRep isVoidRep :: PrimRep -> Bool isGcPtrRep :: PrimRep -> Bool -- | Assumes that Ids have one PrimRep, which holds after unarisation. See -- Note [Post-unarisation invariants] addIdReps :: [NonVoid Id] -> [NonVoid (PrimRep, Id)] -- | Assumes that arguments have one PrimRep, which holds after -- unarisation. See Note [Post-unarisation invariants] addArgReps :: [NonVoid StgArg] -> [NonVoid (PrimRep, StgArg)] -- | Assumes that the argument has one PrimRep, which holds after -- unarisation. See Note [Post-unarisation invariants] argPrimRep :: StgArg -> PrimRep newtype NonVoid a NonVoid :: a -> NonVoid a fromNonVoid :: NonVoid a -> a nonVoidIds :: [Id] -> [NonVoid Id] nonVoidStgArgs :: [StgArg] -> [NonVoid StgArg] -- | Used in places where some invariant ensures that all these Ids are -- non-void; e.g. constructor field binders in case expressions. See Note -- [Post-unarisation invariants] in GHC.Stg.Unarise. assertNonVoidIds :: [Id] -> [NonVoid Id] -- | Used in places where some invariant ensures that all these arguments -- are non-void; e.g. constructor arguments. See Note [Post-unarisation -- invariants] in GHC.Stg.Unarise. assertNonVoidStgArgs :: [StgArg] -> [NonVoid StgArg] -- | Information about an identifier, from the code generator's point of -- view. Every identifier is bound to a LambdaFormInfo in the -- environment, which gives the code generator enough info to be able to -- tail call or return that identifier. data LambdaFormInfo -- | StandardFormInfo tells whether this thunk has one of a small number of -- standard forms data StandardFormInfo mkLFThunk :: Type -> TopLevelFlag -> [Id] -> UpdateFlag -> LambdaFormInfo mkLFReEntrant :: TopLevelFlag -> [Id] -> [Id] -> ArgDescr -> LambdaFormInfo mkConLFInfo :: DataCon -> LambdaFormInfo mkSelectorLFInfo :: Id -> Int -> Bool -> LambdaFormInfo mkApLFInfo :: Id -> UpdateFlag -> Arity -> LambdaFormInfo mkLFImported :: Id -> LambdaFormInfo mkLFArgument :: Id -> LambdaFormInfo mkLFLetNoEscape :: LambdaFormInfo mkLFStringLit :: LambdaFormInfo -- | Return the tag in the low order bits of a variable bound to this -- LambdaForm lfDynTag :: Platform -> LambdaFormInfo -> DynTag isLFThunk :: LambdaFormInfo -> Bool isLFReEntrant :: LambdaFormInfo -> Bool lfUpdatable :: LambdaFormInfo -> Bool data CgLoc CmmLoc :: CmmExpr -> CgLoc LneLoc :: BlockId -> [LocalReg] -> CgLoc type SelfLoopInfo = (Id, BlockId, [LocalReg]) data CallMethod EnterIt :: CallMethod JumpToIt :: BlockId -> [LocalReg] -> CallMethod ReturnIt :: CallMethod SlowCall :: CallMethod DirectEntry :: CLabel -> RepArity -> CallMethod nodeMustPointToIt :: Profile -> LambdaFormInfo -> Bool isKnownFun :: LambdaFormInfo -> Bool funTag :: Platform -> ClosureInfo -> DynTag tagForArity :: Platform -> RepArity -> DynTag data CallOpts CallOpts :: !Profile -> !Bool -> !Bool -> CallOpts -- | Platform profile [co_profile] :: CallOpts -> !Profile -- | Loopification enabled (cf -floopification) [co_loopification] :: CallOpts -> !Bool -- | Ticky profiling enabled (cf -ticky) [co_ticky] :: CallOpts -> !Bool getCallMethod :: CallOpts -> Name -> Id -> LambdaFormInfo -> RepArity -> RepArity -> CgLoc -> Maybe SelfLoopInfo -> CallMethod data ClosureInfo mkClosureInfo :: Profile -> Bool -> Id -> LambdaFormInfo -> Int -> Int -> String -> ClosureInfo -- | Convert from ClosureInfo to CmmInfoTable. mkCmmInfo :: ClosureInfo -> Id -> CostCentreStack -> CmmInfoTable closureLFInfo :: ClosureInfo -> LambdaFormInfo closureName :: ClosureInfo -> Name closureInfoLabel :: ClosureInfo -> CLabel staticClosureLabel :: Platform -> ClosureInfo -> CLabel closureSlowEntryLabel :: Platform -> ClosureInfo -> CLabel closureLocalEntryLabel :: Platform -> ClosureInfo -> CLabel closureUpdReqd :: ClosureInfo -> Bool closureReEntrant :: ClosureInfo -> Bool closureFunInfo :: ClosureInfo -> Maybe (RepArity, ArgDescr) isToplevClosure :: ClosureInfo -> Bool blackHoleOnEntry :: ClosureInfo -> Bool isStaticClosure :: ClosureInfo -> Bool mkDataConInfoTable :: Profile -> DataCon -> ConInfoTableLocation -> Bool -> Int -> Int -> CmmInfoTable cafBlackHoleInfoTable :: CmmInfoTable indStaticInfoTable :: CmmInfoTable staticClosureNeedsLink :: Bool -> CmmInfoTable -> Bool instance GHC.Show.Show a => GHC.Show.Show (GHC.StgToCmm.Closure.NonVoid a) instance GHC.Classes.Eq a => GHC.Classes.Eq (GHC.StgToCmm.Closure.NonVoid a) instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.StgToCmm.Closure.NonVoid a) instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform GHC.StgToCmm.Closure.CgLoc module GHC.StgToCmm.ArgRep data ArgRep P :: ArgRep N :: ArgRep L :: ArgRep V :: ArgRep F :: ArgRep D :: ArgRep V16 :: ArgRep V32 :: ArgRep V64 :: ArgRep toArgRep :: Platform -> PrimRep -> ArgRep argRepSizeW :: Platform -> ArgRep -> WordOff argRepString :: ArgRep -> String isNonV :: ArgRep -> Bool idArgRep :: Platform -> Id -> ArgRep slowCallPattern :: [ArgRep] -> (FastString, RepArity) instance GHC.Utils.Outputable.Outputable GHC.StgToCmm.ArgRep.ArgRep module GHC.StgToCmm.CgUtils -- | Fixup global registers so that they assign to locations within the -- RegTable if they aren't pinned for the current target. fixStgRegisters :: Platform -> RawCmmDecl -> RawCmmDecl baseRegOffset :: Platform -> GlobalReg -> Int get_Regtable_addr_from_offset :: Platform -> Int -> CmmExpr regTableOffset :: Platform -> Int -> CmmExpr -- | We map STG registers onto appropriate CmmExprs. Either they map to -- real machine registers or stored as offsets from BaseReg. Given a -- GlobalReg, get_GlobalReg_addr always produces the register table -- address for it. get_GlobalReg_addr :: Platform -> GlobalReg -> CmmExpr -- | Base LLVM Code Generation module -- -- Contains functions useful through out the code generator. module GHC.CmmToLlvm.Base type LlvmCmmDecl = GenCmmDecl [LlvmData] (Maybe RawCmmStatics) (ListGraph LlvmStatement) type LlvmBasicBlock = GenBasicBlock LlvmStatement -- | Global registers live on proc entry type LiveGlobalRegs = [GlobalReg] -- | Unresolved code. Of the form: (data label, data type, unresolved data) type LlvmUnresData = (CLabel, Section, LlvmType, [UnresStatic]) -- | Top level LLVM Data (globals and type aliases) type LlvmData = ([LMGlobal], [LlvmType]) -- | An unresolved Label. -- -- Labels are unresolved when we haven't yet determined if they are -- defined in the module we are currently compiling, or an external one. type UnresLabel = CmmLit type UnresStatic = Either UnresLabel LlvmStatic data LlvmVersion -- | The (inclusive) lower bound on the LLVM Version that is currently -- supported. supportedLlvmVersionLowerBound :: LlvmVersion -- | The (not-inclusive) upper bound bound on the LLVM Version that is -- currently supported. supportedLlvmVersionUpperBound :: LlvmVersion llvmVersionSupported :: LlvmVersion -> Bool parseLlvmVersion :: String -> Maybe LlvmVersion llvmVersionStr :: LlvmVersion -> String llvmVersionList :: LlvmVersion -> [Int] -- | The Llvm monad. Wraps LlvmEnv state as well as the -- IO monad data LlvmM a -- | Get initial Llvm environment. runLlvm :: Logger -> DynFlags -> LlvmVersion -> BufHandle -> LlvmM a -> IO a -- | Clear variables from the environment for a subcomputation withClearVars :: LlvmM a -> LlvmM a -- | Lookup variables or functions in the environment. varLookup :: Uniquable key => key -> LlvmM (Maybe LlvmType) -- | Insert variables or functions into the environment. varInsert :: Uniquable key => key -> LlvmType -> LlvmM () -- | Set a register as allocated on the stack markStackReg :: GlobalReg -> LlvmM () -- | Check whether a register is allocated on the stack checkStackReg :: GlobalReg -> LlvmM Bool -- | Lookup variables or functions in the environment. funLookup :: Uniquable key => key -> LlvmM (Maybe LlvmType) -- | Insert variables or functions into the environment. funInsert :: Uniquable key => key -> LlvmType -> LlvmM () -- | Get the LLVM version we are generating code for getLlvmVer :: LlvmM LlvmVersion getDynFlags :: HasDynFlags m => m DynFlags -- | Dumps the document if the corresponding flag has been set by the user dumpIfSetLlvm :: DumpFlag -> String -> DumpFormat -> SDoc -> LlvmM () -- | Prints the given contents to the output handle renderLlvm :: SDoc -> LlvmM () -- | Marks a variable as "used" markUsedVar :: LlvmVar -> LlvmM () -- | Return all variables marked as "used" so far getUsedVars :: LlvmM [LlvmVar] -- | Here we pre-initialise some functions that are used internally by GHC -- so as to make sure they have the most general type in the case that -- user code also uses these functions but with a different type than GHC -- internally. (Main offender is treating return type as void -- instead of 'void *'). Fixes trac #5486. ghcInternalFunctions :: LlvmM () -- | Get target platform getPlatform :: LlvmM Platform -- | Get LLVM options getLlvmOpts :: LlvmM LlvmOpts -- | Allocate a new global unnamed metadata identifier getMetaUniqueId :: LlvmM MetaId -- | Sets metadata node for a given unique setUniqMeta :: Unique -> MetaId -> LlvmM () -- | Gets metadata node for given unique getUniqMeta :: Unique -> LlvmM (Maybe MetaId) -- | Lifting of IO actions. Not exported, as we want to encapsulate IO. liftIO :: IO a -> LlvmM a -- | Translate a basic CmmType to an LlvmType. cmmToLlvmType :: CmmType -> LlvmType -- | Translate a Cmm Float Width to a LlvmType. widthToLlvmFloat :: Width -> LlvmType -- | Translate a Cmm Bit Width to a LlvmType. widthToLlvmInt :: Width -> LlvmType -- | Llvm Function type for Cmm function llvmFunTy :: LiveGlobalRegs -> LlvmM LlvmType -- | Llvm Function signature llvmFunSig :: LiveGlobalRegs -> CLabel -> LlvmLinkageType -> LlvmM LlvmFunctionDecl -- | A Function's arguments llvmFunArgs :: Platform -> LiveGlobalRegs -> [LlvmVar] -- | Llvm standard fun attributes llvmStdFunAttrs :: [LlvmFuncAttr] -- | Alignment to use for functions llvmFunAlign :: Platform -> LMAlign -- | Alignment to use for into tables llvmInfAlign :: Platform -> LMAlign -- | Pointer width llvmPtrBits :: Platform -> Int -- | Convert a list of types to a list of function parameters (each with no -- parameter attributes) tysToParams :: [LlvmType] -> [LlvmParameter] -- | Section to use for a function llvmFunSection :: LlvmOpts -> LMString -> LMSection -- | Return a list of "padding" registers for LLVM function calls. -- -- When we generate LLVM function signatures, we can't just make any -- register alive on function entry. Instead, we need to insert fake -- arguments of the same register class until we are sure that one of -- them is mapped to the register we want alive. E.g. to ensure that F5 -- is alive, we may need to insert fake arguments mapped to F1, F2, F3 -- and F4. -- -- Invariant: Cmm FPR regs with number "n" maps to real registers with -- number "n" If the calling convention uses registers in a different -- order or if the invariant doesn't hold, this code probably won't be -- correct. padLiveArgs :: Platform -> LiveGlobalRegs -> LiveGlobalRegs isFPR :: GlobalReg -> Bool -- | Pretty print a CLabel. strCLabel_llvm :: CLabel -> LlvmM LMString -- | Create/get a pointer to a global value. Might return an alias if the -- value in question hasn't been defined yet. We especially make no -- guarantees on the type of the returned pointer. getGlobalPtr :: LMString -> LlvmM LlvmVar -- | Generate definitions for aliases forward-referenced by -- getGlobalPtr. -- -- Must be called at a point where we are sure that no new global -- definitions will be generated anymore! generateExternDecls :: LlvmM ([LMGlobal], [LlvmType]) -- | Here we take a global variable definition, rename it with a -- $def suffix, and generate the appropriate alias. aliasify :: LMGlobal -> LlvmM [LMGlobal] -- | Derive the definition label. It has an identified structure type. llvmDefLabel :: LMString -> LMString instance GHC.Classes.Ord GHC.CmmToLlvm.Base.LlvmVersion instance GHC.Classes.Eq GHC.CmmToLlvm.Base.LlvmVersion instance GHC.Base.Functor GHC.CmmToLlvm.Base.LlvmM instance GHC.Base.Applicative GHC.CmmToLlvm.Base.LlvmM instance GHC.Base.Monad GHC.CmmToLlvm.Base.LlvmM instance GHC.Driver.Session.HasDynFlags GHC.CmmToLlvm.Base.LlvmM instance GHC.Utils.Logger.HasLogger GHC.CmmToLlvm.Base.LlvmM instance GHC.Types.Unique.Supply.MonadUnique GHC.CmmToLlvm.Base.LlvmM module GHC.SysTools.Tasks runUnlit :: Logger -> DynFlags -> [Option] -> IO () runCpp :: Logger -> DynFlags -> [Option] -> IO () runPp :: Logger -> DynFlags -> [Option] -> IO () -- | Run compiler of C-like languages and raw objects (such as gcc or -- clang). runCc :: Maybe ForeignSrcLang -> Logger -> TmpFs -> DynFlags -> [Option] -> IO () isContainedIn :: String -> String -> Bool -- | Run the linker with some arguments and return the output askLd :: Logger -> DynFlags -> [Option] -> IO String runAs :: Logger -> DynFlags -> [Option] -> IO () -- | Run the LLVM Optimiser runLlvmOpt :: Logger -> DynFlags -> [Option] -> IO () -- | Run the LLVM Compiler runLlvmLlc :: Logger -> DynFlags -> [Option] -> IO () -- | Run the clang compiler (used as an assembler for the LLVM backend on -- OS X as LLVM doesn't support the OS X system assembler) runClang :: Logger -> DynFlags -> [Option] -> IO () -- | Figure out which version of LLVM we are running this session figureLlvmVersion :: Logger -> DynFlags -> IO (Maybe LlvmVersion) runLink :: Logger -> TmpFs -> DynFlags -> [Option] -> IO () runMergeObjects :: Logger -> TmpFs -> DynFlags -> [Option] -> IO () runLibtool :: Logger -> DynFlags -> [Option] -> IO () runAr :: Logger -> DynFlags -> Maybe FilePath -> [Option] -> IO () askOtool :: Logger -> DynFlags -> Maybe FilePath -> [Option] -> IO String runInstallNameTool :: Logger -> DynFlags -> [Option] -> IO () runRanlib :: Logger -> DynFlags -> [Option] -> IO () runWindres :: Logger -> DynFlags -> [Option] -> IO () touch :: Logger -> DynFlags -> String -> String -> IO () -- | Record in the eventlog when the given tool command starts and -- finishes, prepending the given String with "systool:", to -- easily be able to collect and process all the systool events. -- -- For those events to show up in the eventlog, you need to run GHC with -- -v2 or -ddump-timings. traceToolCommand :: Logger -> DynFlags -> String -> IO a -> IO a module GHC.Linker.MacOS -- | On macOS we rely on the linkers -dead_strip_dylibs flag to -- remove unused libraries from the dynamic library. We do this to reduce -- the number of load commands that end up in the dylib, and has been -- limited to 32K (32768) since macOS Sierra (10.14). -- -- -dead_strip_dylibs does not dead strip -rpath -- entries, as such passing -l and -rpath to the linker -- will result in the unnecesasry libraries not being included in the -- load commands, however the -rpath entries are all forced to -- be included. This can lead to 100s of -rpath entries being -- included when only a handful of libraries end up being truly linked. -- -- Thus after building the library, we run a fixup phase where we inject -- the -rpath for each found library (in the given library -- search paths) into the dynamic library through -add_rpath. -- -- See Note [Dynamic linking on macOS] runInjectRPaths :: Logger -> DynFlags -> [FilePath] -> FilePath -> IO () getUnitFrameworkOpts :: UnitEnv -> [UnitId] -> IO [String] getFrameworkOpts :: DynFlags -> Platform -> [String] loadFramework :: Interp -> [FilePath] -> FilePath -> IO (Maybe String) module GHC.Linker.ExtraObj mkExtraObj :: Logger -> TmpFs -> DynFlags -> UnitState -> Suffix -> String -> IO FilePath mkExtraObjToLinkIntoBinary :: Logger -> TmpFs -> DynFlags -> UnitState -> IO (Maybe FilePath) mkNoteObjsToLinkIntoBinary :: Logger -> TmpFs -> DynFlags -> UnitEnv -> [UnitId] -> IO [FilePath] checkLinkInfo :: Logger -> DynFlags -> UnitEnv -> [UnitId] -> FilePath -> IO Bool -- | Return the "link info" string -- -- See Note [LinkInfo section] getLinkInfo :: DynFlags -> UnitEnv -> [UnitId] -> IO String getCompilerInfo :: Logger -> DynFlags -> IO CompilerInfo ghcLinkInfoSectionName :: String ghcLinkInfoNoteName :: String platformSupportsSavingLinkOpts :: OS -> Bool haveRtsOptsFlags :: DynFlags -> Bool module GHC.SysTools initSysTools :: String -> IO Settings lazyInitLlvmConfig :: String -> IO LlvmConfig copy :: Logger -> DynFlags -> String -> FilePath -> FilePath -> IO () copyWithHeader :: Logger -> DynFlags -> String -> Maybe String -> FilePath -> FilePath -> IO () -- | When invoking external tools as part of the compilation pipeline, we -- pass these a sequence of options on the command-line. Rather than just -- using a list of Strings, we use a type that allows us to distinguish -- between filepaths and 'other stuff'. The reason for this is that this -- type gives us a handle on transforming filenames, and filenames only, -- to whatever format they're expected to be on a particular platform. data Option FileOption :: String -> String -> Option Option :: String -> Option -- | Expand occurrences of the $topdir interpolation in a string. expandTopDir :: FilePath -> String -> String module GHC.Linker.Windows maybeCreateManifest :: Logger -> TmpFs -> DynFlags -> FilePath -> IO [FilePath] -- | Dynamic linker module GHC.Linker.Dynamic linkDynLib :: Logger -> TmpFs -> DynFlags -> UnitEnv -> [String] -> [UnitId] -> IO () -- | Some platforms require that we explicitly link against libm -- if any math-y things are used (which we assume to include all -- programs). See #14022. libmLinkOpts :: [Option] module GHC.Linker.Static linkBinary :: Logger -> TmpFs -> DynFlags -> UnitEnv -> [FilePath] -> [UnitId] -> IO () linkBinary' :: Bool -> Logger -> TmpFs -> DynFlags -> UnitEnv -> [FilePath] -> [UnitId] -> IO () -- | Linking a static lib will not really link anything. It will merely -- produce a static archive of all dependent static libraries. The -- resulting library will still need to be linked with any remaining link -- flags. linkStaticLib :: Logger -> DynFlags -> UnitEnv -> [String] -> [UnitId] -> IO () -- | Compute the output file name of a program. -- -- StaticLink boolean is used to indicate if the program is actually a -- static library (e.g., on iOS). -- -- Use the provided filename (if any), otherwise use "main.exe" -- (Windows), "a.out (otherwise without StaticLink set), "liba.a". In -- every case, add the extension if it is missing. exeFileName :: Platform -> Bool -> Maybe FilePath -> FilePath -- | Handle conversion of CmmData to LLVM code. module GHC.CmmToLlvm.Data -- | Pass a CmmStatic section to an equivalent Llvm code. genLlvmData :: (Section, RawCmmStatics) -> LlvmM LlvmData -- | Handle static data genData :: CmmStatic -> LlvmM LlvmStatic -- | Pretty print helpers for the LLVM Code generator. module GHC.CmmToLlvm.Ppr -- | Pretty print LLVM code pprLlvmCmmDecl :: LlvmCmmDecl -> LlvmM (SDoc, [LlvmVar]) -- | Pretty print LLVM data code pprLlvmData :: LlvmOpts -> LlvmData -> SDoc -- | The section we are putting info tables and their entry code into, -- should be unique since we process the assembly pattern matching this. infoSection :: String module GHC.Cmm.Switch.Implement -- | Traverses the GenCmmGraph, making sure that CmmSwitch -- are suitable for code generation. cmmImplementSwitchPlans :: Backend -> Platform -> CmmGraph -> UniqSM CmmGraph module GHC.Cmm.Ppr.Decl pprCmms :: (OutputableP Platform info, OutputableP Platform g) => Platform -> [GenCmmGroup RawCmmStatics info g] -> SDoc pprCmmGroup :: (OutputableP Platform d, OutputableP Platform info, OutputableP Platform g) => Platform -> GenCmmGroup d info g -> SDoc pprSection :: Platform -> Section -> SDoc pprStatic :: Platform -> CmmStatic -> SDoc instance (GHC.Utils.Outputable.OutputableP GHC.Platform.Platform d, GHC.Utils.Outputable.OutputableP GHC.Platform.Platform info, GHC.Utils.Outputable.OutputableP GHC.Platform.Platform i) => GHC.Utils.Outputable.OutputableP GHC.Platform.Platform (GHC.Cmm.GenCmmDecl d info i) instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform (GHC.Cmm.GenCmmStatics a) instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform GHC.Cmm.CmmStatic instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform GHC.Cmm.CmmInfoTable instance GHC.Utils.Outputable.Outputable GHC.Cmm.Type.ForeignHint module GHC.Cmm.Ppr instance GHC.Utils.Outputable.Outputable GHC.Cmm.CmmStackInfo instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform GHC.Cmm.CmmTopInfo instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform (GHC.Cmm.Node.CmmNode e x) instance GHC.Utils.Outputable.Outputable GHC.Cmm.Node.Convention instance GHC.Utils.Outputable.Outputable GHC.Cmm.Node.ForeignConvention instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform GHC.Cmm.Node.ForeignTarget instance GHC.Utils.Outputable.Outputable GHC.Cmm.Node.CmmReturnInfo instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform (GHC.Cmm.Dataflow.Block.Block GHC.Cmm.Node.CmmNode GHC.Cmm.Dataflow.Block.C GHC.Cmm.Dataflow.Block.C) instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform (GHC.Cmm.Dataflow.Block.Block GHC.Cmm.Node.CmmNode GHC.Cmm.Dataflow.Block.C GHC.Cmm.Dataflow.Block.O) instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform (GHC.Cmm.Dataflow.Block.Block GHC.Cmm.Node.CmmNode GHC.Cmm.Dataflow.Block.O GHC.Cmm.Dataflow.Block.C) instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform (GHC.Cmm.Dataflow.Block.Block GHC.Cmm.Node.CmmNode GHC.Cmm.Dataflow.Block.O GHC.Cmm.Dataflow.Block.O) instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform (GHC.Cmm.Dataflow.Graph.Graph GHC.Cmm.Node.CmmNode e x) instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform GHC.Cmm.CmmGraph -- | Handle conversion of CmmProc to LLVM code. module GHC.CmmToLlvm.CodeGen -- | Top-level of the LLVM proc Code generator genLlvmProc :: RawCmmDecl -> LlvmM [LlvmCmmDecl] instance GHC.Show.Show GHC.CmmToLlvm.CodeGen.Signage instance GHC.Classes.Eq GHC.CmmToLlvm.CodeGen.Signage instance GHC.Base.Semigroup GHC.CmmToLlvm.CodeGen.LlvmAccum instance GHC.Base.Monoid GHC.CmmToLlvm.CodeGen.LlvmAccum -- | This is the top-level module in the LLVM code generator. module GHC.CmmToLlvm data LlvmVersion llvmVersionList :: LlvmVersion -> [Int] -- | Top-level of the LLVM Code generator llvmCodeGen :: Logger -> DynFlags -> Handle -> Stream IO RawCmmGroup a -> IO a -- | Read in assembly file and process llvmFixupAsm :: Logger -> DynFlags -> FilePath -> FilePath -> IO () module GHC.CmmToC cmmToC :: Platform -> RawCmmGroup -> SDoc instance GHC.Base.Functor GHC.CmmToC.TE instance GHC.Base.Applicative GHC.CmmToC.TE instance GHC.Base.Monad GHC.CmmToC.TE module GHC.CmmToAsm.SPARC.Ppr pprNatCmmDecl :: NCGConfig -> NatCmmDecl RawCmmStatics Instr -> SDoc pprBasicBlock :: Platform -> LabelMap RawCmmStatics -> NatBasicBlock Instr -> SDoc pprData :: Platform -> CmmStatic -> SDoc -- | Pretty print an instruction. pprInstr :: Platform -> Instr -> SDoc -- | Pretty print a format for an instruction suffix. pprFormat :: Format -> SDoc -- | Pretty print an immediate value. pprImm :: Platform -> Imm -> SDoc -- | Pretty print a data item. pprDataItem :: Platform -> CmmLit -> SDoc instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform GHC.CmmToAsm.SPARC.Instr.Instr -- | One ounce of sanity checking is worth 10000000000000000 ounces of -- staring blindly at assembly code trying to find the problem.. module GHC.CmmToAsm.SPARC.CodeGen.Sanity -- | Enforce intra-block invariants. checkBlock :: Platform -> CmmBlock -> NatBasicBlock Instr -> NatBasicBlock Instr module GHC.CmmToAsm.CFG -- | A control flow graph where edges have been annotated with a weight. -- Implemented as IntMap (IntMap <edgeData>) We must uphold the -- invariant that for each edge A -> B we must have: A entry B in the -- outer map. A entry B in the map we get when looking up A. Maintaining -- this invariant is useful as any failed lookup now indicates an actual -- error in code which might go unnoticed for a while otherwise. type CFG = EdgeInfoMap EdgeInfo data CfgEdge CfgEdge :: !BlockId -> !BlockId -> !EdgeInfo -> CfgEdge [edgeFrom] :: CfgEdge -> !BlockId [edgeTo] :: CfgEdge -> !BlockId [edgeInfo] :: CfgEdge -> !EdgeInfo -- | Information about edges data EdgeInfo EdgeInfo :: !TransitionSource -> !EdgeWeight -> EdgeInfo [transitionSource] :: EdgeInfo -> !TransitionSource [edgeWeight] :: EdgeInfo -> !EdgeWeight newtype EdgeWeight EdgeWeight :: Double -> EdgeWeight [weightToDouble] :: EdgeWeight -> Double -- | Can we trace back a edge to a specific Cmm Node or has it been -- introduced during assembly codegen. We use this to maintain some -- information which would otherwise be lost during the Cmm <-> asm -- transition. See also Note [Inverting Conditional Branches] data TransitionSource CmmSource :: CmmNode O C -> BranchInfo -> TransitionSource [trans_cmmNode] :: TransitionSource -> CmmNode O C [trans_info] :: TransitionSource -> BranchInfo AsmCodeGen :: TransitionSource -- | Adds a edge with the given weight to the cfg If there already existed -- an edge it is overwritten. `addWeightEdge from to weight cfg` addWeightEdge :: BlockId -> BlockId -> EdgeWeight -> CFG -> CFG -- | Adds a new edge, overwrites existing edges if present addEdge :: BlockId -> BlockId -> EdgeInfo -> CFG -> CFG delEdge :: BlockId -> BlockId -> CFG -> CFG -- | Insert a block in the control flow between two other blocks. We pass a -- list of tuples (A,B,C) where * A -> C: Old edge * A -> B -> C -- : New Arc, where B is the new block. It's possible that a block has -- two jumps to the same block in the assembly code. However we still -- only store a single edge for these cases. We assign the old edge info -- to the edge A -> B and assign B -> C the weight of an -- unconditional jump. addNodesBetween :: Weights -> CFG -> [(BlockId, BlockId, BlockId)] -> CFG shortcutWeightMap :: LabelMap (Maybe BlockId) -> CFG -> CFG reverseEdges :: CFG -> CFG -- | Filter the CFG with a custom function f. Paramaeters are `f from to -- edgeInfo` filterEdges :: (BlockId -> BlockId -> EdgeInfo -> Bool) -> CFG -> CFG -- | Sometimes we insert a block which should unconditionally be executed -- after a given block. This function updates the CFG for these cases. So -- we get A -> B => A -> A' -> B -- -> C => -> C addImmediateSuccessor :: Weights -> BlockId -> BlockId -> CFG -> CFG -- | Convenience function, generate edge info based on weight not -- originating from cmm. mkWeightInfo :: EdgeWeight -> EdgeInfo -- | Adjust the weight between the blocks using the given function. If -- there is no such edge returns the original map. adjustEdgeWeight :: CFG -> (EdgeWeight -> EdgeWeight) -> BlockId -> BlockId -> CFG -- | Set the weight between the blocks to the given weight. If there is no -- such edge returns the original map. setEdgeWeight :: CFG -> EdgeWeight -> BlockId -> BlockId -> CFG -- | Returns a unordered list of all edges with info infoEdgeList :: CFG -> [CfgEdge] -- | Returns a unordered list of all edges without weights edgeList :: CFG -> [Edge] -- | Get successors of a given node with edge weights. getSuccessorEdges :: HasDebugCallStack => CFG -> BlockId -> [(BlockId, EdgeInfo)] -- | Get successors of a given node without edge weights. getSuccessors :: HasDebugCallStack => CFG -> BlockId -> [BlockId] -- | Destinations from bid ordered by weight (descending) getSuccEdgesSorted :: CFG -> BlockId -> [(BlockId, EdgeInfo)] getEdgeInfo :: BlockId -> BlockId -> CFG -> Maybe EdgeInfo getCfgNodes :: CFG -> [BlockId] -- | Is this block part of this graph? hasNode :: CFG -> BlockId -> Bool -- | Determine loop membership of blocks based on SCC analysis This is -- faster but only gives yes/no answers. loopMembers :: HasDebugCallStack => CFG -> LabelMap Bool loopLevels :: CFG -> BlockId -> LabelMap Int -- | Determine loop membership of blocks based on Dominator analysis. This -- is slower but gives loop levels instead of just loop membership. -- However it only detects natural loops. Irreducible control flow is not -- recognized even if it loops. But that is rare enough that we don't -- have to care about that special case. loopInfo :: HasDebugCallStack => CFG -> BlockId -> LoopInfo getCfg :: Platform -> Weights -> CmmGraph -> CFG -- | Generate weights for a Cmm proc based on some simple heuristics. getCfgProc :: Platform -> Weights -> RawCmmDecl -> CFG pprEdgeWeights :: CFG -> SDoc -- | Check if the nodes in the cfg and the set of blocks are the same. In a -- case of a missmatch we panic and show the difference. sanityCheckCfg :: CFG -> LabelSet -> SDoc -> Bool optimizeCFG :: Bool -> Weights -> RawCmmDecl -> CFG -> CFG -- | We take in a CFG which has on its edges weights which are relative -- only to other edges originating from the same node. -- -- We return a CFG for which each edge represents a GLOBAL weight. This -- means edge weights are comparable across the whole graph. -- -- For irreducible control flow results might be imprecise, otherwise -- they are reliable. -- -- The algorithm is based on the Paper "Static Branch Prediction and -- Program Profile Analysis" by Y Wu, JR Larus The only big change is -- that we go over the nodes in the body of loops in reverse post order. -- Which is required for diamond control flow to work probably. -- -- We also apply a few prediction heuristics (based on the same paper) -- -- The returned result represents frequences. For blocks it's the -- expected number of executions and for edges is the number of -- traversals. mkGlobalWeights :: HasDebugCallStack => BlockId -> CFG -> (LabelMap Double, LabelMap (LabelMap Double)) instance GHC.Real.Fractional GHC.CmmToAsm.CFG.EdgeWeight instance GHC.Real.Real GHC.CmmToAsm.CFG.EdgeWeight instance GHC.Num.Num GHC.CmmToAsm.CFG.EdgeWeight instance GHC.Enum.Enum GHC.CmmToAsm.CFG.EdgeWeight instance GHC.Classes.Ord GHC.CmmToAsm.CFG.EdgeWeight instance GHC.Classes.Eq GHC.CmmToAsm.CFG.EdgeWeight instance GHC.Classes.Eq GHC.CmmToAsm.CFG.BranchInfo instance GHC.Classes.Eq GHC.CmmToAsm.CFG.TransitionSource instance GHC.Classes.Eq GHC.CmmToAsm.CFG.EdgeInfo instance GHC.Cmm.Dataflow.Graph.NonLocal GHC.CmmToAsm.CFG.BlockNode instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.CFG.LoopInfo instance GHC.Classes.Eq GHC.CmmToAsm.CFG.CfgEdge instance GHC.Classes.Ord GHC.CmmToAsm.CFG.CfgEdge instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.CFG.CfgEdge instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.CFG.EdgeInfo instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.CFG.BranchInfo instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.CFG.EdgeWeight module GHC.CmmToAsm.Reg.Liveness type RegSet = UniqSet Reg -- | Map from some kind of register to a. -- -- While we give the type for keys as Reg which is the common case -- sometimes we end up using VirtualReq or naked Uniques. See Note -- [UniqFM and the register allocator] type RegMap a = UniqFM Reg a emptyRegMap :: RegMap a type BlockMap a = LabelMap a mapEmpty :: IsMap map => map a -- | A top level thing which carries liveness information. type LiveCmmDecl statics instr = GenCmmDecl statics LiveInfo [SCC (LiveBasicBlock instr)] -- | The register allocator also wants to use SPILL/RELOAD meta -- instructions, so we'll keep those here. data InstrSR instr -- | A real machine instruction Instr :: instr -> InstrSR instr -- | spill this reg to a stack slot SPILL :: Reg -> Int -> InstrSR instr -- | reload this reg from a stack slot RELOAD :: Int -> Reg -> InstrSR instr -- | An instruction with liveness information. data LiveInstr instr LiveInstr :: InstrSR instr -> Maybe Liveness -> LiveInstr instr -- | Liveness information. The regs which die are ones which are no longer -- live in the *next* instruction in this sequence. (NB. if the -- instruction is a jump, these registers might still be live at the jump -- target(s) - you have to check the liveness at the destination block to -- find out). data Liveness Liveness :: RegSet -> RegSet -> RegSet -> Liveness -- | registers born in this instruction (written to for first time). [liveBorn] :: Liveness -> RegSet -- | registers that died because they were read for the last time. [liveDieRead] :: Liveness -> RegSet -- | registers that died because they were clobbered by something. [liveDieWrite] :: Liveness -> RegSet -- | Stash regs live on entry to each basic block in the info part of the -- cmm code. data LiveInfo LiveInfo :: LabelMap RawCmmStatics -> [BlockId] -> BlockMap RegSet -> BlockMap IntSet -> LiveInfo -- | A basic block with liveness information. type LiveBasicBlock instr = GenBasicBlock (LiveInstr instr) -- | map a function across all the basic blocks in this code mapBlockTop :: (LiveBasicBlock instr -> LiveBasicBlock instr) -> LiveCmmDecl statics instr -> LiveCmmDecl statics instr -- | map a function across all the basic blocks in this code (monadic -- version) mapBlockTopM :: Monad m => (LiveBasicBlock instr -> m (LiveBasicBlock instr)) -> LiveCmmDecl statics instr -> m (LiveCmmDecl statics instr) mapSCCM :: Monad m => (a -> m b) -> SCC a -> m (SCC b) mapGenBlockTop :: (GenBasicBlock i -> GenBasicBlock i) -> GenCmmDecl d h (ListGraph i) -> GenCmmDecl d h (ListGraph i) -- | map a function across all the basic blocks in this code (monadic -- version) mapGenBlockTopM :: Monad m => (GenBasicBlock i -> m (GenBasicBlock i)) -> GenCmmDecl d h (ListGraph i) -> m (GenCmmDecl d h (ListGraph i)) -- | Map over instruction type in LiveCmmDecl mapLiveCmmDecl :: (instr -> b) -> LiveCmmDecl statics instr -> LiveCmmDecl statics b -- | Pretty-print a LiveCmmDecl pprLiveCmmDecl :: (OutputableP Platform statics, Instruction instr) => Platform -> LiveCmmDecl statics instr -> SDoc -- | Strip away liveness information, yielding NatCmmDecl stripLive :: (OutputableP Platform statics, Instruction instr) => NCGConfig -> LiveCmmDecl statics instr -> NatCmmDecl statics instr -- | Strip away liveness information from a basic block, and make real -- spill instructions out of SPILL, RELOAD pseudos along the way. stripLiveBlock :: Instruction instr => NCGConfig -> LiveBasicBlock instr -> NatBasicBlock instr -- | Slurp out the list of register conflicts and reg-reg moves from this -- top level thing. Slurping of conflicts and moves is wrapped up -- together so we don't have to make two passes over the same code when -- we want to build the graph. slurpConflicts :: Instruction instr => LiveCmmDecl statics instr -> (Bag (UniqSet Reg), Bag (Reg, Reg)) -- | For spill/reloads -- -- SPILL v1, slot1 ... RELOAD slot1, v2 -- -- If we can arrange that v1 and v2 are allocated to the same hreg it's -- more likely the spill/reload instrs can be cleaned and replaced by a -- nop reg-reg move. slurpReloadCoalesce :: forall statics instr. Instruction instr => LiveCmmDecl statics instr -> Bag (Reg, Reg) -- | Erase Delta instructions. eraseDeltasLive :: Instruction instr => LiveCmmDecl statics instr -> LiveCmmDecl statics instr -- | Patch the registers in this code according to this register mapping. -- also erase reg -> reg moves when the reg is the same. also erase -- reg -> reg moves when the destination dies in this instr. patchEraseLive :: Instruction instr => (Reg -> Reg) -> LiveCmmDecl statics instr -> LiveCmmDecl statics instr -- | Patch registers in this LiveInstr, including the liveness information. patchRegsLiveInstr :: Instruction instr => (Reg -> Reg) -> LiveInstr instr -> LiveInstr instr -- | If we've compute liveness info for this code already we have to -- reverse the SCCs in each top to get them back to the right order so we -- can do it again. reverseBlocksInTops :: LiveCmmDecl statics instr -> LiveCmmDecl statics instr regLiveness :: Instruction instr => Platform -> LiveCmmDecl statics instr -> UniqSM (LiveCmmDecl statics instr) -- | Convert a NatCmmDecl to a LiveCmmDecl, with liveness information cmmTopLiveness :: Instruction instr => Maybe CFG -> Platform -> NatCmmDecl statics instr -> UniqSM (LiveCmmDecl statics instr) instance GHC.Base.Functor GHC.CmmToAsm.Reg.Liveness.InstrSR instance GHC.Base.Functor GHC.CmmToAsm.Reg.Liveness.LiveInstr instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform GHC.CmmToAsm.Reg.Liveness.LiveInfo instance GHC.Utils.Outputable.Outputable instr => GHC.Utils.Outputable.Outputable (GHC.CmmToAsm.Reg.Liveness.LiveInstr instr) instance GHC.Utils.Outputable.OutputableP env instr => GHC.Utils.Outputable.OutputableP env (GHC.CmmToAsm.Reg.Liveness.LiveInstr instr) instance GHC.CmmToAsm.Instr.Instruction instr => GHC.CmmToAsm.Instr.Instruction (GHC.CmmToAsm.Reg.Liveness.InstrSR instr) instance GHC.Utils.Outputable.Outputable instr => GHC.Utils.Outputable.Outputable (GHC.CmmToAsm.Reg.Liveness.InstrSR instr) -- | Put common type definitions here to break recursive module -- dependencies. module GHC.CmmToAsm.Reg.Linear.Base -- | Used to store the register assignment on entry to a basic block. We -- use this to handle join points, where multiple branch instructions -- target a particular label. We have to insert fixup code to make the -- register assignments from the different sources match up. data BlockAssignment freeRegs -- | Find the register mapping for a specific BlockId. lookupBlockAssignment :: BlockId -> BlockAssignment freeRegs -> Maybe (freeRegs, RegMap Loc) -- | Lookup which register a virtual register was first assigned to. lookupFirstUsed :: VirtualReg -> BlockAssignment freeRegs -> Maybe RealReg -- | An initial empty BlockAssignment emptyBlockAssignment :: BlockAssignment freeRegs -- | Add new register mappings for a specific block. updateBlockAssignment :: BlockId -> (freeRegs, RegMap Loc) -> BlockAssignment freeRegs -> BlockAssignment freeRegs -- | Where a vreg is currently stored A temporary can be marked as living -- in both a register and memory (InBoth), for example if it was recently -- loaded from a spill location. This makes it cheap to spill (no save -- instruction required), but we have to be careful to turn this into -- InReg if the value in the register is changed. data Loc -- | vreg is in a register InReg :: !RealReg -> Loc -- | vreg is held in a stack slot InMem :: {-# UNPACK #-} !StackSlot -> Loc -- | vreg is held in both a register and a stack slot InBoth :: !RealReg -> {-# UNPACK #-} !StackSlot -> Loc -- | Get the reg numbers stored in this Loc. regsOfLoc :: Loc -> [RealReg] -- | Reasons why instructions might be inserted by the spiller. Used when -- generating stats for -ddrop-asm-stats. data SpillReason -- | vreg was spilled to a slot so we could use its current hreg for -- another vreg SpillAlloc :: !Unique -> SpillReason -- | vreg was moved because its hreg was clobbered SpillClobber :: !Unique -> SpillReason -- | vreg was loaded from a spill slot SpillLoad :: !Unique -> SpillReason -- | reg-reg move inserted during join to targets SpillJoinRR :: !Unique -> SpillReason -- | reg-mem move inserted during join to targets SpillJoinRM :: !Unique -> SpillReason -- | Used to carry interesting stats out of the register allocator. data RegAllocStats RegAllocStats :: UniqFM Unique [Int] -> [(BlockId, BlockId, BlockId)] -> RegAllocStats [ra_spillInstrs] :: RegAllocStats -> UniqFM Unique [Int] -- | (from,fixup,to) : We inserted fixup code between from and to [ra_fixupList] :: RegAllocStats -> [(BlockId, BlockId, BlockId)] -- | The register allocator state data RA_State freeRegs RA_State :: BlockAssignment freeRegs -> !freeRegs -> RegMap Loc -> Int -> StackMap -> UniqSupply -> [SpillReason] -> !NCGConfig -> [(BlockId, BlockId, BlockId)] -> RA_State freeRegs -- | the current mapping from basic blocks to the register assignments at -- the beginning of that block. [ra_blockassig] :: RA_State freeRegs -> BlockAssignment freeRegs -- | free machine registers [ra_freeregs] :: RA_State freeRegs -> !freeRegs -- | assignment of temps to locations [ra_assig] :: RA_State freeRegs -> RegMap Loc -- | current stack delta [ra_delta] :: RA_State freeRegs -> Int -- | free stack slots for spilling [ra_stack] :: RA_State freeRegs -> StackMap -- | unique supply for generating names for join point fixup blocks. [ra_us] :: RA_State freeRegs -> UniqSupply -- | Record why things were spilled, for -ddrop-asm-stats. Just keep a list -- here instead of a map of regs -> reasons. We don't want to slow -- down the allocator if we're not going to emit the stats. [ra_spills] :: RA_State freeRegs -> [SpillReason] -- | Native code generator configuration [ra_config] :: RA_State freeRegs -> !NCGConfig -- | (from,fixup,to) : We inserted fixup code between from and to [ra_fixups] :: RA_State freeRegs -> [(BlockId, BlockId, BlockId)] instance GHC.Classes.Ord GHC.CmmToAsm.Reg.Linear.Base.ReadingOrWriting instance GHC.Classes.Eq GHC.CmmToAsm.Reg.Linear.Base.ReadingOrWriting instance GHC.Classes.Ord GHC.CmmToAsm.Reg.Linear.Base.Loc instance GHC.Show.Show GHC.CmmToAsm.Reg.Linear.Base.Loc instance GHC.Classes.Eq GHC.CmmToAsm.Reg.Linear.Base.Loc instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.Reg.Linear.Base.Loc module GHC.CmmToAsm.Reg.Linear.Stats -- | Build a map of how many times each reg was alloced, clobbered, loaded -- etc. binSpillReasons :: [SpillReason] -> UniqFM Unique [Int] -- | Count reg-reg moves remaining in this code. countRegRegMovesNat :: Instruction instr => NatCmmDecl statics instr -> Int -- | Pretty print some RegAllocStats pprStats :: Instruction instr => [NatCmmDecl statics instr] -> [RegAllocStats] -> SDoc -- | State monad for the linear register allocator. module GHC.CmmToAsm.Reg.Linear.State -- | The register allocator state data RA_State freeRegs RA_State :: BlockAssignment freeRegs -> !freeRegs -> RegMap Loc -> Int -> StackMap -> UniqSupply -> [SpillReason] -> !NCGConfig -> [(BlockId, BlockId, BlockId)] -> RA_State freeRegs -- | the current mapping from basic blocks to the register assignments at -- the beginning of that block. [ra_blockassig] :: RA_State freeRegs -> BlockAssignment freeRegs -- | free machine registers [ra_freeregs] :: RA_State freeRegs -> !freeRegs -- | assignment of temps to locations [ra_assig] :: RA_State freeRegs -> RegMap Loc -- | current stack delta [ra_delta] :: RA_State freeRegs -> Int -- | free stack slots for spilling [ra_stack] :: RA_State freeRegs -> StackMap -- | unique supply for generating names for join point fixup blocks. [ra_us] :: RA_State freeRegs -> UniqSupply -- | Record why things were spilled, for -ddrop-asm-stats. Just keep a list -- here instead of a map of regs -> reasons. We don't want to slow -- down the allocator if we're not going to emit the stats. [ra_spills] :: RA_State freeRegs -> [SpillReason] -- | Native code generator configuration [ra_config] :: RA_State freeRegs -> !NCGConfig -- | (from,fixup,to) : We inserted fixup code between from and to [ra_fixups] :: RA_State freeRegs -> [(BlockId, BlockId, BlockId)] -- | The register allocator monad type. data RegM freeRegs a -- | Run a computation in the RegM register allocator monad. runR :: NCGConfig -> BlockAssignment freeRegs -> freeRegs -> RegMap Loc -> StackMap -> UniqSupply -> RegM freeRegs a -> (BlockAssignment freeRegs, StackMap, RegAllocStats, a) spillR :: Instruction instr => Reg -> Unique -> RegM freeRegs ([instr], Int) loadR :: Instruction instr => Reg -> Int -> RegM freeRegs [instr] getFreeRegsR :: RegM freeRegs freeRegs setFreeRegsR :: freeRegs -> RegM freeRegs () getAssigR :: RegM freeRegs (RegMap Loc) setAssigR :: RegMap Loc -> RegM freeRegs () getBlockAssigR :: RegM freeRegs (BlockAssignment freeRegs) setBlockAssigR :: BlockAssignment freeRegs -> RegM freeRegs () setDeltaR :: Int -> RegM freeRegs () getDeltaR :: RegM freeRegs Int getUniqueR :: RegM freeRegs Unique -- | Get native code generator configuration getConfig :: RegM a NCGConfig -- | Get target platform from native code generator configuration getPlatform :: RegM a Platform -- | Record that a spill instruction was inserted, for profiling. recordSpill :: SpillReason -> RegM freeRegs () -- | Record a created fixup block recordFixupBlock :: BlockId -> BlockId -> BlockId -> RegM freeRegs () instance GHC.Base.Functor (GHC.CmmToAsm.Reg.Linear.State.RegM freeRegs) instance GHC.Base.Applicative (GHC.CmmToAsm.Reg.Linear.State.RegM freeRegs) instance GHC.Base.Monad (GHC.CmmToAsm.Reg.Linear.State.RegM freeRegs) -- | Clean out unneeded spill/reload instructions. -- -- Handling of join points ~~~~~~~~~~~~~~~~~~~~~~~ -- --
-- B1: B2: -- ... ... -- RELOAD SLOT(0), %r1 RELOAD SLOT(0), %r1 -- ... A ... ... B ... -- jump B3 jump B3 -- -- B3: ... C ... -- RELOAD SLOT(0), %r1 -- ... -- ---- -- The Plan ~~~~~~~~ -- -- As long as %r1 hasn't been written to in A, B or C then we don't need -- the reload in B3. -- -- What we really care about here is that on the entry to B3, %r1 will -- always have the same value that is in SLOT(0) (ie, %r1 is _valid_) -- -- This also works if the reloads in B1/B2 were spills instead, because -- spilling %r1 to a slot makes that slot have the same value as %r1. module GHC.CmmToAsm.Reg.Graph.SpillClean -- | Clean out unneeded spill/reloads from this top level thing. cleanSpills :: Instruction instr => Platform -> LiveCmmDecl statics instr -> LiveCmmDecl statics instr instance GHC.Types.Unique.Uniquable GHC.CmmToAsm.Reg.Graph.SpillClean.Store instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.Reg.Graph.SpillClean.Store -- | When there aren't enough registers to hold all the vregs we have to -- spill some of those vregs to slots on the stack. This module is used -- modify the code to use those slots. module GHC.CmmToAsm.Reg.Graph.Spill -- | Spill all these virtual regs to stack slots. -- -- Bumps the number of required stack slots if required. -- -- TODO: See if we can split some of the live ranges instead of just -- globally spilling the virtual reg. This might make the spill cleaner's -- job easier. -- -- TODO: On CISCy x86 and x86_64 we don't necessarily have to add a mov -- instruction when making spills. If an instr is using a spilled virtual -- we may be able to address the spill slot directly. regSpill :: Instruction instr => Platform -> [LiveCmmDecl statics instr] -> UniqSet Int -> Int -> UniqSet VirtualReg -> UniqSM ([LiveCmmDecl statics instr], UniqSet Int, Int, SpillStats) -- | Spiller statistics. Tells us what registers were spilled. data SpillStats SpillStats :: UniqFM Reg (Reg, Int, Int) -> SpillStats [spillStoreLoad] :: SpillStats -> UniqFM Reg (Reg, Int, Int) -- | Add a spill/reload count to a stats record for a register. accSpillSL :: (Reg, Int, Int) -> (Reg, Int, Int) -> (Reg, Int, Int) instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.Reg.Graph.Spill.SpillStats -- | Register coalescing. module GHC.CmmToAsm.Reg.Graph.Coalesce -- | Do register coalescing on this top level thing -- -- For Reg -> Reg moves, if the first reg dies at the same time the -- second reg is born then the mov only serves to join live ranges. The -- two regs can be renamed to be the same and the move instruction safely -- erased. regCoalesce :: Instruction instr => [LiveCmmDecl statics instr] -> UniqSM [LiveCmmDecl statics instr] -- | Slurp out mov instructions that only serve to join live ranges. -- -- During a mov, if the source reg dies and the destination reg is born -- then we can rename the two regs to the same thing and eliminate the -- move. slurpJoinMovs :: Instruction instr => LiveCmmDecl statics instr -> Bag (Reg, Reg) module GHC.CmmToAsm.Reg.Graph.SpillCost -- | Records the expected cost to spill some register. type SpillCostRecord = (VirtualReg, Int, Int, Int) -- | Add two spill cost records. plusSpillCostRecord :: SpillCostRecord -> SpillCostRecord -> SpillCostRecord -- | Show a spill cost record, including the degree from the graph and -- final calculated spill cost. pprSpillCostRecord :: (VirtualReg -> RegClass) -> (Reg -> SDoc) -> Graph VirtualReg RegClass RealReg -> SpillCostRecord -> SDoc -- | Map of SpillCostRecord type SpillCostInfo = UniqFM VirtualReg SpillCostRecord -- | An empty map of spill costs. zeroSpillCostInfo :: SpillCostInfo -- | Add two spill cost infos. plusSpillCostInfo :: SpillCostInfo -> SpillCostInfo -> SpillCostInfo -- | Slurp out information used for determining spill costs. -- -- For each vreg, the number of times it was written to, read from, and -- the number of instructions it was live on entry to (lifetime) slurpSpillCostInfo :: forall instr statics. Instruction instr => Platform -> Maybe CFG -> LiveCmmDecl statics instr -> SpillCostInfo -- | Choose a node to spill from this graph chooseSpill :: SpillCostInfo -> Graph VirtualReg RegClass RealReg -> VirtualReg -- | Extract a map of register lifetimes from a SpillCostInfo. lifeMapFromSpillCostInfo :: SpillCostInfo -> UniqFM VirtualReg (VirtualReg, Int) -- | Carries interesting info for debugging / profiling of the graph -- coloring register allocator. module GHC.CmmToAsm.Reg.Graph.Stats -- | Holds interesting statistics from the register allocator. data RegAllocStats statics instr RegAllocStatsStart :: [LiveCmmDecl statics instr] -> Graph VirtualReg RegClass RealReg -> SpillCostInfo -> !Platform -> RegAllocStats statics instr -- | Initial code, with liveness. [raLiveCmm] :: RegAllocStats statics instr -> [LiveCmmDecl statics instr] -- | The initial, uncolored graph. [raGraph] :: RegAllocStats statics instr -> Graph VirtualReg RegClass RealReg -- | Information to help choose which regs to spill. [raSpillCosts] :: RegAllocStats statics instr -> SpillCostInfo -- | Target platform [raPlatform] :: RegAllocStats statics instr -> !Platform RegAllocStatsSpill :: [LiveCmmDecl statics instr] -> Graph VirtualReg RegClass RealReg -> UniqFM VirtualReg VirtualReg -> SpillStats -> SpillCostInfo -> [LiveCmmDecl statics instr] -> !Platform -> RegAllocStats statics instr -- | Code we tried to allocate registers for. [raCode] :: RegAllocStats statics instr -> [LiveCmmDecl statics instr] -- | The initial, uncolored graph. [raGraph] :: RegAllocStats statics instr -> Graph VirtualReg RegClass RealReg -- | The regs that were coalesced. [raCoalesced] :: RegAllocStats statics instr -> UniqFM VirtualReg VirtualReg -- | Spiller stats. [raSpillStats] :: RegAllocStats statics instr -> SpillStats -- | Information to help choose which regs to spill. [raSpillCosts] :: RegAllocStats statics instr -> SpillCostInfo -- | Code with spill instructions added. [raSpilled] :: RegAllocStats statics instr -> [LiveCmmDecl statics instr] -- | Target platform [raPlatform] :: RegAllocStats statics instr -> !Platform RegAllocStatsColored :: [LiveCmmDecl statics instr] -> Graph VirtualReg RegClass RealReg -> Graph VirtualReg RegClass RealReg -> UniqFM VirtualReg VirtualReg -> [LiveCmmDecl statics instr] -> [LiveCmmDecl statics instr] -> [LiveCmmDecl statics instr] -> [NatCmmDecl statics instr] -> (Int, Int, Int) -> !Platform -> RegAllocStats statics instr -- | Code we tried to allocate registers for. [raCode] :: RegAllocStats statics instr -> [LiveCmmDecl statics instr] -- | The initial, uncolored graph. [raGraph] :: RegAllocStats statics instr -> Graph VirtualReg RegClass RealReg -- | Coalesced and colored graph. [raGraphColored] :: RegAllocStats statics instr -> Graph VirtualReg RegClass RealReg -- | The regs that were coalesced. [raCoalesced] :: RegAllocStats statics instr -> UniqFM VirtualReg VirtualReg -- | Code with coalescings applied. [raCodeCoalesced] :: RegAllocStats statics instr -> [LiveCmmDecl statics instr] -- | Code with vregs replaced by hregs. [raPatched] :: RegAllocStats statics instr -> [LiveCmmDecl statics instr] -- | Code with unneeded spill/reloads cleaned out. [raSpillClean] :: RegAllocStats statics instr -> [LiveCmmDecl statics instr] -- | Final code. [raFinal] :: RegAllocStats statics instr -> [NatCmmDecl statics instr] -- | Spill/reload/reg-reg moves present in this code. [raSRMs] :: RegAllocStats statics instr -> (Int, Int, Int) -- | Target platform [raPlatform] :: RegAllocStats statics instr -> !Platform -- | Do all the different analysis on this list of RegAllocStats pprStats :: [RegAllocStats statics instr] -> Graph VirtualReg RegClass RealReg -> SDoc -- | Dump a table of how many spill loads / stores were inserted for each -- vreg. pprStatsSpills :: [RegAllocStats statics instr] -> SDoc -- | Dump a table of how long vregs tend to live for in the initial code. pprStatsLifetimes :: [RegAllocStats statics instr] -> SDoc -- | Dump a table of how many conflicts vregs tend to have in the initial -- code. pprStatsConflict :: [RegAllocStats statics instr] -> SDoc -- | For every vreg, dump how many conflicts it has, and its lifetime. Good -- for making a scatter plot. pprStatsLifeConflict :: [RegAllocStats statics instr] -> Graph VirtualReg RegClass RealReg -> SDoc -- | Count spillreloadreg-reg moves. Lets us see how well the -- register allocator has done. countSRMs :: Instruction instr => LiveCmmDecl statics instr -> (Int, Int, Int) addSRM :: (Int, Int, Int) -> (Int, Int, Int) -> (Int, Int, Int) instance GHC.Base.Functor (GHC.CmmToAsm.Reg.Graph.Stats.RegAllocStats statics) instance (GHC.Utils.Outputable.OutputableP GHC.Platform.Platform statics, GHC.Utils.Outputable.OutputableP GHC.Platform.Platform instr) => GHC.Utils.Outputable.Outputable (GHC.CmmToAsm.Reg.Graph.Stats.RegAllocStats statics instr) -- | Graph coloring register allocator. module GHC.CmmToAsm.Reg.Graph -- | The top level of the graph coloring register allocator. regAlloc :: (OutputableP Platform statics, Instruction instr) => NCGConfig -> UniqFM RegClass (UniqSet RealReg) -> UniqSet Int -> Int -> [LiveCmmDecl statics instr] -> Maybe CFG -> UniqSM ([NatCmmDecl statics instr], Maybe Int, [RegAllocStats statics instr]) module GHC.Cmm.Opt constantFoldNode :: Platform -> CmmNode e x -> CmmNode e x constantFoldExpr :: Platform -> CmmExpr -> CmmExpr cmmMachOpFold :: Platform -> MachOp -> [CmmExpr] -> CmmExpr cmmMachOpFoldM :: Platform -> MachOp -> [CmmExpr] -> Maybe CmmExpr module GHC.Cmm.Info mkEmptyContInfoTable :: CLabel -> CmmInfoTable cmmToRawCmm :: Logger -> DynFlags -> Stream IO CmmGroupSRTs a -> IO (Stream IO RawCmmGroup a) -- | Value of the srt field of an info table when using an StgLargeSRT srtEscape :: Platform -> StgHalfWord data PtrOpts PtrOpts :: !Profile -> !Bool -> PtrOpts -- | Platform profile [po_profile] :: PtrOpts -> !Profile -- | Insert alignment check (cf -falignment-sanitisation) [po_align_check] :: PtrOpts -> !Bool -- | Takes a closure pointer and returns the info table pointer closureInfoPtr :: PtrOpts -> CmmExpr -> CmmExpr -- | Takes an info pointer (the first word of a closure) and returns its -- entry code entryCode :: Platform -> CmmExpr -> CmmExpr -- | Takes a closure pointer, and return the *zero-indexed* constructor tag -- obtained from the info table This lives in the SRT field of the info -- table (constructors don't need SRTs). getConstrTag :: PtrOpts -> CmmExpr -> CmmExpr -- | Takes a closure pointer, and return the closure type obtained from the -- info table cmmGetClosureType :: PtrOpts -> CmmExpr -> CmmExpr -- | Takes an info pointer (the first word of a closure) and returns a -- pointer to the first word of the standard-form info table, excluding -- the entry-code word (if present) infoTable :: Profile -> CmmExpr -> CmmExpr -- | Takes an info table pointer (from infoTable) and returns the constr -- tag field of the info table (same as the srt_bitmap field) infoTableConstrTag :: Profile -> CmmExpr -> CmmExpr -- | Takes an info table pointer (from infoTable) and returns the -- srt_bitmap field of the info table infoTableSrtBitmap :: Profile -> CmmExpr -> CmmExpr -- | Takes an info table pointer (from infoTable) and returns the closure -- type field of the info table. infoTableClosureType :: Profile -> CmmExpr -> CmmExpr infoTablePtrs :: Profile -> CmmExpr -> CmmExpr infoTableNonPtrs :: Profile -> CmmExpr -> CmmExpr -- | Takes the info pointer of a function, and returns a pointer to the -- first word of the StgFunInfoExtra struct in the info table. funInfoTable :: Profile -> CmmExpr -> CmmExpr -- | Takes the info pointer of a function, returns the function's arity funInfoArity :: Profile -> CmmExpr -> CmmExpr stdInfoTableSizeW :: Profile -> WordOff fixedInfoTableSizeW :: WordOff profInfoTableSizeW :: WordOff maxStdInfoTableSizeW :: WordOff maxRetInfoTableSizeW :: WordOff stdInfoTableSizeB :: Profile -> ByteOff conInfoTableSizeB :: Profile -> Int -- | Byte offset of the SRT bitmap half-word which is in the -- *higher-addressed* part of the type_lit stdSrtBitmapOffset :: Profile -> ByteOff -- | Byte offset of the closure type half-word stdClosureTypeOffset :: Profile -> ByteOff stdPtrsOffset :: Profile -> ByteOff stdNonPtrsOffset :: Profile -> ByteOff module GHC.CmmToAsm.PPC.Instr data Instr COMMENT :: FastString -> Instr LOCATION :: Int -> Int -> Int -> String -> Instr LDATA :: Section -> RawCmmStatics -> Instr NEWBLOCK :: BlockId -> Instr DELTA :: Int -> Instr LD :: Format -> Reg -> AddrMode -> Instr LDFAR :: Format -> Reg -> AddrMode -> Instr LDR :: Format -> Reg -> AddrMode -> Instr LA :: Format -> Reg -> AddrMode -> Instr ST :: Format -> Reg -> AddrMode -> Instr STFAR :: Format -> Reg -> AddrMode -> Instr STU :: Format -> Reg -> AddrMode -> Instr STC :: Format -> Reg -> AddrMode -> Instr LIS :: Reg -> Imm -> Instr LI :: Reg -> Imm -> Instr MR :: Reg -> Reg -> Instr CMP :: Format -> Reg -> RI -> Instr CMPL :: Format -> Reg -> RI -> Instr BCC :: Cond -> BlockId -> Maybe Bool -> Instr BCCFAR :: Cond -> BlockId -> Maybe Bool -> Instr JMP :: CLabel -> [Reg] -> Instr MTCTR :: Reg -> Instr BCTR :: [Maybe BlockId] -> Maybe CLabel -> [Reg] -> Instr BL :: CLabel -> [Reg] -> Instr BCTRL :: [Reg] -> Instr ADD :: Reg -> Reg -> RI -> Instr ADDO :: Reg -> Reg -> Reg -> Instr ADDC :: Reg -> Reg -> Reg -> Instr ADDE :: Reg -> Reg -> Reg -> Instr ADDZE :: Reg -> Reg -> Instr ADDIS :: Reg -> Reg -> Imm -> Instr SUBF :: Reg -> Reg -> Reg -> Instr SUBFO :: Reg -> Reg -> Reg -> Instr SUBFC :: Reg -> Reg -> RI -> Instr SUBFE :: Reg -> Reg -> Reg -> Instr MULL :: Format -> Reg -> Reg -> RI -> Instr MULLO :: Format -> Reg -> Reg -> Reg -> Instr MFOV :: Format -> Reg -> Instr MULHU :: Format -> Reg -> Reg -> Reg -> Instr DIV :: Format -> Bool -> Reg -> Reg -> Reg -> Instr AND :: Reg -> Reg -> RI -> Instr ANDC :: Reg -> Reg -> Reg -> Instr NAND :: Reg -> Reg -> Reg -> Instr OR :: Reg -> Reg -> RI -> Instr ORIS :: Reg -> Reg -> Imm -> Instr XOR :: Reg -> Reg -> RI -> Instr XORIS :: Reg -> Reg -> Imm -> Instr EXTS :: Format -> Reg -> Reg -> Instr CNTLZ :: Format -> Reg -> Reg -> Instr NEG :: Reg -> Reg -> Instr NOT :: Reg -> Reg -> Instr SL :: Format -> Reg -> Reg -> RI -> Instr SR :: Format -> Reg -> Reg -> RI -> Instr SRA :: Format -> Reg -> Reg -> RI -> Instr RLWINM :: Reg -> Reg -> Int -> Int -> Int -> Instr CLRLI :: Format -> Reg -> Reg -> Int -> Instr CLRRI :: Format -> Reg -> Reg -> Int -> Instr FADD :: Format -> Reg -> Reg -> Reg -> Instr FSUB :: Format -> Reg -> Reg -> Reg -> Instr FMUL :: Format -> Reg -> Reg -> Reg -> Instr FDIV :: Format -> Reg -> Reg -> Reg -> Instr FABS :: Reg -> Reg -> Instr FNEG :: Reg -> Reg -> Instr FCMP :: Reg -> Reg -> Instr FCTIWZ :: Reg -> Reg -> Instr FCTIDZ :: Reg -> Reg -> Instr FCFID :: Reg -> Reg -> Instr FRSP :: Reg -> Reg -> Instr CRNOR :: Int -> Int -> Int -> Instr MFCR :: Reg -> Instr MFLR :: Reg -> Instr FETCHPC :: Reg -> Instr HWSYNC :: Instr ISYNC :: Instr LWSYNC :: Instr NOP :: Instr data RI RIReg :: Reg -> RI RIImm :: Imm -> RI archWordFormat :: Bool -> Format -- | The size of a minimal stackframe header including minimal parameter -- save area. stackFrameHeaderSize :: Platform -> Int -- | The number of spill slots available without allocating more. maxSpillSlots :: NCGConfig -> Int allocMoreStack :: Platform -> Int -> NatCmmDecl statics Instr -> UniqSM (NatCmmDecl statics Instr, [(BlockId, BlockId)]) makeFarBranches :: LabelMap RawCmmStatics -> [NatBasicBlock Instr] -> [NatBasicBlock Instr] -- | Make an unconditional jump instruction. mkJumpInstr :: BlockId -> [Instr] mkLoadInstr :: NCGConfig -> Reg -> Int -> Int -> [Instr] -- | An instruction to spill a register into a spill slot. mkSpillInstr :: NCGConfig -> Reg -> Int -> Int -> [Instr] -- | Change the destination of this jump instruction. Used in the linear -- allocator when adding fixup blocks for join points. patchJumpInstr :: Instr -> (BlockId -> BlockId) -> Instr -- | Apply a given mapping to all the register references in this -- instruction. patchRegsOfInstr :: Instr -> (Reg -> Reg) -> Instr -- | Checks whether this instruction is a jump/branch instruction. One that -- can change the flow of control in a way that the register allocator -- needs to worry about. jumpDestsOfInstr :: Instr -> [BlockId] -- | Take the source and destination from this reg -> reg move -- instruction or Nothing if it's not one takeRegRegMoveInstr :: Instr -> Maybe (Reg, Reg) -- | See if this instruction is telling us the current C stack delta takeDeltaInstr :: Instr -> Maybe Int -- | Copy the value in a register to another one. Must work for all -- register classes. mkRegRegMoveInstr :: Reg -> Reg -> Instr mkStackAllocInstr :: Platform -> Int -> [Instr] mkStackDeallocInstr :: Platform -> Int -> [Instr] -- | Get the registers that are being used by this instruction. regUsage -- doesn't need to do any trickery for jumps and such. Just state -- precisely the regs read and written by that insn. The consequences of -- control flow transfers, as far as register allocation goes, are taken -- care of by the register allocator. regUsageOfInstr :: Platform -> Instr -> RegUsage -- | Checks whether this instruction is a jump/branch instruction. One that -- can change the flow of control in a way that the register allocator -- needs to worry about. isJumpishInstr :: Instr -> Bool isMetaInstr :: Instr -> Bool module GHC.CmmToAsm.PPC.RegInfo data JumpDest DestBlockId :: BlockId -> JumpDest getJumpDestBlockId :: JumpDest -> Maybe BlockId canShortcut :: Instr -> Maybe JumpDest shortcutJump :: (BlockId -> Maybe JumpDest) -> Instr -> Instr shortcutStatics :: (BlockId -> Maybe JumpDest) -> RawCmmStatics -> RawCmmStatics instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.PPC.RegInfo.JumpDest module GHC.CmmToAsm.PPC.Ppr pprNatCmmDecl :: NCGConfig -> NatCmmDecl RawCmmStatics Instr -> SDoc pprInstr :: Platform -> Instr -> SDoc module GHC.Cmm.Parser.Monad newtype PD a PD :: (DynFlags -> HomeUnit -> PState -> ParseResult a) -> PD a [unPD] :: PD a -> DynFlags -> HomeUnit -> PState -> ParseResult a liftP :: P a -> PD a failMsgPD :: (SrcSpan -> PsError) -> PD a getProfile :: PD Profile getPlatform :: PD Platform getPtrOpts :: PD PtrOpts -- | Return the UnitId of the home-unit. This is used to create labels. getHomeUnitId :: PD UnitId instance GHC.Base.Functor GHC.Cmm.Parser.Monad.PD instance GHC.Base.Applicative GHC.Cmm.Parser.Monad.PD instance GHC.Base.Monad GHC.Cmm.Parser.Monad.PD instance GHC.Driver.Session.HasDynFlags GHC.Cmm.Parser.Monad.PD module GHC.Cmm.Lexer data CmmToken CmmT_SpecChar :: Char -> CmmToken CmmT_DotDot :: CmmToken CmmT_DoubleColon :: CmmToken CmmT_Shr :: CmmToken CmmT_Shl :: CmmToken CmmT_Ge :: CmmToken CmmT_Le :: CmmToken CmmT_Eq :: CmmToken CmmT_Ne :: CmmToken CmmT_BoolAnd :: CmmToken CmmT_BoolOr :: CmmToken CmmT_CLOSURE :: CmmToken CmmT_INFO_TABLE :: CmmToken CmmT_INFO_TABLE_RET :: CmmToken CmmT_INFO_TABLE_FUN :: CmmToken CmmT_INFO_TABLE_CONSTR :: CmmToken CmmT_INFO_TABLE_SELECTOR :: CmmToken CmmT_else :: CmmToken CmmT_export :: CmmToken CmmT_section :: CmmToken CmmT_goto :: CmmToken CmmT_if :: CmmToken CmmT_call :: CmmToken CmmT_jump :: CmmToken CmmT_foreign :: CmmToken CmmT_never :: CmmToken CmmT_prim :: CmmToken CmmT_reserve :: CmmToken CmmT_return :: CmmToken CmmT_returns :: CmmToken CmmT_import :: CmmToken CmmT_switch :: CmmToken CmmT_case :: CmmToken CmmT_default :: CmmToken CmmT_push :: CmmToken CmmT_unwind :: CmmToken CmmT_bits8 :: CmmToken CmmT_bits16 :: CmmToken CmmT_bits32 :: CmmToken CmmT_bits64 :: CmmToken CmmT_bits128 :: CmmToken CmmT_bits256 :: CmmToken CmmT_bits512 :: CmmToken CmmT_float32 :: CmmToken CmmT_float64 :: CmmToken CmmT_gcptr :: CmmToken CmmT_GlobalReg :: GlobalReg -> CmmToken CmmT_Name :: FastString -> CmmToken CmmT_String :: String -> CmmToken CmmT_Int :: Integer -> CmmToken CmmT_Float :: Rational -> CmmToken CmmT_EOF :: CmmToken CmmT_False :: CmmToken CmmT_True :: CmmToken CmmT_likely :: CmmToken cmmlex :: (Located CmmToken -> PD a) -> PD a instance GHC.Show.Show GHC.Cmm.Lexer.CmmToken module GHC.Cmm.DebugBlock -- | Debug information about a block of code. Ticks scope over nested -- blocks. data DebugBlock DebugBlock :: !Label -> !Label -> !CLabel -> !Bool -> !Maybe DebugBlock -> ![CmmTickish] -> !Maybe CmmTickish -> !Maybe Int -> [UnwindPoint] -> ![DebugBlock] -> DebugBlock -- | Entry label of containing proc [dblProcedure] :: DebugBlock -> !Label -- | Hoopl label [dblLabel] :: DebugBlock -> !Label -- | Output label [dblCLabel] :: DebugBlock -> !CLabel -- | Has an info table? [dblHasInfoTbl] :: DebugBlock -> !Bool -- | The parent of this proc. See Note [Splitting DebugBlocks] [dblParent] :: DebugBlock -> !Maybe DebugBlock -- | Ticks defined in this block [dblTicks] :: DebugBlock -> ![CmmTickish] -- | Best source tick covering block [dblSourceTick] :: DebugBlock -> !Maybe CmmTickish -- | Output position relative to other blocks. Nothing means the -- block was optimized out [dblPosition] :: DebugBlock -> !Maybe Int [dblUnwind] :: DebugBlock -> [UnwindPoint] -- | Nested blocks [dblBlocks] :: DebugBlock -> ![DebugBlock] -- | Extract debug data from a group of procedures. We will prefer source -- notes that come from the given module (presumably the module that we -- are currently compiling). cmmDebugGen :: ModLocation -> RawCmmGroup -> [DebugBlock] cmmDebugLabels :: (i -> Bool) -> GenCmmGroup d g (ListGraph i) -> [Label] -- | Sets position and unwind table fields in the debug block tree -- according to native generated code. cmmDebugLink :: [Label] -> LabelMap [UnwindPoint] -> [DebugBlock] -> [DebugBlock] -- | Converts debug blocks into a label map for easier lookups debugToMap :: [DebugBlock] -> LabelMap DebugBlock -- | Maps registers to expressions that yield their "old" values further up -- the stack. Most interesting for the stack pointer Sp, but -- might be useful to document saved registers, too. Note that a -- register's value will be Nothing when the register's previous -- value cannot be reconstructed. type UnwindTable = Map GlobalReg (Maybe UnwindExpr) -- | A label associated with an UnwindTable data UnwindPoint UnwindPoint :: !CLabel -> !UnwindTable -> UnwindPoint -- | Expressions, used for unwind information data UnwindExpr -- | literal value UwConst :: !Int -> UnwindExpr -- | register plus offset UwReg :: !GlobalReg -> !Int -> UnwindExpr -- | pointer dereferencing UwDeref :: UnwindExpr -> UnwindExpr UwLabel :: CLabel -> UnwindExpr UwPlus :: UnwindExpr -> UnwindExpr -> UnwindExpr UwMinus :: UnwindExpr -> UnwindExpr -> UnwindExpr UwTimes :: UnwindExpr -> UnwindExpr -> UnwindExpr -- | Conversion of Cmm expressions to unwind expressions. We check for -- unsupported operator usages and simplify the expression as far as -- possible. toUnwindExpr :: Platform -> CmmExpr -> UnwindExpr instance GHC.Classes.Eq GHC.Cmm.DebugBlock.UnwindExpr instance GHC.Utils.Outputable.OutputableP env GHC.Cmm.CLabel.CLabel => GHC.Utils.Outputable.OutputableP env GHC.Cmm.DebugBlock.DebugBlock instance GHC.Utils.Outputable.OutputableP env GHC.Cmm.CLabel.CLabel => GHC.Utils.Outputable.OutputableP env GHC.Cmm.DebugBlock.UnwindPoint instance GHC.Utils.Outputable.OutputableP env GHC.Cmm.CLabel.CLabel => GHC.Utils.Outputable.OutputableP env GHC.Cmm.DebugBlock.UnwindExpr module GHC.CmmToAsm.X86.Instr data Instr COMMENT :: FastString -> Instr LOCATION :: Int -> Int -> Int -> String -> Instr LDATA :: Section -> (Alignment, RawCmmStatics) -> Instr NEWBLOCK :: BlockId -> Instr UNWIND :: CLabel -> UnwindTable -> Instr DELTA :: Int -> Instr MOV :: Format -> Operand -> Operand -> Instr CMOV :: Cond -> Format -> Operand -> Reg -> Instr MOVZxL :: Format -> Operand -> Operand -> Instr MOVSxL :: Format -> Operand -> Operand -> Instr LEA :: Format -> Operand -> Operand -> Instr ADD :: Format -> Operand -> Operand -> Instr ADC :: Format -> Operand -> Operand -> Instr SUB :: Format -> Operand -> Operand -> Instr SBB :: Format -> Operand -> Operand -> Instr MUL :: Format -> Operand -> Operand -> Instr MUL2 :: Format -> Operand -> Instr IMUL :: Format -> Operand -> Operand -> Instr IMUL2 :: Format -> Operand -> Instr DIV :: Format -> Operand -> Instr IDIV :: Format -> Operand -> Instr ADD_CC :: Format -> Operand -> Operand -> Instr SUB_CC :: Format -> Operand -> Operand -> Instr AND :: Format -> Operand -> Operand -> Instr OR :: Format -> Operand -> Operand -> Instr XOR :: Format -> Operand -> Operand -> Instr NOT :: Format -> Operand -> Instr NEGI :: Format -> Operand -> Instr BSWAP :: Format -> Reg -> Instr SHL :: Format -> Operand -> Operand -> Instr SAR :: Format -> Operand -> Operand -> Instr SHR :: Format -> Operand -> Operand -> Instr BT :: Format -> Imm -> Operand -> Instr NOP :: Instr X87Store :: Format -> AddrMode -> Instr CVTSS2SD :: Reg -> Reg -> Instr CVTSD2SS :: Reg -> Reg -> Instr CVTTSS2SIQ :: Format -> Operand -> Reg -> Instr CVTTSD2SIQ :: Format -> Operand -> Reg -> Instr CVTSI2SS :: Format -> Operand -> Reg -> Instr CVTSI2SD :: Format -> Operand -> Reg -> Instr FDIV :: Format -> Operand -> Operand -> Instr SQRT :: Format -> Operand -> Reg -> Instr TEST :: Format -> Operand -> Operand -> Instr CMP :: Format -> Operand -> Operand -> Instr SETCC :: Cond -> Operand -> Instr PUSH :: Format -> Operand -> Instr POP :: Format -> Operand -> Instr JMP :: Operand -> [Reg] -> Instr JXX :: Cond -> BlockId -> Instr JXX_GBL :: Cond -> Imm -> Instr JMP_TBL :: Operand -> [Maybe JumpDest] -> Section -> CLabel -> Instr -- | X86 call instruction CALL :: Either Imm Reg -> [Reg] -> Instr CLTD :: Format -> Instr FETCHGOT :: Reg -> Instr FETCHPC :: Reg -> Instr POPCNT :: Format -> Operand -> Reg -> Instr LZCNT :: Format -> Operand -> Reg -> Instr TZCNT :: Format -> Operand -> Reg -> Instr BSF :: Format -> Operand -> Reg -> Instr BSR :: Format -> Operand -> Reg -> Instr PDEP :: Format -> Operand -> Operand -> Reg -> Instr PEXT :: Format -> Operand -> Operand -> Reg -> Instr PREFETCH :: PrefetchVariant -> Format -> Operand -> Instr LOCK :: Instr -> Instr XADD :: Format -> Operand -> Operand -> Instr CMPXCHG :: Format -> Operand -> Operand -> Instr XCHG :: Format -> Operand -> Reg -> Instr MFENCE :: Instr data Operand OpReg :: Reg -> Operand OpImm :: Imm -> Operand OpAddr :: AddrMode -> Operand data PrefetchVariant NTA :: PrefetchVariant Lvl0 :: PrefetchVariant Lvl1 :: PrefetchVariant Lvl2 :: PrefetchVariant data JumpDest DestBlockId :: BlockId -> JumpDest DestImm :: Imm -> JumpDest getJumpDestBlockId :: JumpDest -> Maybe BlockId canShortcut :: Instr -> Maybe JumpDest shortcutStatics :: (BlockId -> Maybe JumpDest) -> (Alignment, RawCmmStatics) -> (Alignment, RawCmmStatics) shortcutJump :: (BlockId -> Maybe JumpDest) -> Instr -> Instr allocMoreStack :: Platform -> Int -> NatCmmDecl statics Instr -> UniqSM (NatCmmDecl statics Instr, [(BlockId, BlockId)]) maxSpillSlots :: NCGConfig -> Int archWordFormat :: Bool -> Format -- | Check whether an instruction represents a reg-reg move. The register -- allocator attempts to eliminate reg->reg moves whenever it can, by -- assigning the src and dest temporaries to the same real register. takeRegRegMoveInstr :: Instr -> Maybe (Reg, Reg) -- | Returns which registers are read and written as a (read, written) -- pair. regUsageOfInstr :: Platform -> Instr -> RegUsage -- | See if this instruction is telling us the current C stack delta takeDeltaInstr :: Instr -> Maybe Int -- | Make a spill reload instruction. mkLoadInstr :: NCGConfig -> Reg -> Int -> Int -> [Instr] -- | Make an unconditional branch instruction. mkJumpInstr :: BlockId -> [Instr] mkStackAllocInstr :: Platform -> Int -> [Instr] mkStackDeallocInstr :: Platform -> Int -> [Instr] -- | Make a spill instruction. mkSpillInstr :: NCGConfig -> Reg -> Int -> Int -> [Instr] -- | Make a reg-reg move instruction. On SPARC v8 there are no instructions -- to move directly between floating point and integer regs. If we need -- to do that then we have to go via memory. mkRegRegMoveInstr :: Platform -> Reg -> Reg -> Instr jumpDestsOfInstr :: Instr -> [BlockId] -- | Applies the supplied function to all registers in instructions. -- Typically used to change virtual registers to real registers. patchRegsOfInstr :: Instr -> (Reg -> Reg) -> Instr patchJumpInstr :: Instr -> (BlockId -> BlockId) -> Instr isMetaInstr :: Instr -> Bool isJumpishInstr :: Instr -> Bool instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.X86.Instr.JumpDest module GHC.CmmToAsm.X86.Ppr pprNatCmmDecl :: NCGConfig -> NatCmmDecl (Alignment, RawCmmStatics) Instr -> SDoc pprData :: NCGConfig -> CmmStatic -> SDoc pprInstr :: Platform -> Instr -> SDoc pprFormat :: Format -> SDoc pprImm :: Platform -> Imm -> SDoc pprDataItem :: NCGConfig -> CmmLit -> SDoc module GHC.CmmToAsm.Reg.Linear.FreeRegs class Show freeRegs => FR freeRegs frAllocateReg :: FR freeRegs => Platform -> RealReg -> freeRegs -> freeRegs frGetFreeRegs :: FR freeRegs => Platform -> RegClass -> freeRegs -> [RealReg] frInitFreeRegs :: FR freeRegs => Platform -> freeRegs frReleaseReg :: FR freeRegs => Platform -> RealReg -> freeRegs -> freeRegs maxSpillSlots :: NCGConfig -> Int instance GHC.CmmToAsm.Reg.Linear.FreeRegs.FR GHC.CmmToAsm.Reg.Linear.X86.FreeRegs instance GHC.CmmToAsm.Reg.Linear.FreeRegs.FR GHC.CmmToAsm.Reg.Linear.X86_64.FreeRegs instance GHC.CmmToAsm.Reg.Linear.FreeRegs.FR GHC.CmmToAsm.Reg.Linear.PPC.FreeRegs instance GHC.CmmToAsm.Reg.Linear.FreeRegs.FR GHC.CmmToAsm.Reg.Linear.AArch64.FreeRegs instance GHC.CmmToAsm.Reg.Linear.FreeRegs.FR GHC.CmmToAsm.Reg.Linear.SPARC.FreeRegs -- | Handles joining of a jump instruction to its targets. module GHC.CmmToAsm.Reg.Linear.JoinToTargets -- | For a jump instruction at the end of a block, generate fixup code so -- its vregs are in the correct regs for its destination. joinToTargets :: (FR freeRegs, Instruction instr) => BlockMap RegSet -> BlockId -> instr -> RegM freeRegs ([NatBasicBlock instr], instr) module GHC.CmmToAsm.Reg.Linear regAlloc :: Instruction instr => NCGConfig -> LiveCmmDecl statics instr -> UniqSM (NatCmmDecl statics instr, Maybe Int, Maybe RegAllocStats) module GHC.CmmToAsm.Monad data NcgImpl statics instr jumpDest NcgImpl :: !NCGConfig -> (RawCmmDecl -> NatM [NatCmmDecl statics instr]) -> (instr -> Maybe (NatCmmDecl statics instr)) -> (jumpDest -> Maybe BlockId) -> (instr -> Maybe jumpDest) -> ((BlockId -> Maybe jumpDest) -> statics -> statics) -> ((BlockId -> Maybe jumpDest) -> instr -> instr) -> (NatCmmDecl statics instr -> SDoc) -> Int -> [RealReg] -> ([NatCmmDecl statics instr] -> [NatCmmDecl statics instr]) -> (Int -> NatCmmDecl statics instr -> UniqSM (NatCmmDecl statics instr, [(BlockId, BlockId)])) -> (LabelMap RawCmmStatics -> [NatBasicBlock instr] -> [NatBasicBlock instr]) -> ([instr] -> [UnwindPoint]) -> (Maybe CFG -> LabelMap RawCmmStatics -> [NatBasicBlock instr] -> [NatBasicBlock instr]) -> NcgImpl statics instr jumpDest [ncgConfig] :: NcgImpl statics instr jumpDest -> !NCGConfig [cmmTopCodeGen] :: NcgImpl statics instr jumpDest -> RawCmmDecl -> NatM [NatCmmDecl statics instr] [generateJumpTableForInstr] :: NcgImpl statics instr jumpDest -> instr -> Maybe (NatCmmDecl statics instr) [getJumpDestBlockId] :: NcgImpl statics instr jumpDest -> jumpDest -> Maybe BlockId [canShortcut] :: NcgImpl statics instr jumpDest -> instr -> Maybe jumpDest [shortcutStatics] :: NcgImpl statics instr jumpDest -> (BlockId -> Maybe jumpDest) -> statics -> statics [shortcutJump] :: NcgImpl statics instr jumpDest -> (BlockId -> Maybe jumpDest) -> instr -> instr -- | Module is only for printing internal labels. See Note [Internal -- proc labels] in CLabel. [pprNatCmmDecl] :: NcgImpl statics instr jumpDest -> NatCmmDecl statics instr -> SDoc [maxSpillSlots] :: NcgImpl statics instr jumpDest -> Int [allocatableRegs] :: NcgImpl statics instr jumpDest -> [RealReg] [ncgExpandTop] :: NcgImpl statics instr jumpDest -> [NatCmmDecl statics instr] -> [NatCmmDecl statics instr] -- | The list of block ids records the redirected jumps to allow us to -- update the CFG. [ncgAllocMoreStack] :: NcgImpl statics instr jumpDest -> Int -> NatCmmDecl statics instr -> UniqSM (NatCmmDecl statics instr, [(BlockId, BlockId)]) [ncgMakeFarBranches] :: NcgImpl statics instr jumpDest -> LabelMap RawCmmStatics -> [NatBasicBlock instr] -> [NatBasicBlock instr] -- | given the instruction sequence of a block, produce a list of the -- block's UnwindPoints See Note [What is this unwinding -- business?] in GHC.Cmm.DebugBlock and Note [Unwinding -- information in the NCG] in this module. [extractUnwindPoints] :: NcgImpl statics instr jumpDest -> [instr] -> [UnwindPoint] -- | Turn the sequence of jcc l1; jmp l2 into jncc l2; -- <block_l1> when possible. [invertCondBranches] :: NcgImpl statics instr jumpDest -> Maybe CFG -> LabelMap RawCmmStatics -> [NatBasicBlock instr] -> [NatBasicBlock instr] data NatM_State NatM_State :: UniqSupply -> Int -> [CLabel] -> Maybe Reg -> NCGConfig -> ModLocation -> DwarfFiles -> LabelMap DebugBlock -> CFG -> NatM_State [natm_us] :: NatM_State -> UniqSupply [natm_delta] :: NatM_State -> Int [natm_imports] :: NatM_State -> [CLabel] [natm_pic] :: NatM_State -> Maybe Reg [natm_config] :: NatM_State -> NCGConfig [natm_modloc] :: NatM_State -> ModLocation [natm_fileid] :: NatM_State -> DwarfFiles [natm_debug_map] :: NatM_State -> LabelMap DebugBlock -- | Having a CFG with additional information is essential for some -- operations. However we can't reconstruct all information once we -- generated instructions. So instead we update the CFG as we go. [natm_cfg] :: NatM_State -> CFG mkNatM_State :: UniqSupply -> Int -> NCGConfig -> ModLocation -> DwarfFiles -> LabelMap DebugBlock -> CFG -> NatM_State data NatM result initNat :: NatM_State -> NatM a -> (a, NatM_State) addImportNat :: CLabel -> NatM () -- | Record that we added a block between from and old. addNodeBetweenNat :: BlockId -> BlockId -> BlockId -> NatM () -- | Place succ after block and change any edges block -- -> X to succ -> X addImmediateSuccessorNat :: BlockId -> BlockId -> NatM () updateCfgNat :: (CFG -> CFG) -> NatM () getUniqueNat :: NatM Unique mapAccumLNat :: (acc -> x -> NatM (acc, y)) -> acc -> [x] -> NatM (acc, [y]) setDeltaNat :: Int -> NatM () -- | Get native code generator configuration getConfig :: NatM NCGConfig -- | Get target platform from native code generator configuration getPlatform :: NatM Platform getDeltaNat :: NatM Int getThisModuleNat :: NatM Module getBlockIdNat :: NatM BlockId getNewLabelNat :: NatM CLabel getNewRegNat :: Format -> NatM Reg getNewRegPairNat :: Format -> NatM (Reg, Reg) getPicBaseMaybeNat :: NatM (Maybe Reg) getPicBaseNat :: Format -> NatM Reg -- | Get CFG edge weights getCfgWeights :: NatM Weights getModLoc :: NatM ModLocation getFileId :: FastString -> NatM Int getDebugBlock :: Label -> NatM (Maybe DebugBlock) type DwarfFiles = UniqFM FastString (FastString, Int) instance GHC.Base.Functor GHC.CmmToAsm.Monad.NatM instance GHC.Base.Applicative GHC.CmmToAsm.Monad.NatM instance GHC.Base.Monad GHC.CmmToAsm.Monad.NatM instance GHC.Types.Unique.Supply.MonadUnique GHC.CmmToAsm.Monad.NatM instance GHC.Unit.Module.HasModule GHC.CmmToAsm.Monad.NatM module GHC.CmmToAsm.SPARC.CodeGen.Amode -- | Generate code to reference a memory address. getAmode :: CmmExpr -> NatM Amode -- | Evaluation of 32 bit values. module GHC.CmmToAsm.SPARC.CodeGen.Gen32 -- | The dual to getAnyReg: compute an expression into a register, but we -- don't mind which one it is. getSomeReg :: CmmExpr -> NatM (Reg, InstrBlock) -- | Make code to evaluate a 32 bit expression. getRegister :: CmmExpr -> NatM Register -- | Evaluation of 64 bit values on 32 bit platforms. module GHC.CmmToAsm.SPARC.CodeGen.Gen64 -- | Code to assign a 64 bit value to memory. assignMem_I64Code :: CmmExpr -> CmmExpr -> NatM InstrBlock -- | Code to assign a 64 bit value to a register. assignReg_I64Code :: CmmReg -> CmmExpr -> NatM InstrBlock -- | Get the value of an expression into a 64 bit register. iselExpr64 :: CmmExpr -> NatM ChildCode64 module GHC.CmmToAsm.SPARC.CodeGen.CondCode getCondCode :: CmmExpr -> NatM CondCode condIntCode :: Cond -> CmmExpr -> CmmExpr -> NatM CondCode condFltCode :: Cond -> CmmExpr -> CmmExpr -> NatM CondCode module GHC.CmmToAsm.PIC cmmMakeDynamicReference :: CmmMakeDynamicReferenceM m => NCGConfig -> ReferenceKind -> CLabel -> m CmmExpr class Monad m => CmmMakeDynamicReferenceM m addImport :: CmmMakeDynamicReferenceM m => CLabel -> m () data ReferenceKind DataReference :: ReferenceKind CallReference :: ReferenceKind JumpReference :: ReferenceKind needImportedSymbols :: NCGConfig -> Bool pprImportedSymbol :: NCGConfig -> CLabel -> SDoc pprGotDeclaration :: NCGConfig -> SDoc initializePicBase_ppc :: Arch -> OS -> Reg -> [NatCmmDecl RawCmmStatics Instr] -> NatM [NatCmmDecl RawCmmStatics Instr] initializePicBase_x86 :: Arch -> OS -> Reg -> [NatCmmDecl (Alignment, RawCmmStatics) Instr] -> NatM [NatCmmDecl (Alignment, RawCmmStatics) Instr] instance GHC.Classes.Eq GHC.CmmToAsm.PIC.ReferenceKind instance GHC.CmmToAsm.PIC.CmmMakeDynamicReferenceM GHC.CmmToAsm.Monad.NatM module GHC.CmmToAsm.X86.CodeGen cmmTopCodeGen :: RawCmmDecl -> NatM [NatCmmDecl (Alignment, RawCmmStatics) Instr] generateJumpTableForInstr :: NCGConfig -> Instr -> Maybe (NatCmmDecl (Alignment, RawCmmStatics) Instr) extractUnwindPoints :: [Instr] -> [UnwindPoint] -- | This works on the invariant that all jumps in the given blocks are -- required. Starting from there we try to make a few more jumps -- redundant by reordering them. We depend on the information in the CFG -- to do so so without a given CFG we do nothing. invertCondBranches :: Maybe CFG -> LabelMap a -> [NatBasicBlock Instr] -> [NatBasicBlock Instr] -- | InstrBlocks are the insn sequences generated by the insn -- selectors. They are really trees of insns to facilitate fast -- appending, where a left-to-right traversal yields the insns in the -- correct order. type InstrBlock = OrdList Instr -- | Native code generator for x86 and x86-64 architectures module GHC.CmmToAsm.X86 ncgX86_64 :: NCGConfig -> NcgImpl (Alignment, RawCmmStatics) Instr JumpDest ncgX86 :: NCGConfig -> NcgImpl (Alignment, RawCmmStatics) Instr JumpDest instance GHC.CmmToAsm.Instr.Instruction GHC.CmmToAsm.X86.Instr.Instr module GHC.CmmToAsm.SPARC.CodeGen -- | Top level code generation cmmTopCodeGen :: RawCmmDecl -> NatM [NatCmmDecl RawCmmStatics Instr] generateJumpTableForInstr :: Platform -> Instr -> Maybe (NatCmmDecl RawCmmStatics Instr) -- | InstrBlocks are the insn sequences generated by the insn -- selectors. They are really trees of insns to facilitate fast -- appending, where a left-to-right traversal yields the insns in the -- correct order. type InstrBlock = OrdList Instr -- | Native code generator for SPARC architectures module GHC.CmmToAsm.SPARC ncgSPARC :: NCGConfig -> NcgImpl RawCmmStatics Instr JumpDest instance GHC.CmmToAsm.Instr.Instruction GHC.CmmToAsm.SPARC.Instr.Instr module GHC.CmmToAsm.PPC.CodeGen -- | InstrBlocks are the insn sequences generated by the insn -- selectors. They are really trees of insns to facilitate fast -- appending, where a left-to-right traversal (pre-order?) yields the -- insns in the correct order. cmmTopCodeGen :: RawCmmDecl -> NatM [NatCmmDecl RawCmmStatics Instr] generateJumpTableForInstr :: NCGConfig -> Instr -> Maybe (NatCmmDecl RawCmmStatics Instr) -- | InstrBlocks are the insn sequences generated by the insn -- selectors. They are really trees of insns to facilitate fast -- appending, where a left-to-right traversal yields the insns in the -- correct order. type InstrBlock = OrdList Instr -- | Native code generator for PPC architectures module GHC.CmmToAsm.PPC ncgPPC :: NCGConfig -> NcgImpl RawCmmStatics Instr JumpDest instance GHC.CmmToAsm.Instr.Instruction GHC.CmmToAsm.PPC.Instr.Instr module GHC.CmmToAsm.BlockLayout sequenceTop :: Instruction instr => NcgImpl statics instr jumpDest -> Maybe CFG -> NatCmmDecl statics instr -> NatCmmDecl statics instr backendMaintainsCfg :: Platform -> Bool instance GHC.Classes.Eq GHC.CmmToAsm.BlockLayout.BlockChain instance GHC.Classes.Ord GHC.CmmToAsm.BlockLayout.BlockChain instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.BlockLayout.BlockChain module GHC.CmmToAsm.Dwarf.Types -- | Individual dwarf records. Each one will be encoded as an entry in the -- .debug_info section. data DwarfInfo DwarfCompileUnit :: [DwarfInfo] -> String -> String -> String -> CLabel -> CLabel -> PtrString -> DwarfInfo [dwChildren] :: DwarfInfo -> [DwarfInfo] [dwName] :: DwarfInfo -> String [dwProducer] :: DwarfInfo -> String [dwCompDir] :: DwarfInfo -> String [dwLowLabel] :: DwarfInfo -> CLabel [dwHighLabel] :: DwarfInfo -> CLabel [dwLineLabel] :: DwarfInfo -> PtrString DwarfSubprogram :: [DwarfInfo] -> String -> CLabel -> Maybe CLabel -> DwarfInfo [dwChildren] :: DwarfInfo -> [DwarfInfo] [dwName] :: DwarfInfo -> String [dwLabel] :: DwarfInfo -> CLabel -- | label of DIE belonging to the parent tick [dwParent] :: DwarfInfo -> Maybe CLabel DwarfBlock :: [DwarfInfo] -> CLabel -> Maybe CLabel -> DwarfInfo [dwChildren] :: DwarfInfo -> [DwarfInfo] [dwLabel] :: DwarfInfo -> CLabel [dwMarker] :: DwarfInfo -> Maybe CLabel DwarfSrcNote :: RealSrcSpan -> DwarfInfo [dwSrcSpan] :: DwarfInfo -> RealSrcSpan -- | Generate assembly for DWARF data pprDwarfInfo :: Platform -> Bool -> DwarfInfo -> SDoc -- | Abbreviation declaration. This explains the binary encoding we use for -- representing DwarfInfo. Be aware that this must be updated -- along with pprDwarfInfo. pprAbbrevDecls :: Platform -> Bool -> SDoc -- | A DWARF address range. This is used by the debugger to quickly locate -- which compilation unit a given address belongs to. This type assumes a -- non-segmented address-space. data DwarfARange DwarfARange :: CLabel -> CLabel -> DwarfARange [dwArngStartLabel] :: DwarfARange -> CLabel [dwArngEndLabel] :: DwarfARange -> CLabel -- | Print assembler directives corresponding to a DWARF -- .debug_aranges address table entry. pprDwarfARanges :: Platform -> [DwarfARange] -> Unique -> SDoc -- | Information about unwind instructions for a procedure. This -- corresponds to a "Common Information Entry" (CIE) in DWARF. data DwarfFrame DwarfFrame :: CLabel -> UnwindTable -> [DwarfFrameProc] -> DwarfFrame [dwCieLabel] :: DwarfFrame -> CLabel [dwCieInit] :: DwarfFrame -> UnwindTable [dwCieProcs] :: DwarfFrame -> [DwarfFrameProc] -- | Unwind instructions for an individual procedure. Corresponds to a -- "Frame Description Entry" (FDE) in DWARF. data DwarfFrameProc DwarfFrameProc :: CLabel -> Bool -> [DwarfFrameBlock] -> DwarfFrameProc [dwFdeProc] :: DwarfFrameProc -> CLabel [dwFdeHasInfo] :: DwarfFrameProc -> Bool -- | List of blocks. Order must match asm! [dwFdeBlocks] :: DwarfFrameProc -> [DwarfFrameBlock] -- | Unwind instructions for a block. Will become part of the containing -- FDE. data DwarfFrameBlock DwarfFrameBlock :: Bool -> [UnwindPoint] -> DwarfFrameBlock [dwFdeBlkHasInfo] :: DwarfFrameBlock -> Bool -- | these unwind points must occur in the same order as they occur in the -- block [dwFdeUnwind] :: DwarfFrameBlock -> [UnwindPoint] -- | Header for the .debug_frame section. Here we emit the "Common -- Information Entry" record that establishes general call frame -- parameters and the default stack layout. pprDwarfFrame :: Platform -> DwarfFrame -> SDoc -- | Assembly for a single byte of constant DWARF data pprByte :: Word8 -> SDoc -- | Assembly for a two-byte constant integer pprHalf :: Word16 -> SDoc -- | Assembly for 4 bytes of dynamic DWARF data pprData4' :: SDoc -> SDoc -- | Assembly for a DWARF word of dynamic data. This means 32 bit, as we -- are generating 32 bit DWARF. pprDwWord :: SDoc -> SDoc -- | Assembly for a machine word of dynamic data. Depends on the -- architecture we are currently generating code for. pprWord :: Platform -> SDoc -> SDoc -- | Prints a number in "little endian base 128" format. The idea is to -- optimize for small numbers by stopping once all further bytes would be -- 0. The highest bit in every byte signals whether there are further -- bytes to read. pprLEBWord :: Word -> SDoc -- | Same as pprLEBWord, but for a signed number pprLEBInt :: Int -> SDoc -- | Align assembly at (machine) word boundary wordAlign :: Platform -> SDoc -- | Generate an offset into another section. This is tricky because this -- is handled differently depending on platform: Mac Os expects us to -- calculate the offset using assembler arithmetic. Linux expects us to -- just reference the target directly, and will figure out on their own -- that we actually need an offset. Finally, Windows has a special -- directive to refer to relative offsets. Fun. sectionOffset :: Platform -> SDoc -> SDoc -> SDoc instance GHC.Enum.Enum GHC.CmmToAsm.Dwarf.Types.DwarfAbbrev instance GHC.Classes.Eq GHC.CmmToAsm.Dwarf.Types.DwarfAbbrev instance GHC.Utils.Outputable.OutputableP env GHC.Cmm.CLabel.CLabel => GHC.Utils.Outputable.OutputableP env GHC.CmmToAsm.Dwarf.Types.DwarfFrameBlock module GHC.CmmToAsm.Dwarf -- | Generate DWARF/debug information dwarfGen :: NCGConfig -> ModLocation -> UniqSupply -> [DebugBlock] -> IO (SDoc, UniqSupply) module GHC.CmmToAsm.AArch64.CodeGen cmmTopCodeGen :: RawCmmDecl -> NatM [NatCmmDecl RawCmmStatics Instr] generateJumpTableForInstr :: NCGConfig -> Instr -> Maybe (NatCmmDecl RawCmmStatics Instr) -- | Native code generator for x86 and x86-64 architectures module GHC.CmmToAsm.AArch64 ncgAArch64 :: NCGConfig -> NcgImpl RawCmmStatics Instr JumpDest instance GHC.CmmToAsm.Instr.Instruction GHC.CmmToAsm.AArch64.Instr.Instr -- | Native code generator -- -- The native-code generator has machine-independent and -- machine-dependent modules. -- -- This module (GHC.CmmToAsm) is the top-level machine-independent -- module. Before entering machine-dependent land, we do some -- machine-independent optimisations (defined below) on the -- CmmStmtss. -- -- We convert to the machine-specific Instr datatype with -- cmmCodeGen, assuming an infinite supply of registers. We then -- use a machine-independent register allocator (regAlloc) to -- rejoin reality. Obviously, regAlloc has machine-specific -- helper functions (see about RegAllocInfo below). -- -- Finally, we order the basic blocks of the function so as to minimise -- the number of jumps between blocks, by utilising fallthrough wherever -- possible. -- -- The machine-dependent bits break down as follows: -- --
-- return (x,y) ---- -- If the sequel is AssignTo [p,q] -- --
-- p=x; q=y; --emitReturn :: [CmmExpr] -> FCode ReturnKind adjustHpBackwards :: FCode () emitClosureProcAndInfoTable :: Bool -> Id -> LambdaFormInfo -> CmmInfoTable -> [NonVoid Id] -> ((Int, LocalReg, [LocalReg]) -> FCode ()) -> FCode () emitClosureAndInfoTable :: Platform -> CmmInfoTable -> Convention -> [LocalReg] -> FCode () -> FCode () slowCall :: CmmExpr -> [StgArg] -> FCode ReturnKind directCall :: Convention -> CLabel -> RepArity -> [StgArg] -> FCode ReturnKind data FieldOffOrPadding a FieldOff :: NonVoid a -> ByteOff -> FieldOffOrPadding a Padding :: ByteOff -> ByteOff -> FieldOffOrPadding a -- | Used to tell the various mkVirtHeapOffsets functions what -- kind of header the object has. This will be accounted for in the -- offsets of the fields returned. data ClosureHeader NoHeader :: ClosureHeader StdHeader :: ClosureHeader ThunkHeader :: ClosureHeader mkVirtHeapOffsets :: Profile -> ClosureHeader -> [NonVoid (PrimRep, a)] -> (WordOff, WordOff, [(NonVoid a, ByteOff)]) mkVirtHeapOffsetsWithPadding :: Profile -> ClosureHeader -> [NonVoid (PrimRep, a)] -> (WordOff, WordOff, [FieldOffOrPadding a]) -- | Just like mkVirtHeapOffsets, but for constructors mkVirtConstrOffsets :: Profile -> [NonVoid (PrimRep, a)] -> (WordOff, WordOff, [(NonVoid a, ByteOff)]) -- | Just like mkVirtConstrOffsets, but used when we don't have the actual -- arguments. Useful when e.g. generating info tables; we just need to -- know sizes of pointer and non-pointer fields. mkVirtConstrSizes :: Profile -> [NonVoid PrimRep] -> (WordOff, WordOff) getHpRelOffset :: VirtualHpOffset -> FCode CmmExpr data ArgRep P :: ArgRep N :: ArgRep L :: ArgRep V :: ArgRep F :: ArgRep D :: ArgRep V16 :: ArgRep V32 :: ArgRep V64 :: ArgRep toArgRep :: Platform -> PrimRep -> ArgRep argRepSizeW :: Platform -> ArgRep -> WordOff module GHC.StgToCmm.Ticky withNewTickyCounterFun :: Bool -> Name -> [NonVoid Id] -> FCode a -> FCode a withNewTickyCounterLNE :: Name -> [NonVoid Id] -> FCode a -> FCode a withNewTickyCounterThunk :: Bool -> Bool -> Name -> FCode a -> FCode a withNewTickyCounterStdThunk :: Bool -> Name -> FCode a -> FCode a withNewTickyCounterCon :: Name -> DataCon -> FCode a -> FCode a tickyDynAlloc :: Maybe Id -> SMRep -> LambdaFormInfo -> FCode () tickyAllocHeap :: Bool -> VirtualHpOffset -> FCode () tickyAllocPrim :: CmmExpr -> CmmExpr -> CmmExpr -> FCode () tickyAllocThunk :: CmmExpr -> CmmExpr -> FCode () tickyAllocPAP :: CmmExpr -> CmmExpr -> FCode () tickyHeapCheck :: FCode () tickyStackCheck :: FCode () tickyDirectCall :: RepArity -> [StgArg] -> FCode () tickyPushUpdateFrame :: FCode () tickyUpdateFrameOmitted :: FCode () tickyEnterDynCon :: FCode () tickyEnterFun :: ClosureInfo -> FCode () tickyEnterThunk :: ClosureInfo -> FCode () tickyEnterLNE :: FCode () tickyUpdateBhCaf :: ClosureInfo -> FCode () tickyUnboxedTupleReturn :: RepArity -> FCode () tickyReturnOldCon :: RepArity -> FCode () tickyReturnNewCon :: RepArity -> FCode () tickySlowCall :: LambdaFormInfo -> [StgArg] -> FCode () -- | Provides the heuristics for when it's beneficial to lambda lift -- bindings. Most significantly, this employs a cost model to estimate -- impact on heap allocations, by looking at an STG expression's -- Skeleton. module GHC.Stg.Lift.Analysis -- | Captures details of the syntax tree relevant to the cost model, such -- as closures, multi-shot lambdas and case expressions. data Skeleton ClosureSk :: !Id -> !DIdSet -> !Skeleton -> Skeleton RhsSk :: !Card -> !Skeleton -> Skeleton AltSk :: !Skeleton -> !Skeleton -> Skeleton BothSk :: !Skeleton -> !Skeleton -> Skeleton NilSk :: Skeleton -- | The type used in binder positions in GenStgExprs. data BinderInfo -- | Let(-no-escape)-bound thing with a flag indicating whether it occurs -- as an argument or in a nullary application (see -- GHC.Stg.Lift.Analysis#arg_occs). BindsClosure :: !Id -> !Bool -> BinderInfo -- | Every other kind of binder BoringBinder :: !Id -> BinderInfo -- | Gets the bound Id out a BinderInfo. binderInfoBndr :: BinderInfo -> Id type LlStgBinding = GenStgBinding 'LiftLams type LlStgExpr = GenStgExpr 'LiftLams type LlStgRhs = GenStgRhs 'LiftLams type LlStgAlt = GenStgAlt 'LiftLams -- | Tags every binder with its BinderInfo and let bindings with -- their Skeletons. tagSkeletonTopBind :: CgStgBinding -> LlStgBinding -- | Combines several heuristics to decide whether to lambda-lift a given -- let-binding to top-level. See -- GHC.Stg.Lift.Analysis#when for details. goodToLift :: DynFlags -> TopLevelFlag -> RecFlag -> (DIdSet -> DIdSet) -> [(BinderInfo, LlStgRhs)] -> Skeleton -> Maybe DIdSet -- | closureGrowth expander sizer f fvs computes the closure -- growth in words as a result of lifting f to top-level. If -- there was any growing closure under a multi-shot lambda, the result -- will be infinity. Also see GHC.Stg.Lift.Analysis#clogro. closureGrowth :: (DIdSet -> DIdSet) -> (Id -> Int) -> IdSet -> DIdSet -> Skeleton -> IntWithInf instance GHC.Utils.Outputable.Outputable GHC.Stg.Lift.Analysis.BinderInfo instance GHC.Utils.Outputable.OutputableBndr GHC.Stg.Lift.Analysis.BinderInfo instance GHC.Utils.Outputable.Outputable GHC.Stg.Lift.Analysis.Skeleton -- | Implements a selective lambda lifter, running late in the optimisation -- pipeline. -- -- If you are interested in the cost model that is employed to decide -- whether to lift a binding or not, look at -- GHC.Stg.Lift.Analysis. GHC.Stg.Lift.Monad contains the -- transformation monad that hides away some plumbing of the -- transformation. module GHC.Stg.Lift -- | Lambda lifts bindings to top-level deemed worth lifting (see -- goodToLift). -- -- (Mostly) textbook instance of the lambda lifting transformation, -- selecting which bindings to lambda lift by consulting -- goodToLift. stgLiftLams :: DynFlags -> UniqSupply -> [InStgTopBinding] -> [OutStgTopBinding] -- | Bytecode instruction definitions module GHC.ByteCode.Instr data BCInstr STKCHECK :: Word -> BCInstr PUSH_L :: !Word16 -> BCInstr PUSH_LL :: !Word16 -> !Word16 -> BCInstr PUSH_LLL :: !Word16 -> !Word16 -> !Word16 -> BCInstr PUSH8 :: !Word16 -> BCInstr PUSH16 :: !Word16 -> BCInstr PUSH32 :: !Word16 -> BCInstr PUSH8_W :: !Word16 -> BCInstr PUSH16_W :: !Word16 -> BCInstr PUSH32_W :: !Word16 -> BCInstr PUSH_G :: Name -> BCInstr PUSH_PRIMOP :: PrimOp -> BCInstr PUSH_BCO :: ProtoBCO Name -> BCInstr PUSH_ALTS :: ProtoBCO Name -> BCInstr PUSH_ALTS_UNLIFTED :: ProtoBCO Name -> ArgRep -> BCInstr PUSH_ALTS_TUPLE :: ProtoBCO Name -> !TupleInfo -> ProtoBCO Name -> BCInstr PUSH_PAD8 :: BCInstr PUSH_PAD16 :: BCInstr PUSH_PAD32 :: BCInstr PUSH_UBX8 :: Literal -> BCInstr PUSH_UBX16 :: Literal -> BCInstr PUSH_UBX32 :: Literal -> BCInstr PUSH_UBX :: Literal -> Word16 -> BCInstr PUSH_APPLY_N :: BCInstr PUSH_APPLY_V :: BCInstr PUSH_APPLY_F :: BCInstr PUSH_APPLY_D :: BCInstr PUSH_APPLY_L :: BCInstr PUSH_APPLY_P :: BCInstr PUSH_APPLY_PP :: BCInstr PUSH_APPLY_PPP :: BCInstr PUSH_APPLY_PPPP :: BCInstr PUSH_APPLY_PPPPP :: BCInstr PUSH_APPLY_PPPPPP :: BCInstr SLIDE :: Word16 -> Word16 -> BCInstr ALLOC_AP :: !Word16 -> BCInstr ALLOC_AP_NOUPD :: !Word16 -> BCInstr ALLOC_PAP :: !Word16 -> !Word16 -> BCInstr MKAP :: !Word16 -> !Word16 -> BCInstr MKPAP :: !Word16 -> !Word16 -> BCInstr UNPACK :: !Word16 -> BCInstr PACK :: DataCon -> !Word16 -> BCInstr LABEL :: LocalLabel -> BCInstr TESTLT_I :: Int -> LocalLabel -> BCInstr TESTEQ_I :: Int -> LocalLabel -> BCInstr TESTLT_W :: Word -> LocalLabel -> BCInstr TESTEQ_W :: Word -> LocalLabel -> BCInstr TESTLT_F :: Float -> LocalLabel -> BCInstr TESTEQ_F :: Float -> LocalLabel -> BCInstr TESTLT_D :: Double -> LocalLabel -> BCInstr TESTEQ_D :: Double -> LocalLabel -> BCInstr TESTLT_P :: Word16 -> LocalLabel -> BCInstr TESTEQ_P :: Word16 -> LocalLabel -> BCInstr CASEFAIL :: BCInstr JMP :: LocalLabel -> BCInstr CCALL :: Word16 -> RemotePtr C_ffi_cif -> Word16 -> BCInstr SWIZZLE :: Word16 -> Word16 -> BCInstr ENTER :: BCInstr RETURN :: BCInstr RETURN_UNLIFTED :: ArgRep -> BCInstr RETURN_TUPLE :: BCInstr BRK_FUN :: Word16 -> Unique -> RemotePtr CostCentre -> BCInstr data ProtoBCO a ProtoBCO :: a -> [BCInstr] -> [StgWord] -> Word16 -> Int -> Either [CgStgAlt] CgStgRhs -> [FFIInfo] -> ProtoBCO a [protoBCOName] :: ProtoBCO a -> a [protoBCOInstrs] :: ProtoBCO a -> [BCInstr] [protoBCOBitmap] :: ProtoBCO a -> [StgWord] [protoBCOBitmapSize] :: ProtoBCO a -> Word16 [protoBCOArity] :: ProtoBCO a -> Int [protoBCOExpr] :: ProtoBCO a -> Either [CgStgAlt] CgStgRhs [protoBCOFFIs] :: ProtoBCO a -> [FFIInfo] bciStackUse :: BCInstr -> Word -- | A local block label (e.g. identifying a case alternative). newtype LocalLabel LocalLabel :: Word32 -> LocalLabel [getLocalLabel] :: LocalLabel -> Word32 instance GHC.Classes.Ord GHC.ByteCode.Instr.LocalLabel instance GHC.Classes.Eq GHC.ByteCode.Instr.LocalLabel instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.ByteCode.Instr.ProtoBCO a) instance GHC.Utils.Outputable.Outputable GHC.ByteCode.Instr.BCInstr instance GHC.Utils.Outputable.Outputable GHC.ByteCode.Instr.LocalLabel module GHC.StgToCmm.Heap getVirtHp :: FCode VirtualHpOffset setVirtHp :: VirtualHpOffset -> FCode () setRealHp :: VirtualHpOffset -> FCode () getHpRelOffset :: VirtualHpOffset -> FCode CmmExpr entryHeapCheck :: ClosureInfo -> Maybe LocalReg -> Int -> [LocalReg] -> FCode () -> FCode () altHeapCheck :: [LocalReg] -> FCode a -> FCode a noEscapeHeapCheck :: [LocalReg] -> FCode a -> FCode a altHeapCheckReturnsTo :: [LocalReg] -> Label -> ByteOff -> FCode a -> FCode a heapStackCheckGen :: Maybe CmmExpr -> Maybe CmmExpr -> FCode () -- | lower-level version for GHC.Cmm.Parser entryHeapCheck' :: Bool -> CmmExpr -> Int -> [LocalReg] -> FCode () -> FCode () mkStaticClosureFields :: Profile -> CmmInfoTable -> CostCentreStack -> CafInfo -> [CmmLit] -> [CmmLit] mkStaticClosure :: Profile -> CLabel -> CostCentreStack -> [CmmLit] -> [CmmLit] -> [CmmLit] -> [CmmLit] -> [CmmLit] allocDynClosure :: Maybe Id -> CmmInfoTable -> LambdaFormInfo -> CmmExpr -> CmmExpr -> [(NonVoid StgArg, VirtualHpOffset)] -> FCode CmmExpr allocDynClosureCmm :: Maybe Id -> CmmInfoTable -> LambdaFormInfo -> CmmExpr -> CmmExpr -> [(CmmExpr, ByteOff)] -> FCode CmmExpr -- | Low-level heap object allocation. allocHeapClosure :: SMRep -> CmmExpr -> CmmExpr -> [(CmmExpr, ByteOff)] -> FCode CmmExpr emitSetDynHdr :: CmmExpr -> CmmExpr -> CmmExpr -> FCode () module GHC.Cmm.Info.Build type CAFSet = Set CAFLabel type CAFEnv = LabelMap CAFSet -- | For each code block: - collect the references reachable from this code -- block to FUN, THUNK or RET labels for which hasCAF == True -- -- This gives us a CAFEnv: a mapping from code block to sets of -- labels cafAnal :: Platform -> LabelSet -> CLabel -> CmmGraph -> CAFEnv cafAnalData :: Platform -> CmmStatics -> CAFSet -- | Attach SRTs to all info tables in the CmmDecls, and add SRT -- declarations to the ModuleSRTInfo. doSRTs :: DynFlags -> ModuleSRTInfo -> [(CAFEnv, [CmmDecl])] -> [(CAFSet, CmmDecl)] -> IO (ModuleSRTInfo, [CmmDeclSRTs]) data ModuleSRTInfo ModuleSRTInfo :: Module -> Map (Set SRTEntry) SRTEntry -> Map SRTEntry (Set SRTEntry) -> SRTMap -> ModuleSRTInfo -- | Current module being compiled. Required for calling labelDynamic. [thisModule] :: ModuleSRTInfo -> Module -- | previous SRTs we've emitted, so we can de-duplicate. Used to implement -- the [Common] optimisation. [dedupSRTs] :: ModuleSRTInfo -> Map (Set SRTEntry) SRTEntry -- | The reverse mapping, so that we can remove redundant entries. e.g. if -- we have an SRT [a,b,c], and we know that b points to [c,d], we can -- omit c and emit [a,b]. Used to implement the [Filter] optimisation. [flatSRTs] :: ModuleSRTInfo -> Map SRTEntry (Set SRTEntry) [moduleSRTMap] :: ModuleSRTInfo -> SRTMap emptySRT :: Module -> ModuleSRTInfo -- | Maps labels from cafAnal to the final CLabel that will appear -- in the SRT. - closures with singleton SRTs resolve to their single -- entry - closures with larger SRTs map to the label for that SRT - CAFs -- must not map to anything! - if a labels maps to Nothing, we found that -- this label's SRT is empty, so we don't need to refer to it from other -- SRTs. type SRTMap = Map CAFLabel (Maybe SRTEntry) -- | Given SRTMap of a module, returns the set of non-CAFFY names in -- the module. Any Names not in the set are CAFFY. srtMapNonCAFs :: SRTMap -> NonCaffySet instance GHC.Classes.Ord GHC.Cmm.Info.Build.CAFLabel instance GHC.Classes.Eq GHC.Cmm.Info.Build.CAFLabel instance GHC.Classes.Ord GHC.Cmm.Info.Build.SRTEntry instance GHC.Classes.Eq GHC.Cmm.Info.Build.SRTEntry instance GHC.Classes.Ord GHC.Cmm.Info.Build.SomeLabel instance GHC.Classes.Eq GHC.Cmm.Info.Build.SomeLabel instance GHC.Utils.Outputable.OutputableP env GHC.Cmm.CLabel.CLabel => GHC.Utils.Outputable.OutputableP env GHC.Cmm.Info.Build.CAFLabel instance GHC.Utils.Outputable.OutputableP env GHC.Cmm.CLabel.CLabel => GHC.Utils.Outputable.OutputableP env GHC.Cmm.Info.Build.SRTEntry instance GHC.Utils.Outputable.OutputableP env GHC.Cmm.CLabel.CLabel => GHC.Utils.Outputable.OutputableP env GHC.Cmm.Info.Build.ModuleSRTInfo instance GHC.Utils.Outputable.OutputableP env GHC.Cmm.CLabel.CLabel => GHC.Utils.Outputable.OutputableP env GHC.Cmm.Info.Build.SomeLabel module GHC.StgToCmm.Prim cgOpApp :: StgOp -> [StgArg] -> Type -> FCode ReturnKind shouldInlinePrimOp :: DynFlags -> PrimOp -> [CmmExpr] -> Bool module GHC.StgToCmm.DataCon cgTopRhsCon :: DynFlags -> Id -> DataCon -> ConstructorNumber -> [NonVoid StgArg] -> (CgIdInfo, FCode ()) buildDynCon :: Id -> ConstructorNumber -> Bool -> CostCentreStack -> DataCon -> [NonVoid StgArg] -> FCode (CgIdInfo, FCode CmmAGraph) bindConArgs :: AltCon -> LocalReg -> [NonVoid Id] -> FCode [LocalReg] module GHC.StgToCmm.Bind cgTopRhsClosure :: Platform -> RecFlag -> Id -> CostCentreStack -> UpdateFlag -> [Id] -> CgStgExpr -> (CgIdInfo, FCode ()) cgBind :: CgStgBinding -> FCode () emitBlackHoleCode :: CmmExpr -> FCode () pushUpdateFrame :: CLabel -> CmmExpr -> FCode () -> FCode () emitUpdateFrame :: CmmExpr -> CLabel -> CmmExpr -> FCode () module GHC.StgToCmm.Expr cgExpr :: CgStgExpr -> FCode ReturnKind module GHC.StgToCmm codeGen :: Logger -> TmpFs -> DynFlags -> Module -> InfoTableProvMap -> [TyCon] -> CollectedCCs -> [CgStgTopBinding] -> HpcInfo -> Stream IO CmmGroup (CStub, ModuleLFInfos) module GHC.Cmm.Parser parseCmmFile :: DynFlags -> Module -> HomeUnit -> FilePath -> IO (Bag PsWarning, Bag PsError, Maybe (CmmGroup, [InfoProvEnt])) module GHC.Cmm.LayoutStack cmmLayoutStack :: DynFlags -> ProcPointSet -> ByteOff -> CmmGraph -> UniqSM (CmmGraph, LabelMap StackMap) setInfoTableStackMap :: Platform -> LabelMap StackMap -> CmmDecl -> CmmDecl instance GHC.Utils.Outputable.Outputable GHC.Cmm.LayoutStack.StackSlot instance GHC.Utils.Outputable.Outputable GHC.Cmm.LayoutStack.StackMap -- | Generate infotables for interpreter-made bytecodes module GHC.ByteCode.InfoTable mkITbls :: Interp -> Profile -> [TyCon] -> IO ItblEnv -- | Bytecode assembler and linker module GHC.ByteCode.Asm assembleBCOs :: Interp -> Profile -> [ProtoBCO Name] -> [TyCon] -> [RemotePtr ()] -> Maybe ModBreaks -> IO CompiledByteCode assembleOneBCO :: Interp -> Profile -> ProtoBCO Name -> IO UnlinkedBCO -- | Finds external references. Remember to remove the names defined by -- this group of BCOs themselves bcoFreeNames :: UnlinkedBCO -> UniqDSet Name data SizedSeq a sizeSS :: SizedSeq a -> Word ssElts :: SizedSeq a -> [a] iNTERP_STACK_CHECK_THRESH :: Int mkTupleInfoLit :: Platform -> TupleInfo -> Literal instance GHC.Base.Functor GHC.ByteCode.Asm.Assembler instance GHC.Base.Applicative GHC.ByteCode.Asm.Assembler instance GHC.Base.Monad GHC.ByteCode.Asm.Assembler -- | GHC.StgToByteCode: Generate bytecode from STG module GHC.StgToByteCode data UnlinkedBCO byteCodeGen :: HscEnv -> Module -> [StgTopBinding] -> [TyCon] -> Maybe ModBreaks -> IO CompiledByteCode instance GHC.Classes.Ord GHC.StgToByteCode.Discr instance GHC.Classes.Eq GHC.StgToByteCode.Discr instance GHC.Base.Functor GHC.StgToByteCode.BcM instance GHC.Base.Applicative GHC.StgToByteCode.BcM instance GHC.Base.Monad GHC.StgToByteCode.BcM instance GHC.Driver.Session.HasDynFlags GHC.StgToByteCode.BcM instance GHC.Utils.Outputable.Outputable GHC.StgToByteCode.Discr -- | (c) The GRASP/AQUA Project, Glasgow University, 1993-1998 -- -- A lint pass to check basic STG invariants: -- --
-- runParser :: ParserOpts -> String -> P a -> ParseResult a -- runParser opts str parser = unP parser parseState -- where -- filename = "<interactive>" -- location = mkRealSrcLoc (mkFastString filename) 1 1 -- buffer = stringToStringBuffer str -- parseState = initParserState opts buffer location --module GHC.Parser -- | Parse a Haskell module with Haddock comments. This is done in two -- steps: -- --
-- forall a. C a => <blah> ---- -- newMethodFromName is supposed to instantiate just the outer -- type variable and constraint newMethodFromName :: CtOrigin -> Name -> [TcRhoType] -> TcM (HsExpr GhcTc) tcSyntaxName :: CtOrigin -> TcType -> (Name, HsExpr GhcRn) -> TcM (Name, HsExpr GhcTc) -- | Returns free variables of WantedConstraints as a non-deterministic -- set. See Note [Deterministic FV] in GHC.Utils.FV. tyCoVarsOfWC :: WantedConstraints -> TyCoVarSet -- | Returns free variables of constraints as a non-deterministic set tyCoVarsOfCt :: Ct -> TcTyCoVarSet -- | Returns free variables of a bag of constraints as a non-deterministic -- set. See Note [Deterministic FV] in GHC.Utils.FV. tyCoVarsOfCts :: Cts -> TcTyCoVarSet module GHC.Tc.Gen.Expr tcCheckPolyExpr :: LHsExpr GhcRn -> TcSigmaType -> TcM (LHsExpr GhcTc) tcCheckPolyExprNC :: LHsExpr GhcRn -> TcSigmaType -> TcM (LHsExpr GhcTc) tcCheckMonoExpr :: LHsExpr GhcRn -> TcRhoType -> TcM (LHsExpr GhcTc) tcCheckMonoExprNC :: LHsExpr GhcRn -> TcRhoType -> TcM (LHsExpr GhcTc) tcMonoExpr :: LHsExpr GhcRn -> ExpRhoType -> TcM (LHsExpr GhcTc) tcMonoExprNC :: LHsExpr GhcRn -> ExpRhoType -> TcM (LHsExpr GhcTc) tcInferRho :: LHsExpr GhcRn -> TcM (LHsExpr GhcTc, TcRhoType) tcInferRhoNC :: LHsExpr GhcRn -> TcM (LHsExpr GhcTc, TcRhoType) tcPolyExpr :: HsExpr GhcRn -> ExpSigmaType -> TcM (HsExpr GhcTc) tcExpr :: HsExpr GhcRn -> ExpRhoType -> TcM (HsExpr GhcTc) -- | Typecheck a syntax operator The operator is a variable or a lambda at -- this stage (i.e. renamer output)t tcSyntaxOp :: CtOrigin -> SyntaxExprRn -> [SyntaxOpType] -> ExpRhoType -> ([TcSigmaType] -> [Mult] -> TcM a) -> TcM (a, SyntaxExprTc) -- | Slightly more general version of tcSyntaxOp that allows the -- caller to specify the shape of the result of the syntax operator tcSyntaxOpGen :: CtOrigin -> SyntaxExprRn -> [SyntaxOpType] -> SyntaxOpType -> ([TcSigmaType] -> [Mult] -> TcM a) -> TcM (a, SyntaxExprTc) -- | What to expect for an argument to a rebindable-syntax operator. Quite -- like Type, but allows for holes to be filled in by tcSyntaxOp. -- The callback called from tcSyntaxOp gets a list of types; the meaning -- of these types is determined by a left-to-right depth-first traversal -- of the SyntaxOpType tree. So if you pass in -- --
-- SynAny `SynFun` (SynList `SynFun` SynType Int) `SynFun` SynAny ---- -- you'll get three types back: one for the first SynAny, the -- element type of the list, and one for the last SynAny. -- You don't get anything for the SynType, because you've said -- positively that it should be an Int, and so it shall be. -- -- You'll also get three multiplicities back: one for each function -- arrow. See also Note [Linear types] in Multiplicity. -- -- This is defined here to avoid defining it in GHC.Tc.Gen.Expr -- boot file. data SyntaxOpType -- | Any type SynAny :: SyntaxOpType -- | A rho type, skolemised or instantiated as appropriate SynRho :: SyntaxOpType -- | A list type. You get back the element type of the list SynList :: SyntaxOpType -- | A function. SynFun :: SyntaxOpType -> SyntaxOpType -> SyntaxOpType -- | A known type. SynType :: ExpType -> SyntaxOpType infixr 0 `SynFun` -- | Like SynType but accepts a regular TcType synKnownType :: TcType -> SyntaxOpType tcCheckId :: Name -> ExpRhoType -> TcM (HsExpr GhcTc) -- | This name really is ambiguous, so add a suitable "ambiguous -- occurrence" error, then continue addAmbiguousNameErr :: RdrName -> TcM () getFixedTyVars :: [FieldLabelString] -> [TyVar] -> [ConLike] -> TyVarSet -- | The FamInst type: family instance heads module GHC.Tc.Instance.Family type FamInstEnvs = (FamInstEnv, FamInstEnv) tcGetFamInstEnvs :: TcM FamInstEnvs checkFamInstConsistency :: [Module] -> TcM () tcExtendLocalFamInstEnv :: [FamInst] -> TcM a -> TcM a -- | Like tcLookupDataFamInst_maybe, but returns the arguments back -- if there is no data family to unwrap. Returns a Representational -- coercion tcLookupDataFamInst :: FamInstEnvs -> TyCon -> [TcType] -> (TyCon, [TcType], Coercion) -- | Converts a data family type (eg F [a]) to its representation type (eg -- FList a) and returns a coercion between the two: co :: F [a] ~R FList -- a. tcLookupDataFamInst_maybe :: FamInstEnvs -> TyCon -> [TcType] -> Maybe (TyCon, [TcType], Coercion) -- | If co :: T ts ~ rep_ty then: -- --
-- instNewTyCon_maybe T ts = Just (rep_ty, co) ---- -- Checks for a newtype, and for being saturated Just like -- Coercion.instNewTyCon_maybe, but returns a TcCoercion tcInstNewTyCon_maybe :: TyCon -> [TcType] -> Maybe (TcType, TcCoercion) -- | tcTopNormaliseNewTypeTF_maybe gets rid of top-level newtypes, -- potentially looking through newtype instances. -- -- It is only used by the type inference engine (specifically, when -- solving representational equality), and hence it is careful to unwrap -- only if the relevant data constructor is in scope. That's why it gets -- a GlobalRdrEnv argument. -- -- It is careful not to unwrap data/newtype instances if it can't -- continue unwrapping. Such care is necessary for proper error messages. -- -- It does not look through type families. It does not normalise -- arguments to a tycon. -- -- If the result is Just (rep_ty, (co, gres), rep_ty), then co : ty ~R -- rep_ty gres are the GREs for the data constructors that had to be in -- scope tcTopNormaliseNewTypeTF_maybe :: FamInstEnvs -> GlobalRdrEnv -> Type -> Maybe ((Bag GlobalRdrElt, TcCoercion), Type) newFamInst :: FamFlavor -> CoAxiom Unbranched -> TcM FamInst -- | Report a list of injectivity errors together with their source -- locations. Looks only at one equation; does not look for conflicts -- *among* equations. reportInjectivityErrors :: DynFlags -> CoAxiom br -> CoAxBranch -> [Bool] -> TcM () -- | Report error message for a pair of equations violating an injectivity -- annotation. No error message if there are no branches. reportConflictingInjectivityErrs :: TyCon -> [CoAxBranch] -> CoAxBranch -> TcM () -- | Template Haskell splices module GHC.Tc.Gen.Splice tcSpliceExpr :: HsSplice GhcRn -> ExpRhoType -> TcM (HsExpr GhcTc) tcTypedBracket :: HsExpr GhcRn -> HsBracket GhcRn -> ExpRhoType -> TcM (HsExpr GhcTc) tcUntypedBracket :: HsExpr GhcRn -> HsBracket GhcRn -> [PendingRnSplice] -> ExpRhoType -> TcM (HsExpr GhcTc) runAnnotation :: CoreAnnTarget -> LHsExpr GhcRn -> TcM Annotation runMetaE :: LHsExpr GhcTc -> TcM (LHsExpr GhcPs) runMetaP :: LHsExpr GhcTc -> TcM (LPat GhcPs) runMetaT :: LHsExpr GhcTc -> TcM (LHsType GhcPs) runMetaD :: LHsExpr GhcTc -> TcM [LHsDecl GhcPs] runQuasi :: Q a -> TcM a tcTopSpliceExpr :: SpliceType -> TcM (LHsExpr GhcTc) -> TcM (LHsExpr GhcTc) lookupThName_maybe :: Name -> TcM (Maybe Name) defaultRunMeta :: MetaHook TcM runMeta' :: Bool -> (hs_syn -> SDoc) -> (SrcSpan -> ForeignHValue -> TcM (Either SDoc hs_syn)) -> LHsExpr GhcTc -> TcM hs_syn runRemoteModFinalizers :: ThModFinalizers -> TcM () -- | Releases the external interpreter state. finishTH :: TcM () runTopSplice :: DelayedSplice -> TcM (HsExpr GhcTc) instance GHC.Tc.Gen.Splice.ReifyFlag () () instance GHC.Tc.Gen.Splice.ReifyFlag GHC.Types.Var.Specificity Language.Haskell.TH.Syntax.Specificity instance Language.Haskell.TH.Syntax.Quasi GHC.Tc.Types.TcM module GHC.Tc.Solver -- | How should we choose which constraints to quantify over? data InferMode -- | Apply the monomorphism restriction, never quantifying over any -- constraints ApplyMR :: InferMode -- | See Note [TcRnExprMode] in GHC.Tc.Module, the :type +d case; -- this mode refuses to quantify over any defaultable constraint EagerDefaulting :: InferMode -- | Quantify over any constraint that satisfies -- pickQuantifiablePreds NoRestrictions :: InferMode simplifyInfer :: TcLevel -> InferMode -> [TcIdSigInst] -> [(Name, TcTauType)] -> WantedConstraints -> TcM ([TcTyVar], [EvVar], TcEvBinds, Bool) findInferredDiff :: TcThetaType -> TcThetaType -> TcM TcThetaType growThetaTyVars :: ThetaType -> TyCoVarSet -> TyCoVarSet simplifyAmbiguityCheck :: Type -> WantedConstraints -> TcM () simplifyDefault :: ThetaType -> TcM Bool simplifyTop :: WantedConstraints -> TcM (Bag EvBind) simplifyTopImplic :: Bag Implication -> TcM () simplifyInteractive :: WantedConstraints -> TcM (Bag EvBind) -- | Type-check a thing that emits only equality constraints, solving any -- constraints we can and re-emitting constraints that we can't. Use this -- variant only when we'll get another crack at it later See Note -- [Failure in local type signatures] -- -- Panics if we solve any non-equality constraints. (In runTCSEqualities -- we use an error thunk for the evidence bindings.) solveEqualities :: String -> TcM a -> TcM a pushLevelAndSolveEqualities :: SkolemInfo -> [TcTyVar] -> TcM a -> TcM a pushLevelAndSolveEqualitiesX :: String -> TcM a -> TcM (TcLevel, WantedConstraints, a) reportUnsolvedEqualities :: SkolemInfo -> [TcTyVar] -> TcLevel -> WantedConstraints -> TcM () simplifyWantedsTcM :: [CtEvidence] -> TcM WantedConstraints -- | Return (Just new_inerts) if the Givens are satisfiable, Nothing if -- definitely contradictory tcCheckGivens :: InertSet -> Bag EvVar -> TcM (Maybe InertSet) -- | Return True if the Wanteds are soluble, False if not tcCheckWanteds :: InertSet -> ThetaType -> TcM Bool -- | Normalise a type as much as possible using the given constraints. See -- Note [tcNormalise]. tcNormalise :: InertSet -> Type -> TcM Type captureTopConstraints :: TcM a -> TcM (a, WantedConstraints) -- | Simplify top-level constraints, but without reporting any unsolved -- constraints nor unsafe overlapping. simplifyTopWanteds :: WantedConstraints -> TcS WantedConstraints promoteTyVarSet :: TcTyVarSet -> TcM Bool simplifyAndEmitFlatConstraints :: WantedConstraints -> TcM () solveWanteds :: WantedConstraints -> TcS WantedConstraints solveWantedsAndDrop :: WantedConstraints -> TcS WantedConstraints approximateWC :: Bool -> WantedConstraints -> Cts -- | This variant of runTcS will keep solving, even when only -- Deriveds are left around. It also doesn't return any evidence, as -- callers won't need it. runTcSDeriveds :: TcS a -> TcM a instance GHC.Utils.Outputable.Outputable GHC.Tc.Solver.InferMode module GHC.Tc.Solver.Rewrite -- | See Note [Rewriting]. If (xi, co) <- rewrite mode ev ty, then co :: -- xi ~r ty where r is the role in ev. rewrite :: CtEvidence -> TcType -> TcS (Xi, TcCoercion) rewriteKind :: CtLoc -> CtFlavour -> TcType -> TcS (Xi, TcCoercionN) rewriteArgsNom :: CtEvidence -> TyCon -> [TcType] -> TcS ([Xi], [TcCoercion]) -- | Rewrite a type w.r.t. nominal equality. This is useful to rewrite a -- type w.r.t. any givens. It does not do type-family reduction. This -- will never emit new constraints. Call this when the inert set contains -- only givens. rewriteType :: CtLoc -> TcType -> TcS TcType instance GHC.Base.Functor GHC.Tc.Solver.Rewrite.RewriteM instance GHC.Base.Monad GHC.Tc.Solver.Rewrite.RewriteM instance GHC.Base.Applicative GHC.Tc.Solver.Rewrite.RewriteM instance GHC.Driver.Session.HasDynFlags GHC.Tc.Solver.Rewrite.RewriteM -- | Type definitions for the constraint solver module GHC.Tc.Solver.Monad data WorkList WL :: [Ct] -> [Ct] -> Bag Implication -> WorkList [wl_eqs] :: WorkList -> [Ct] [wl_rest] :: WorkList -> [Ct] [wl_implics] :: WorkList -> Bag Implication isEmptyWorkList :: WorkList -> Bool emptyWorkList :: WorkList extendWorkListNonEq :: Ct -> WorkList -> WorkList extendWorkListCt :: Ct -> WorkList -> WorkList extendWorkListCts :: [Ct] -> WorkList -> WorkList extendWorkListEq :: Ct -> WorkList -> WorkList appendWorkList :: WorkList -> WorkList -> WorkList selectNextWorkItem :: TcS (Maybe Ct) workListSize :: WorkList -> Int getWorkList :: TcS WorkList updWorkListTcS :: (WorkList -> WorkList) -> TcS () pushLevelNoWorkList :: SDoc -> TcS a -> TcS (TcLevel, a) data TcS a runTcS :: TcS a -> TcM (a, EvBindMap) -- | This variant of runTcS will keep solving, even when only -- Deriveds are left around. It also doesn't return any evidence, as -- callers won't need it. runTcSDeriveds :: TcS a -> TcM a runTcSWithEvBinds :: EvBindsVar -> TcS a -> TcM a -- | A variant of runTcS that takes and returns an InertSet -- for later resumption of the TcS session. runTcSInerts :: InertSet -> TcS a -> TcM (a, InertSet) failTcS :: SDoc -> TcS a warnTcS :: WarningFlag -> SDoc -> TcS () addErrTcS :: SDoc -> TcS () wrapTcS :: TcM a -> TcS a -- | This can deal only with equality constraints. runTcSEqualities :: TcS a -> TcM a nestTcS :: TcS a -> TcS a nestImplicTcS :: EvBindsVar -> TcLevel -> TcS a -> TcS a setEvBindsTcS :: EvBindsVar -> TcS a -> TcS a emitImplicationTcS :: TcLevel -> SkolemInfo -> [TcTyVar] -> [EvVar] -> Cts -> TcS TcEvBinds emitTvImplicationTcS :: TcLevel -> SkolemInfo -> [TcTyVar] -> Cts -> TcS () runTcPluginTcS :: TcPluginM a -> TcS a addUsedGRE :: Bool -> GlobalRdrElt -> TcS () addUsedGREs :: [GlobalRdrElt] -> TcS () keepAlive :: Name -> TcS () matchGlobalInst :: DynFlags -> Bool -> Class -> [Type] -> TcS ClsInstResult data ClsInstResult NoInstance :: ClsInstResult OneInst :: [TcPredType] -> ([EvExpr] -> EvTerm) -> InstanceWhat -> ClsInstResult [cir_new_theta] :: ClsInstResult -> [TcPredType] [cir_mk_ev] :: ClsInstResult -> [EvExpr] -> EvTerm [cir_what] :: ClsInstResult -> InstanceWhat NotSure :: ClsInstResult data QCInst QCI :: CtEvidence -> [TcTyVar] -> TcPredType -> Bool -> QCInst [qci_ev] :: QCInst -> CtEvidence [qci_tvs] :: QCInst -> [TcTyVar] [qci_pred] :: QCInst -> TcPredType [qci_pend_sc] :: QCInst -> Bool panicTcS :: SDoc -> TcS a traceTcS :: String -> SDoc -> TcS () traceFireTcS :: CtEvidence -> SDoc -> TcS () bumpStepCountTcS :: TcS () csTraceTcS :: SDoc -> TcS () wrapErrTcS :: TcM a -> TcS a wrapWarnTcS :: TcM a -> TcS a resetUnificationFlag :: TcS Bool setUnificationFlag :: TcLevel -> TcS () data MaybeNew Fresh :: CtEvidence -> MaybeNew Cached :: EvExpr -> MaybeNew freshGoals :: [MaybeNew] -> [CtEvidence] isFresh :: MaybeNew -> Bool getEvExpr :: MaybeNew -> EvExpr newTcEvBinds :: TcS EvBindsVar newNoTcEvBinds :: TcS EvBindsVar -- | Make a new equality CtEvidence newWantedEq :: CtLoc -> Role -> TcType -> TcType -> TcS (CtEvidence, Coercion) newWantedEq_SI :: ShadowInfo -> CtLoc -> Role -> TcType -> TcType -> TcS (CtEvidence, Coercion) -- | Emit a new Wanted equality into the work-list emitNewWantedEq :: CtLoc -> Role -> TcType -> TcType -> TcS Coercion newWanted :: CtLoc -> PredType -> TcS MaybeNew newWanted_SI :: ShadowInfo -> CtLoc -> PredType -> TcS MaybeNew newWantedEvVar :: CtLoc -> TcPredType -> TcS MaybeNew newWantedNC :: CtLoc -> PredType -> TcS CtEvidence newWantedEvVarNC :: CtLoc -> TcPredType -> TcS CtEvidence newDerivedNC :: CtLoc -> TcPredType -> TcS CtEvidence -- | Make a new Id of the given type, bound (in the monad's EvBinds) -- to the given term newBoundEvVarId :: TcPredType -> EvTerm -> TcS EvVar unifyTyVar :: TcTyVar -> TcType -> TcS () reportUnifications :: TcS a -> TcS (Int, a) touchabilityTest :: CtFlavour -> TcTyVar -> TcType -> TcS TouchabilityTestResult data TouchabilityTestResult TouchableSameLevel :: TouchabilityTestResult TouchableOuterLevel :: [TcTyVar] -> TcLevel -> TouchabilityTestResult Untouchable :: TouchabilityTestResult setEvBind :: EvBind -> TcS () -- | Equalities only setWantedEq :: TcEvDest -> Coercion -> TcS () -- | Good for both equalities and non-equalities setWantedEvTerm :: TcEvDest -> EvTerm -> TcS () setEvBindIfWanted :: CtEvidence -> EvTerm -> TcS () newEvVar :: TcPredType -> TcS EvVar newGivenEvVar :: CtLoc -> (TcPredType, EvTerm) -> TcS CtEvidence newGivenEvVars :: CtLoc -> [(TcPredType, EvTerm)] -> TcS [CtEvidence] emitNewDeriveds :: CtLoc -> [TcPredType] -> TcS () emitNewDerivedEq :: CtLoc -> Role -> TcType -> TcType -> TcS () -- | Checks if the depth of the given location is too much. Fails if it's -- too big, with an appropriate error message. checkReductionDepth :: CtLoc -> TcType -> TcS () getSolvedDicts :: TcS (DictMap CtEvidence) setSolvedDicts :: DictMap CtEvidence -> TcS () getInstEnvs :: TcS InstEnvs getFamInstEnvs :: TcS (FamInstEnv, FamInstEnv) getTopEnv :: TcS HscEnv getGblEnv :: TcS TcGblEnv getLclEnv :: TcS TcLclEnv getTcEvBindsVar :: TcS EvBindsVar getTcLevel :: TcS TcLevel getTcEvTyCoVars :: EvBindsVar -> TcS TyCoVarSet getTcEvBindsMap :: EvBindsVar -> TcS EvBindMap setTcEvBindsMap :: EvBindsVar -> EvBindMap -> TcS () tcLookupClass :: Name -> TcS Class tcLookupId :: Name -> TcS Id data InertSet IS :: InertCans -> CycleBreakerVarStack -> FunEqMap (TcCoercion, TcType) -> DictMap CtEvidence -> InertSet [inert_cans] :: InertSet -> InertCans [inert_cycle_breakers] :: InertSet -> CycleBreakerVarStack [inert_famapp_cache] :: InertSet -> FunEqMap (TcCoercion, TcType) [inert_solved_dicts] :: InertSet -> DictMap CtEvidence data InertCans IC :: InertEqs -> FunEqMap EqualCtList -> DictMap Ct -> [QCInst] -> DictMap Ct -> Cts -> Cts -> TcLevel -> Bool -> InertCans [inert_eqs] :: InertCans -> InertEqs [inert_funeqs] :: InertCans -> FunEqMap EqualCtList [inert_dicts] :: InertCans -> DictMap Ct [inert_insts] :: InertCans -> [QCInst] -- | See Note [Safe Haskell Overlapping Instances Implementation] in -- GHC.Tc.Solver [inert_safehask] :: InertCans -> DictMap Ct [inert_irreds] :: InertCans -> Cts [inert_blocked] :: InertCans -> Cts [inert_given_eq_lvl] :: InertCans -> TcLevel [inert_given_eqs] :: InertCans -> Bool emptyInert :: InertSet updInertTcS :: (InertSet -> InertSet) -> TcS () updInertCans :: (InertCans -> InertCans) -> TcS () updInertDicts :: (DictMap Ct -> DictMap Ct) -> TcS () updInertIrreds :: (Cts -> Cts) -> TcS () getHasGivenEqs :: TcLevel -> TcS (HasGivenEqs, Cts) setInertCans :: InertCans -> TcS () getInertEqs :: TcS (DTyVarEnv EqualCtList) getInertCans :: TcS InertCans getInertGivens :: TcS [Ct] getInertInsols :: TcS Cts getInnermostGivenEqLevel :: TcS TcLevel getTcSInerts :: TcS InertSet setTcSInerts :: InertSet -> TcS () -- | Returns Given constraints that might, potentially, match the given -- pred. This is used when checking to see if a Given might overlap with -- an instance. See Note [Instance and Given overlap] in -- GHC.Tc.Solver.Interact matchableGivens :: CtLoc -> PredType -> InertSet -> Cts prohibitedSuperClassSolve :: CtLoc -> CtLoc -> Bool mightEqualLater :: InertSet -> TcPredType -> CtLoc -> TcPredType -> CtLoc -> Bool getUnsolvedInerts :: TcS (Bag Implication, Cts) -- | Remove inert constraints from the InertCans, for use when a -- typechecker plugin wishes to discard a given. removeInertCts :: [Ct] -> InertCans -> InertCans getPendingGivenScs :: TcS [Ct] addInertCan :: Ct -> TcS () insertFunEq :: FunEqMap a -> TyCon -> [Type] -> a -> FunEqMap a addInertForAll :: QCInst -> TcS () emitWorkNC :: [CtEvidence] -> TcS () emitWork :: [Ct] -> TcS () isImprovable :: CtEvidence -> Bool kickOutAfterUnification :: TcTyVar -> TcS Int addInertSafehask :: InertCans -> Ct -> InertCans insertSafeOverlapFailureTcS :: InstanceWhat -> Ct -> TcS () updInertSafehask :: (DictMap Ct -> DictMap Ct) -> TcS () getSafeOverlapFailures :: TcS Cts type DictMap a = TcAppMap a emptyDictMap :: DictMap a -- | Look up a dictionary inert. lookupInertDict :: InertCans -> CtLoc -> Class -> [Type] -> Maybe Ct findDictsByClass :: DictMap a -> Class -> Bag a addDict :: DictMap a -> Class -> [Type] -> a -> DictMap a addDictsByClass :: DictMap Ct -> Class -> Bag Ct -> DictMap Ct delDict :: DictMap a -> Class -> [Type] -> DictMap a foldDicts :: (a -> b -> b) -> DictMap a -> b -> b filterDicts :: (Ct -> Bool) -> DictMap Ct -> DictMap Ct findDict :: DictMap a -> CtLoc -> Class -> [Type] -> Maybe a newtype EqualCtList EqualCtList :: NonEmpty Ct -> EqualCtList findTyEqs :: InertCans -> TyVar -> [Ct] foldTyEqs :: (Ct -> b -> b) -> InertEqs -> b -> b findEq :: InertCans -> CanEqLHS -> [Ct] addSolvedDict :: InstanceWhat -> CtEvidence -> Class -> [Type] -> TcS () -- | Look up a solved inert. lookupSolvedDict :: InertSet -> CtLoc -> Class -> [Type] -> Maybe CtEvidence foldIrreds :: (Ct -> b -> b) -> Cts -> b -> b -- | Looks up a family application in the inerts; returned coercion is -- oriented input ~ output lookupFamAppInert :: TyCon -> [Type] -> TcS (Maybe (TcCoercion, TcType, CtFlavourRole)) lookupFamAppCache :: TyCon -> [Type] -> TcS (Maybe (TcCoercion, TcType)) extendFamAppCache :: TyCon -> [Type] -> (TcCoercion, TcType) -> TcS () pprKicked :: Int -> SDoc findFunEq :: FunEqMap a -> TyCon -> [Type] -> Maybe a findFunEqsByTyCon :: FunEqMap a -> TyCon -> [a] instDFunType :: DFunId -> [DFunInstType] -> TcS ([TcType], TcThetaType) newFlexiTcSTy :: Kind -> TcS TcType instFlexi :: [TKVar] -> TcS TCvSubst instFlexiX :: TCvSubst -> [TKVar] -> TcS TCvSubst cloneMetaTyVar :: TcTyVar -> TcS TcTyVar tcInstSkolTyVarsX :: TCvSubst -> [TyVar] -> TcS (TCvSubst, [TcTyVar]) data TcLevel isFilledMetaTyVar_maybe :: TcTyVar -> TcS (Maybe Type) isFilledMetaTyVar :: TcTyVar -> TcS Bool zonkTyCoVarsAndFV :: TcTyCoVarSet -> TcS TcTyCoVarSet zonkTcType :: TcType -> TcS TcType zonkTcTypes :: [TcType] -> TcS [TcType] zonkTcTyVar :: TcTyVar -> TcS TcType zonkCo :: Coercion -> TcS Coercion zonkTyCoVarsAndFVList :: [TcTyCoVar] -> TcS [TcTyCoVar] zonkSimples :: Cts -> TcS Cts zonkWC :: WantedConstraints -> TcS WantedConstraints zonkTyCoVarKind :: TcTyCoVar -> TcS TcTyCoVar newTcRef :: a -> TcS (TcRef a) readTcRef :: TcRef a -> TcS a writeTcRef :: TcRef a -> a -> TcS () updTcRef :: TcRef a -> (a -> a) -> TcS () getDefaultInfo :: TcS ([Type], (Bool, Bool)) getDynFlags :: HasDynFlags m => m DynFlags getGlobalRdrEnvTcS :: TcS GlobalRdrEnv matchFam :: TyCon -> [Type] -> TcS (Maybe (CoercionN, TcType)) matchFamTcM :: TyCon -> [Type] -> TcM (Maybe (CoercionN, TcType)) checkWellStagedDFun :: CtLoc -> InstanceWhat -> PredType -> TcS () pprEq :: TcType -> TcType -> SDoc -- | Conditionally replace all type family applications in the RHS with -- fresh variables, emitting givens that relate the type family -- application to the variable. See Note [Type equality cycles] in -- GHC.Tc.Solver.Canonical. This only works under conditions as described -- in the Note; otherwise, returns Nothing. breakTyEqCycle_maybe :: CtEvidence -> CheckTyEqResult -> CanEqLHS -> TcType -> TcS (Maybe (CoercionN, TcType)) rewriterView :: TcType -> Maybe TcType instance GHC.Utils.Outputable.Outputable GHC.Tc.Solver.Monad.EqualCtList instance GHC.Base.Functor GHC.Tc.Solver.Monad.TcS instance GHC.Utils.Outputable.Outputable GHC.Tc.Solver.Monad.TouchabilityTestResult instance GHC.Base.Applicative GHC.Tc.Solver.Monad.TcS instance GHC.Base.Monad GHC.Tc.Solver.Monad.TcS instance Control.Monad.Fail.MonadFail GHC.Tc.Solver.Monad.TcS instance GHC.Types.Unique.Supply.MonadUnique GHC.Tc.Solver.Monad.TcS instance GHC.Unit.Module.HasModule GHC.Tc.Solver.Monad.TcS instance GHC.Types.TyThing.MonadThings GHC.Tc.Solver.Monad.TcS instance GHC.Driver.Session.HasDynFlags GHC.Tc.Solver.Monad.TcS instance GHC.Utils.Outputable.Outputable GHC.Tc.Solver.Monad.InertSet instance GHC.Utils.Outputable.Outputable GHC.Tc.Solver.Monad.InertCans instance GHC.Utils.Outputable.Outputable GHC.Tc.Solver.Monad.WorkList module GHC.Tc.Instance.Class matchGlobalInst :: DynFlags -> Bool -> Class -> [Type] -> TcM ClsInstResult data ClsInstResult NoInstance :: ClsInstResult OneInst :: [TcPredType] -> ([EvExpr] -> EvTerm) -> InstanceWhat -> ClsInstResult [cir_new_theta] :: ClsInstResult -> [TcPredType] [cir_mk_ev] :: ClsInstResult -> [EvExpr] -> EvTerm [cir_what] :: ClsInstResult -> InstanceWhat NotSure :: ClsInstResult data InstanceWhat BuiltinInstance :: InstanceWhat BuiltinEqInstance :: InstanceWhat LocalInstance :: InstanceWhat TopLevInstance :: DFunId -> SafeOverlapping -> InstanceWhat [iw_dfun_id] :: InstanceWhat -> DFunId [iw_safe_over] :: InstanceWhat -> SafeOverlapping safeOverlap :: InstanceWhat -> Bool instanceReturnsDictCon :: InstanceWhat -> Bool -- | Extra information about the parent instance declaration, needed when -- type-checking associated types. The Class is the enclosing -- class, the [TyVar] are the scoped type variable of the instance -- decl. The VarEnv Type maps class variables to their instance -- types. data AssocInstInfo NotAssociated :: AssocInstInfo InClsInst :: Class -> [TyVar] -> VarEnv Type -> AssocInstInfo [ai_class] :: AssocInstInfo -> Class -- | The scoped tyvars of the instance Why scoped? See bind_me in -- checkConsistentFamInst [ai_tyvars] :: AssocInstInfo -> [TyVar] -- | Maps class tyvars to their instance types See Note [Matching in -- the consistent-instantiation check] [ai_inst_env] :: AssocInstInfo -> VarEnv Type isNotAssociated :: AssocInstInfo -> Bool instance GHC.Utils.Outputable.Outputable GHC.Tc.Instance.Class.ClsInstResult instance GHC.Utils.Outputable.Outputable GHC.Tc.Instance.Class.InstanceWhat module GHC.Tc.Instance.Typeable -- | Generate the Typeable bindings for a module. This is the only -- entry-point of this module and is invoked by the typechecker driver in -- tcRnSrcDecls. -- -- See Note [Grand plan for Typeable] in GHC.Tc.Instance.Typeable. mkTypeableBinds :: TcM TcGblEnv -- | Is a particular TyCon representable by Typeable?. -- These exclude type families and polytypes. tyConIsTypeable :: TyCon -> Bool instance GHC.Base.Monad GHC.Tc.Instance.Typeable.KindRepM instance GHC.Base.Applicative GHC.Tc.Instance.Typeable.KindRepM instance GHC.Base.Functor GHC.Tc.Instance.Typeable.KindRepM module GHC.Rename.Env newTopSrcBinder :: LocatedN RdrName -> RnM Name lookupLocatedTopBndrRn :: Located RdrName -> RnM (Located Name) lookupLocatedTopBndrRnN :: LocatedN RdrName -> RnM (LocatedN Name) lookupTopBndrRn :: RdrName -> RnM Name lookupLocatedOccRn :: GenLocated (SrcSpanAnn' ann) RdrName -> TcRn (GenLocated (SrcSpanAnn' ann) Name) lookupOccRn :: RdrName -> RnM Name lookupOccRn_maybe :: RdrName -> RnM (Maybe Name) lookupLocalOccRn_maybe :: RdrName -> RnM (Maybe Name) lookupInfoOccRn :: RdrName -> RnM [Name] lookupLocalOccThLvl_maybe :: Name -> RnM (Maybe (TopLevelFlag, ThLevel)) lookupLocalOccRn :: RdrName -> RnM Name lookupTypeOccRn :: RdrName -> RnM Name lookupGlobalOccRn :: RdrName -> RnM Name lookupGlobalOccRn_maybe :: RdrName -> RnM (Maybe Name) -- | Result of looking up an occurrence that might be an ambiguous field. data AmbiguousResult -- | Occurrence picked out a single name, which may or may not belong to a -- field (or might be unbound, if an error has been reported already, per -- Note [ Unbound vs Ambiguous Names ]). UnambiguousGre :: GreName -> AmbiguousResult -- | Occurrence picked out two or more fields, and no non-fields. For now -- this is allowed by DuplicateRecordFields in certain circumstances, as -- the type-checker may be able to disambiguate later. AmbiguousFields :: AmbiguousResult -- | Look up a RdrName used as a variable in an expression. -- -- This may be a local variable, global variable, or one or more record -- selector functions. It will not return record fields created with the -- NoFieldSelectors extension (see Note [NoFieldSelectors]). The -- DuplicateRecordFields argument controls whether ambiguous -- fields will be allowed (resulting in an AmbiguousFields result -- being returned). -- -- If the name is not in scope at the term level, but its promoted -- equivalent is in scope at the type level, the lookup will succeed (so -- that the type-checker can report a more informative error later). See -- Note [Promotion]. lookupExprOccRn :: DuplicateRecordFields -> RdrName -> RnM (Maybe AmbiguousResult) -- | Look up an occurrence of a field in record construction or pattern -- matching (but not update). When the -XDisambiguateRecordFields flag is -- on, take account of the data constructor name to disambiguate which -- field to use. -- -- See Note [DisambiguateRecordFields] and Note [NoFieldSelectors]. lookupRecFieldOcc :: Maybe Name -> RdrName -> RnM Name -- | Look up an occurrence of a field in a record update, returning the -- selector name. -- -- Unlike construction and pattern matching with -- -XDisambiguateRecordFields (see lookupRecFieldOcc), -- there is no data constructor to help disambiguate, so this may be -- ambiguous if the field is in scope multiple times. However we ignore -- non-fields in scope with the same name if -- -XDisambiguateRecordFields is on (see Note -- [DisambiguateRecordFields for updates]). -- -- Here a field is in scope even if NoFieldSelectors was enabled -- at its definition site (see Note [NoFieldSelectors]). lookupRecFieldOcc_update :: DuplicateRecordFields -> RdrName -> RnM AmbiguousResult data ChildLookupResult NameNotFound :: ChildLookupResult IncorrectParent :: Name -> GreName -> [Name] -> ChildLookupResult FoundChild :: Parent -> GreName -> ChildLookupResult -- | Used in export lists to lookup the children. lookupSubBndrOcc_helper :: Bool -> Bool -> Name -> RdrName -> RnM ChildLookupResult -- | Specialised version of msum for RnM ChildLookupResult combineChildLookupResult :: [RnM ChildLookupResult] -> RnM ChildLookupResult data HsSigCtxt TopSigCtxt :: NameSet -> HsSigCtxt LocalBindCtxt :: NameSet -> HsSigCtxt ClsDeclCtxt :: Name -> HsSigCtxt InstDeclCtxt :: NameSet -> HsSigCtxt HsBootCtxt :: NameSet -> HsSigCtxt RoleAnnotCtxt :: NameSet -> HsSigCtxt lookupLocalTcNames :: HsSigCtxt -> SDoc -> RdrName -> RnM [(RdrName, Name)] lookupSigOccRn :: HsSigCtxt -> Sig GhcPs -> LocatedA RdrName -> RnM (LocatedA Name) lookupSigOccRnN :: HsSigCtxt -> Sig GhcPs -> LocatedN RdrName -> RnM (LocatedN Name) -- | Lookup a name in relation to the names in a HsSigCtxt lookupSigCtxtOccRn :: HsSigCtxt -> SDoc -> LocatedA RdrName -> RnM (LocatedA Name) -- | Lookup a name in relation to the names in a HsSigCtxt lookupSigCtxtOccRnN :: HsSigCtxt -> SDoc -> LocatedN RdrName -> RnM (LocatedN Name) lookupInstDeclBndr :: Name -> SDoc -> RdrName -> RnM Name lookupFamInstName :: Maybe Name -> LocatedN RdrName -> RnM (LocatedN Name) lookupConstructorFields :: Name -> RnM [FieldLabel] lookupGreAvailRn :: RdrName -> RnM (Name, AvailInfo) lookupSyntax :: Name -> RnM (SyntaxExpr GhcRn, FreeVars) lookupSyntaxExpr :: Name -> RnM (HsExpr GhcRn, FreeVars) lookupSyntaxNames :: [Name] -> RnM ([HsExpr GhcRn], FreeVars) lookupSyntaxName :: Name -> RnM (Name, FreeVars) lookupIfThenElse :: RnM (Maybe Name) lookupQualifiedDoExpr :: HsStmtContext p -> Name -> RnM (HsExpr GhcRn, FreeVars) lookupQualifiedDo :: HsStmtContext p -> Name -> RnM (SyntaxExpr GhcRn, FreeVars) lookupQualifiedDoName :: HsStmtContext p -> Name -> RnM (Name, FreeVars) lookupNameWithQualifier :: Name -> ModuleName -> RnM (Name, FreeVars) addUsedGRE :: Bool -> GlobalRdrElt -> RnM () addUsedGREs :: [GlobalRdrElt] -> RnM () addUsedDataCons :: GlobalRdrEnv -> TyCon -> RnM () dataTcOccs :: RdrName -> [RdrName] instance GHC.Classes.Eq GHC.Rename.Env.FieldsOrSelectors instance GHC.Utils.Outputable.Outputable GHC.Rename.Env.HsSigCtxt instance GHC.Utils.Outputable.Outputable GHC.Rename.Env.ChildLookupResult instance GHC.Utils.Outputable.Outputable GHC.Rename.Env.DisambigInfo instance GHC.Base.Semigroup GHC.Rename.Env.DisambigInfo instance GHC.Base.Monoid GHC.Rename.Env.DisambigInfo module GHC.Rename.Utils checkDupRdrNames :: [LocatedN RdrName] -> RnM () checkDupRdrNamesN :: [LocatedN RdrName] -> RnM () checkShadowedRdrNames :: [LocatedN RdrName] -> RnM () checkDupNames :: [Name] -> RnM () checkDupAndShadowedNames :: (GlobalRdrEnv, LocalRdrEnv) -> [Name] -> RnM () dupNamesErr :: Outputable n => (n -> SrcSpan) -> NonEmpty n -> RnM () -- | Ensure that a boxed or unboxed tuple has arity no larger than -- mAX_TUPLE_SIZE. checkTupSize :: Int -> TcM () -- | Ensure that a constraint tuple has arity no larger than -- mAX_CTUPLE_SIZE. checkCTupSize :: Int -> TcM () addFvRn :: FreeVars -> RnM (thing, FreeVars) -> RnM (thing, FreeVars) mapFvRn :: (a -> RnM (b, FreeVars)) -> [a] -> RnM ([b], FreeVars) mapMaybeFvRn :: (a -> RnM (b, FreeVars)) -> Maybe a -> RnM (Maybe b, FreeVars) warnUnusedMatches :: [Name] -> FreeVars -> RnM () warnUnusedTypePatterns :: [Name] -> FreeVars -> RnM () warnUnusedTopBinds :: [GlobalRdrElt] -> RnM () warnUnusedLocalBinds :: [Name] -> FreeVars -> RnM () -- | Checks to see if we need to warn for -Wunused-record-wildcards or -- -Wredundant-record-wildcards checkUnusedRecordWildcard :: SrcSpan -> FreeVars -> Maybe [Name] -> RnM () -- | Make a map from selector names to field labels and parent tycon names, -- to be used when reporting unused record fields. mkFieldEnv :: GlobalRdrEnv -> NameEnv (FieldLabelString, Parent) unknownSubordinateErr :: SDoc -> RdrName -> SDoc badQualBndrErr :: RdrName -> SDoc typeAppErr :: String -> LHsType GhcPs -> SDoc data HsDocContext TypeSigCtx :: SDoc -> HsDocContext StandaloneKindSigCtx :: SDoc -> HsDocContext PatCtx :: HsDocContext SpecInstSigCtx :: HsDocContext DefaultDeclCtx :: HsDocContext ForeignDeclCtx :: LocatedN RdrName -> HsDocContext DerivDeclCtx :: HsDocContext RuleCtx :: FastString -> HsDocContext TyDataCtx :: LocatedN RdrName -> HsDocContext TySynCtx :: LocatedN RdrName -> HsDocContext TyFamilyCtx :: LocatedN RdrName -> HsDocContext FamPatCtx :: LocatedN RdrName -> HsDocContext ConDeclCtx :: [LocatedN Name] -> HsDocContext ClassDeclCtx :: LocatedN RdrName -> HsDocContext ExprWithTySigCtx :: HsDocContext TypBrCtx :: HsDocContext HsTypeCtx :: HsDocContext HsTypePatCtx :: HsDocContext GHCiCtx :: HsDocContext SpliceTypeCtx :: LHsType GhcPs -> HsDocContext ClassInstanceCtx :: HsDocContext GenericCtx :: SDoc -> HsDocContext pprHsDocContext :: HsDocContext -> SDoc inHsDocContext :: HsDocContext -> SDoc withHsDocContext :: HsDocContext -> SDoc -> SDoc newLocalBndrRn :: LocatedN RdrName -> RnM Name newLocalBndrsRn :: [LocatedN RdrName] -> RnM [Name] bindLocalNames :: [Name] -> RnM a -> RnM a bindLocalNamesFV :: [Name] -> RnM (a, FreeVars) -> RnM (a, FreeVars) addNameClashErrRn :: RdrName -> NonEmpty GlobalRdrElt -> RnM () -- | Throw an error message if a user attempts to quantify an inferred type -- variable in a place where specificity cannot be observed. For example, -- forall {a}. [a] -> [a] would be rejected to the inferred -- type variable {a}, but forall a. [a] -> [a] would -- be accepted. See Note [Unobservably inferred type variables]. checkInferredVars :: HsDocContext -> Maybe SDoc -> LHsSigType GhcPs -> RnM () -- | Examines a non-outermost type for foralls or contexts, which -- are assumed to be nested. For example, in the following declaration: -- --
-- instance forall a. forall b. C (Either a b) ---- -- The outermost forall a is fine, but the nested forall -- b is not. We invoke noNestedForallsContextsErr on the type -- forall b. C (Either a b) to catch the nested forall -- and create a suitable error message. noNestedForallsContextsErr -- returns Just err_msg if such a forall or -- context is found, and returns Nothing otherwise. -- -- This is currently used in the following places: -- --
-- \ (x :: forall a. a -> b) -> e ---- -- Here we do bring b into scope. -- -- RULES can also use AlwaysBind, such as in the following -- example: -- --
-- {-# RULES \"f\" forall (x :: forall a. a -> b). f x = ... b ... #-}
--
--
-- This only applies to RULES that do not explicitly bind their type
-- variables. If a RULE explicitly quantifies its type variables, then
-- NeverBind is used instead. See also Note [Pattern signature
-- binders and scoping] in GHC.Hs.Type.
AlwaysBind :: HsPatSigTypeScoping
-- | Never bind any free tyvars. This is used for RULES that have both
-- explicit type and term variable binders, e.g.:
--
--
-- {-# RULES \"const\" forall a. forall (x :: a) y. const x y = x #-}
--
--
-- The presence of the type variable binder forall a. implies
-- that the free variables in the types of the term variable binders
-- x and y are not bound. In the example above,
-- there are no such free variables, but if the user had written (y
-- :: b) instead of y in the term variable binders, then
-- b would be rejected for being out of scope. See also Note
-- [Pattern signature binders and scoping] in GHC.Hs.Type.
NeverBind :: HsPatSigTypeScoping
rnHsSigWcType :: HsDocContext -> LHsSigWcType GhcPs -> RnM (LHsSigWcType GhcRn, FreeVars)
rnHsPatSigType :: HsPatSigTypeScoping -> HsDocContext -> HsPatSigType GhcPs -> (HsPatSigType GhcRn -> RnM (a, FreeVars)) -> RnM (a, FreeVars)
newTyVarNameRn :: Maybe a -> LocatedN RdrName -> RnM Name
rnConDeclFields :: HsDocContext -> [FieldLabel] -> [LConDeclField GhcPs] -> RnM ([LConDeclField GhcRn], FreeVars)
lookupField :: FastStringEnv FieldLabel -> FieldOcc GhcPs -> FieldOcc GhcRn
rnLTyVar :: LocatedN RdrName -> RnM (LocatedN Name)
rnScaledLHsType :: HsDocContext -> HsScaled GhcPs (LHsType GhcPs) -> RnM (HsScaled GhcRn (LHsType GhcRn), FreeVars)
data NegationHandling
ReassociateNegation :: NegationHandling
KeepNegationIntact :: NegationHandling
mkOpAppRn :: NegationHandling -> LHsExpr GhcRn -> LHsExpr GhcRn -> Fixity -> LHsExpr GhcRn -> RnM (HsExpr GhcRn)
mkNegAppRn :: LHsExpr GhcRn -> SyntaxExpr GhcRn -> RnM (HsExpr GhcRn)
mkOpFormRn :: LHsCmdTop GhcRn -> LHsExpr GhcRn -> Fixity -> LHsCmdTop GhcRn -> RnM (HsCmd GhcRn)
mkConOpPatRn :: LocatedN Name -> Fixity -> LPat GhcRn -> LPat GhcRn -> RnM (Pat GhcRn)
checkPrecMatch :: Name -> MatchGroup GhcRn body -> RnM ()
checkSectionPrec :: FixityDirection -> HsExpr GhcPs -> LHsExpr GhcRn -> LHsExpr GhcRn -> RnM ()
bindHsOuterTyVarBndrs :: OutputableBndrFlag flag 'Renamed => HsDocContext -> Maybe assoc -> FreeKiTyVars -> HsOuterTyVarBndrs flag GhcPs -> (HsOuterTyVarBndrs flag GhcRn -> RnM (a, FreeVars)) -> RnM (a, FreeVars)
bindHsForAllTelescope :: HsDocContext -> HsForAllTelescope GhcPs -> (HsForAllTelescope GhcRn -> RnM (a, FreeVars)) -> RnM (a, FreeVars)
bindLHsTyVarBndr :: HsDocContext -> Maybe a -> LHsTyVarBndr flag GhcPs -> (LHsTyVarBndr flag GhcRn -> RnM (b, FreeVars)) -> RnM (b, FreeVars)
bindLHsTyVarBndrs :: OutputableBndrFlag flag 'Renamed => HsDocContext -> WarnUnusedForalls -> Maybe a -> [LHsTyVarBndr flag GhcPs] -> ([LHsTyVarBndr flag GhcRn] -> RnM (b, FreeVars)) -> RnM (b, FreeVars)
-- | Should GHC warn if a quantified type variable goes unused? Usually,
-- the answer is "yes", but in the particular case of binding
-- LHsQTyVars, we avoid emitting warnings. See Note [Suppress
-- -Wunused-foralls when binding LHsQTyVars].
data WarnUnusedForalls
WarnUnusedForalls :: WarnUnusedForalls
NoWarnUnusedForalls :: WarnUnusedForalls
-- | Create new renamed type variables corresponding to source-level ones.
-- Duplicates are permitted, but will be removed. This is intended
-- especially for the case of handling the implicitly bound free
-- variables of a type signature.
rnImplicitTvOccs :: Maybe assoc -> FreeKiTyVars -> ([Name] -> RnM (a, FreeVars)) -> RnM (a, FreeVars)
bindSigTyVarsFV :: [Name] -> RnM (a, FreeVars) -> RnM (a, FreeVars)
bindHsQTyVars :: forall a b. HsDocContext -> Maybe a -> FreeKiTyVars -> LHsQTyVars GhcPs -> (LHsQTyVars GhcRn -> Bool -> RnM (b, FreeVars)) -> RnM (b, FreeVars)
type FreeKiTyVars = [LocatedN RdrName]
-- | extractHsTyRdrTyVars finds the type/kind variables of a
-- HsType/HsKind. It's used when making the foralls explicit.
-- See Note [Kind and type-variable binders]
extractHsTyRdrTyVars :: LHsType GhcPs -> FreeKiTyVars
-- | Extracts the free type/kind variables from the kind signature of a
-- HsType. This is used to implicitly quantify over k in
-- type T = Nothing :: Maybe k. The left-to-right order of
-- variables is preserved. See Note [Kind and type-variable binders] and
-- Note [Ordering of implicit variables] and Note [Implicit
-- quantification in type synonyms].
extractHsTyRdrTyVarsKindVars :: LHsType GhcPs -> FreeKiTyVars
-- | Extracts free type and kind variables from types in a list. When the
-- same name occurs multiple times in the types, all occurrences are
-- returned.
extractHsTysRdrTyVars :: [LHsType GhcPs] -> FreeKiTyVars -> FreeKiTyVars
extractRdrKindSigVars :: LFamilyResultSig GhcPs -> FreeKiTyVars
-- | Extracts free type and kind variables from an argument in a GADT
-- constructor, returning variable occurrences in left-to-right order.
-- See Note [Ordering of implicit variables].
extractConDeclGADTDetailsTyVars :: HsConDeclGADTDetails GhcPs -> FreeKiTyVars -> FreeKiTyVars
-- | Get type/kind variables mentioned in the kind signature, preserving
-- left-to-right order:
--
-- -- foldlM f z t = do -- aa <- f z a -- bb <- f aa b -- ... -- xx <- f ww x -- yy <- f xx y -- return yy -- Just @return z@ when the structure is empty ---- -- For a Monad m, given two functions f1 :: a -> m b -- and f2 :: b -> m c, their Kleisli composition (f1 -- >=> f2) :: a -> m c is defined by: -- --
-- (f1 >=> f2) a = f1 a >>= f2 ---- -- Another way of thinking about foldlM is that it amounts to an -- application to z of a Kleisli composition: -- --
-- foldlM f z t = -- flip f a >=> flip f b >=> ... >=> flip f x >=> flip f y $ z ---- -- The monadic effects of foldlM are sequenced from left to -- right. -- -- If at some step the bind operator (>>=) -- short-circuits (as with, e.g., mzero in a MonadPlus), -- the evaluated effects will be from an initial segment of the element -- sequence. If you want to evaluate the monadic effects in right-to-left -- order, or perhaps be able to short-circuit after processing a tail of -- the sequence of elements, you'll need to use foldrM instead. -- -- If the monadic effects don't short-circuit, the outermost application -- of f is to the rightmost element y, so that, -- ignoring effects, the result looks like a left fold: -- --
-- ((((z `f` a) `f` b) ... `f` w) `f` x) `f` y ---- --
-- >>> let f a e = do { print e ; return $ e : a }
--
-- >>> foldlM f [] [0..3]
-- 0
-- 1
-- 2
-- 3
-- [3,2,1,0]
--
foldlM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b
-- | Right-to-left monadic fold over the elements of a structure.
--
-- Given a structure t with elements (a, b, c, ..., x,
-- y), the result of a fold with an operator function f is
-- equivalent to:
--
-- -- foldrM f z t = do -- yy <- f y z -- xx <- f x yy -- ... -- bb <- f b cc -- aa <- f a bb -- return aa -- Just @return z@ when the structure is empty ---- -- For a Monad m, given two functions f1 :: a -> m b -- and f2 :: b -> m c, their Kleisli composition (f1 -- >=> f2) :: a -> m c is defined by: -- --
-- (f1 >=> f2) a = f1 a >>= f2 ---- -- Another way of thinking about foldrM is that it amounts to an -- application to z of a Kleisli composition: -- --
-- foldrM f z t = f y >=> f x >=> ... >=> f b >=> f a $ z ---- -- The monadic effects of foldrM are sequenced from right to -- left, and e.g. folds of infinite lists will diverge. -- -- If at some step the bind operator (>>=) -- short-circuits (as with, e.g., mzero in a MonadPlus), -- the evaluated effects will be from a tail of the element sequence. If -- you want to evaluate the monadic effects in left-to-right order, or -- perhaps be able to short-circuit after an initial sequence of -- elements, you'll need to use foldlM instead. -- -- If the monadic effects don't short-circuit, the outermost application -- of f is to the leftmost element a, so that, ignoring -- effects, the result looks like a right fold: -- --
-- a `f` (b `f` (c `f` (... (x `f` (y `f` z))))). ---- --
-- >>> let f i acc = do { print i ; return $ i : acc }
--
-- >>> foldrM f [] [0..3]
-- 3
-- 2
-- 1
-- 0
-- [0,1,2,3]
--
foldrM :: (Foldable t, Monad m) => (a -> b -> m b) -> b -> t a -> m b
whenGOptM :: GeneralFlag -> TcRnIf gbl lcl () -> TcRnIf gbl lcl ()
unsetGOptM :: GeneralFlag -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a
unsetWOptM :: WarningFlag -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a
xoptM :: Extension -> TcRnIf gbl lcl Bool
-- | A functor with application, providing operations to
--
-- -- (<*>) = liftA2 id ---- --
-- liftA2 f x y = f <$> x <*> y ---- -- Further, any definition must satisfy the following: -- --
pure id <*> v = -- v
pure (.) <*> u -- <*> v <*> w = u <*> (v -- <*> w)
pure f <*> -- pure x = pure (f x)
u <*> pure y = -- pure ($ y) <*> u
-- forall x y. p (q x y) = f x . g y ---- -- it follows from the above that -- --
-- liftA2 p (liftA2 q u v) = liftA2 f u . liftA2 g v ---- -- If f is also a Monad, it should satisfy -- -- -- -- (which implies that pure and <*> satisfy the -- applicative functor laws). class Functor f => Applicative (f :: Type -> Type) -- | Lift a value. pure :: Applicative f => a -> f a -- | Sequential application. -- -- A few functors support an implementation of <*> that is -- more efficient than the default one. -- --
-- >>> data MyState = MyState {arg1 :: Foo, arg2 :: Bar, arg3 :: Baz}
--
--
-- -- >>> produceFoo :: Applicative f => f Foo ---- --
-- >>> produceBar :: Applicative f => f Bar -- -- >>> produceBaz :: Applicative f => f Baz ---- --
-- >>> mkState :: Applicative f => f MyState -- -- >>> mkState = MyState <$> produceFoo <*> produceBar <*> produceBaz --(<*>) :: Applicative f => f (a -> b) -> f a -> f b -- | Lift a binary function to actions. -- -- Some functors support an implementation of liftA2 that is more -- efficient than the default one. In particular, if fmap is an -- expensive operation, it is likely better to use liftA2 than to -- fmap over the structure and then use <*>. -- -- This became a typeclass method in 4.10.0.0. Prior to that, it was a -- function defined in terms of <*> and fmap. -- --
-- >>> liftA2 (,) (Just 3) (Just 5) -- Just (3,5) --liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c -- | Sequence actions, discarding the value of the first argument. -- --
-- >>> Just 2 *> Just 3 -- Just 3 ---- --
-- >>> Nothing *> Just 3 -- Nothing ---- -- Of course a more interesting use case would be to have effectful -- computations instead of just returning pure values. -- --
-- >>> import Data.Char
--
-- >>> import Text.ParserCombinators.ReadP
--
-- >>> let p = string "my name is " *> munch1 isAlpha <* eof
--
-- >>> readP_to_S p "my name is Simon"
-- [("Simon","")]
--
(*>) :: Applicative f => f a -> f b -> f b
-- | Sequence actions, discarding the value of the second argument.
(<*) :: Applicative f => f a -> f b -> f a
infixl 4 <*>
infixl 4 *>
infixl 4 <*
-- | An infix synonym for fmap.
--
-- The name of this operator is an allusion to $. Note the
-- similarities between their types:
--
-- -- ($) :: (a -> b) -> a -> b -- (<$>) :: Functor f => (a -> b) -> f a -> f b ---- -- Whereas $ is function application, <$> is function -- application lifted over a Functor. -- --
-- >>> show <$> Nothing -- Nothing -- -- >>> show <$> Just 3 -- Just "3" ---- -- Convert from an Either Int Int to an -- Either Int String using show: -- --
-- >>> show <$> Left 17 -- Left 17 -- -- >>> show <$> Right 17 -- Right "17" ---- -- Double each element of a list: -- --
-- >>> (*2) <$> [1,2,3] -- [2,4,6] ---- -- Apply even to the second element of a pair: -- --
-- >>> even <$> (2,2) -- (2,True) --(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 <$> duplicateLocalDs :: Id -> DsM Id newSysLocalDsNoLP :: Mult -> Type -> DsM Id newSysLocalDs :: Mult -> Type -> DsM Id newSysLocalsDsNoLP :: [Scaled Type] -> DsM [Id] newSysLocalsDs :: [Scaled Type] -> DsM [Id] newUniqueId :: Id -> Mult -> Type -> DsM Id newFailLocalDs :: Mult -> Type -> DsM Id newPredVarDs :: PredType -> DsM Var getSrcSpanDs :: DsM SrcSpan putSrcSpanDs :: SrcSpan -> DsM a -> DsM a putSrcSpanDsA :: SrcSpanAnn' ann -> DsM a -> DsM a mkPrintUnqualifiedDs :: DsM PrintUnqualified newUnique :: TcRnIf gbl lcl Unique -- | Unique Supply -- -- A value of type UniqSupply is unique, and it can supply -- one distinct Unique. Also, from the supply, one can also -- manufacture an arbitrary number of further UniqueSupply -- values, which will be distinct from the first and from all others. data UniqSupply newUniqueSupply :: TcRnIf gbl lcl UniqSupply getGhcModeDs :: DsM GhcMode dsGetFamInstEnvs :: DsM FamInstEnvs dsLookupGlobal :: Name -> DsM TyThing dsLookupGlobalId :: Name -> DsM Id dsLookupTyCon :: Name -> DsM TyCon dsLookupDataCon :: Name -> DsM DataCon dsLookupConLike :: Name -> DsM ConLike -- | See getCCIndexM. getCCIndexDsM :: FastString -> DsM CostCentreIndex type DsMetaEnv = NameEnv DsMetaVal data DsMetaVal DsBound :: Id -> DsMetaVal DsSplice :: HsExpr GhcTc -> DsMetaVal dsGetMetaEnv :: DsM (NameEnv DsMetaVal) dsLookupMetaEnv :: Name -> DsM (Maybe DsMetaVal) dsExtendMetaEnv :: DsMetaEnv -> DsM a -> DsM a -- | Get the current pattern match oracle state. See dsl_nablas. getPmNablas :: DsM Nablas -- | Set the pattern match oracle state within the scope of the given -- action. See dsl_nablas. updPmNablas :: Nablas -> DsM a -> DsM a -- | The COMPLETE pragmas that are in scope. dsGetCompleteMatches :: DsM CompleteMatches type DsWarning = (SrcSpan, SDoc) -- | Emit a warning for the current source location NB: Warns whether or -- not -Wxyz is set warnDs :: WarnReason -> SDoc -> DsM () -- | Emit a warning only if the correct WarnReason is set in the DynFlags warnIfSetDs :: WarningFlag -> SDoc -> DsM () errDs :: SDoc -> DsM () -- | Issue an error, but return the expression for (), so that we can -- continue reporting errors. errDsCoreExpr :: SDoc -> DsM CoreExpr failWithDs :: SDoc -> DsM a failDs :: DsM a discardWarningsDs :: DsM a -> DsM a askNoErrsDs :: DsM a -> DsM (a, Bool) data DsMatchContext DsMatchContext :: HsMatchContext GhcRn -> SrcSpan -> DsMatchContext data EquationInfo EqnInfo :: [Pat GhcTc] -> Origin -> MatchResult CoreExpr -> EquationInfo -- | The patterns for an equation -- -- NB: We have already applied decideBangHood to these -- patterns. See Note [decideBangHood] in GHC.HsToCore.Utils [eqn_pats] :: EquationInfo -> [Pat GhcTc] -- | Was this equation present in the user source? -- -- This helps us avoid warnings on patterns that GHC elaborated. -- -- For instance, the pattern -1 :: Word gets desugared into -- W# -1## :: Word, but we shouldn't warn about an overflowed -- literal for both of these cases. [eqn_orig] :: EquationInfo -> Origin -- | What to do after match [eqn_rhs] :: EquationInfo -> MatchResult CoreExpr -- | This is a value of type a with potentially a CoreExpr-shaped hole in -- it. This is used to deal with cases where we are potentially handling -- pattern match failure, and want to later specify how failure is -- handled. data MatchResult a -- | We represent the case where there is no hole without a function from -- CoreExpr, like this, because sometimes we have nothing to put -- in the hole and so want to be sure there is in fact no hole. MR_Infallible :: DsM a -> MatchResult a MR_Fallible :: (CoreExpr -> DsM a) -> MatchResult a runMatchResult :: CoreExpr -> MatchResult a -> DsM a type DsWrapper = CoreExpr -> CoreExpr idDsWrapper :: DsWrapper -- | Fail with an error message if the type is levity polymorphic. dsNoLevPoly :: Type -> SDoc -> DsM () -- | Check an expression for levity polymorphism, failing if it is levity -- polymorphic. dsNoLevPolyExpr :: CoreExpr -> SDoc -> DsM () -- | Runs the thing_inside. If there are no errors, then returns the expr -- given. Otherwise, returns unitExpr. This is useful for doing a bunch -- of levity polymorphism checks and then avoiding making a core App. (If -- we make a core App on a levity polymorphic argument, detecting how to -- handle the let/app invariant might call isUnliftedType, which panics -- on a levity polymorphic type.) See #12709 for an example of why this -- machinery is necessary. dsWhenNoErrs :: DsM a -> (a -> CoreExpr) -> DsM CoreExpr -- | Inject a trace message into the compiled program. Whereas pprTrace -- prints out information *while compiling*, pprRuntimeTrace captures -- that information and causes it to be printed *at runtime* using -- Debug.Trace.trace. -- -- pprRuntimeTrace hdr doc expr -- -- will produce an expression that looks like -- -- trace (hdr + doc) expr -- -- When using this to debug a module that Debug.Trace depends on, it is -- necessary to import {-# SOURCE #-} Debug.Trace () in that module. We -- could avoid this inconvenience by wiring in Debug.Trace.trace, but -- that doesn't seem worth the effort and maintenance cost. pprRuntimeTrace :: String -> SDoc -> CoreExpr -> DsM CoreExpr instance GHC.Base.Functor GHC.HsToCore.Monad.MatchResult instance GHC.Utils.Outputable.Outputable GHC.HsToCore.Monad.EquationInfo instance GHC.Base.Applicative GHC.HsToCore.Monad.MatchResult instance GHC.Utils.Outputable.Outputable GHC.HsToCore.Monad.DsMatchContext instance GHC.Types.TyThing.MonadThings (GHC.Data.IOEnv.IOEnv (GHC.Tc.Types.Env GHC.HsToCore.Types.DsGblEnv GHC.HsToCore.Types.DsLclEnv)) -- | Various types used during desugaring. module GHC.HsToCore.Types -- | Desugaring monad. See also TcM. type DsM = TcRnIf DsGblEnv DsLclEnv -- | Local state of the desugarer, extended as we lexically descend data DsLclEnv DsLclEnv :: DsMetaEnv -> RealSrcSpan -> Nablas -> DsLclEnv -- | Template Haskell bindings [dsl_meta] :: DsLclEnv -> DsMetaEnv -- | To put in pattern-matching error msgs [dsl_loc] :: DsLclEnv -> RealSrcSpan -- | See Note [Note [Long-distance information] in GHC.HsToCore.Pmc. -- The set of reaching values Nablas is augmented as we walk inwards, -- refined through each pattern match in turn [dsl_nablas] :: DsLclEnv -> Nablas -- | Global read-only context and state of the desugarer. The statefulness -- is implemented through IORefs. data DsGblEnv DsGblEnv :: Module -> FamInstEnv -> GlobalRdrEnv -> PrintUnqualified -> IORef (Messages DecoratedSDoc) -> (IfGblEnv, IfLclEnv) -> CompleteMatches -> IORef CostCentreState -> DsGblEnv [ds_mod] :: DsGblEnv -> Module [ds_fam_inst_env] :: DsGblEnv -> FamInstEnv [ds_gbl_rdr_env] :: DsGblEnv -> GlobalRdrEnv [ds_unqual] :: DsGblEnv -> PrintUnqualified [ds_msgs] :: DsGblEnv -> IORef (Messages DecoratedSDoc) [ds_if_env] :: DsGblEnv -> (IfGblEnv, IfLclEnv) [ds_complete_matches] :: DsGblEnv -> CompleteMatches [ds_cc_st] :: DsGblEnv -> IORef CostCentreState type DsMetaEnv = NameEnv DsMetaVal data DsMetaVal DsBound :: Id -> DsMetaVal DsSplice :: HsExpr GhcTc -> DsMetaVal type CompleteMatches = [CompleteMatch] instance GHC.Unit.Module.ContainsModule GHC.HsToCore.Types.DsGblEnv -- | Types used through-out pattern match checking. This module is mostly -- there to be imported from GHC.HsToCore.Types. The exposed API -- is that of GHC.HsToCore.Pmc. -- -- These types model the paper Lower Your Guards: A Compositional -- Pattern-Match Coverage Checker". module GHC.HsToCore.Pmc.Types -- | Means by which we identify a source construct for later -- pretty-printing in a warning message. SDoc for the equation to -- show, Located for the location. newtype SrcInfo SrcInfo :: Located SDoc -> SrcInfo -- | A very simple language for pattern guards. Let bindings, bang -- patterns, and matching variables against flat constructor patterns. -- The LYG guard language. data PmGrd -- | PmCon x K dicts args corresponds to a K dicts args <- -- x guard. The args are bound in this construct, the -- x is just a use. For the arguments' meaning see -- ConPatOut. PmCon :: !Id -> !PmAltCon -> ![TyVar] -> ![EvVar] -> ![Id] -> PmGrd [pm_id] :: PmGrd -> !Id [pm_con_con] :: PmGrd -> !PmAltCon [pm_con_tvs] :: PmGrd -> ![TyVar] [pm_con_dicts] :: PmGrd -> ![EvVar] [pm_con_args] :: PmGrd -> ![Id] -- | PmBang x corresponds to a seq x True guard. If the -- extra SrcInfo is present, the bang guard came from a source -- bang pattern, in which case we might want to report it as redundant. -- See Note [Dead bang patterns] in GHC.HsToCore.Pmc.Check. PmBang :: !Id -> !Maybe SrcInfo -> PmGrd [pm_id] :: PmGrd -> !Id [_pm_loc] :: PmGrd -> !Maybe SrcInfo -- | PmLet x expr corresponds to a let x = expr guard. -- This actually binds x. PmLet :: !Id -> !CoreExpr -> PmGrd [pm_id] :: PmGrd -> !Id [_pm_let_expr] :: PmGrd -> !CoreExpr -- | A sequence of PmGrds. newtype GrdVec GrdVec :: [PmGrd] -> GrdVec -- | A guard tree denoting MatchGroup. newtype PmMatchGroup p PmMatchGroup :: NonEmpty (PmMatch p) -> PmMatchGroup p -- | A guard tree denoting Match: A payload describing the pats -- and a bunch of GRHS. data PmMatch p PmMatch :: !p -> !PmGRHSs p -> PmMatch p [pm_pats] :: PmMatch p -> !p [pm_grhss] :: PmMatch p -> !PmGRHSs p -- | A guard tree denoting GRHSs: A bunch of PmLet guards -- for local bindings from the GRHSss where clauses and -- the actual list of GRHS. See Note [Long-distance information -- for HsLocalBinds] in GHC.HsToCore.Pmc.Desugar. data PmGRHSs p PmGRHSs :: !p -> !NonEmpty (PmGRHS p) -> PmGRHSs p [pgs_lcls] :: PmGRHSs p -> !p [pgs_grhss] :: PmGRHSs p -> !NonEmpty (PmGRHS p) -- | A guard tree denoting GRHS: A payload describing the grds and -- a SrcInfo useful for printing out in warnings messages. data PmGRHS p PmGRHS :: !p -> !SrcInfo -> PmGRHS p [pg_grds] :: PmGRHS p -> !p [pg_rhs] :: PmGRHS p -> !SrcInfo -- | A guard tree denoting a pattern binding. newtype PmPatBind p PmPatBind :: PmGRHS p -> PmPatBind p -- | A guard tree denoting an -XEmptyCase. newtype PmEmptyCase PmEmptyCase :: Id -> PmEmptyCase [pe_var] :: PmEmptyCase -> Id -- | Redundancy sets, used to determine redundancy of RHSs and bang -- patterns (later digested into a CIRB). data RedSets RedSets :: !Nablas -> !Nablas -> !OrdList (Nablas, SrcInfo) -> RedSets -- | The Covered set; the set of values reaching a particular -- program point. [rs_cov] :: RedSets -> !Nablas -- | The Diverging set; empty if no match can lead to divergence. If -- it wasn't empty, we have to turn redundancy warnings into -- inaccessibility warnings for any subclauses. [rs_div] :: RedSets -> !Nablas -- | If any of the Nablas is empty, the corresponding SrcInfo -- pin-points a bang pattern in source that is redundant. See Note [Dead -- bang patterns]. [rs_bangs] :: RedSets -> !OrdList (Nablas, SrcInfo) data Precision Approximate :: Precision Precise :: Precision -- | Pattern-match coverage check result data CheckResult a CheckResult :: !a -> !Nablas -> !Precision -> CheckResult a -- | A hole for redundancy info and covered sets. [cr_ret] :: CheckResult a -> !a -- | The set of uncovered values falling out at the bottom. (for -- -Wincomplete-patterns, but also important state for the algorithm) [cr_uncov] :: CheckResult a -> !Nablas -- | A flag saying whether we ran into the maxPmCheckModels limit -- for the purpose of suggesting to crank it up in the warning message. -- Writer state. [cr_approx] :: CheckResult a -> !Precision -- | Used as tree payload pre-checking. The LYG guards to check. type Pre = GrdVec -- | Used as tree payload post-checking. The redundancy info we elaborated. type Post = RedSets instance GHC.Show.Show GHC.HsToCore.Pmc.Types.Precision instance GHC.Classes.Eq GHC.HsToCore.Pmc.Types.Precision instance GHC.Base.Functor GHC.HsToCore.Pmc.Types.CheckResult instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.HsToCore.Pmc.Types.CheckResult a) instance GHC.Utils.Outputable.Outputable GHC.HsToCore.Pmc.Types.RedSets instance GHC.Utils.Outputable.Outputable GHC.HsToCore.Pmc.Types.Precision instance GHC.Base.Semigroup GHC.HsToCore.Pmc.Types.Precision instance GHC.Base.Monoid GHC.HsToCore.Pmc.Types.Precision instance GHC.Utils.Outputable.Outputable p => GHC.Utils.Outputable.Outputable (GHC.HsToCore.Pmc.Types.PmPatBind p) instance GHC.Utils.Outputable.Outputable GHC.HsToCore.Pmc.Types.PmEmptyCase instance GHC.Utils.Outputable.Outputable p => GHC.Utils.Outputable.Outputable (GHC.HsToCore.Pmc.Types.PmMatchGroup p) instance GHC.Utils.Outputable.Outputable p => GHC.Utils.Outputable.Outputable (GHC.HsToCore.Pmc.Types.PmMatch p) instance GHC.Utils.Outputable.Outputable p => GHC.Utils.Outputable.Outputable (GHC.HsToCore.Pmc.Types.PmGRHSs p) instance GHC.Utils.Outputable.Outputable p => GHC.Utils.Outputable.Outputable (GHC.HsToCore.Pmc.Types.PmGRHS p) instance GHC.Utils.Outputable.Outputable GHC.HsToCore.Pmc.Types.GrdVec instance GHC.Utils.Outputable.Outputable GHC.HsToCore.Pmc.Types.PmGrd instance GHC.Utils.Outputable.Outputable GHC.HsToCore.Pmc.Types.SrcInfo -- | Domain types used in GHC.HsToCore.Pmc.Solver. The ultimate goal -- is to define Nabla, which models normalised refinement types -- from the paper Lower Your Guards: A Compositional Pattern-Match -- Coverage Checker". module GHC.HsToCore.Pmc.Solver.Types -- | See vi_bot. data BotInfo IsBot :: BotInfo IsNotBot :: BotInfo MaybeBot :: BotInfo data PmAltConApp PACA :: !PmAltCon -> ![TyVar] -> ![Id] -> PmAltConApp [paca_con] :: PmAltConApp -> !PmAltCon [paca_tvs] :: PmAltConApp -> ![TyVar] [paca_ids] :: PmAltConApp -> ![Id] -- | Information about an Id. Stores positive (vi_pos) facts, -- like x ~ Just 42, and negative (vi_neg) facts, like "x -- is not (:)". Also caches the type (vi_ty), the -- ResidualCompleteMatches of a COMPLETE set (vi_rcm). -- -- Subject to Note [The Pos/Neg invariant] in -- GHC.HsToCore.Pmc.Solver. data VarInfo VI :: !Id -> ![PmAltConApp] -> !PmAltConSet -> BotInfo -> !ResidualCompleteMatches -> VarInfo -- | The Id in question. Important for adding new constraints -- relative to this VarInfo when we don't easily have the -- Id available. [vi_id] :: VarInfo -> !Id -- | Positive info: PmAltCon apps it is (i.e. x ~ [Just y, -- PatSyn z]), all at the same time (i.e. conjunctive). We need a -- list because of nested pattern matches involving pattern synonym case -- x of { Just y -> case x of PatSyn z -> ... } However, no more -- than one RealDataCon in the list, otherwise contradiction because of -- generativity. [vi_pos] :: VarInfo -> ![PmAltConApp] -- | Negative info: A list of PmAltCons that it cannot match. -- Example, assuming -- --
-- data T = Leaf Int | Branch T T | Node Int T ---- -- then x ≁ [Leaf, Node] means that x cannot match a -- Leaf or Node, and hence can only match -- Branch. Is orthogonal to anything from vi_pos, in the -- sense that eqPmAltCon returns PossiblyOverlap for any -- pairing between vi_pos and vi_neg. [vi_neg] :: VarInfo -> !PmAltConSet -- | Can this variable be ⊥? Models (mutually contradicting) x ~ ⊥ -- and x ≁ ⊥ constraints. E.g. * MaybeBot: Don't know; -- Neither x ~ ⊥ nor x ≁ ⊥. * IsBot: x ~ -- ⊥ * IsNotBot: x ≁ ⊥ [vi_bot] :: VarInfo -> BotInfo -- | A cache of the associated COMPLETE sets. At any time a superset of -- possible constructors of each COMPLETE set. So, if it's not in here, -- we can't possibly match on it. Complementary to vi_neg. We -- still need it to recognise completion of a COMPLETE set efficiently -- for large enums. [vi_rcm] :: VarInfo -> !ResidualCompleteMatches -- | The term oracle state. Stores VarInfo for encountered -- Ids. These entries are possibly shared when we figure out that -- two variables must be equal, thus represent the same set of values. -- -- See Note [TmState invariants] in GHC.HsToCore.Pmc.Solver. data TmState TmSt :: !UniqSDFM Id VarInfo -> !CoreMap Id -> !DIdSet -> TmState -- | Facts about term variables. Deterministic env, so that we generate -- deterministic error messages. [ts_facts] :: TmState -> !UniqSDFM Id VarInfo -- | An environment for looking up whether we already encountered -- semantically equivalent expressions that we want to represent by the -- same Id representative. [ts_reps] :: TmState -> !CoreMap Id -- | Which VarInfo needs to be checked for inhabitants because of -- new negative constraints (e.g. x ≁ ⊥ or x ≁ K). [ts_dirty] :: TmState -> !DIdSet -- | The type oracle state. An InertSet that we incrementally add -- local type constraints to, together with a sequence number that counts -- the number of times we extended it with new facts. data TyState TySt :: !Int -> !InertSet -> TyState [ty_st_n] :: TyState -> !Int [ty_st_inert] :: TyState -> !InertSet -- | A normalised refinement type ∇ ("nabla"), comprised of an inert set of -- canonical (i.e. mutually compatible) term and type constraints that -- form the refinement type's predicate. data Nabla MkNabla :: !TyState -> !TmState -> Nabla -- | Type oracle; things like a~Int [nabla_ty_st] :: Nabla -> !TyState -- | Term oracle; things like x~Nothing [nabla_tm_st] :: Nabla -> !TmState -- | A disjunctive bag of Nablas, representing a refinement type. newtype Nablas MkNablas :: Bag Nabla -> Nablas initNablas :: Nablas -- | A list of conlikes which represents a complete pattern match. These -- arise from COMPLETE signatures. See also Note [Implementation -- of COMPLETE pragmas]. data CompleteMatch -- | A data type that caches for the VarInfo of x the -- results of querying dsGetCompleteMatches and then striking -- out all occurrences of K for which we already know x ≁ -- K from these sets. -- -- For motivation, see Section 5.3 in Lower Your Guards. See also Note -- [Implementation of COMPLETE pragmas] data ResidualCompleteMatches RCM :: !Maybe CompleteMatch -> !Maybe [CompleteMatch] -> ResidualCompleteMatches -- | The residual set for the vanilla COMPLETE set from the data defn. -- Tracked separately from rcm_pragmas, because it might only be -- known much later (when we have enough type information to see the -- TyCon of the match), or not at all even. Until that happens, it -- is Nothing. [rcm_vanilla] :: ResidualCompleteMatches -> !Maybe CompleteMatch -- | The residual sets for all COMPLETE sets from pragmas that are -- visible when compiling this module. Querying that set with -- dsGetCompleteMatches requires DsM, so we initialise -- it with Nothing until first needed in a DsM context. [rcm_pragmas] :: ResidualCompleteMatches -> !Maybe [CompleteMatch] getRcm :: ResidualCompleteMatches -> [CompleteMatch] isRcmInitialised :: ResidualCompleteMatches -> Bool -- | Literals (simple and overloaded ones) for pattern match checking. -- -- See Note [Undecidable Equality for PmAltCons] data PmLit PmLit :: Type -> PmLitValue -> PmLit [pm_lit_ty] :: PmLit -> Type [pm_lit_val] :: PmLit -> PmLitValue data PmLitValue PmLitInt :: Integer -> PmLitValue PmLitRat :: Rational -> PmLitValue PmLitChar :: Char -> PmLitValue PmLitString :: FastString -> PmLitValue PmLitOverInt :: Int -> Integer -> PmLitValue PmLitOverRat :: Int -> FractionalLit -> PmLitValue PmLitOverString :: FastString -> PmLitValue -- | Represents the head of a match against a ConLike or literal. -- Really similar to AltCon. data PmAltCon PmAltConLike :: ConLike -> PmAltCon PmAltLit :: PmLit -> PmAltCon -- | Type of a PmLit pmLitType :: PmLit -> Type -- | Type of a PmAltCon pmAltConType :: PmAltCon -> [Type] -> Type -- | Is a match on this constructor forcing the match variable? True of -- data constructors, literals and pattern synonyms (#17357), but not of -- newtypes. See Note [Coverage checking Newtype matches] in -- GHC.HsToCore.Pmc.Solver. isPmAltConMatchStrict :: PmAltCon -> Bool pmAltConImplBangs :: PmAltCon -> [HsImplBang] data PmAltConSet emptyPmAltConSet :: PmAltConSet isEmptyPmAltConSet :: PmAltConSet -> Bool -- | Whether there is a PmAltCon in the PmAltConSet that -- compares Equal to the given PmAltCon according to -- eqPmAltCon. elemPmAltConSet :: PmAltCon -> PmAltConSet -> Bool extendPmAltConSet :: PmAltConSet -> PmAltCon -> PmAltConSet pmAltConSetElems :: PmAltConSet -> [PmAltCon] -- | Undecidable semantic equality result. See Note [Undecidable Equality -- for PmAltCons] data PmEquality Equal :: PmEquality Disjoint :: PmEquality PossiblyOverlap :: PmEquality -- | We can't in general decide whether two PmAltCons match the same -- set of values. In addition to the reasons in eqPmLit and -- eqConLike, a PmAltConLike might or might not represent -- the same value as a PmAltLit. See Note [Undecidable Equality -- for PmAltCons]. -- --
-- f x y | x == y = 1 -- match on x and y with two guarded RHSs -- | otherwise = 2 -- f _ _ = 3 -- clause with a single, un-guarded RHS ---- -- Returns one non-empty Nablas for 1.) each pattern of a -- Match and 2.) each of a Matches GRHS for Note -- [Long-distance information]. -- -- Special case: When there are no matches, then the -- functionassumes it checks and -XEmptyCase with only a single -- match variable. See Note [Checking EmptyCase]. pmcMatches :: DsMatchContext -> [Id] -> [LMatch GhcTc (LHsExpr GhcTc)] -> DsM [(Nablas, NonEmpty Nablas)] -- | Exhaustive for guard matches, is used for guards in pattern bindings -- and in MultiIf expressions. Returns the Nablas covered -- by the RHSs. pmcGRHSs :: HsMatchContext GhcRn -> GRHSs GhcTc (LHsExpr GhcTc) -> DsM (NonEmpty Nablas) -- | Check whether any part of pattern match checking is enabled for this -- HsMatchContext (does not matter whether it is the redundancy -- check or the exhaustiveness check). isMatchContextPmChecked :: DynFlags -> Origin -> HsMatchContext id -> Bool -- | Add in-scope type constraints if the coverage checker might run and -- then run the given action. addTyCs :: Origin -> Bag EvVar -> DsM a -> DsM a -- | Add equalities for the CoreExpr scrutinee to the local -- DsM environment when checking a case expression: case e of x { -- matches } When checking matches we record that (x ~ e) where x is the -- initial uncovered. All matches will have to satisfy this equality. addCoreScrutTmCs :: Maybe CoreExpr -> [Id] -> DsM a -> DsM a -- | addCoreScrutTmCs, but desugars the LHsExpr first. addHsScrutTmCs :: Maybe (LHsExpr GhcTc) -> [Id] -> DsM a -> DsM a instance GHC.Base.Semigroup GHC.HsToCore.Pmc.CIRB instance GHC.Base.Monoid GHC.HsToCore.Pmc.CIRB -- | Utility module for the pattern-match coverage checker. module GHC.HsToCore.Pmc.Utils tracePm :: String -> SDoc -> DsM () -- | Generate a fresh Id of a given type mkPmId :: Type -> DsM Id -- | All warning flags that need to run the pattern match checker. allPmCheckWarnings :: [WarningFlag] -- | Check whether the redundancy checker should run (redundancy only) overlapping :: DynFlags -> HsMatchContext id -> Bool -- | Check whether the exhaustiveness checker should run (exhaustiveness -- only) exhaustive :: DynFlags -> HsMatchContext id -> Bool -- | Check whether unnecessary bangs should be warned about redundantBang :: DynFlags -> Bool -- | Denotes whether an exhaustiveness check is supported, and if so, via -- which WarningFlag it's controlled. Returns Nothing if -- check is not supported. exhaustiveWarningFlag :: HsMatchContext id -> Maybe WarningFlag -- | Check whether any part of pattern match checking is enabled for this -- HsMatchContext (does not matter whether it is the redundancy -- check or the exhaustiveness check). isMatchContextPmChecked :: DynFlags -> Origin -> HsMatchContext id -> Bool -- | Return True when any of the pattern match warnings -- (allPmCheckWarnings) are enabled, in which case we need to run -- the pattern match checker. needToRunPmCheck :: DynFlags -> Origin -> Bool -- | Model refinements type as per the Lower Your Guards paper. The -- main export of the module are the functions addPhiCtsNablas for -- adding facts to the oracle, isInhabited to check if a -- refinement type is inhabited and generateInhabitingPatterns to -- turn a Nabla into a concrete pattern for an equation. -- -- In terms of the LYG paper, this module is concerned with Sections 3.4, -- 3.6 and 3.7. E.g., it represents refinement types directly as a bunch -- of normalised refinement types Nabla. module GHC.HsToCore.Pmc.Solver -- | A normalised refinement type ∇ ("nabla"), comprised of an inert set of -- canonical (i.e. mutually compatible) term and type constraints that -- form the refinement type's predicate. data Nabla -- | A disjunctive bag of Nablas, representing a refinement type. newtype Nablas MkNablas :: Bag Nabla -> Nablas initNablas :: Nablas lookupRefuts :: Nabla -> Id -> [PmAltCon] lookupSolution :: Nabla -> Id -> Maybe PmAltConApp -- | A high-level pattern-match constraint. Corresponds to φ from Figure 3 -- of the LYG paper. data PhiCt -- | A type constraint "T ~ U". PhiTyCt :: !PredType -> PhiCt -- | PhiCoreCt x e encodes "x ~ e", equating x with the -- CoreExpr e. PhiCoreCt :: !Id -> !CoreExpr -> PhiCt -- | PhiConCt x K tvs dicts ys encodes K @tvs dicts ys <- -- x, matching x against the PmAltCon application -- K @tvs dicts ys, binding tvs, dicts and -- possibly unlifted fields ys in the process. See Note [Strict -- fields and variables of unlifted type]. PhiConCt :: !Id -> !PmAltCon -> ![TyVar] -> ![PredType] -> ![Id] -> PhiCt -- | PhiNotConCt x K encodes "x ≁ K", asserting that x -- can't be headed by K. PhiNotConCt :: !Id -> !PmAltCon -> PhiCt -- | PhiBotCt x encodes "x ~ ⊥", equating x to ⊥. by -- K. PhiBotCt :: !Id -> PhiCt -- | PhiNotBotCt x y encodes "x ≁ ⊥", asserting that x -- can't be ⊥. PhiNotBotCt :: !Id -> PhiCt type PhiCts = Bag PhiCt -- | addPmCtsNablas for a single PmCt. addPhiCtNablas :: Nablas -> PhiCt -> DsM Nablas -- | Add a bunch of PhiCts to all the Nablas. Lifts -- addPhiCts over many Nablas. addPhiCtsNablas :: Nablas -> PhiCts -> DsM Nablas -- | Test if any of the Nablas is inhabited. Currently this is pure, -- because we preserve the invariant that there are no uninhabited -- Nablas. But that could change in the future, for example by -- implementing this function in terms of notNull $ -- generateInhabitingPatterns 1 ds. isInhabited :: Nablas -> DsM Bool -- | generateInhabitingPatterns vs n nabla returns a list of at -- most n (but perhaps empty) refinements of nabla that -- represent inhabited patterns. Negative information is only retained if -- literals are involved or for recursive GADTs. generateInhabitingPatterns :: [Id] -> Int -> Nabla -> DsM [Nabla] instance GHC.Utils.Outputable.Outputable GHC.HsToCore.Pmc.Solver.PhiCt instance GHC.Utils.Outputable.Outputable GHC.HsToCore.Pmc.Solver.TopNormaliseTypeResult -- | Provides factilities for pretty-printing Nablas in a way -- appropriate for user facing pattern match warnings. module GHC.HsToCore.Pmc.Ppr -- | Pretty-print the guts of an uncovered value vector abstraction, i.e., -- its components and refutable shapes associated to any mentioned -- variables. -- -- Example for ([Just p, q], [p :-> [3,4], q :-> [0,5]]): -- --
-- (Just p) q
-- where p is not one of {3, 4}
-- q is not one of {0, 5}
--
--
-- When the set of refutable shapes contains more than 3 elements, the
-- additional elements are indicated by "...".
pprUncovered :: Nabla -> [Id] -> SDoc
-- | Desugaring step of the Lower Your Guards paper.
--
-- Desugars Haskell source syntax into guard tree variants Pm*. In terms
-- of the paper, this module is concerned with Sections 3.1, Figure 4, in
-- particular.
module GHC.HsToCore.Pmc.Desugar
desugarPatBind :: SrcSpan -> Id -> Pat GhcTc -> DsM (PmPatBind Pre)
desugarGRHSs :: SrcSpan -> SDoc -> GRHSs GhcTc (LHsExpr GhcTc) -> DsM (PmGRHSs Pre)
-- | Desugar the non-empty Matches of a MatchGroup.
desugarMatches :: [Id] -> NonEmpty (LMatch GhcTc (LHsExpr GhcTc)) -> DsM (PmMatchGroup Pre)
desugarEmptyCase :: Id -> DsM PmEmptyCase
module GHC.HsToCore.Match.Literal
dsLit :: HsLit GhcRn -> DsM CoreExpr
-- | Post-typechecker, the HsExpr field of an OverLit
-- contains (an expression for) the literal value itself.
dsOverLit :: HsOverLit GhcTc -> DsM CoreExpr
hsLitKey :: Platform -> HsLit GhcTc -> Literal
tidyLitPat :: HsLit GhcTc -> Pat GhcTc
tidyNPat :: HsOverLit GhcTc -> Maybe (SyntaxExpr GhcTc) -> SyntaxExpr GhcTc -> Type -> Pat GhcTc
matchLiterals :: NonEmpty Id -> Type -> NonEmpty (NonEmpty EquationInfo) -> DsM (MatchResult CoreExpr)
matchNPlusKPats :: NonEmpty Id -> Type -> NonEmpty EquationInfo -> DsM (MatchResult CoreExpr)
matchNPats :: NonEmpty Id -> Type -> NonEmpty EquationInfo -> DsM (MatchResult CoreExpr)
warnAboutIdentities :: DynFlags -> Id -> Type -> DsM ()
-- | Emit warnings on overloaded integral literals which overflow the
-- bounds implied by their type.
warnAboutOverflowedOverLit :: HsOverLit GhcTc -> DsM ()
-- | Emit warnings on integral literals which overflow the bounds implied
-- by their type.
warnAboutOverflowedLit :: HsLit GhcTc -> DsM ()
-- | Warns about [2,3 .. 1] or [b .. a]
-- which return the empty list. For numeric literals, only works for
-- integral types, not floating point.
warnAboutEmptyEnumerations :: FamInstEnvs -> DynFlags -> LHsExpr GhcTc -> Maybe (LHsExpr GhcTc) -> LHsExpr GhcTc -> DsM ()
module GHC.HsToCore.Binds
-- | Desugar top level binds, strict binds are treated like normal binds
-- since there is no good time to force before first usage.
dsTopLHsBinds :: LHsBinds GhcTc -> DsM (OrdList (Id, CoreExpr))
-- | Desugar all other kind of bindings, Ids of strict binds are returned
-- to later be forced in the binding group body, see Note [Desugar Strict
-- binds]
dsLHsBinds :: LHsBinds GhcTc -> DsM ([Id], [(Id, CoreExpr)])
decomposeRuleLhs :: DynFlags -> [Var] -> CoreExpr -> Either SDoc ([Var], Id, [CoreExpr])
dsSpec :: Maybe CoreExpr -> Located TcSpecPrag -> DsM (Maybe (OrdList (Id, CoreExpr), CoreRule))
dsHsWrapper :: HsWrapper -> DsM (CoreExpr -> CoreExpr)
dsEvTerm :: EvTerm -> DsM CoreExpr
dsTcEvBinds :: TcEvBinds -> DsM [CoreBind]
dsTcEvBinds_s :: [TcEvBinds] -> DsM [CoreBind]
dsEvBinds :: Bag EvBind -> DsM [CoreBind]
dsMkUserRule :: Module -> Bool -> RuleName -> Activation -> Name -> [CoreBndr] -> [CoreExpr] -> CoreExpr -> DsM CoreRule
module GHC.HsToCore.GuardedRHSs
dsGuarded :: GRHSs GhcTc (LHsExpr GhcTc) -> Type -> NonEmpty Nablas -> DsM CoreExpr
dsGRHSs :: HsMatchContext GhcRn -> GRHSs GhcTc (LHsExpr GhcTc) -> Type -> NonEmpty Nablas -> DsM (MatchResult CoreExpr)
isTrueLHsExpr :: LHsExpr GhcTc -> Maybe (CoreExpr -> DsM CoreExpr)
-- | Coverage checking step of the Lower Your Guards paper.
--
-- Coverage check guard trees (like PmMatch Pre)
-- to get a CheckResult, containing
--
-- -- GeneralizedNewtypeDeriving --DerivSpecNewtype :: DerivInstTys -> Type -> DerivSpecMechanism -- | Information about the arguments to the class in the derived instance, -- including what type constructor the last argument is headed by. See -- Note [DerivEnv and DerivSpecMechanism]. [dsm_newtype_dit] :: DerivSpecMechanism -> DerivInstTys -- | The newtype rep type. [dsm_newtype_rep_ty] :: DerivSpecMechanism -> Type -- |
-- DeriveAnyClass --DerivSpecAnyClass :: DerivSpecMechanism -- |
-- DerivingVia --DerivSpecVia :: [Type] -> Type -> Type -> DerivSpecMechanism -- | All arguments to the class besides the last one. [dsm_via_cls_tys] :: DerivSpecMechanism -> [Type] -- | The last argument to the class. [dsm_via_inst_ty] :: DerivSpecMechanism -> Type -- | The via type [dsm_via_ty] :: DerivSpecMechanism -> Type -- | Convert a DerivSpecMechanism to its corresponding -- DerivStrategy. derivSpecMechanismToStrategy :: DerivSpecMechanism -> DerivStrategy GhcTc isDerivSpecStock :: DerivSpecMechanism -> Bool isDerivSpecNewtype :: DerivSpecMechanism -> Bool isDerivSpecAnyClass :: DerivSpecMechanism -> Bool isDerivSpecVia :: DerivSpecMechanism -> Bool -- | Whether GHC is processing a deriving clause or a standalone -- deriving declaration. data DerivContext -- | 'InferContext mb_wildcard is either: -- --
-- class Foo a where -- bar :: forall b. Ix b => a -> b -> String -- default bar :: forall y. (Show a, Ix y) => a -> y -> String -- bar x y = show x ++ show (range (y, y)) -- -- baz :: Eq a => a -> a -> Bool -- default baz :: Ord a => a -> a -> Bool -- baz x y = compare x y == EQ -- -- data Quux q = Quux deriving anyclass Foo ---- -- Then it would generate two ThetaOrigins, one for each method: -- --
-- [ ThetaOrigin { to_anyclass_skols = [b]
-- , to_anyclass_metas = [y]
-- , to_anyclass_givens = [Ix b]
-- , to_wanted_origins = [ Show (Quux q), Ix y
-- , (Quux q -> b -> String) ~
-- (Quux q -> y -> String)
-- ] }
-- , ThetaOrigin { to_anyclass_skols = []
-- , to_anyclass_metas = []
-- , to_anyclass_givens = [Eq (Quux q)]
-- , to_wanted_origins = [ Ord (Quux q)
-- , (Quux q -> Quux q -> Bool) ~
-- (Quux q -> Quux q -> Bool)
-- ] }
-- ]
--
--
-- (Note that the type variable q is bound by the data type
-- Quux, and thus it appears in neither to_anyclass_skols
-- nor to_anyclass_metas.)
--
-- See Note [Gathering and simplifying constraints for
-- DeriveAnyClass] in GHC.Tc.Deriv.Infer for an explanation
-- of how to_wanted_origins are determined in
-- DeriveAnyClass, as well as how to_anyclass_skols,
-- to_anyclass_metas, and to_anyclass_givens are used.
data ThetaOrigin
ThetaOrigin :: [TyVar] -> [TyVar] -> ThetaType -> [PredOrigin] -> ThetaOrigin
[to_anyclass_skols] :: ThetaOrigin -> [TyVar]
[to_anyclass_metas] :: ThetaOrigin -> [TyVar]
[to_anyclass_givens] :: ThetaOrigin -> ThetaType
[to_wanted_origins] :: ThetaOrigin -> [PredOrigin]
mkPredOrigin :: CtOrigin -> TypeOrKind -> PredType -> PredOrigin
mkThetaOrigin :: CtOrigin -> TypeOrKind -> [TyVar] -> [TyVar] -> ThetaType -> ThetaType -> ThetaOrigin
mkThetaOriginFromPreds :: [PredOrigin] -> ThetaOrigin
substPredOrigin :: HasCallStack => TCvSubst -> PredOrigin -> PredOrigin
checkOriginativeSideConditions :: DynFlags -> DerivContext -> Class -> [TcType] -> TyCon -> TyCon -> OriginativeDerivStatus
hasStockDeriving :: Class -> Maybe (SrcSpan -> TyCon -> [Type] -> [Type] -> TcM (LHsBinds GhcPs, [LSig GhcPs], BagDerivStuff, [Name]))
canDeriveAnyClass :: DynFlags -> Validity
std_class_via_coercible :: Class -> Bool
non_coercible_class :: Class -> Bool
newDerivClsInst :: ThetaType -> DerivSpec theta -> TcM ClsInst
extendLocalInstEnv :: [ClsInst] -> TcM a -> TcM a
instance GHC.Utils.Outputable.Outputable GHC.Tc.Deriv.Utils.ThetaOrigin
instance GHC.Utils.Outputable.Outputable GHC.Tc.Deriv.Utils.PredOrigin
instance GHC.Utils.Outputable.Outputable GHC.Tc.Deriv.Utils.DerivEnv
instance GHC.Utils.Outputable.Outputable GHC.Tc.Deriv.Utils.DerivContext
instance GHC.Utils.Outputable.Outputable theta => GHC.Utils.Outputable.Outputable (GHC.Tc.Deriv.Utils.DerivSpec theta)
instance GHC.Utils.Outputable.Outputable GHC.Tc.Deriv.Utils.DerivSpecMechanism
instance GHC.Utils.Outputable.Outputable GHC.Tc.Deriv.Utils.DerivInstTys
-- | The deriving code for the Generic class
module GHC.Tc.Deriv.Generics
canDoGenerics :: TyCon -> Validity
canDoGenerics1 :: TyCon -> Validity
data GenericKind
Gen0 :: GenericKind
Gen1 :: GenericKind
gen_Generic_binds :: GenericKind -> TyCon -> [Type] -> TcM (LHsBinds GhcPs, [LSig GhcPs], FamInst)
get_gen1_constrained_tys :: TyVar -> Type -> [Type]
-- | Generating derived instance declarations
--
-- This module is nominally `subordinate' to
-- GHC.Tc.Deriv, which is the `official' interface to
-- deriving-related things.
--
-- This is where we do all the grimy bindings' generation.
module GHC.Tc.Deriv.Generate
type BagDerivStuff = Bag DerivStuff
data DerivStuff
-- | A new, top-level auxiliary binding. Used for deriving Eq,
-- Ord, Enum, Ix, and Data. See Note
-- [Auxiliary binders].
DerivAuxBind :: AuxBindSpec -> DerivStuff
-- | A new type family instance. Used for:
--
-- -- tyConInstArgTys tycon tycon_args ---- -- returns -- --
-- [tycon_arg_{1}, tycon_arg_{2}, ..., tycon_arg_{m}, extra_arg_{m+1}, ..., extra_arg_{n}]
--
--
-- where extra_args are distinct type variables.
--
-- Examples:
--
--
-- static void hs_hpc_init_Main(void) __attribute__((constructor));
-- static void hs_hpc_init_Main(void) {
--
-- static StgWord64 k0[2] = {16252233372134256ULL,7370534374096082ULL};
-- extern StgPtr Main_r2wb_closure;
-- hs_spt_insert(k0, &Main_r2wb_closure);
--
-- static StgWord64 k1[2] = {12545634534567898ULL,5409674567544151ULL};
-- extern StgPtr Main_r2wc_closure;
-- hs_spt_insert(k1, &Main_r2wc_closure);
--
-- }
--
--
-- where the constants are fingerprints produced from the static forms.
--
-- The linker must find the definitions matching the extern StgPtr
-- name declarations. For this to work, the identifiers of
-- static pointers need to be exported. This is done in newLvlVar.
--
-- There is also a finalization function for the time when the module is
-- unloaded.
--
--
-- static void hs_hpc_fini_Main(void) __attribute__((destructor));
-- static void hs_hpc_fini_Main(void) {
--
-- static StgWord64 k0[2] = {16252233372134256ULL,7370534374096082ULL};
-- hs_spt_remove(k0);
--
-- static StgWord64 k1[2] = {12545634534567898ULL,5409674567544151ULL};
-- hs_spt_remove(k1);
--
-- }
--
module GHC.Iface.Tidy.StaticPtrTable
-- | Replaces all bindings of the form
--
-- -- b = /\ ... -> makeStatic location value ---- -- with -- --
-- b = /\ ... -> -- StaticPtr key (StaticPtrInfo "pkg key" "module" location) value ---- -- where a distinct key is generated for each binding. -- -- It also yields the C stub that inserts these bindings into the static -- pointer table. sptCreateStaticBinds :: HscEnv -> Module -> CoreProgram -> IO ([SptEntry], CoreProgram) -- | sptModuleInitCode module fps is a C stub to insert the static -- entries of module into the static pointer table. -- -- fps is a list associating each binding corresponding to a -- static entry with its fingerprint. sptModuleInitCode :: Platform -> Module -> [SptEntry] -> CStub module GHC.Iface.Ext.Binary -- | Read a HieFile from a FilePath. Can use an existing -- NameCache. readHieFile :: NameCacheUpdater -> FilePath -> IO HieFileResult -- | Read a HieFile from a FilePath. Can use an existing -- NameCache. Allows you to specify which versions of hieFile to -- attempt to read. Left case returns the failing header versions. readHieFileWithVersion :: (HieHeader -> Bool) -> NameCacheUpdater -> FilePath -> IO (Either HieHeader HieFileResult) type HieHeader = (Integer, ByteString) -- | Write a HieFile to the given FilePath, with a proper -- header and symbol tables for Names and FastStrings writeHieFile :: FilePath -> HieFile -> IO () -- | Name's get converted into HieName's before being written -- into .hie files. See toHieName and -- fromHieName for logic on how to convert between these two -- types. data HieName ExternalName :: !Module -> !OccName -> !SrcSpan -> HieName LocalName :: !OccName -> !SrcSpan -> HieName KnownKeyName :: !Unique -> HieName toHieName :: Name -> HieName data HieFileResult HieFileResult :: Integer -> ByteString -> HieFile -> HieFileResult [hie_file_result_version] :: HieFileResult -> Integer [hie_file_result_ghc_version] :: HieFileResult -> ByteString [hie_file_result] :: HieFileResult -> HieFile -- | The header for HIE files - Capital ASCII letters "HIE". hieMagic :: [Word8] hieNameOcc :: HieName -> OccName -- | A function that atomically updates the name cache given a modifier -- function. The second result of the modifier function will be the -- result of the IO action. newtype NameCacheUpdater NCU :: (forall c. (NameCache -> (NameCache, c)) -> IO c) -> NameCacheUpdater [updateNameCache] :: NameCacheUpdater -> forall c. (NameCache -> (NameCache, c)) -> IO c module GHC.Iface.Ext.Ast -- | Construct an HieFile from the outputs of the typechecker. mkHieFile :: ModSummary -> TcGblEnv -> RenamedSource -> Hsc HieFile -- | Construct an HieFile from the outputs of the typechecker but -- don't read the source file again from disk. mkHieFileWithSource :: FilePath -> ByteString -> ModSummary -> TcGblEnv -> RenamedSource -> Hsc HieFile getCompressedAsts :: TypecheckedSource -> RenamedSource -> Bag EvBind -> [ClsInst] -> [TyCon] -> DsM (HieASTs TypeIndex, Array TypeIndex HieTypeFlat) enrichHie :: TypecheckedSource -> RenamedSource -> Bag EvBind -> [ClsInst] -> [TyCon] -> DsM (HieASTs Type) instance Data.Data.Data a => Data.Data.Data (GHC.Iface.Ext.Ast.PScoped a) instance (GHC.Iface.Ext.Ast.HiePass p, GHC.Iface.Ext.Ast.AnnoBody p body, GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (body (GHC.Hs.Extension.GhcPass p)))) => GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Expr.MatchGroup (GHC.Hs.Extension.GhcPass p) (GHC.Parser.Annotation.LocatedA (body (GHC.Hs.Extension.GhcPass p)))) instance (GHC.Iface.Ext.Ast.HiePass p, Data.Data.Data (body (GHC.Hs.Extension.GhcPass p)), GHC.Iface.Ext.Ast.AnnoBody p body, GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (body (GHC.Hs.Extension.GhcPass p)))) => GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Expr.Match (GHC.Hs.Extension.GhcPass p) (GHC.Parser.Annotation.LocatedA (body (GHC.Hs.Extension.GhcPass p))))) instance (GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (body (GHC.Hs.Extension.GhcPass p))), GHC.Iface.Ext.Ast.HiePass p, GHC.Iface.Ext.Ast.AnnoBody p body) => GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Expr.GRHSs (GHC.Hs.Extension.GhcPass p) (GHC.Parser.Annotation.LocatedA (body (GHC.Hs.Extension.GhcPass p)))) instance (GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (body (GHC.Hs.Extension.GhcPass p))), GHC.Iface.Ext.Ast.HiePass p, GHC.Iface.Ext.Ast.AnnoBody p body) => GHC.Iface.Ext.Ast.ToHie (GHC.Types.SrcLoc.Located (Language.Haskell.Syntax.Expr.GRHS (GHC.Hs.Extension.GhcPass p) (GHC.Parser.Annotation.LocatedA (body (GHC.Hs.Extension.GhcPass p))))) instance (GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (body (GHC.Hs.Extension.GhcPass p))), GHC.Iface.Ext.Ast.AnnoBody p body, GHC.Iface.Ext.Ast.HiePass p) => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RScoped (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Expr.Stmt (GHC.Hs.Extension.GhcPass p) (GHC.Parser.Annotation.LocatedA (body (GHC.Hs.Extension.GhcPass p)))))) instance (GHC.Iface.Ext.Ast.HasLoc a, GHC.Iface.Ext.Ast.HiePass p) => GHC.Iface.Ext.Ast.HasLoc (Language.Haskell.Syntax.Decls.FamEqn (GHC.Hs.Extension.GhcPass p) a) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.HasType (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Binds.HsBind (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.HasType (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Pat.Pat (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.HasType (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Expr.HsExpr (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass 'GHC.Hs.Extension.Renamed instance GHC.Iface.Ext.Ast.HiePass 'GHC.Hs.Extension.Typechecked instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.BindContext (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Binds.HsBind (GHC.Hs.Extension.GhcPass p)))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Types.SrcLoc.Located (Language.Haskell.Syntax.Binds.PatSynBind (GHC.Hs.Extension.GhcPass p) (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Binds.HsPatSynDir (GHC.Hs.Extension.GhcPass p)) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Expr.HsMatchContext (GHC.Hs.Extension.GhcPass p)) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Expr.HsStmtContext (GHC.Hs.Extension.GhcPass p)) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.PScoped (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Pat.Pat (GHC.Hs.Extension.GhcPass p)))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Expr.HsExpr (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Expr.HsTupArg (GHC.Hs.Extension.GhcPass p)) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RScoped (Language.Haskell.Syntax.Binds.HsLocalBinds (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RScoped (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Binds.IPBind (GHC.Hs.Extension.GhcPass p)))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RScoped (Language.Haskell.Syntax.Binds.HsValBindsLR (GHC.Hs.Extension.GhcPass p) (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RScoped (GHC.Hs.Binds.NHsValBindsLR (GHC.Hs.Extension.GhcPass p))) instance (GHC.Iface.Ext.Ast.ToHie arg, GHC.Iface.Ext.Ast.HasLoc arg, Data.Data.Data arg, GHC.Iface.Ext.Ast.HiePass p) => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RContext (Language.Haskell.Syntax.Pat.HsRecFields (GHC.Hs.Extension.GhcPass p) arg)) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RScoped (Language.Haskell.Syntax.Expr.ApplicativeArg (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Types.SrcLoc.Located (Language.Haskell.Syntax.Expr.HsCmdTop (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Expr.HsCmd (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.SigContext (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Binds.Sig (GHC.Hs.Extension.GhcPass p)))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Expr.HsSplice (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.Context (Language.Haskell.Syntax.Type.FieldOcc (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.PatSynFieldContext (Language.Haskell.Syntax.Binds.RecordPatSynField (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.ToHie Data.Void.Void instance GHC.Iface.Ext.Ast.ToHie a => GHC.Iface.Ext.Ast.ToHie [a] instance GHC.Iface.Ext.Ast.ToHie a => GHC.Iface.Ext.Ast.ToHie (GHC.Data.Bag.Bag a) instance GHC.Iface.Ext.Ast.ToHie a => GHC.Iface.Ext.Ast.ToHie (GHC.Maybe.Maybe a) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.IEContext (GHC.Parser.Annotation.LocatedA GHC.Unit.Module.Name.ModuleName)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.Context (GHC.Types.SrcLoc.Located a)) => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.Context (GHC.Parser.Annotation.LocatedN a)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.Context (GHC.Types.SrcLoc.Located a)) => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.Context (GHC.Parser.Annotation.LocatedA a)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.Context (GHC.Types.SrcLoc.Located GHC.Types.Var.Var)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.Context (GHC.Types.SrcLoc.Located GHC.Types.Name.Name)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.EvBindContext (GHC.Parser.Annotation.LocatedA GHC.Tc.Types.Evidence.TcEvBinds)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA GHC.Tc.Types.Evidence.HsWrapper) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.Context (GHC.Types.SrcLoc.Located Language.Haskell.Syntax.Extension.NoExtField)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.TScoped (Language.Haskell.Syntax.Type.HsPatSigType GHC.Hs.Extension.GhcRn)) instance (GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RFContext (GHC.Types.SrcLoc.Located label)), GHC.Iface.Ext.Ast.ToHie arg, GHC.Iface.Ext.Ast.HasLoc arg, Data.Data.Data arg, Data.Data.Data label) => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RContext (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Pat.HsRecField' label arg))) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RFContext (GHC.Types.SrcLoc.Located (Language.Haskell.Syntax.Type.FieldOcc GHC.Hs.Extension.GhcRn))) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RFContext (GHC.Types.SrcLoc.Located (Language.Haskell.Syntax.Type.FieldOcc GHC.Hs.Extension.GhcTc))) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RFContext (GHC.Types.SrcLoc.Located (Language.Haskell.Syntax.Type.AmbiguousFieldOcc GHC.Hs.Extension.GhcRn))) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RFContext (GHC.Types.SrcLoc.Located (Language.Haskell.Syntax.Type.AmbiguousFieldOcc GHC.Hs.Extension.GhcTc))) instance (GHC.Iface.Ext.Ast.ToHie tyarg, GHC.Iface.Ext.Ast.ToHie arg, GHC.Iface.Ext.Ast.ToHie rec) => GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Type.HsConDetails tyarg arg rec) instance GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Decls.HsConDeclGADTDetails GHC.Hs.Extension.GhcRn) instance GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Decls.TyClGroup GHC.Hs.Extension.GhcRn) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.TyClDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.FamilyDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Decls.FamilyInfo GHC.Hs.Extension.GhcRn) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RScoped (GHC.Types.SrcLoc.Located (Language.Haskell.Syntax.Decls.FamilyResultSig GHC.Hs.Extension.GhcRn))) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.FunDep GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.TScoped (Language.Haskell.Syntax.Decls.FamEqn GHC.Hs.Extension.GhcRn (Language.Haskell.Syntax.Decls.HsDataDefn GHC.Hs.Extension.GhcRn))) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.TScoped (Language.Haskell.Syntax.Decls.FamEqn GHC.Hs.Extension.GhcRn (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Type.HsType GHC.Hs.Extension.GhcRn)))) instance (GHC.Iface.Ext.Ast.ToHie rhs, GHC.Iface.Ext.Ast.HasLoc rhs) => GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Decls.FamEqn GHC.Hs.Extension.GhcRn rhs) instance GHC.Iface.Ext.Ast.ToHie (GHC.Types.SrcLoc.Located (Language.Haskell.Syntax.Decls.InjectivityAnn GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Decls.HsDataDefn GHC.Hs.Extension.GhcRn) instance GHC.Iface.Ext.Ast.ToHie (GHC.Types.SrcLoc.Located [GHC.Types.SrcLoc.Located (Language.Haskell.Syntax.Decls.HsDerivingClause GHC.Hs.Extension.GhcRn)]) instance GHC.Iface.Ext.Ast.ToHie (GHC.Types.SrcLoc.Located (Language.Haskell.Syntax.Decls.HsDerivingClause GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedC (Language.Haskell.Syntax.Decls.DerivClauseTys GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Types.SrcLoc.Located (Language.Haskell.Syntax.Decls.DerivStrategy GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedP GHC.Types.Basic.OverlapMode) instance GHC.Iface.Ext.Ast.ToHie a => GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Type.HsScaled GHC.Hs.Extension.GhcRn a) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.ConDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedL [GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Type.ConDeclField GHC.Hs.Extension.GhcRn)]) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.TScoped (Language.Haskell.Syntax.Type.HsWildCardBndrs GHC.Hs.Extension.GhcRn (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Type.HsSigType GHC.Hs.Extension.GhcRn)))) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.TScoped (Language.Haskell.Syntax.Type.HsWildCardBndrs GHC.Hs.Extension.GhcRn (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Type.HsType GHC.Hs.Extension.GhcRn)))) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.StandaloneKindSig GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Decls.StandaloneKindSig GHC.Hs.Extension.GhcRn) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.TScoped (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Type.HsSigType GHC.Hs.Extension.GhcRn))) instance Data.Data.Data flag => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.TVScoped (Language.Haskell.Syntax.Type.HsOuterTyVarBndrs flag GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Type.HsType GHC.Hs.Extension.GhcRn)) instance (GHC.Iface.Ext.Ast.ToHie tm, GHC.Iface.Ext.Ast.ToHie ty) => GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Type.HsArg tm ty) instance Data.Data.Data flag => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.TVScoped (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Type.HsTyVarBndr flag GHC.Hs.Extension.GhcRn))) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.TScoped (Language.Haskell.Syntax.Type.LHsQTyVars GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedC [GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Type.HsType GHC.Hs.Extension.GhcRn)]) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Type.ConDeclField GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Expr.LHsExpr a) => GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Expr.ArithSeqInfo a) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.SpliceDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Expr.HsBracket a) instance GHC.Iface.Ext.Ast.ToHie GHC.Hs.Expr.PendingRnSplice instance GHC.Iface.Ext.Ast.ToHie GHC.Hs.Expr.PendingTcSplice instance GHC.Iface.Ext.Ast.ToHie (GHC.Data.BooleanFormula.LBooleanFormula (GHC.Parser.Annotation.LocatedN GHC.Types.Name.Name)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Types.SrcLoc.Located Language.Haskell.Syntax.Type.HsIPName) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.RoleAnnotDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.InstDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.ClsInstDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.DataFamInstDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.TyFamInstDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.DerivDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Binds.FixitySig GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.DefaultDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.ForeignDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie Language.Haskell.Syntax.Decls.ForeignImport instance GHC.Iface.Ext.Ast.ToHie Language.Haskell.Syntax.Decls.ForeignExport instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.WarnDecls GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.WarnDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.AnnDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Decls.AnnProvenance GHC.Hs.Extension.GhcRn) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.RuleDecls GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.RuleDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RScoped (GHC.Types.SrcLoc.Located (Language.Haskell.Syntax.Decls.RuleBndr GHC.Hs.Extension.GhcRn))) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (GHC.Hs.ImpExp.ImportDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.IEContext (GHC.Parser.Annotation.LocatedA (GHC.Hs.ImpExp.IE GHC.Hs.Extension.GhcRn))) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.IEContext (GHC.Hs.ImpExp.LIEWrappedName GHC.Types.Name.Name)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.IEContext (GHC.Types.SrcLoc.Located GHC.Types.FieldLabel.FieldLabel)) instance GHC.Iface.Ext.Ast.HasLoc thing => GHC.Iface.Ext.Ast.HasLoc (GHC.Iface.Ext.Ast.PScoped thing) instance GHC.Iface.Ext.Ast.HasLoc (GHC.Types.SrcLoc.Located a) instance GHC.Iface.Ext.Ast.HasLoc (GHC.Parser.Annotation.LocatedA a) instance GHC.Iface.Ext.Ast.HasLoc (GHC.Parser.Annotation.LocatedN a) instance GHC.Iface.Ext.Ast.HasLoc a => GHC.Iface.Ext.Ast.HasLoc [a] instance (GHC.Iface.Ext.Ast.HasLoc tm, GHC.Iface.Ext.Ast.HasLoc ty) => GHC.Iface.Ext.Ast.HasLoc (Language.Haskell.Syntax.Type.HsArg tm ty) instance GHC.Iface.Ext.Ast.HasLoc (Language.Haskell.Syntax.Decls.HsDataDefn GHC.Hs.Extension.GhcRn) instance GHC.Iface.Ext.Ast.ModifyState GHC.Types.Name.Name instance GHC.Iface.Ext.Ast.ModifyState GHC.Types.Var.Id module GHC.HsToCore -- | Main entry point to the desugarer. deSugar :: HscEnv -> ModLocation -> TcGblEnv -> IO (Messages DecoratedSDoc, Maybe ModGuts) deSugarExpr :: HscEnv -> LHsExpr GhcTc -> IO (Messages DecoratedSDoc, Maybe CoreExpr) module GHC.HsToCore.Foreign.Decl dsForeigns :: [LForeignDecl GhcTc] -> DsM (ForeignStubs, OrdList Binding) module GHC.HsToCore.Foreign.Call dsCCall :: CLabelString -> [CoreExpr] -> Safety -> Type -> DsM CoreExpr mkFCall :: DynFlags -> Unique -> ForeignCall -> [CoreExpr] -> Type -> CoreExpr unboxArg :: CoreExpr -> DsM (CoreExpr, CoreExpr -> CoreExpr) boxResult :: Type -> DsM (Type, CoreExpr -> CoreExpr) resultWrapper :: Type -> DsM (Maybe Type, CoreExpr -> CoreExpr) module GHC.CoreToStg.Prep corePrepPgm :: HscEnv -> Module -> ModLocation -> CoreProgram -> [TyCon] -> IO (CoreProgram, Set CostCentre) corePrepExpr :: HscEnv -> CoreExpr -> IO CoreExpr -- | Create a function that converts Bignum literals into their final -- CoreExpr mkConvertNumLiteral :: HscEnv -> IO (LitNumType -> Integer -> Maybe CoreExpr) instance GHC.Utils.Outputable.Outputable GHC.CoreToStg.Prep.Floats instance GHC.Utils.Outputable.Outputable GHC.CoreToStg.Prep.OkToSpec instance GHC.Utils.Outputable.Outputable GHC.CoreToStg.Prep.FloatingBind instance GHC.Utils.Outputable.Outputable GHC.CoreToStg.Prep.ArgInfo -- | This module is not used by GHC itself. Rather, it exports all of the -- functions and types you are likely to need when writing a plugin for -- GHC. So authors of plugins can probably get away simply with saying -- "import GHC.Plugins". -- -- Particularly interesting modules for plugin writers include -- GHC.Core and GHC.Core.Opt.Monad. module GHC.Plugins mkRecFldSelOcc :: String -> OccName mkVarOccFS :: FastString -> OccName occNameString :: OccName -> String -- | Other names in the compiler add additional information to an OccName. -- This class provides a consistent way to access the underlying OccName. class HasOccName name occName :: HasOccName name => name -> OccName -- | Occurrence Name -- -- In this context that means: "classified (i.e. as a type name, value -- name, etc) but not qualified and not yet resolved" data OccName emptyFsEnv :: FastStringEnv a extendFsEnv :: FastStringEnv a -> FastString -> a -> FastStringEnv a lookupFsEnv :: FastStringEnv a -> FastString -> Maybe a mkFsEnv :: [(FastString, a)] -> FastStringEnv a -- | A non-deterministic set of FastStrings. See Note [Deterministic -- UniqFM] in GHC.Types.Unique.DFM for explanation why it's not -- deterministic and why it matters. Use DFastStringEnv if the set -- eventually gets converted into a list or folded over in a way where -- the order changes the generated code. type FastStringEnv a = UniqFM FastString a alterOccEnv :: (Maybe elt -> Maybe elt) -> OccEnv elt -> OccName -> OccEnv elt avoidClashesOccEnv :: TidyOccEnv -> [OccName] -> TidyOccEnv clsName :: NameSpace dataName :: NameSpace delFromOccEnv :: OccEnv a -> OccName -> OccEnv a delListFromOccEnv :: OccEnv a -> [OccName] -> OccEnv a delTidyOccEnvList :: TidyOccEnv -> [FastString] -> TidyOccEnv demoteOccName :: OccName -> Maybe OccName elemOccEnv :: OccName -> OccEnv a -> Bool elemOccSet :: OccName -> OccSet -> Bool emptyOccEnv :: OccEnv a emptyOccSet :: OccSet emptyTidyOccEnv :: TidyOccEnv extendOccEnv :: OccEnv a -> OccName -> a -> OccEnv a extendOccEnvList :: OccEnv a -> [(OccName, a)] -> OccEnv a extendOccEnv_Acc :: (a -> b -> b) -> (a -> b) -> OccEnv b -> OccName -> a -> OccEnv b extendOccEnv_C :: (a -> a -> a) -> OccEnv a -> OccName -> a -> OccEnv a extendOccSet :: OccSet -> OccName -> OccSet extendOccSetList :: OccSet -> [OccName] -> OccSet filterOccEnv :: (elt -> Bool) -> OccEnv elt -> OccEnv elt filterOccSet :: (OccName -> Bool) -> OccSet -> OccSet foldOccEnv :: (a -> b -> b) -> b -> OccEnv a -> b initTidyOccEnv :: [OccName] -> TidyOccEnv intersectOccSet :: OccSet -> OccSet -> OccSet isDataConNameSpace :: NameSpace -> Bool isDataOcc :: OccName -> Bool -- | Test if the OccName is a data constructor that starts with a -- symbol (e.g. :, or []) isDataSymOcc :: OccName -> Bool isDefaultMethodOcc :: OccName -> Bool -- | Test for definitions internally generated by GHC. This predicate is -- used to suppress printing of internal definitions in some debug prints isDerivedOccName :: OccName -> Bool isEmptyOccSet :: OccSet -> Bool -- | Test if the OccName is that for any operator (whether it is a -- data constructor or variable or whatever) isSymOcc :: OccName -> Bool isTcClsNameSpace :: NameSpace -> Bool isTcOcc :: OccName -> Bool isTvNameSpace :: NameSpace -> Bool isTvOcc :: OccName -> Bool -- | Is an OccName one of a Typeable TyCon or -- Module binding? This is needed as these bindings are renamed -- differently. See Note [Grand plan for Typeable] in -- GHC.Tc.Instance.Typeable. isTypeableBindOcc :: OccName -> Bool isValNameSpace :: NameSpace -> Bool -- | Value OccNamess are those that are either in the -- variable or data constructor namespaces isValOcc :: OccName -> Bool isVarNameSpace :: NameSpace -> Bool isVarOcc :: OccName -> Bool lookupOccEnv :: OccEnv a -> OccName -> Maybe a mapOccEnv :: (a -> b) -> OccEnv a -> OccEnv b minusOccSet :: OccSet -> OccSet -> OccSet mkBuilderOcc :: OccName -> OccName mkClassDataConOcc :: OccName -> OccName mkClassOpAuxOcc :: OccName -> OccName mkClsOcc :: String -> OccName mkClsOccFS :: FastString -> OccName mkCon2TagOcc :: OccName -> OccName mkDFunOcc :: String -> Bool -> OccSet -> OccName mkDataCOcc :: OccName -> OccName mkDataConWorkerOcc :: OccName -> OccName mkDataConWrapperOcc :: OccName -> OccName mkDataOcc :: String -> OccName mkDataOccFS :: FastString -> OccName mkDataTOcc :: OccName -> OccName mkDefaultMethodOcc :: OccName -> OccName mkDictOcc :: OccName -> OccName mkEqPredCoOcc :: OccName -> OccName mkForeignExportOcc :: OccName -> OccName mkGen1R :: OccName -> OccName mkGenR :: OccName -> OccName mkIPOcc :: OccName -> OccName mkInstTyCoOcc :: OccName -> OccName -- | Derive a name for the representation type constructor of a -- data/newtype instance. mkInstTyTcOcc :: String -> OccSet -> OccName mkLocalOcc :: Unique -> OccName -> OccName mkMatcherOcc :: OccName -> OccName mkMaxTagOcc :: OccName -> OccName mkMethodOcc :: OccName -> OccName mkNewTyCoOcc :: OccName -> OccName mkOccEnv :: [(OccName, a)] -> OccEnv a mkOccEnv_C :: (a -> a -> a) -> [(OccName, a)] -> OccEnv a mkOccName :: NameSpace -> String -> OccName mkOccNameFS :: NameSpace -> FastString -> OccName mkOccSet :: [OccName] -> OccSet mkRepEqOcc :: OccName -> OccName mkSpecOcc :: OccName -> OccName mkSuperDictAuxOcc :: Int -> OccName -> OccName mkSuperDictSelOcc :: Int -> OccName -> OccName mkTag2ConOcc :: OccName -> OccName mkTcOcc :: String -> OccName mkTcOccFS :: FastString -> OccName mkTyConRepOcc :: OccName -> OccName mkTyVarOcc :: String -> OccName mkTyVarOccFS :: FastString -> OccName mkVarOcc :: String -> OccName mkWorkerOcc :: OccName -> OccName nameSpacesRelated :: NameSpace -> NameSpace -> Bool occEnvElts :: OccEnv a -> [a] -- | Wrap parens around an operator parenSymOcc :: OccName -> SDoc -> SDoc plusOccEnv :: OccEnv a -> OccEnv a -> OccEnv a plusOccEnv_C :: (a -> a -> a) -> OccEnv a -> OccEnv a -> OccEnv a pprNameSpace :: NameSpace -> SDoc pprNameSpaceBrief :: NameSpace -> SDoc pprNonVarNameSpace :: NameSpace -> SDoc pprOccEnv :: (a -> SDoc) -> OccEnv a -> SDoc pprOccName :: OccName -> SDoc promoteOccName :: OccName -> Maybe OccName setOccNameSpace :: NameSpace -> OccName -> OccName srcDataName :: NameSpace -- | Haskell 98 encourages compilers to suppress warnings about unused -- names in a pattern if they start with _: this implements that -- test startsWithUnderscore :: OccName -> Bool tcClsName :: NameSpace tcName :: NameSpace tidyOccName :: TidyOccEnv -> OccName -> (TidyOccEnv, OccName) tvName :: NameSpace unionManyOccSets :: [OccSet] -> OccSet unionOccSets :: OccSet -> OccSet -> OccSet unitOccEnv :: OccName -> a -> OccEnv a unitOccSet :: OccName -> OccSet data NameSpace data OccEnv a type OccSet = UniqSet OccName type TidyOccEnv = UniqFM FastString Int mkRecFldSelOcc :: String -> OccName mkVarOccFS :: FastString -> OccName occNameString :: OccName -> String -- | Other names in the compiler add additional information to an OccName. -- This class provides a consistent way to access the underlying OccName. class HasOccName name occName :: HasOccName name => name -> OccName -- | Occurrence Name -- -- In this context that means: "classified (i.e. as a type name, value -- name, etc) but not qualified and not yet resolved" data OccName emptyFsEnv :: FastStringEnv a extendFsEnv :: FastStringEnv a -> FastString -> a -> FastStringEnv a lookupFsEnv :: FastStringEnv a -> FastString -> Maybe a mkFsEnv :: [(FastString, a)] -> FastStringEnv a -- | A non-deterministic set of FastStrings. See Note [Deterministic -- UniqFM] in GHC.Types.Unique.DFM for explanation why it's not -- deterministic and why it matters. Use DFastStringEnv if the set -- eventually gets converted into a list or folded over in a way where -- the order changes the generated code. type FastStringEnv a = UniqFM FastString a nameOccName :: Name -> OccName nameUnique :: Name -> Unique setNameUnique :: Name -> Unique -> Name tidyNameOcc :: Name -> OccName -> Name -- | A unique, unambiguous name for something, containing information about -- where that thing originated. data Name -- | A class allowing convenient access to the Name of various -- datatypes class NamedThing a getOccName :: NamedThing a => a -> OccName getName :: NamedThing a => a -> Name alterOccEnv :: (Maybe elt -> Maybe elt) -> OccEnv elt -> OccName -> OccEnv elt avoidClashesOccEnv :: TidyOccEnv -> [OccName] -> TidyOccEnv clsName :: NameSpace dataName :: NameSpace delFromOccEnv :: OccEnv a -> OccName -> OccEnv a delListFromOccEnv :: OccEnv a -> [OccName] -> OccEnv a delTidyOccEnvList :: TidyOccEnv -> [FastString] -> TidyOccEnv demoteOccName :: OccName -> Maybe OccName elemOccEnv :: OccName -> OccEnv a -> Bool elemOccSet :: OccName -> OccSet -> Bool emptyOccEnv :: OccEnv a emptyOccSet :: OccSet emptyTidyOccEnv :: TidyOccEnv extendOccEnv :: OccEnv a -> OccName -> a -> OccEnv a extendOccEnvList :: OccEnv a -> [(OccName, a)] -> OccEnv a extendOccEnv_Acc :: (a -> b -> b) -> (a -> b) -> OccEnv b -> OccName -> a -> OccEnv b extendOccEnv_C :: (a -> a -> a) -> OccEnv a -> OccName -> a -> OccEnv a extendOccSet :: OccSet -> OccName -> OccSet extendOccSetList :: OccSet -> [OccName] -> OccSet filterOccEnv :: (elt -> Bool) -> OccEnv elt -> OccEnv elt filterOccSet :: (OccName -> Bool) -> OccSet -> OccSet foldOccEnv :: (a -> b -> b) -> b -> OccEnv a -> b initTidyOccEnv :: [OccName] -> TidyOccEnv intersectOccSet :: OccSet -> OccSet -> OccSet isDataConNameSpace :: NameSpace -> Bool isDataOcc :: OccName -> Bool -- | Test if the OccName is a data constructor that starts with a -- symbol (e.g. :, or []) isDataSymOcc :: OccName -> Bool isDefaultMethodOcc :: OccName -> Bool -- | Test for definitions internally generated by GHC. This predicate is -- used to suppress printing of internal definitions in some debug prints isDerivedOccName :: OccName -> Bool isEmptyOccSet :: OccSet -> Bool -- | Test if the OccName is that for any operator (whether it is a -- data constructor or variable or whatever) isSymOcc :: OccName -> Bool isTcClsNameSpace :: NameSpace -> Bool isTcOcc :: OccName -> Bool isTvNameSpace :: NameSpace -> Bool isTvOcc :: OccName -> Bool -- | Is an OccName one of a Typeable TyCon or -- Module binding? This is needed as these bindings are renamed -- differently. See Note [Grand plan for Typeable] in -- GHC.Tc.Instance.Typeable. isTypeableBindOcc :: OccName -> Bool isValNameSpace :: NameSpace -> Bool -- | Value OccNamess are those that are either in the -- variable or data constructor namespaces isValOcc :: OccName -> Bool isVarNameSpace :: NameSpace -> Bool isVarOcc :: OccName -> Bool lookupOccEnv :: OccEnv a -> OccName -> Maybe a mapOccEnv :: (a -> b) -> OccEnv a -> OccEnv b minusOccSet :: OccSet -> OccSet -> OccSet mkBuilderOcc :: OccName -> OccName mkClassDataConOcc :: OccName -> OccName mkClassOpAuxOcc :: OccName -> OccName mkClsOcc :: String -> OccName mkClsOccFS :: FastString -> OccName mkCon2TagOcc :: OccName -> OccName mkDFunOcc :: String -> Bool -> OccSet -> OccName mkDataCOcc :: OccName -> OccName mkDataConWorkerOcc :: OccName -> OccName mkDataConWrapperOcc :: OccName -> OccName mkDataOcc :: String -> OccName mkDataOccFS :: FastString -> OccName mkDataTOcc :: OccName -> OccName mkDefaultMethodOcc :: OccName -> OccName mkDictOcc :: OccName -> OccName mkEqPredCoOcc :: OccName -> OccName mkForeignExportOcc :: OccName -> OccName mkGen1R :: OccName -> OccName mkGenR :: OccName -> OccName mkIPOcc :: OccName -> OccName mkInstTyCoOcc :: OccName -> OccName -- | Derive a name for the representation type constructor of a -- data/newtype instance. mkInstTyTcOcc :: String -> OccSet -> OccName mkLocalOcc :: Unique -> OccName -> OccName mkMatcherOcc :: OccName -> OccName mkMaxTagOcc :: OccName -> OccName mkMethodOcc :: OccName -> OccName mkNewTyCoOcc :: OccName -> OccName mkOccEnv :: [(OccName, a)] -> OccEnv a mkOccEnv_C :: (a -> a -> a) -> [(OccName, a)] -> OccEnv a mkOccName :: NameSpace -> String -> OccName mkOccNameFS :: NameSpace -> FastString -> OccName mkOccSet :: [OccName] -> OccSet mkRepEqOcc :: OccName -> OccName mkSpecOcc :: OccName -> OccName mkSuperDictAuxOcc :: Int -> OccName -> OccName mkSuperDictSelOcc :: Int -> OccName -> OccName mkTag2ConOcc :: OccName -> OccName mkTcOcc :: String -> OccName mkTcOccFS :: FastString -> OccName mkTyConRepOcc :: OccName -> OccName mkTyVarOcc :: String -> OccName mkTyVarOccFS :: FastString -> OccName mkVarOcc :: String -> OccName mkWorkerOcc :: OccName -> OccName nameSpacesRelated :: NameSpace -> NameSpace -> Bool occEnvElts :: OccEnv a -> [a] -- | Wrap parens around an operator parenSymOcc :: OccName -> SDoc -> SDoc plusOccEnv :: OccEnv a -> OccEnv a -> OccEnv a plusOccEnv_C :: (a -> a -> a) -> OccEnv a -> OccEnv a -> OccEnv a pprNameSpace :: NameSpace -> SDoc pprNameSpaceBrief :: NameSpace -> SDoc pprNonVarNameSpace :: NameSpace -> SDoc pprOccEnv :: (a -> SDoc) -> OccEnv a -> SDoc pprOccName :: OccName -> SDoc promoteOccName :: OccName -> Maybe OccName setOccNameSpace :: NameSpace -> OccName -> OccName srcDataName :: NameSpace -- | Haskell 98 encourages compilers to suppress warnings about unused -- names in a pattern if they start with _: this implements that -- test startsWithUnderscore :: OccName -> Bool tcClsName :: NameSpace tcName :: NameSpace tidyOccName :: TidyOccEnv -> OccName -> (TidyOccEnv, OccName) tvName :: NameSpace unionManyOccSets :: [OccSet] -> OccSet unionOccSets :: OccSet -> OccSet -> OccSet unitOccEnv :: OccName -> a -> OccEnv a unitOccSet :: OccName -> OccSet data NameSpace data OccEnv a type OccSet = UniqSet OccName type TidyOccEnv = UniqFM FastString Int getOccFS :: NamedThing a => a -> FastString getOccString :: NamedThing a => a -> String getSrcLoc :: NamedThing a => a -> SrcLoc getSrcSpan :: NamedThing a => a -> SrcSpan isBuiltInSyntax :: Name -> Bool isDataConName :: Name -> Bool -- | Will the Name come from a dynamically linked package? isDynLinkName :: Platform -> Module -> Name -> Bool isExternalName :: Name -> Bool isHoleName :: Name -> Bool isInternalName :: Name -> Bool isSystemName :: Name -> Bool isTyConName :: Name -> Bool isTyVarName :: Name -> Bool isValName :: Name -> Bool isVarName :: Name -> Bool isWiredIn :: NamedThing thing => thing -> Bool isWiredInName :: Name -> Bool -- | Make the Name into an internal name, regardless of what it was -- to begin with localiseName :: Name -> Name mkClonedInternalName :: Unique -> Name -> Name mkDerivedInternalName :: (OccName -> OccName) -> Unique -> Name -> Name -- | Create a name which definitely originates in the given module mkExternalName :: Unique -> Module -> OccName -> SrcSpan -> Name -- | Make a name for a foreign call mkFCallName :: Unique -> String -> Name -- | Create a name which is (for now at least) local to the current module -- and hence does not need a Module to disambiguate it from other -- Names mkInternalName :: Unique -> OccName -> SrcSpan -> Name mkSysTvName :: Unique -> FastString -> Name -- | Create a name brought into being by the compiler mkSystemName :: Unique -> OccName -> Name mkSystemNameAt :: Unique -> OccName -> SrcSpan -> Name mkSystemVarName :: Unique -> FastString -> Name -- | Create a name which is actually defined by the compiler itself mkWiredInName :: Module -> OccName -> Unique -> TyThing -> BuiltInSyntax -> Name -- | Returns True if the Name comes from some other package: neither this -- package nor the interactive package. nameIsFromExternalPackage :: HomeUnit -> Name -> Bool nameIsHomePackage :: Module -> Name -> Bool nameIsHomePackageImport :: Module -> Name -> Bool -- | Returns True if the name is (a) Internal (b) External but from the -- specified module (c) External but from the interactive -- package -- -- The key idea is that False means: the entity is defined in some other -- module you can find the details (type, fixity, instances) in some -- interface file those details will be stored in the EPT or HPT -- -- True means: the entity is defined in this module or earlier in the -- GHCi session you can find details (type, fixity, instances) in the -- TcGblEnv or TcLclEnv -- -- The isInteractiveModule part is because successive interactions of a -- GHCi session each give rise to a fresh module (Ghci1, Ghci2, etc), but -- they all come from the magic interactive package; and all the -- details are kept in the TcLclEnv, TcGblEnv, NOT in the HPT or EPT. See -- Note [The interactive package] in GHC.Runtime.Context nameIsLocalOrFrom :: Module -> Name -> Bool nameModule :: HasDebugCallStack => Name -> Module nameModule_maybe :: Name -> Maybe Module nameNameSpace :: Name -> NameSpace nameSrcLoc :: Name -> SrcLoc nameSrcSpan :: Name -> SrcSpan -- | Get a string representation of a Name that's unique and stable -- across recompilations. Used for deterministic generation of binds for -- derived instances. eg. -- "$aeson_70dylHtv1FFGeai1IoxcQr$Data.Aeson.Types.Internal$String" nameStableString :: Name -> String pprDefinedAt :: Name -> SDoc pprInfixName :: (Outputable a, NamedThing a) => a -> SDoc pprModulePrefix :: PprStyle -> Module -> OccName -> SDoc pprNameDefnLoc :: Name -> SDoc -- | Print the string of Name unqualifiedly directly. pprNameUnqualified :: Name -> SDoc pprPrefixName :: NamedThing a => a -> SDoc setNameLoc :: Name -> SrcSpan -> Name -- | Compare Names lexicographically This only works for Names that -- originate in the source code or have been tidied. stableNameCmp :: Name -> Name -> Ordering wiredInNameTyThing_maybe :: Name -> Maybe TyThing -- | BuiltInSyntax is for things like (:), [] and tuples, -- which have special syntactic forms. They aren't in scope as such. data BuiltInSyntax BuiltInSyntax :: BuiltInSyntax UserSyntax :: BuiltInSyntax -- | Identifier type Id = Var -- | Variable -- -- Essentially a typed Name, that may also contain some additional -- information about the Var and its use sites. data Var idName :: Id -> Name -- | If it's a local, make it global globaliseId :: Id -> Id idDetails :: Id -> IdDetails idInfo :: HasDebugCallStack => Id -> IdInfo -- | isExportedIdVar means "don't throw this away" isExportedId :: Var -> Bool isGlobalId :: Var -> Bool -- | Is this a value-level (i.e., computationally relevant) -- Varentifier? Satisfies isId = not . isTyVar. isId :: Var -> Bool isLocalId :: Var -> Bool setIdMult :: Id -> Mult -> Id updateIdTypeAndMult :: (Type -> Type) -> Id -> Id updateIdTypeAndMultM :: Monad m => (Type -> m Type) -> Id -> m Id updateIdTypeButNotMult :: (Type -> Type) -> Id -> Id type InId = Id type InVar = Var type JoinId = Id type OutId = Id type OutVar = Var asJoinId :: Id -> JoinArity -> JoinId infixl 1 `asJoinId` asJoinId_maybe :: Id -> Maybe JoinArity -> Id infixl 1 `asJoinId_maybe` clearOneShotLambda :: Id -> Id -- | Returns True of an Id which may not have a binding, -- even though it is defined in this module. hasNoBinding :: Id -> Bool idArity :: Id -> Arity idCafInfo :: Id -> CafInfo infixl 1 `idCafInfo` idCallArity :: Id -> Arity idCoreRules :: Id -> [CoreRule] idCprInfo :: Id -> CprSig -- | Get from either the worker or the wrapper Id to the -- DataCon. Currently used only in the desugarer. -- -- INVARIANT: idDataCon (dataConWrapId d) = d: remember, -- dataConWrapId can return either the wrapper or the worker idDataCon :: Id -> DataCon idDemandInfo :: Id -> Demand idFunRepArity :: Id -> RepArity idHasRules :: Id -> Bool idInlineActivation :: Id -> Activation idInlinePragma :: Id -> InlinePragma idIsFrom :: Module -> Id -> Bool idJoinArity :: JoinId -> JoinArity idLFInfo_maybe :: Id -> Maybe LambdaFormInfo idMult :: Id -> Mult idOccInfo :: Id -> OccInfo idOneShotInfo :: Id -> OneShotInfo idRuleMatchInfo :: Id -> RuleMatchInfo idScaledType :: Id -> Scaled Type idSpecialisation :: Id -> RuleInfo -- | Like idOneShotInfo, but taking the Horrible State Hack in to -- account See Note [The state-transformer hack] in -- GHC.Core.Opt.Arity idStateHackOneShotInfo :: Id -> OneShotInfo -- | Accesses the Id's strictnessInfo. idStrictness :: Id -> StrictSig idType :: Id -> Kind idUnfolding :: Id -> Unfolding idUnique :: Id -> Unique isClassOpId :: Id -> Bool isClassOpId_maybe :: Id -> Maybe Class isConLikeId :: Id -> Bool isDFunId :: Id -> Bool isDataConId_maybe :: Id -> Maybe DataCon isDataConRecordSelector :: Id -> Bool isDataConWorkId :: Id -> Bool isDataConWorkId_maybe :: Id -> Maybe DataCon isDataConWrapId :: Id -> Bool isDataConWrapId_maybe :: Id -> Maybe DataCon isDeadBinder :: Id -> Bool -- | Returns true if an application to n args diverges or throws an -- exception See Note [Dead ends] in GHC.Types.Demand. isDeadEndId :: Var -> Bool isFCallId :: Id -> Bool isFCallId_maybe :: Id -> Maybe ForeignCall -- | isImplicitId tells whether an Ids info is implied by -- other declarations, so we don't need to put its signature in an -- interface file, even if it's mentioned in some other interface -- unfolding. isImplicitId :: Id -> Bool isJoinId :: Var -> Bool isJoinId_maybe :: Var -> Maybe JoinArity isNaughtyRecordSelector :: Id -> Bool isNeverLevPolyId :: Id -> Bool -- | Returns whether the lambda associated with the Id is certainly -- applied at most once This one is the "business end", called -- externally. It works on type variables as well as Ids, returning True -- Its main purpose is to encapsulate the Horrible State Hack See Note -- [The state-transformer hack] in GHC.Core.Opt.Arity isOneShotBndr :: Var -> Bool isPatSynRecordSelector :: Id -> Bool isPrimOpId :: Id -> Bool isPrimOpId_maybe :: Id -> Maybe PrimOp isProbablyOneShotLambda :: Id -> Bool isRecordSelector :: Id -> Bool isStateHackType :: Type -> Bool -- | This predicate says whether the Id has a strict demand placed -- on it or has a type such that it can always be evaluated strictly (i.e -- an unlifted type, as of GHC 7.6). We need to check separately whether -- the Id has a so-called "strict type" because if the demand for -- the given id hasn't been computed yet but id has a -- strict type, we still want isStrictId id to be True. isStrictId :: Id -> Bool localiseId :: Id -> Id maybeModifyIdInfo :: Maybe IdInfo -> Id -> Id -- | Create a local Id that is marked as exported. This prevents -- things attached to it from being removed as dead code. See Note -- [Exported LocalIds] mkExportedLocalId :: IdDetails -> Name -> Type -> Id mkExportedVanillaId :: Name -> Type -> Id -- | For an explanation of global vs. local Ids, see -- GHC.Types.Var.Var#globalvslocal mkGlobalId :: IdDetails -> Name -> Type -> IdInfo -> Id -- | Make a local CoVar mkLocalCoVar :: Name -> Type -> CoVar -- | For an explanation of global vs. local Ids, see -- GHC.Types.Var#globalvslocal mkLocalId :: HasDebugCallStack => Name -> Mult -> Type -> Id -- | Like mkLocalId, but checks the type to see if it should make a -- covar mkLocalIdOrCoVar :: Name -> Mult -> Type -> Id mkLocalIdWithInfo :: HasDebugCallStack => Name -> Mult -> Type -> IdInfo -> Id mkScaledTemplateLocal :: Int -> Scaled Type -> Id -- | Create a system local Id. These are local Ids (see -- Var#globalvslocal) that are created by the compiler out of thin -- air mkSysLocal :: FastString -> Unique -> Mult -> Type -> Id mkSysLocalM :: MonadUnique m => FastString -> Mult -> Type -> m Id -- | Like mkSysLocal, but checks to see if we have a covar type mkSysLocalOrCoVar :: FastString -> Unique -> Mult -> Type -> Id mkSysLocalOrCoVarM :: MonadUnique m => FastString -> Mult -> Type -> m Id -- | Create a template local: a family of system local Ids in -- bijection with Ints, typically used in unfoldings mkTemplateLocal :: Int -> Type -> Id -- | Create a template local for a series of types mkTemplateLocals :: [Type] -> [Id] -- | Create a template local for a series of type, but start from a -- specified template local mkTemplateLocalsNum :: Int -> [Type] -> [Id] -- | Create a user local Id. These are local Ids (see -- GHC.Types.Var#globalvslocal) with a name and location that the -- user might recognize mkUserLocal :: OccName -> Unique -> Mult -> Type -> SrcSpan -> Id -- | Like mkUserLocal, but checks if we have a coercion type mkUserLocalOrCoVar :: OccName -> Unique -> Mult -> Type -> SrcSpan -> Id -- | Make a global Id without any extra information at all mkVanillaGlobal :: Name -> Type -> Id -- | Make a global Id with no global information but some generic -- IdInfo mkVanillaGlobalWithInfo :: Name -> Type -> IdInfo -> Id -- | Workers get local names. CoreTidy will externalise these if -- necessary mkWorkerId :: Unique -> Id -> Type -> Id modifyIdInfo :: HasDebugCallStack => (IdInfo -> IdInfo) -> Id -> Id modifyInlinePragma :: Id -> (InlinePragma -> InlinePragma) -> Id realIdUnfolding :: Id -> Unfolding -- | If the Id is that for a record selector, extract the -- sel_tycon. Panic otherwise. recordSelectorTyCon :: Id -> RecSelParent recordSelectorTyCon_maybe :: Id -> Maybe RecSelParent scaleIdBy :: Mult -> Id -> Id -- | Like scaleIdBy, but skips non-Ids. Useful for scaling a mixed -- list of ids and tyvars. scaleVarBy :: Mult -> Var -> Var setCaseBndrEvald :: StrictnessMark -> Id -> Id setIdArity :: Id -> Arity -> Id infixl 1 `setIdArity` setIdCafInfo :: Id -> CafInfo -> Id setIdCallArity :: Id -> Arity -> Id infixl 1 `setIdCallArity` setIdCprInfo :: Id -> CprSig -> Id infixl 1 `setIdCprInfo` setIdDemandInfo :: Id -> Demand -> Id infixl 1 `setIdDemandInfo` setIdInfo :: Id -> IdInfo -> Id setIdLFInfo :: Id -> LambdaFormInfo -> Id setIdName :: Id -> Name -> Id setIdOccInfo :: Id -> OccInfo -> Id infixl 1 `setIdOccInfo` setIdOneShotInfo :: Id -> OneShotInfo -> Id infixl 1 `setIdOneShotInfo` setIdSpecialisation :: Id -> RuleInfo -> Id infixl 1 `setIdSpecialisation` setIdStrictness :: Id -> StrictSig -> Id infixl 1 `setIdStrictness` -- | Not only does this set the Id Type, it also evaluates -- the type to try and reduce space usage setIdType :: Id -> Type -> Id setIdUnfolding :: Id -> Unfolding -> Id infixl 1 `setIdUnfolding` setIdUnique :: Id -> Unique -> Id setInlineActivation :: Id -> Activation -> Id infixl 1 `setInlineActivation` setInlinePragma :: Id -> InlinePragma -> Id infixl 1 `setInlinePragma` setOneShotLambda :: Id -> Id -- | Should we apply the state hack to values of this Type? stateHackOneShot :: OneShotInfo transferPolyIdInfo :: Id -> [Var] -> Id -> Id typeOneShot :: Type -> OneShotInfo updOneShotInfo :: Id -> OneShotInfo -> Id zapFragileIdInfo :: Id -> Id zapIdDemandInfo :: Id -> Id zapIdOccInfo :: Id -> Id zapIdStrictness :: Id -> Id zapIdTailCallInfo :: Id -> Id zapIdUsageEnvInfo :: Id -> Id zapIdUsageInfo :: Id -> Id zapIdUsedOnceInfo :: Id -> Id zapJoinId :: Id -> Id zapLamIdInfo :: Id -> Id zapStableUnfolding :: Id -> Id -- | A set of variables that are in scope at some point "Secrets of the -- Glasgow Haskell Compiler inliner" Section 3.2 provides the motivation -- for this abstraction. data InScopeSet extendTCvSubst :: TCvSubst -> TyCoVar -> Type -> TCvSubst -- | A substitution of Types for TyVars and Kinds for -- KindVars type TvSubstEnv = TyVarEnv Type cloneBndr :: Subst -> Unique -> Var -> (Subst, Var) cloneBndrs :: Subst -> UniqSupply -> [Var] -> (Subst, [Var]) -- | Very similar to substBndr, but it always allocates a new -- Unique for each variable in its output. It substitutes the -- IdInfo though. cloneIdBndr :: Subst -> UniqSupply -> Id -> (Subst, Id) -- | Applies cloneIdBndr to a number of Ids, accumulating a -- final substitution from left to right cloneIdBndrs :: Subst -> UniqSupply -> [Id] -> (Subst, [Id]) -- | Clone a mutually recursive group of Ids cloneRecIdBndrs :: Subst -> UniqSupply -> [Id] -> (Subst, [Id]) -- | De-shadowing the program is sometimes a useful pre-pass. It can be -- done simply by running over the bindings with an empty substitution, -- because substitution returns a result that has no-shadowing -- guaranteed. -- -- (Actually, within a single type there might still be shadowing, -- because substTy is a no-op for the empty substitution, but -- that's probably OK.) -- --
-- f :: (Eq a) => a -> Int
-- g :: (?x :: Int -> Int) => a -> Int
-- h :: (r\l) => {r} => {l::Int | r}
--
--
-- Here the Eq a and ?x :: Int -> Int and
-- rl are all called "predicates"
type PredType = Type
-- | A shorthand for data with an attached Mult element (the
-- multiplicity).
data Scaled a
-- | A collection of PredTypes
type ThetaType = [PredType]
-- | A TyCoBinder represents an argument to a function. TyCoBinders
-- can be dependent (Named) or nondependent (Anon). They
-- may also be visible or not. See Note [TyCoBinders]
data TyCoBinder
data Type
-- | This function strips off the top layer only of a type synonym
-- application (if any) its underlying representation type. Returns
-- Nothing if there is nothing to look through. This function
-- considers Constraint to be a synonym of Type.
--
-- By being non-recursive and inlined, this case analysis gets
-- efficiently joined onto the case analysis that the caller is already
-- doing
coreView :: Type -> Maybe Type
isCoercionTy :: Type -> Bool
-- | This version considers Constraint to be the same as *. Returns True if
-- the argument is equivalent to Type/Constraint and False otherwise. See
-- Note [Kind Constraint and kind Type]
isLiftedTypeKind :: Kind -> Bool
-- | Is this the type Multiplicity?
isMultiplicityTy :: Type -> Bool
isPredTy :: HasDebugCallStack => Type -> Bool
-- | Is this the type RuntimeRep?
isRuntimeRepTy :: Type -> Bool
-- | Applies a type to another, as in e.g. k a
mkAppTy :: Type -> Type -> Type
-- | Make a CastTy. The Coercion must be nominal. Checks the
-- Coercion for reflexivity, dropping it if it's reflexive. See Note
-- [Respecting definitional equality] in GHC.Core.TyCo.Rep
mkCastTy :: Type -> Coercion -> Type
-- | A key function: builds a TyConApp or FunTy as
-- appropriate to its arguments. Applies its arguments to the constructor
-- from left to right.
mkTyConApp :: TyCon -> [Type] -> Type
-- | Create the plain type constructor type which has been applied to no
-- type arguments at all.
mkTyConTy :: TyCon -> Type
-- | Given a TyCon and a list of argument types, partition the
-- arguments into:
--
--
-- FUN :: forall (m :: Multiplicity) ->
-- forall {rep1 :: RuntimeRep} {rep2 :: RuntimeRep}.
-- TYPE rep1 -> TYPE rep2 -> *
--
--
-- The runtime representations quantification is left inferred. This
-- means they cannot be specified with -XTypeApplications.
--
-- This is a deliberate choice to allow future extensions to the function
-- arrow. To allow visible application a type synonym can be defined:
--
-- -- type Arr :: forall (rep1 :: RuntimeRep) (rep2 :: RuntimeRep). -- TYPE rep1 -> TYPE rep2 -> Type -- type Arr = FUN 'Many --funTyCon :: TyCon pattern Many :: Mult pattern One :: Mult -- | Given a Type and a list of argument types to which the -- Type is applied, determine each argument's visibility -- (Inferred, Specified, or Required). -- -- Most of the time, the arguments will be Required, but not -- always. Consider f :: forall a. a -> Type. In f Type -- Bool, the first argument (Type) is Specified and -- the second argument (Bool) is Required. It is -- precisely this sort of higher-rank situation in which -- appTyArgFlags comes in handy, since f Type Bool would -- be represented in Core using AppTys. (See also #15792). appTyArgFlags :: Type -> [Type] -> [ArgFlag] applyTysX :: [TyVar] -> Type -> [Type] -> Type -- | Extract a relevant type, if there is one. binderRelevantType_maybe :: TyCoBinder -> Maybe Type buildSynTyCon :: Name -> [KnotTied TyConBinder] -> Kind -> [Role] -> KnotTied Type -> TyCon -- | Does this classify a type allowed to have values? Responds True to -- things like *, #, TYPE Lifted, TYPE v, Constraint. -- -- True of any sub-kind of OpenTypeKind classifiesTypeWithValues :: Kind -> Bool -- | Get the type on the LHS of a coercion induced by a type/data family -- instance. coAxNthLHS :: CoAxiom br -> Int -> Type -- | Drops all ForAllTys dropForAlls :: Type -> Type -- | Drops prefix of RuntimeRep constructors in TyConApps. Useful -- for e.g. dropping 'LiftedRep arguments of unboxed tuple TyCon -- applications: -- -- dropRuntimeRepArgs [ 'LiftedRep, 'IntRep , String, Int# ] == [String, -- Int#] dropRuntimeRepArgs :: [Type] -> [Type] -- | Type equality on source types. Does not look through newtypes -- or PredTypes, but it does look through type synonyms. This -- first checks that the kinds of the types are equal and then checks -- whether the types are equal, ignoring casts and coercions. (The kind -- check is a recursive call, but since all kinds have type -- Type, there is no need to check the types of kinds.) See also -- Note [Non-trivial definitional equality] in GHC.Core.TyCo.Rep. eqType :: Type -> Type -> Bool -- | Compare types with respect to a (presumably) non-empty RnEnv2. eqTypeX :: RnEnv2 -> Type -> Type -> Bool -- | Type equality on lists of types, looking through type synonyms but not -- newtypes. eqTypes :: [Type] -> [Type] -> Bool eqVarBndrs :: RnEnv2 -> [Var] -> [Var] -> Maybe RnEnv2 -- | Expand out all type synonyms. Actually, it'd suffice to expand out -- just the ones that discard type variables (e.g. type Funny a = Int) -- But we don't know which those are currently, so we just expand all. -- -- expandTypeSynonyms only expands out type synonyms mentioned in -- the type, not in the kinds of any TyCon or TyVar mentioned in the -- type. -- -- Keep this synchronized with synonymTyConsOfType expandTypeSynonyms :: Type -> Type -- | Given a TyCon and a list of argument types, filter out any -- Inferred arguments. filterOutInferredTypes :: TyCon -> [Type] -> [Type] -- | Given a TyCon and a list of argument types, filter out any -- invisible (i.e., Inferred or Specified) arguments. filterOutInvisibleTypes :: TyCon -> [Type] -> [Type] -- | Just like piResultTys but for a single argument Try not to -- iterate piResultTy, because it's inefficient to substitute one -- variable at a time; instead use 'piResultTys" -- -- Extract the function argument type and panic if that is not possible funArgTy :: Type -> Type -- | Extract the function result type and panic if that is not possible funResultTy :: Type -> Type -- | If the type is a tyvar, possibly under a cast, returns it, along with -- the coercion. Thus, the co is :: kind tv ~N kind ty getCastedTyVar_maybe :: Type -> Maybe (TyVar, CoercionN) -- | Extract the RuntimeRep classifier of a type. For instance, -- getRuntimeRep_maybe Int = LiftedRep. Panics if this is not -- possible. getRuntimeRep :: HasDebugCallStack => Type -> Type -- | Extract the RuntimeRep classifier of a type. For instance, -- getRuntimeRep_maybe Int = LiftedRep. Returns Nothing -- if this is not possible. getRuntimeRep_maybe :: HasDebugCallStack => Type -> Maybe Type -- | Attempts to obtain the type variable underlying a Type, and -- panics with the given message if this is not a type variable type. See -- also getTyVar_maybe getTyVar :: String -> Type -> TyVar -- | Attempts to obtain the type variable underlying a Type getTyVar_maybe :: Type -> Maybe TyVar invisibleTyBndrCount :: Type -> Int irrelevantMult :: Scaled a -> a -- | See Type#type_classification for what an algebraic type is. -- Should only be applied to types, as opposed to e.g. partially -- saturated type constructors isAlgType :: Type -> Bool -- | Does this binder bind a variable that is not erased? Returns -- True for anonymous binders. isAnonTyCoBinder :: TyCoBinder -> Bool isAtomicTy :: Type -> Bool -- | See isBoxedRuntimeRep_maybe. isBoxedRuntimeRep :: Type -> Bool -- | See Type#type_classification for what a boxed type is. Panics -- on levity polymorphic types; See mightBeUnliftedType for a more -- approximate predicate that behaves better in the presence of levity -- polymorphism. isBoxedType :: Type -> Bool -- | Returns True if the kind classifies types which are allocated on the -- GC'd heap and False otherwise. Note that this returns False for -- levity-polymorphic kinds, which may be specialized to a kind that -- classifies AddrRep or even unboxed kinds. isBoxedTypeKind :: Kind -> Bool -- | Is this a char literal? We also look through type synonyms. isCharLitTy :: Type -> Maybe Char -- | Does this type classify a core (unlifted) Coercion? At either role -- nominal or representational (t1 ~# t2) or (t1 ~R# t2) See Note [Types -- for coercions, predicates, and evidence] in GHC.Core.TyCo.Rep isCoVarType :: Type -> Bool isCoercionTy_maybe :: Type -> Maybe Coercion -- | Check whether a type is a data family type isDataFamilyAppType :: Type -> Bool isFamFreeTy :: Type -> Bool -- | Checks whether this is a proper forall (with a named binder) isForAllTy :: Type -> Bool -- | Like isForAllTy, but returns True only if it is a covar binder isForAllTy_co :: Type -> Bool -- | Like isForAllTy, but returns True only if it is a tyvar binder isForAllTy_ty :: Type -> Bool -- | Is this a function? isFunTy :: Type -> Bool -- | Tests whether the given kind (which should look like TYPE x) -- is something other than a constructor tree (that is, constructors at -- every node). E.g. True of TYPE k, TYPE (F Int) False of TYPE -- 'LiftedRep isKindLevPoly :: Kind -> Bool -- | Is this the type Levity? isLevityTy :: Type -> Bool -- | Is a tyvar of type Levity? isLevityVar :: TyVar -> Bool isLiftedLevity :: Type -> Bool isLiftedRuntimeRep :: Type -> Bool -- | Returns Just True if this type is surely lifted, Just False if it is -- surely unlifted, Nothing if we can't be sure (i.e., it is levity -- polymorphic), and panics if the kind does not have the shape TYPE r. isLiftedType_maybe :: HasDebugCallStack => Type -> Maybe Bool -- | isLinear t returns True of a if t is a type -- of (curried) function where at least one argument is linear (or -- otherwise non-unrestricted). We use this function to check whether it -- is safe to eta reduce an Id in CorePrep. It is always safe to return -- True, because True deactivates the optimisation. isLinearType :: Type -> Bool -- | Is this a type literal (symbol, numeric, or char)? isLitTy :: Type -> Maybe TyLit isManyDataConTy :: Mult -> Bool -- | Is a tyvar of type Multiplicity? isMultiplicityVar :: TyVar -> Bool -- | Is this a numeric literal. We also look through type synonyms. isNumLitTy :: Type -> Maybe Integer isOneDataConTy :: Mult -> Bool -- | Is this a function or forall? isPiTy :: Type -> Bool -- | Returns true of types that are opaque to Haskell. isPrimitiveType :: Type -> Bool -- | Is this a type of kind RuntimeRep? (e.g. LiftedRep) isRuntimeRepKindedTy :: Type -> Bool -- | Is a tyvar of type RuntimeRep? isRuntimeRepVar :: TyVar -> Bool -- | Is this a symbol literal. We also look through type synonyms. isStrLitTy :: Type -> Maybe FastString -- | Computes whether an argument (or let right hand side) should be -- computed strictly or lazily, based only on its type. Currently, it's -- just isUnliftedType. Panics on levity-polymorphic types. isStrictType :: HasDebugCallStack => Type -> Bool isTauTy :: Type -> Bool isTyVarTy :: Type -> Bool -- | Returns True if a type is levity polymorphic. Should be the same as -- (isKindLevPoly . typeKind) but much faster. Precondition: The type has -- kind (TYPE blah) isTypeLevPoly :: Type -> Bool isUnboxedSumType :: Type -> Bool isUnboxedTupleType :: Type -> Bool isUnliftedLevity :: Type -> Bool isUnliftedRuntimeRep :: Type -> Bool -- | See Type#type_classification for what an unlifted type is. -- Panics on levity polymorphic types; See mightBeUnliftedType for -- a more approximate predicate that behaves better in the presence of -- levity polymorphism. isUnliftedType :: HasDebugCallStack => Type -> Bool -- | Returns True if the kind classifies unlifted types (like 'Int#') and -- False otherwise. Note that this returns False for levity-polymorphic -- kinds, which may be specialized to a kind that classifies unlifted -- types. isUnliftedTypeKind :: Kind -> Bool -- | Determine whether a type could be the type of a join point of given -- total arity, according to the polymorphism rule. A join point cannot -- be polymorphic in its return type, since given join j a b x y -- z = e1 in e2, the types of e1 and e2 must be the same, and a and b are -- not in scope for e2. (See Note [The polymorphism rule of join points] -- in GHC.Core.) Returns False also if the type simply doesn't -- have enough arguments. -- -- Note that we need to know how many arguments (type *and* value) the -- putative join point takes; for instance, if j :: forall a. a -> Int -- then j could be a binary join point returning an Int, but it could -- *not* be a unary join point returning a -> Int. -- -- TODO: See Note [Excess polymorphism and join points] isValidJoinPointType :: JoinArity -> Type -> Bool -- | Extract the RuntimeRep classifier of a type from its kind. For -- example, kindRep * = LiftedRep; Panics if this is not -- possible. Treats * and Constraint as the same kindRep :: HasDebugCallStack => Kind -> Type -- | Given a kind (TYPE rr), extract its RuntimeRep classifier rr. For -- example, kindRep_maybe * = Just LiftedRep Returns -- Nothing if the kind is not of form (TYPE rr) Treats * and -- Constraint as the same kindRep_maybe :: HasDebugCallStack => Kind -> Maybe Type -- | Scale a payload by One linear :: a -> Scaled a mapTyCo :: Monad m => TyCoMapper () m -> (Type -> m Type, [Type] -> m [Type], Coercion -> m Coercion, [Coercion] -> m [Coercion]) mapTyCoX :: Monad m => TyCoMapper env m -> (env -> Type -> m Type, env -> [Type] -> m [Type], env -> Coercion -> m Coercion, env -> [Coercion] -> m [Coercion]) -- | Returns: -- --
-- data family T a -- data instance T (Maybe b) = MkT b ---- -- Where the instance tycon is :RTL, so: -- --
-- mkFamilyTyConApp :RTL Int = T (Maybe Int) --mkFamilyTyConApp :: TyCon -> [Type] -> Type -- | Like mkTyCoInvForAllTy, but tv should be a tyvar mkInfForAllTy :: TyVar -> Type -> Type -- | Like mkTyCoInvForAllTys, but tvs should be a list of tyvar mkInfForAllTys :: [TyVar] -> Type -> Type mkNumLitTy :: Integer -> Type mkScaled :: Mult -> a -> Scaled a -- | Like mkForAllTy, but assumes the variable is dependent and -- Specified, a common case mkSpecForAllTy :: TyVar -> Type -> Type -- | Like mkForAllTys, but assumes all variables are dependent and -- Specified, a common case mkSpecForAllTys :: [TyVar] -> Type -> Type mkStrLitTy :: FastString -> Type -- | Make a dependent forall over an Inferred variable mkTyCoInvForAllTy :: TyCoVar -> Type -> Type -- | Like mkForAllTys, but assumes all variables are dependent and -- Inferred, a common case mkTyCoInvForAllTys :: [TyCoVar] -> Type -> Type -- | Given a list of type-level vars and the free vars of a result kind, -- makes TyCoBinders, preferring anonymous binders if the variable is, in -- fact, not dependent. e.g. mkTyConBindersPreferAnon -- (k:*),(b:k),(c:k) We want (k:*) Named, (b:k) Anon, (c:k) Anon -- -- All non-coercion binders are visible. mkTyConBindersPreferAnon :: [TyVar] -> TyCoVarSet -> [TyConBinder] -- | Like mkForAllTys, but assumes all variables are dependent and visible mkVisForAllTys :: [TyVar] -> Type -> Type -- | Unwrap one layer of newtype on a type constructor and its -- arguments, using an eta-reduced version of the newtype if -- possible. This requires tys to have at least newTyConInstArity -- tycon elements. newTyConInstRhs :: TyCon -> [Type] -> Type -- | Compare two TyCons. NB: This should never see -- Constraint (as recognized by Kind.isConstraintKindCon) which -- is considered a synonym for Type in Core. See Note [Kind -- Constraint and kind Type] in GHC.Core.Type. See Note -- [nonDetCmpType nondeterminism] nonDetCmpTc :: TyCon -> TyCon -> Ordering nonDetCmpType :: Type -> Type -> Ordering nonDetCmpTypeX :: RnEnv2 -> Type -> Type -> Ordering nonDetCmpTypes :: [Type] -> [Type] -> Ordering nonDetCmpTypesX :: RnEnv2 -> [Type] -> [Type] -> Ordering occCheckExpand :: [Var] -> Type -> Maybe Type -- | Given a list of things paired with their visibilities, partition the -- things into (invisible things, visible things). partitionInvisibles :: [(a, ArgFlag)] -> ([a], [a]) -- | (piResultTys f_ty [ty1, .., tyn]) gives the type of (f ty1 .. tyn) -- where f :: f_ty piResultTys is interesting because: 1. -- f_ty may have more for-alls than there are args 2. Less -- obviously, it may have fewer for-alls For case 2. think of: -- piResultTys (forall a.a) [forall b.b, Int] This really can happen, but -- only (I think) in situations involving undefined. For example: -- undefined :: forall a. a Term: undefined (forall b. b->b) -- Int This term should have type (Int -> Int), but notice that -- there are more type args than foralls in undefineds type. piResultTys :: HasDebugCallStack => Type -> [Type] -> Type pickyIsLiftedTypeKind :: Kind -> Bool -- | Render a type corresponding to a user type error into a SDoc. pprUserTypeErrorTy :: Type -> SDoc -- | Attempts to obtain the type variable underlying a Type, without -- any expansion repGetTyVar_maybe :: Type -> Maybe TyVar -- | Does the AppTy split as in splitAppTy_maybe, but assumes that -- any Core view stuff is already done repSplitAppTy_maybe :: HasDebugCallStack => Type -> Maybe (Type, Type) -- | Like splitAppTys, but doesn't look through type synonyms repSplitAppTys :: HasDebugCallStack => Type -> (Type, [Type]) -- | Like splitTyConApp_maybe, but doesn't look through synonyms. -- This assumes the synonyms have already been dealt with. repSplitTyConApp_maybe :: HasDebugCallStack => Type -> Maybe (TyCon, [Type]) -- | Looking past all pi-types, is the end result potentially levity -- polymorphic? Example: True for (forall r (a :: TYPE r). String -> -- a) Example: False for (forall r1 r2 (a :: TYPE r1) (b :: TYPE r2). a -- -> b -> Type) resultIsLevPoly :: Type -> Bool scaledSet :: Scaled a -> b -> Scaled b seqType :: Type -> () seqTypes :: [Type] -> () -- | Attempts to take a type application apart, as in -- splitAppTy_maybe, and panics if this is not possible splitAppTy :: Type -> (Type, Type) -- | Attempt to take a type application apart, whether it is a function, -- type constructor, or plain type application. Note that type family -- applications are NEVER unsaturated by this! splitAppTy_maybe :: Type -> Maybe (Type, Type) -- | Recursively splits a type as far as is possible, leaving a residual -- type being applied to and the type arguments applied to it. Never -- fails, even if that means returning an empty list of type -- applications. splitAppTys :: Type -> (Type, [Type]) splitCastTy_maybe :: Type -> Maybe (Type, Coercion) -- | Like splitForAllTyCoVar_maybe, but only returns Just if it is a -- covar binder. splitForAllCoVar_maybe :: Type -> Maybe (TyCoVar, Type) -- | Like splitForAllTyCoVars, but only splits ForAllTys with -- Invisible type variable binders. Furthermore, each returned -- tyvar is annotated with its Specificity. splitForAllInvisTVBinders :: Type -> ([InvisTVBinder], Type) -- | Like splitForAllTyCoVars, but only splits ForAllTys with -- Required type variable binders. Furthermore, each returned -- tyvar is annotated with (). splitForAllReqTVBinders :: Type -> ([ReqTVBinder], Type) -- | Take a forall type apart, or panics if that is not possible. splitForAllTyCoVar :: Type -> (TyCoVar, Type) -- | Like splitPiTys but split off only named binders and -- returns TyCoVarBinders rather than TyCoBinders splitForAllTyCoVarBinders :: Type -> ([TyCoVarBinder], Type) -- | Attempts to take a forall type apart, but only if it's a proper -- forall, with a named binder splitForAllTyCoVar_maybe :: Type -> Maybe (TyCoVar, Type) -- | Take a ForAllTy apart, returning the list of tycovars and the result -- type. This always succeeds, even if it returns only an empty list. -- Note that the result type returned may have free variables that were -- bound by a forall. splitForAllTyCoVars :: Type -> ([TyCoVar], Type) -- | Like splitForAllTyCoVar_maybe, but only returns Just if it is a -- tyvar binder. splitForAllTyVar_maybe :: Type -> Maybe (TyCoVar, Type) -- | Attempts to extract the multiplicity, argument and result types from a -- type, and panics if that is not possible. See also -- splitFunTy_maybe splitFunTy :: Type -> (Mult, Type, Type) -- | Attempts to extract the multiplicity, argument and result types from a -- type splitFunTy_maybe :: Type -> Maybe (Mult, Type, Type) splitFunTys :: Type -> ([Scaled Type], Type) -- | Like splitPiTys, but returns only *invisible* binders, -- including constraints. Stops at the first visible binder. splitInvisPiTys :: Type -> ([TyCoBinder], Type) -- | Same as splitInvisPiTys, but stop when - you have found -- n TyCoBinders, - or you run out of invisible binders splitInvisPiTysN :: Int -> Type -> ([TyCoBinder], Type) -- | Attempts to tease a list type apart and gives the type of the elements -- if successful (looks through type synonyms) splitListTyConApp_maybe :: Type -> Maybe Type -- | Takes a forall type apart, or panics splitPiTy :: Type -> (TyCoBinder, Type) -- | Attempts to take a forall type apart; works with proper foralls and -- functions splitPiTy_maybe :: Type -> Maybe (TyCoBinder, Type) -- | Split off all TyCoBinders to a type, splitting both proper foralls and -- functions splitPiTys :: Type -> ([TyCoBinder], Type) -- | Attempts to tease a type apart into a type constructor and the -- application of a number of arguments to that constructor. Panics if -- that is not possible. See also splitTyConApp_maybe splitTyConApp :: Type -> (TyCon, [Type]) -- | Retrieve the free variables in this type, splitting them based on -- whether they are used visibly or invisibly. Invisible ones come first. splitVisVarsOfType :: Type -> Pair TyCoVarSet splitVisVarsOfTypes :: [Type] -> Pair TyCoVarSet stripCoercionTy :: Type -> Coercion -- | Is this kind equivalent to TYPE (BoxedRep l) for some l -- :: Levity? -- -- This considers Constraint to be distinct from Type. -- For a version that treats them as the same type, see -- isLiftedTypeKind. tcIsBoxedTypeKind :: Kind -> Bool tcIsConstraintKind :: Kind -> Bool -- | Is this kind equivalent to Type? -- -- This considers Constraint to be distinct from Type. -- For a version that treats them as the same type, see -- isLiftedTypeKind. tcIsLiftedTypeKind :: Kind -> Bool -- | Is this kind equivalent to TYPE r (for some unknown r)? -- -- This considers Constraint to be distinct from *. tcIsRuntimeTypeKind :: Kind -> Bool -- | Does the AppTy split as in tcSplitAppTy_maybe, but assumes -- that any coreView stuff is already done. Refuses to look through (c -- => t) tcRepSplitAppTy_maybe :: Type -> Maybe (Type, Type) -- | Like tcSplitTyConApp_maybe, but doesn't look through synonyms. -- This assumes the synonyms have already been dealt with. -- -- Moreover, for a FunTy, it only succeeds if the argument types have -- enough info to extract the runtime-rep arguments that the funTyCon -- requires. This will usually be true; but may be temporarily false -- during canonicalization: see Note [Decomposing FunTy] in -- GHC.Tc.Solver.Canonical and Note [The Purely Kinded Type Invariant -- (PKTI)] in GHC.Tc.Gen.HsType, Wrinkle around FunTy tcRepSplitTyConApp_maybe :: HasDebugCallStack => Type -> Maybe (TyCon, [Type]) tcReturnsConstraintKind :: Kind -> Bool -- | Split a type constructor application into its type constructor and -- applied types. Note that this may fail in the case of a FunTy -- with an argument of unknown kind FunTy (e.g. FunTy (a :: k) -- Int. since the kind of a isn't of the form TYPE -- rep). Consequently, you may need to zonk your type before using -- this function. -- -- This does *not* split types headed with (=>), as that's not a TyCon -- in the type-checker. -- -- If you only need the TyCon, consider using -- tcTyConAppTyCon_maybe. tcSplitTyConApp_maybe :: HasCallStack => Type -> Maybe (TyCon, [Type]) tcTypeKind :: HasDebugCallStack => Type -> Kind tyBinderType :: TyBinder -> Type tyCoBinderType :: TyCoBinder -> Type tyCoBinderVar_maybe :: TyCoBinder -> Maybe TyCoVar tyConAppArgN :: Int -> Type -> Type tyConAppArgs :: Type -> [Type] -- | The same as snd . splitTyConApp tyConAppArgs_maybe :: Type -> Maybe [Type] -- | Does a TyCon (that is applied to some number of arguments) need -- to be ascribed with an explicit kind signature to resolve ambiguity if -- rendered as a source-syntax type? (See Note [When does a tycon -- application need an explicit kind signature?] for a full -- explanation of what this function checks for.) tyConAppNeedsKindSig :: Bool -> TyCon -> Int -> Bool tyConAppTyCon :: Type -> TyCon -- | Retrieve the tycon heading this type, if there is one. Does not -- look through synonyms. tyConAppTyConPicky_maybe :: Type -> Maybe TyCon -- | Given a TyCon and a list of argument types to which the -- TyCon is applied, determine each argument's visibility -- (Inferred, Specified, or Required). -- -- Wrinkle: consider the following scenario: -- --
-- T :: forall k. k -> k -- tyConArgFlags T [forall m. m -> m -> m, S, R, Q] ---- -- After substituting, we get -- --
-- T (forall m. m -> m -> m) :: (forall m. m -> m -> m) -> forall n. n -> n -> n ---- -- Thus, the first argument is invisible, S is visible, -- R is invisible again, and Q is visible. tyConArgFlags :: TyCon -> [Type] -> [ArgFlag] tyConBindersTyCoBinders :: [TyConBinder] -> [TyCoBinder] -- | All type constructors occurring in the type; looking through type -- synonyms, but not newtypes. When it finds a Class, it returns the -- class TyCon. tyConsOfType :: Type -> UniqSet TyCon -- | Scale a payload by Many; used for type arguments in core tymult :: a -> Scaled a typeKind :: HasDebugCallStack => Type -> Kind -- | Scale a payload by Many unrestricted :: a -> Scaled a -- | Is this type a custom user error? If so, give us the kind and the -- error message. userTypeError_maybe :: Type -> Maybe Type -- | This describes how a "map" operation over a type/coercion should -- behave data TyCoMapper env m TyCoMapper :: (env -> TyVar -> m Type) -> (env -> CoVar -> m Coercion) -> (env -> CoercionHole -> m Coercion) -> (env -> TyCoVar -> ArgFlag -> m (env, TyCoVar)) -> (TyCon -> m TyCon) -> TyCoMapper env m [tcm_tyvar] :: TyCoMapper env m -> env -> TyVar -> m Type [tcm_covar] :: TyCoMapper env m -> env -> CoVar -> m Coercion -- | What to do with coercion holes. See Note [Coercion holes] in -- GHC.Core.TyCo.Rep. [tcm_hole] :: TyCoMapper env m -> env -> CoercionHole -> m Coercion -- | The returned env is used in the extended scope [tcm_tycobinder] :: TyCoMapper env m -> env -> TyCoVar -> ArgFlag -> m (env, TyCoVar) -- | This is used only for TcTyCons a) To zonk TcTyCons b) To turn TcTyCons -- into TyCons. See Note [Type checking recursive type and class -- declarations] in GHC.Tc.TyCl [tcm_tycon] :: TyCoMapper env m -> TyCon -> m TyCon -- | Type or Coercion Variable type TyCoVar = Id -- | Variable -- -- Essentially a typed Name, that may also contain some additional -- information about the Var and its use sites. data Var pickLR :: LeftOrRight -> (a, a) -> a data LeftOrRight CLeft :: LeftOrRight CRight :: LeftOrRight -- | A Coercion is concrete evidence of the equality/convertibility -- of two types. data Coercion type CoercionN = Coercion -- | A semantically more meaningful type to represent what may or may not -- be a useful Coercion. data MCoercion MRefl :: MCoercion MCo :: Coercion -> MCoercion type MCoercionN = MCoercion -- | For simplicity, we have just one UnivCo that represents a coercion -- from some type to some other type, with (in general) no restrictions -- on the type. The UnivCoProvenance specifies more exactly what the -- coercion really is and why a program should (or shouldn't!) trust the -- coercion. It is reasonable to consider each constructor of -- UnivCoProvenance as a totally independent coercion form; their -- only commonality is that they don't tell you what types they coercion -- between. (That info is in the UnivCo constructor of -- Coercion. data UnivCoProvenance pprCo :: Coercion -> SDoc -- | Is this a coercion variable? Satisfies isId v ==> -- isCoVar v == not (isNonCoVarId v). isCoVar :: Var -> Bool mkCoVar :: Name -> Type -> CoVar -- | Coercion Variable type CoVar = Id data Role Nominal :: Role Representational :: Role Phantom :: Role coVarKindsTypesRole :: HasDebugCallStack => CoVar -> (Kind, Kind, Type, Type, Role) coVarRole :: CoVar -> Role -- | If it is the case that -- --
-- c :: (t1 ~ t2) ---- -- i.e. the kind of c relates t1 and t2, then -- coercionKind c = Pair t1 t2. coercionKind :: Coercion -> Pair Type coercionLKind :: Coercion -> Type coercionRKind :: Coercion -> Type coercionType :: Coercion -> Type decomposePiCos :: HasDebugCallStack => CoercionN -> Pair Type -> [Type] -> ([CoercionN], CoercionN) -- | Tests if this coercion is obviously a generalized reflexive coercion. -- Guaranteed to work very quickly. isGReflCo :: Coercion -> Bool -- | Tests if this coercion is obviously reflexive. Guaranteed to work very -- quickly. Sometimes a coercion can be reflexive, but not obviously so. -- c.f. isReflexiveCo isReflCo :: Coercion -> Bool -- | Slowly checks if the coercion is reflexive. Don't call this in a loop, -- as it walks over the entire coercion. isReflexiveCo :: Coercion -> Bool -- | liftCoSubst role lc ty produces a coercion (at role -- role) that coerces between lc_left(ty) and -- lc_right(ty), where lc_left is a substitution -- mapping type variables to the left-hand types of the mapped coercions -- in lc, and similar for lc_right. liftCoSubst :: HasDebugCallStack => Role -> LiftingContext -> Type -> Coercion -- | Apply a Coercion to another Coercion. The second -- coercion must be Nominal, unless the first is Phantom. If the first is -- Phantom, then the second can be either Phantom or Nominal. mkAppCo :: Coercion -> Coercion -> Coercion mkAxiomInstCo :: CoAxiom Branched -> BranchIndex -> [Coercion] -> Coercion mkAxiomRuleCo :: CoAxiomRule -> [Coercion] -> Coercion mkCoVarCo :: CoVar -> Coercion -- | Makes a coercion type from two types: the types whose equality is -- proven by the relevant Coercion mkCoercionType :: Role -> Type -> Type -> Type -- | Make a Coercion from a tycovar, a kind coercion, and a body coercion. -- The kind of the tycovar should be the left-hand kind of the kind -- coercion. See Note [Unused coercion variable in ForAllCo] mkForAllCo :: TyCoVar -> CoercionN -> Coercion -> Coercion -- | Build a function Coercion from two other Coercions. That -- is, given co1 :: a ~ b and co2 :: x ~ y produce -- co :: (a -> x) ~ (b -> y). mkFunCo :: Role -> CoercionN -> Coercion -> Coercion -> Coercion -- | Make a generalized reflexive coercion mkGReflCo :: Role -> Type -> MCoercionN -> Coercion -- | Instantiates a Coercion. mkInstCo :: Coercion -> Coercion -> Coercion -- | Given co :: (a :: k) ~ (b :: k') produce co' :: k ~ -- k'. mkKindCo :: Coercion -> Coercion mkLRCo :: LeftOrRight -> Coercion -> Coercion -- | Make a nominal reflexive coercion mkNomReflCo :: Type -> Coercion mkNthCo :: HasDebugCallStack => Role -> Int -> Coercion -> Coercion -- | Make a phantom coercion between two types. The coercion passed in must -- be a nominal coercion between the kinds of the types. mkPhantomCo :: Coercion -> Type -> Type -> Coercion -- | Make a "coercion between coercions". mkProofIrrelCo :: Role -> Coercion -> Coercion -> Coercion -> Coercion -- | Make a reflexive coercion mkReflCo :: Role -> Type -> Coercion mkSubCo :: HasDebugCallStack => Coercion -> Coercion -- | Create a symmetric version of the given Coercion that asserts -- equality between the same types but in the other "direction", so a -- kind of t1 ~ t2 becomes the kind t2 ~ t1. mkSymCo :: Coercion -> Coercion -- | Create a new Coercion by composing the two given -- Coercions transitively. (co1 ; co2) mkTransCo :: Coercion -> Coercion -> Coercion -- | Apply a type constructor to a list of coercions. It is the caller's -- responsibility to get the roles correct on argument coercions. mkTyConAppCo :: HasDebugCallStack => Role -> TyCon -> [Coercion] -> Coercion -- | Make a universal coercion between two arbitrary types. mkUnivCo :: UnivCoProvenance -> Role -> Type -> Type -> Coercion seqCo :: Coercion -> () data LiftingContext LC :: TCvSubst -> LiftCoEnv -> LiftingContext coHoleCoVar :: CoercionHole -> CoVar coercionSize :: Coercion -> Int setCoHoleCoVar :: CoercionHole -> CoVar -> CoercionHole -- | A coercion to be filled in by the type-checker. See Note [Coercion -- holes] data CoercionHole CoercionHole :: CoVar -> IORef (Maybe Coercion) -> CoercionHole [ch_co_var] :: CoercionHole -> CoVar [ch_ref] :: CoercionHole -> IORef (Maybe Coercion) type CoercionP = Coercion type CoercionR = Coercion type MCoercionR = MCoercion anyFreeVarsOfCo :: (TyCoVar -> Bool) -> Coercion -> Bool coVarsOfCo :: Coercion -> CoVarSet tyCoFVsOfCo :: Coercion -> FV tyCoFVsOfCos :: [Coercion] -> FV tyCoVarsOfCo :: Coercion -> TyCoVarSet -- | Get a deterministic set of the vars free in a coercion tyCoVarsOfCoDSet :: Coercion -> DTyCoVarSet tyCoVarsOfCos :: [Coercion] -> TyCoVarSet -- | Tidy a Coercion -- -- See Note [Strictness in tidyType and friends] tidyCo :: TidyEnv -> Coercion -> Coercion tidyCos :: TidyEnv -> [Coercion] -> [Coercion] emptyCvSubstEnv :: CvSubstEnv extendTvSubstAndInScope :: TCvSubst -> TyVar -> Type -> TCvSubst getCvSubstEnv :: TCvSubst -> CvSubstEnv lookupCoVar :: TCvSubst -> Var -> Maybe Coercion substCoVar :: TCvSubst -> CoVar -> Coercion substCoVarBndr :: HasCallStack => TCvSubst -> CoVar -> (TCvSubst, CoVar) substCoVars :: TCvSubst -> [CoVar] -> [Coercion] -- | Coercion substitution, see zipTvSubst substCoWith :: HasCallStack => [TyVar] -> [Type] -> Coercion -> Coercion -- | Substitute within several Coercions The substitution has to -- satisfy the invariants described in Note [The substitution invariant]. substCos :: HasCallStack => TCvSubst -> [Coercion] -> [Coercion] -- | A substitution of Coercions for CoVars type CvSubstEnv = CoVarEnv Coercion pprParendCo :: Coercion -> SDoc -- | Assuming that two types are the same, ignoring coercions, find a -- nominal coercion between the types. This is useful when optimizing -- transitivity over coercion applications, where splitting two AppCos -- might yield different kinds. See Note [EtaAppCo] in -- GHC.Core.Coercion.Opt. buildCoercion :: Type -> Type -> CoercionN -- | Creates a new coercion with both of its types casted by different -- casts castCoercionKind g h1 h2, where g :: t1 ~r t2, -- has type (t1 |> h1) ~r (t2 |> h2). h1 and -- h2 must be nominal. It calls coercionKindRole, so -- it's quite inefficient (which I stands for) Use -- castCoercionKind2 instead if t1, t2, and -- r are known beforehand. castCoercionKind :: Coercion -> CoercionN -> CoercionN -> Coercion -- | castCoercionKind1 g r t1 t2 h = coercionKind g r t1 t2 h -- h That is, it's a specialised form of castCoercionKind, where the -- two kind coercions are identical castCoercionKind1 g r t1 t2 -- h, where g :: t1 ~r t2, has type (t1 |> h) ~r (t2 -- |> h). h must be nominal. See Note -- [castCoercionKind1] castCoercionKind1 :: Coercion -> Role -> Type -> Type -> CoercionN -> Coercion -- | Creates a new coercion with both of its types casted by different -- casts castCoercionKind2 g r t1 t2 h1 h2, where g :: t1 ~r -- t2, has type (t1 |> h1) ~r (t2 |> h2). h1 -- and h2 must be nominal. castCoercionKind2 :: Coercion -> Role -> Type -> Type -> CoercionN -> CoercionN -> Coercion checkReflexiveMCo :: MCoercion -> MCoercion coToMCo :: Coercion -> MCoercion coVarKind :: CoVar -> Type coVarName :: CoVar -> Name coVarTypes :: HasDebugCallStack => CoVar -> Pair Type coercionHolesOfCo :: Coercion -> UniqSet CoercionHole -- | Extract out all the coercion holes from a given type coercionHolesOfType :: Type -> UniqSet CoercionHole -- | Get a coercion's kind and role. coercionKindRole :: Coercion -> (Pair Type, Role) -- | Apply coercionKind to multiple Coercions coercionKinds :: [Coercion] -> Pair [Type] -- | Retrieve the role from a coercion. coercionRole :: Coercion -> Role -- | Try one stepper and then try the next, if the first doesn't make -- progress. So if it returns NS_Done, it means that both steppers are -- satisfied composeSteppers :: NormaliseStepper ev -> NormaliseStepper ev -> NormaliseStepper ev -- | This breaks a Coercion with type T A B C ~ T D E F -- into a list of Coercions of kinds A ~ D, B ~ -- E and E ~ F. Hence: -- --
-- decomposeCo 3 c [r1, r2, r3] = [nth r1 0 c, nth r2 1 c, nth r3 2 c] --decomposeCo :: Arity -> Coercion -> [Role] -> [Coercion] decomposeFunCo :: HasDebugCallStack => Role -> Coercion -> (CoercionN, Coercion, Coercion) -- | Like downgradeRole_maybe, but panics if the change isn't a -- downgrade. See Note [Role twiddling functions] downgradeRole :: Role -> Role -> Coercion -> Coercion emptyLiftingContext :: InScopeSet -> LiftingContext -- | Syntactic equality of coercions eqCoercion :: Coercion -> Coercion -> Bool -- | Compare two Coercions, with respect to an RnEnv2 eqCoercionX :: RnEnv2 -> Coercion -> Coercion -> Bool etaExpandCoAxBranch :: CoAxBranch -> ([TyVar], [Type], Type) -- | Extend a lifting context with a new mapping. extendLiftingContext :: LiftingContext -> TyCoVar -> Coercion -> LiftingContext -- | Extend a lifting context with a new mapping, and extend the in-scope -- set extendLiftingContextAndInScope :: LiftingContext -> TyCoVar -> Coercion -> LiftingContext -- | Attempts to obtain the type variable underlying a Coercion getCoVar_maybe :: Coercion -> Maybe CoVar -- | Is there a coercion hole in this coercion? hasCoercionHoleCo :: Coercion -> Bool -- | Is there a coercion hole in this type? hasCoercionHoleTy :: Type -> Bool -- | If co :: T ts ~ rep_ty then: -- --
-- instNewTyCon_maybe T ts = Just (rep_ty, co) ---- -- Checks for a newtype, and for being saturated instNewTyCon_maybe :: TyCon -> [Type] -> Maybe (Type, Coercion) -- | Extract a covar, if possible. This check is dirty. Be ashamed of -- yourself. (It's dirty because it cares about the structure of a -- coercion, which is morally reprehensible.) isCoVar_maybe :: Coercion -> Maybe CoVar -- | Returns the type coerced if this coercion is a generalized reflexive -- coercion. Guaranteed to work very quickly. isGReflCo_maybe :: Coercion -> Maybe (Type, Role) -- | Tests if this MCoercion is obviously generalized reflexive Guaranteed -- to work very quickly. isGReflMCo :: MCoercion -> Bool -- | Is a var in the domain of a lifting context? isMappedByLC :: TyCoVar -> LiftingContext -> Bool isReflCoVar_maybe :: Var -> Maybe Coercion -- | Returns the type coerced if this coercion is reflexive. Guaranteed to -- work very quickly. Sometimes a coercion can be reflexive, but not -- obviously so. c.f. isReflexiveCo_maybe isReflCo_maybe :: Coercion -> Maybe (Type, Role) isReflMCo :: MCoercion -> Bool -- | Extracts the coerced type from a reflexive coercion. This potentially -- walks over the entire coercion, so avoid doing this in a loop. isReflexiveCo_maybe :: Coercion -> Maybe (Type, Role) -- | Get the InScopeSet from a LiftingContext lcInScopeSet :: LiftingContext -> InScopeSet lcSubstLeft :: LiftingContext -> TCvSubst lcSubstRight :: LiftingContext -> TCvSubst -- | Extract the underlying substitution from the LiftingContext lcTCvSubst :: LiftingContext -> TCvSubst liftCoSubstTyVar :: LiftingContext -> Role -> TyVar -> Maybe Coercion liftCoSubstVarBndrUsing :: (LiftingContext -> Type -> (CoercionN, a)) -> LiftingContext -> TyCoVar -> (LiftingContext, TyCoVar, CoercionN, a) liftCoSubstWith :: Role -> [TyCoVar] -> [Coercion] -> Type -> Coercion liftCoSubstWithEx :: Role -> [TyVar] -> [Coercion] -> [TyCoVar] -> [Type] -> (Type -> Coercion, [Type]) liftEnvSubstLeft :: TCvSubst -> LiftCoEnv -> TCvSubst liftEnvSubstRight :: TCvSubst -> LiftCoEnv -> TCvSubst ltRole :: Role -> Role -> Bool mapStepResult :: (ev1 -> ev2) -> NormaliseStepResult ev1 -> NormaliseStepResult ev2 -- | Applies multiple Coercions to another Coercion, from -- left to right. See also mkAppCo. mkAppCos :: Coercion -> [Coercion] -> Coercion mkAxInstCo :: Role -> CoAxiom br -> BranchIndex -> [Type] -> [Coercion] -> Coercion -- | Return the left-hand type of the axiom, when the axiom is instantiated -- at the types given. mkAxInstLHS :: CoAxiom br -> BranchIndex -> [Type] -> [Coercion] -> Type mkAxInstRHS :: CoAxiom br -> BranchIndex -> [Type] -> [Coercion] -> Type -- | Cast a type by an MCoercion mkCastTyMCo :: Type -> MCoercion -> Type mkCoCast :: Coercion -> CoercionR -> Coercion mkCoVarCos :: [CoVar] -> [Coercion] -- | Given ty :: k1, co :: k1 ~ k2, co2:: ty ~r -- ty', produces @co' :: (ty |> co) ~r ty' It is not only a -- utility function, but it saves allocation when co is a GRefl coercion. mkCoherenceLeftCo :: Role -> Type -> CoercionN -> Coercion -> Coercion -- | Given ty :: k1, co :: k1 ~ k2, co2:: ty' ~r -- ty, produces @co' :: ty' ~r (ty |> co) It is not only a -- utility function, but it saves allocation when co is a GRefl coercion. mkCoherenceRightCo :: Role -> Type -> CoercionN -> Coercion -> Coercion -- | Like mkCoherenceRightCo, but with an MCoercion mkCoherenceRightMCo :: Role -> Type -> MCoercionN -> Coercion -> Coercion -- | Given a family instance TyCon and its arg Coercions, -- return the corresponding family Coercion. E.g: -- --
-- data family T a -- data instance T (Maybe b) = MkT b ---- -- Where the instance TyCon is :RTL, so: -- --
-- mkFamilyTyConAppCo :RTL (co :: a ~# Int) = T (Maybe a) ~# T (Maybe Int) ---- -- cf. mkFamilyTyConApp mkFamilyTyConAppCo :: TyCon -> [CoercionN] -> CoercionN -- | Make nested ForAllCos mkForAllCos :: [(TyCoVar, CoercionN)] -> Coercion -> Coercion mkFunResCo :: Role -> Scaled Type -> Coercion -> Coercion mkFunResMCo :: Scaled Type -> MCoercionR -> MCoercionR -- | Given ty :: k1, co :: k1 ~ k2, produces co' :: -- (ty |> co) ~r ty mkGReflLeftCo :: Role -> Type -> CoercionN -> Coercion mkGReflLeftMCo :: Role -> Type -> MCoercionN -> Coercion -- | Given ty :: k1, co :: k1 ~ k2, produces co' :: -- ty ~r (ty |> co) mkGReflRightCo :: Role -> Type -> CoercionN -> Coercion mkGReflRightMCo :: Role -> Type -> MCoercionN -> Coercion mkHeteroCoercionType :: Role -> Kind -> Kind -> Type -> Type -> Type -- | Creates a primitive type equality predicate with explicit kinds mkHeteroPrimEqPred :: Kind -> Kind -> Type -> Type -> Type -- | Creates a primitive representational type equality predicate with -- explicit kinds mkHeteroReprPrimEqPred :: Kind -> Kind -> Type -> Type -> Type -- | Make a coercion from a coercion hole mkHoleCo :: CoercionHole -> Coercion -- | Make a Coercion quantified over a type/coercion variable; the variable -- has the same type in both sides of the coercion mkHomoForAllCos :: [TyCoVar] -> Coercion -> Coercion mkHomoForAllMCo :: TyCoVar -> MCoercion -> MCoercion -- | Extract the nth field of a FunCo mkNthCoFunCo :: Int -> CoercionN -> Coercion -> Coercion -> Coercion -- | Make a forall Coercion, where both types related by the -- coercion are quantified over the same variable. mkPiCo :: Role -> Var -> Coercion -> Coercion mkPiCos :: Role -> [Var] -> Coercion -> Coercion mkPiMCos :: [Var] -> MCoercion -> MCoercion -- | Creates a primitive type equality predicate. Invariant: the types are -- not Coercions mkPrimEqPred :: Type -> Type -> Type -- | Makes a lifted equality predicate at the given role mkPrimEqPredRole :: Role -> Type -> Type -> PredType -- | Make a representational reflexive coercion mkRepReflCo :: Type -> Coercion mkReprPrimEqPred :: Type -> Type -> Type mkSubstLiftingContext :: TCvSubst -> LiftingContext -- | Get the reverse of an MCoercion mkSymMCo :: MCoercion -> MCoercion -- | Compose two MCoercions via transitivity mkTransMCo :: MCoercion -> MCoercion -> MCoercion mkTransMCoL :: MCoercion -> Coercion -> MCoercion mkTransMCoR :: Coercion -> MCoercion -> MCoercion mkUnbranchedAxInstCo :: Role -> CoAxiom Unbranched -> [Type] -> [Coercion] -> Coercion -- | Instantiate the left-hand side of an unbranched axiom mkUnbranchedAxInstLHS :: CoAxiom Unbranched -> [Type] -> [Coercion] -> Type mkUnbranchedAxInstRHS :: CoAxiom Unbranched -> [Type] -> [Coercion] -> Type multToCo :: Mult -> Coercion -- | If you're about to call mkNthCo r n co, then r -- should be whatever nthCoRole n co returns. nthCoRole :: Int -> Coercion -> Role nthRole :: Role -> TyCon -> Int -> Role pprCoAxBranch :: TyCon -> CoAxBranch -> SDoc pprCoAxBranchLHS :: TyCon -> CoAxBranch -> SDoc pprCoAxBranchUser :: TyCon -> CoAxBranch -> SDoc pprCoAxiom :: CoAxiom br -> SDoc -- | like mkKindCo, but aggressively & recursively optimizes to avoid -- using a KindCo constructor. The output role is nominal. promoteCoercion :: Coercion -> CoercionN setCoVarName :: CoVar -> Name -> CoVar setCoVarUnique :: CoVar -> Unique -> CoVar -- | Converts a coercion to be nominal, if possible. See Note [Role -- twiddling functions] setNominalRole_maybe :: Role -> Coercion -> Maybe Coercion simplifyArgsWorker :: [TyCoBinder] -> Kind -> TyCoVarSet -> [Role] -> [(Type, Coercion)] -> ([Type], [Coercion], MCoercionN) -- | Attempt to take a coercion application apart. splitAppCo_maybe :: Coercion -> Maybe (Coercion, Coercion) -- | Like splitForAllCo_maybe, but only returns Just for covar -- binder splitForAllCo_co_maybe :: Coercion -> Maybe (CoVar, Coercion, Coercion) splitForAllCo_maybe :: Coercion -> Maybe (TyCoVar, Coercion, Coercion) -- | Like splitForAllCo_maybe, but only returns Just for tyvar -- binder splitForAllCo_ty_maybe :: Coercion -> Maybe (TyVar, Coercion, Coercion) splitFunCo_maybe :: Coercion -> Maybe (Coercion, Coercion) -- | Attempts to tease a coercion apart into a type constructor and the -- application of a number of coercion arguments to that constructor splitTyConAppCo_maybe :: Coercion -> Maybe (TyCon, [Coercion]) -- | Like substForAllCoBndr, but works on a lifting context substForAllCoBndrUsingLC :: Bool -> (Coercion -> Coercion) -> LiftingContext -> TyCoVar -> Coercion -> (LiftingContext, TyCoVar, Coercion) substLeftCo :: LiftingContext -> Coercion -> Coercion substRightCo :: LiftingContext -> Coercion -> Coercion -- | Apply "sym" to all coercions in a LiftCoEnv swapLiftCoEnv :: LiftCoEnv -> LiftCoEnv tidyCoAxBndrsForUser :: TidyEnv -> [Var] -> (TidyEnv, [Var]) -- | Sometimes we want to look through a newtype and get its -- associated coercion. This function strips off newtype layers -- enough to reveal something that isn't a newtype. -- Specifically, here's the invariant: -- --
-- topNormaliseNewType_maybe rec_nts ty = Just (co, ty') ---- -- then (a) co : ty ~ ty'. (b) ty' is not a newtype. -- -- The function returns Nothing for non-newtypes, or -- unsaturated applications -- -- This function does *not* look through type families, because it has no -- access to the type family environment. If you do have that at hand, -- consider to use topNormaliseType_maybe, which should be a drop-in -- replacement for topNormaliseNewType_maybe If topNormliseNewType_maybe -- ty = Just (co, ty'), then co : ty ~R ty' topNormaliseNewType_maybe :: Type -> Maybe (Coercion, Type) -- | A general function for normalising the top-level of a type. It -- continues to use the provided NormaliseStepper until that -- function fails, and then this function returns. The roles of the -- coercions produced by the NormaliseStepper must all be the -- same, which is the role returned from the call to -- topNormaliseTypeX. -- -- Typically ev is Coercion. -- -- If topNormaliseTypeX step plus ty = Just (ev, ty') then ty ~ev1~ t1 -- ~ev2~ t2 ... ~evn~ ty' and ev = ev1 plus ev2 plus -- ... plus evn If it returns Nothing then no newtype unwrapping -- could happen topNormaliseTypeX :: NormaliseStepper ev -> (ev -> ev -> ev) -> Type -> Maybe (ev, Type) tyConRolesRepresentational :: TyCon -> [Role] tyConRolesX :: Role -> TyCon -> [Role] -- | A NormaliseStepper that unwraps newtypes, careful not to fall -- into a loop. If it would fall into a loop, it produces -- NS_Abort. unwrapNewTypeStepper :: NormaliseStepper Coercion -- | Erase the environments in a lifting context zapLiftingContext :: LiftingContext -> LiftingContext -- | A set of CoercionHoles type HoleSet = UniqSet CoercionHole type LiftCoEnv = VarEnv Coercion -- | The result of stepping in a normalisation function. See -- topNormaliseTypeX. data NormaliseStepResult ev -- | Nothing more to do NS_Done :: NormaliseStepResult ev -- | Utter failure. The outer function should fail too. NS_Abort :: NormaliseStepResult ev -- | We stepped, yielding new bits; ^ ev is evidence; Usually a co :: old -- type ~ new type NS_Step :: RecTcChecker -> Type -> ev -> NormaliseStepResult ev -- | A function to check if we can reduce a type by one step. Used with -- topNormaliseTypeX. type NormaliseStepper ev = RecTcChecker -> TyCon -> [Type] -> NormaliseStepResult ev -- | Class of things that we can obtain a Unique from class Uniquable a getUnique :: Uniquable a => a -> Unique -- | Unique identifier. -- -- The type of unique identifiers that are used in many places in GHC for -- fast ordering and equality tests. You should generate these with the -- functions from the UniqSupply module -- -- These are sometimes also referred to as "keys" in comments in GHC. data Unique -- | Attempt to convert a Template Haskell name to one that GHC can -- understand. Original TH names such as those you get when you use the -- 'foo syntax will be translated to their equivalent GHC name -- exactly. Qualified or unqualified TH names will be dynamically bound -- to names in the module being compiled, if possible. Exact TH names -- will be bound to the name they represent, exactly. thNameToGhcName :: Name -> CoreM (Maybe Name) instance GHC.Types.TyThing.MonadThings GHC.Core.Opt.Monad.CoreM module GHC.Runtime.Heap.Inspect -- | Term reconstruction -- -- Given a pointer to a heap object (HValue) and its type, build a -- Term representation of the object. Subterms (objects in the -- payload) are also built up to the given max_depth. After -- max_depth any subterms will appear as Suspensions. Any -- thunks found while traversing the object will be forced based on -- force parameter. -- -- Types of terms will be refined based on constructors we find during -- term reconstruction. See cvReconstructType for an overview of -- how type reconstruction works. cvObtainTerm :: HscEnv -> Int -> Bool -> RttiType -> ForeignHValue -> IO Term -- | Fast, breadth-first Type reconstruction -- -- Given a heap object (HValue) and its (possibly polymorphic) -- type (usually obtained in GHCi), try to reconstruct a more monomorphic -- type of the object. This is used for improving type information in -- debugger. For example, if we have a polymorphic function: -- -- sumNumList :: Num a => [a] -> a sumNumList [] = 0 sumNumList (x -- : xs) = x + sumList xs -- -- and add a breakpoint to it: -- -- ghci> break sumNumList ghci> sumNumList ([0 .. 9] :: [Int]) -- -- ghci shows us more precise types than just as: -- -- Stopped in Main.sumNumList, debugger.hs:3:23-39 _result :: Int = _ x -- :: Int = 0 xs :: [Int] = _ cvReconstructType :: HscEnv -> Int -> GhciType -> ForeignHValue -> IO (Maybe Type) improveRTTIType :: HscEnv -> RttiType -> RttiType -> Maybe TCvSubst data Term Term :: RttiType -> Either String DataCon -> ForeignHValue -> [Term] -> Term [ty] :: Term -> RttiType [dc] :: Term -> Either String DataCon [val] :: Term -> ForeignHValue [subTerms] :: Term -> [Term] Prim :: RttiType -> [Word] -> Term [ty] :: Term -> RttiType [valRaw] :: Term -> [Word] Suspension :: ClosureType -> RttiType -> ForeignHValue -> Maybe Name -> Term [ctype] :: Term -> ClosureType [ty] :: Term -> RttiType [val] :: Term -> ForeignHValue [bound_to] :: Term -> Maybe Name NewtypeWrap :: RttiType -> Either String DataCon -> Term -> Term [ty] :: Term -> RttiType [dc] :: Term -> Either String DataCon [wrapped_term] :: Term -> Term RefWrap :: RttiType -> Term -> Term [ty] :: Term -> RttiType [wrapped_term] :: Term -> Term isFullyEvaluatedTerm :: Term -> Bool termType :: Term -> RttiType mapTermType :: (RttiType -> Type) -> Term -> Term termTyCoVars :: Term -> TyCoVarSet foldTerm :: TermFold a -> Term -> a data TermFold a TermFold :: TermProcessor a a -> (RttiType -> [Word] -> a) -> (ClosureType -> RttiType -> ForeignHValue -> Maybe Name -> a) -> (RttiType -> Either String DataCon -> a -> a) -> (RttiType -> a -> a) -> TermFold a [fTerm] :: TermFold a -> TermProcessor a a [fPrim] :: TermFold a -> RttiType -> [Word] -> a [fSuspension] :: TermFold a -> ClosureType -> RttiType -> ForeignHValue -> Maybe Name -> a [fNewtypeWrap] :: TermFold a -> RttiType -> Either String DataCon -> a -> a [fRefWrap] :: TermFold a -> RttiType -> a -> a -- | Takes a list of custom printers with a explicit recursion knot and a -- term, and returns the output of the first successful printer, or the -- default printer cPprTerm :: Monad m => CustomTermPrinter m -> Term -> m SDoc cPprTermBase :: forall m. Monad m => CustomTermPrinter m constrClosToName :: HscEnv -> GenClosure a -> IO (Either String Name) instance GHC.Utils.Outputable.Outputable GHC.Runtime.Heap.Inspect.Term -- | This module provides an interface for typechecker plugins to access -- select functions of the TcM, principally those to do with -- reading parts of the state. module GHC.Tc.Plugin data TcPluginM a -- | Perform some IO, typically to interact with an external tool. tcPluginIO :: IO a -> TcPluginM a -- | Output useful for debugging the compiler. tcPluginTrace :: String -> SDoc -> TcPluginM () -- | This function provides an escape for direct access to the TcM -- monad. It should not be used lightly, and the provided -- TcPluginM API should be favoured instead. unsafeTcPluginTcM :: TcM a -> TcPluginM a -- | The result of searching for an imported module. -- -- NB: FindResult manages both user source-import lookups (which can -- result in Module) as well as direct imports for interfaces -- (which always result in InstalledModule). data FindResult -- | The module was found Found :: ModLocation -> Module -> FindResult -- | The requested unit was not found NoPackage :: Unit -> FindResult -- | _Error_: both in multiple packages FoundMultiple :: [(Module, ModuleOrigin)] -> FindResult -- | Not found NotFound :: [FilePath] -> Maybe Unit -> [Unit] -> [Unit] -> [(Unit, UnusableUnitReason)] -> [ModuleSuggestion] -> FindResult -- | Places where I looked [fr_paths] :: FindResult -> [FilePath] -- | Just p => module is in this unit's manifest, but couldn't find the -- .hi file [fr_pkg] :: FindResult -> Maybe Unit -- | Module is in these units, but the *module* is hidden [fr_mods_hidden] :: FindResult -> [Unit] -- | Module is in these units, but the *unit* is hidden [fr_pkgs_hidden] :: FindResult -> [Unit] -- | Module is in these units, but it is unusable [fr_unusables] :: FindResult -> [(Unit, UnusableUnitReason)] -- | Possible mis-spelled modules [fr_suggestions] :: FindResult -> [ModuleSuggestion] findImportedModule :: ModuleName -> Maybe FastString -> TcPluginM FindResult lookupOrig :: Module -> OccName -> TcPluginM Name tcLookupGlobal :: Name -> TcPluginM TyThing tcLookupTyCon :: Name -> TcPluginM TyCon tcLookupDataCon :: Name -> TcPluginM DataCon tcLookupClass :: Name -> TcPluginM Class tcLookup :: Name -> TcPluginM TcTyThing tcLookupId :: Name -> TcPluginM Id getTopEnv :: TcPluginM HscEnv getEnvs :: TcPluginM (TcGblEnv, TcLclEnv) getInstEnvs :: TcPluginM InstEnvs getFamInstEnvs :: TcPluginM (FamInstEnv, FamInstEnv) matchFam :: TyCon -> [Type] -> TcPluginM (Maybe (TcCoercion, TcType)) newUnique :: TcPluginM Unique newFlexiTyVar :: Kind -> TcPluginM TcTyVar isTouchableTcPluginM :: TcTyVar -> TcPluginM Bool zonkTcType :: TcType -> TcPluginM TcType zonkCt :: Ct -> TcPluginM Ct -- | Create a new wanted constraint. newWanted :: CtLoc -> PredType -> TcPluginM CtEvidence -- | Create a new derived constraint. newDerived :: CtLoc -> PredType -> TcPluginM CtEvidence -- | Create a new given constraint, with the supplied evidence. This must -- not be invoked from tcPluginInit or tcPluginStop, or -- it will panic. newGiven :: CtLoc -> PredType -> EvExpr -> TcPluginM CtEvidence -- | Create a fresh coercion hole. newCoercionHole :: PredType -> TcPluginM CoercionHole -- | Create a fresh evidence variable. newEvVar :: PredType -> TcPluginM EvVar -- | Bind an evidence variable. This must not be invoked from -- tcPluginInit or tcPluginStop, or it will panic. setEvBind :: EvBind -> TcPluginM () -- | Access the EvBindsVar carried by the TcPluginM during -- constraint solving. Returns Nothing if invoked during -- tcPluginInit or tcPluginStop. getEvBindsTcPluginM :: TcPluginM EvBindsVar module GHC.Runtime.Eval data Resume Resume :: String -> ForeignRef (ResumeContext [HValueRef]) -> ([TyThing], GlobalRdrEnv) -> [Id] -> ForeignHValue -> Maybe BreakInfo -> SrcSpan -> String -> RemotePtr CostCentreStack -> [History] -> Int -> Resume [resumeStmt] :: Resume -> String [resumeContext] :: Resume -> ForeignRef (ResumeContext [HValueRef]) [resumeBindings] :: Resume -> ([TyThing], GlobalRdrEnv) [resumeFinalIds] :: Resume -> [Id] [resumeApStack] :: Resume -> ForeignHValue [resumeBreakInfo] :: Resume -> Maybe BreakInfo [resumeSpan] :: Resume -> SrcSpan [resumeDecl] :: Resume -> String [resumeCCS] :: Resume -> RemotePtr CostCentreStack [resumeHistory] :: Resume -> [History] [resumeHistoryIx] :: Resume -> Int data History History :: ForeignHValue -> BreakInfo -> [String] -> History [historyApStack] :: History -> ForeignHValue [historyBreakInfo] :: History -> BreakInfo [historyEnclosingDecls] :: History -> [String] -- | Run a statement in the current interactive context. execStmt :: GhcMonad m => String -> ExecOptions -> m ExecResult -- | Like execStmt, but takes a parsed statement as argument. Useful -- when doing preprocessing on the AST before execution, e.g. in GHCi -- (see GHCi.UI.runStmt). execStmt' :: GhcMonad m => GhciLStmt GhcPs -> String -> ExecOptions -> m ExecResult data ExecOptions ExecOptions :: SingleStep -> String -> Int -> (ForeignHValue -> EvalExpr ForeignHValue) -> ExecOptions -- | stepping mode [execSingleStep] :: ExecOptions -> SingleStep -- | filename (for errors) [execSourceFile] :: ExecOptions -> String -- | line number (for errors) [execLineNumber] :: ExecOptions -> Int [execWrap] :: ExecOptions -> ForeignHValue -> EvalExpr ForeignHValue -- | default ExecOptions execOptions :: ExecOptions data ExecResult ExecComplete :: Either SomeException [Name] -> Word64 -> ExecResult [execResult] :: ExecResult -> Either SomeException [Name] [execAllocation] :: ExecResult -> Word64 ExecBreak :: [Name] -> Maybe BreakInfo -> ExecResult [breakNames] :: ExecResult -> [Name] [breakInfo] :: ExecResult -> Maybe BreakInfo resumeExec :: GhcMonad m => (SrcSpan -> Bool) -> SingleStep -> Maybe Int -> m ExecResult runDecls :: GhcMonad m => String -> m [Name] -- | Run some declarations and return any user-visible names that were -- brought into scope. runDeclsWithLocation :: GhcMonad m => String -> Int -> String -> m [Name] -- | Like runDeclsWithLocation, but takes parsed declarations as -- argument. Useful when doing preprocessing on the AST before execution, -- e.g. in GHCi (see GHCi.UI.runStmt). runParsedDecls :: GhcMonad m => [LHsDecl GhcPs] -> m [Name] parseImportDecl :: GhcMonad m => String -> m (ImportDecl GhcPs) data SingleStep RunToCompletion :: SingleStep SingleStep :: SingleStep RunAndLogSteps :: SingleStep abandon :: GhcMonad m => m Bool abandonAll :: GhcMonad m => m Bool getResumeContext :: GhcMonad m => m [Resume] getHistorySpan :: HscEnv -> History -> SrcSpan getModBreaks :: HomeModInfo -> ModBreaks getHistoryModule :: History -> Module setupBreakpoint :: GhcMonad m => HscEnv -> BreakInfo -> Int -> m () back :: GhcMonad m => Int -> m ([Name], Int, SrcSpan, String) forward :: GhcMonad m => Int -> m ([Name], Int, SrcSpan, String) -- | Set the interactive evaluation context. -- -- (setContext imports) sets the ic_imports field (which in turn -- determines what is in scope at the prompt) to imports, and -- constructs the ic_rn_glb_env environment to reflect it. -- -- We retain in scope all the things defined at the prompt, and kept in -- ic_tythings. (Indeed, they shadow stuff from ic_imports.) setContext :: GhcMonad m => [InteractiveImport] -> m () -- | Get the interactive evaluation context, consisting of a pair of the -- set of modules from which we take the full top-level scope, and the -- set of modules from which we take just the exports respectively. getContext :: GhcMonad m => m [InteractiveImport] -- | Returns all names in scope in the current interactive context getNamesInScope :: GhcMonad m => m [Name] -- | Returns all RdrNames in scope in the current interactive -- context, excluding any that are internally-generated. getRdrNamesInScope :: GhcMonad m => m [RdrName] -- | Returns True if the specified module is interpreted, and -- hence has its full top-level scope available. moduleIsInterpreted :: GhcMonad m => Module -> m Bool -- | Looks up an identifier in the current interactive context (for :info) -- Filter the instances by the ones whose tycons (or clases resp) are in -- scope (qualified or otherwise). Otherwise we list a whole lot too -- many! The exact choice of which ones to show, and which to hide, is a -- judgement call. (see #1581) getInfo :: GhcMonad m => Bool -> Name -> m (Maybe (TyThing, Fixity, [ClsInst], [FamInst], SDoc)) -- | Get the type of an expression Returns the type as described by -- TcRnExprMode exprType :: GhcMonad m => TcRnExprMode -> String -> m Type -- | Get the kind of a type typeKind :: GhcMonad m => Bool -> String -> m (Type, Kind) -- | Parses a string as an identifier, and returns the list of Names -- that the identifier can refer to in the current interactive context. parseName :: GhcMonad m => String -> m [Name] parseInstanceHead :: GhcMonad m => String -> m Type getInstancesForType :: GhcMonad m => Type -> m [ClsInst] getDocs :: GhcMonad m => Name -> m (Either GetDocsFailure (Maybe HsDocString, IntMap HsDocString)) -- | Failure modes for getDocs. data GetDocsFailure -- | nameModule_maybe returned Nothing. NameHasNoModule :: Name -> GetDocsFailure -- | This is probably because the module was loaded without -- -haddock, but it's also possible that the entire module -- contains no documentation. NoDocsInIface :: Module -> Bool -> GetDocsFailure -- | The Name was defined interactively. InteractiveName :: GetDocsFailure showModule :: GhcMonad m => ModSummary -> m String moduleIsBootOrNotObjectLinkable :: GhcMonad m => ModSummary -> m Bool -- | Parse an expression, the parsed expression can be further processed -- and passed to compileParsedExpr. parseExpr :: GhcMonad m => String -> m (LHsExpr GhcPs) compileParsedExpr :: GhcMonad m => LHsExpr GhcPs -> m HValue -- | Compile an expression, run it, and deliver the resulting HValue. compileExpr :: GhcMonad m => String -> m HValue -- | Compile an expression, run it and return the result as a Dynamic. dynCompileExpr :: GhcMonad m => String -> m Dynamic -- | Compile an expression, run it, and deliver the resulting HValue. compileExprRemote :: GhcMonad m => String -> m ForeignHValue -- | Compile a parsed expression (before renaming), run it, and deliver the -- resulting HValue. compileParsedExprRemote :: GhcMonad m => LHsExpr GhcPs -> m ForeignHValue data Term Term :: RttiType -> Either String DataCon -> ForeignHValue -> [Term] -> Term [ty] :: Term -> RttiType [dc] :: Term -> Either String DataCon [val] :: Term -> ForeignHValue [subTerms] :: Term -> [Term] Prim :: RttiType -> [Word] -> Term [ty] :: Term -> RttiType [valRaw] :: Term -> [Word] Suspension :: ClosureType -> RttiType -> ForeignHValue -> Maybe Name -> Term [ctype] :: Term -> ClosureType [ty] :: Term -> RttiType [val] :: Term -> ForeignHValue [bound_to] :: Term -> Maybe Name NewtypeWrap :: RttiType -> Either String DataCon -> Term -> Term [ty] :: Term -> RttiType [dc] :: Term -> Either String DataCon [wrapped_term] :: Term -> Term RefWrap :: RttiType -> Term -> Term [ty] :: Term -> RttiType [wrapped_term] :: Term -> Term obtainTermFromId :: HscEnv -> Int -> Bool -> Id -> IO Term obtainTermFromVal :: HscEnv -> Int -> Bool -> Type -> a -> IO Term reconstructType :: HscEnv -> Int -> Id -> IO (Maybe Type) instance GHC.Utils.Outputable.Outputable GHC.Runtime.Eval.GetDocsFailure module GHC.Driver.Pipeline oneShot :: HscEnv -> Phase -> [(String, Maybe Phase)] -> IO () compileFile :: HscEnv -> Phase -> (FilePath, Maybe Phase) -> IO FilePath -- | Just preprocess a file, put the result in a temp. file (used by the -- compilation manager during the summary phase). -- -- We return the augmented DynFlags, because they contain the result of -- slurping in the OPTIONS pragmas preprocess :: HscEnv -> FilePath -> Maybe InputFileBuffer -> Maybe Phase -> IO (Either ErrorMessages (DynFlags, FilePath)) -- | Compile -- -- Compile a single module, under the control of the compilation manager. -- -- This is the interface between the compilation manager and the compiler -- proper (hsc), where we deal with tedious details like reading the -- OPTIONS pragma from the source file, converting the C or assembly that -- GHC produces into an object file, and compiling FFI stub files. -- -- NB. No old interface can also mean that the source has changed. compileOne :: HscEnv -> ModSummary -> Int -> Int -> Maybe ModIface -> Maybe Linkable -> SourceModified -> IO HomeModInfo compileOne' :: Maybe TcGblEnv -> Maybe Messager -> HscEnv -> ModSummary -> Int -> Int -> Maybe ModIface -> Maybe Linkable -> SourceModified -> IO HomeModInfo link :: GhcLink -> Logger -> TmpFs -> Hooks -> DynFlags -> UnitEnv -> Bool -> HomePackageTable -> IO SuccessFlag data PhasePlus RealPhase :: Phase -> PhasePlus HscOut :: HscSource -> ModuleName -> HscStatus -> PhasePlus newtype CompPipeline a P :: (PipeEnv -> PipeState -> IO (PipeState, a)) -> CompPipeline a [unP] :: CompPipeline a -> PipeEnv -> PipeState -> IO (PipeState, a) data PipeEnv PipeEnv :: Phase -> String -> String -> String -> PipelineOutput -> PipeEnv -- | Stop just before this phase [stop_phase] :: PipeEnv -> Phase -- | basename of original input source [src_filename] :: PipeEnv -> String -- | basename of original input source [src_basename] :: PipeEnv -> String -- | its extension [src_suffix] :: PipeEnv -> String -- | says where to put the pipeline output [output_spec] :: PipeEnv -> PipelineOutput data PipeState PipeState :: HscEnv -> Maybe ModLocation -> [FilePath] -> Maybe ModIface -> PipeState -- | only the DynFlags and the Plugins change in the HscEnv. The DynFlags -- change at various points, for example when we read the OPTIONS_GHC -- pragmas in the Cpp phase. [hsc_env] :: PipeState -> HscEnv -- | the ModLocation. This is discovered during compilation, in the Hsc -- phase where we read the module header. [maybe_loc] :: PipeState -> Maybe ModLocation -- | additional object files resulting from compiling foreign code. They -- come from two sources: foreign stubs, and add{C,Cxx,Objc,Objcxx}File -- from template haskell [foreign_os] :: PipeState -> [FilePath] -- | Interface generated by HscOut phase. Only available after the phase -- runs. [iface] :: PipeState -> Maybe ModIface -- | Computes the next output filename after we run next_phase. -- Like getOutputFilename, but it operates in the -- CompPipeline monad (which specifies all of the ambient -- information.) phaseOutputFilename :: Phase -> CompPipeline FilePath -- | Computes the next output filename for something in the compilation -- pipeline. This is controlled by several variables: -- --
-- -fPIC --Opt_PIC :: GeneralFlag -- |
-- -fPIE --Opt_PIE :: GeneralFlag -- |
-- -pie --Opt_PICExecutable :: GeneralFlag Opt_ExternalDynamicRefs :: GeneralFlag Opt_Ticky :: GeneralFlag Opt_Ticky_Allocd :: GeneralFlag Opt_Ticky_LNE :: GeneralFlag Opt_Ticky_Dyn_Thunk :: GeneralFlag Opt_RPath :: GeneralFlag Opt_RelativeDynlibPaths :: GeneralFlag -- |
-- -fcompact-unwind --Opt_CompactUnwind :: GeneralFlag Opt_Hpc :: GeneralFlag Opt_FamAppCache :: GeneralFlag Opt_ExternalInterpreter :: GeneralFlag Opt_OptimalApplicativeDo :: GeneralFlag Opt_VersionMacros :: GeneralFlag Opt_WholeArchiveHsLibs :: GeneralFlag Opt_SingleLibFolder :: GeneralFlag Opt_ExposeInternalSymbols :: GeneralFlag Opt_KeepCAFs :: GeneralFlag Opt_KeepGoing :: GeneralFlag Opt_ByteCode :: GeneralFlag Opt_LinkRts :: GeneralFlag Opt_ErrorSpans :: GeneralFlag Opt_DeferDiagnostics :: GeneralFlag Opt_DiagnosticsShowCaret :: GeneralFlag Opt_PprCaseAsLet :: GeneralFlag Opt_PprShowTicks :: GeneralFlag Opt_ShowHoleConstraints :: GeneralFlag Opt_ShowValidHoleFits :: GeneralFlag Opt_SortValidHoleFits :: GeneralFlag Opt_SortBySizeHoleFits :: GeneralFlag Opt_SortBySubsumHoleFits :: GeneralFlag Opt_AbstractRefHoleFits :: GeneralFlag Opt_UnclutterValidHoleFits :: GeneralFlag Opt_ShowTypeAppOfHoleFits :: GeneralFlag Opt_ShowTypeAppVarsOfHoleFits :: GeneralFlag Opt_ShowDocsOfHoleFits :: GeneralFlag Opt_ShowTypeOfHoleFits :: GeneralFlag Opt_ShowProvOfHoleFits :: GeneralFlag Opt_ShowMatchesOfHoleFits :: GeneralFlag Opt_ShowLoadedModules :: GeneralFlag Opt_HexWordLiterals :: GeneralFlag Opt_SuppressCoercions :: GeneralFlag Opt_SuppressVarKinds :: GeneralFlag Opt_SuppressModulePrefixes :: GeneralFlag Opt_SuppressTypeApplications :: GeneralFlag Opt_SuppressIdInfo :: GeneralFlag Opt_SuppressUnfoldings :: GeneralFlag Opt_SuppressTypeSignatures :: GeneralFlag Opt_SuppressUniques :: GeneralFlag Opt_SuppressStgExts :: GeneralFlag Opt_SuppressTicks :: GeneralFlag -- | Suppress timestamps in dumps Opt_SuppressTimestamps :: GeneralFlag Opt_AutoLinkPackages :: GeneralFlag Opt_ImplicitImportQualified :: GeneralFlag Opt_KeepHscppFiles :: GeneralFlag Opt_KeepHiDiffs :: GeneralFlag Opt_KeepHcFiles :: GeneralFlag Opt_KeepSFiles :: GeneralFlag Opt_KeepTmpFiles :: GeneralFlag Opt_KeepRawTokenStream :: GeneralFlag Opt_KeepLlvmFiles :: GeneralFlag Opt_KeepHiFiles :: GeneralFlag Opt_KeepOFiles :: GeneralFlag Opt_BuildDynamicToo :: GeneralFlag Opt_DistrustAllPackages :: GeneralFlag Opt_PackageTrust :: GeneralFlag Opt_PluginTrustworthy :: GeneralFlag Opt_G_NoStateHack :: GeneralFlag Opt_G_NoOptCoercion :: GeneralFlag data Severity SevOutput :: Severity SevFatal :: Severity SevInteractive :: Severity -- | Log message intended for compiler developers No file/line/column stuff SevDump :: Severity -- | Log messages intended for end users. No file/line/column stuff. SevInfo :: Severity SevWarning :: Severity -- | SevWarning and SevError are used for warnings and errors o The message -- has a file/line/column heading, plus "warning:" or "error:", added by -- mkLocMessags o Output is intended for end users SevError :: Severity -- | Code generation backends. -- -- GHC supports several code generation backends serving different -- purposes (producing machine code, producing ByteCode for the -- interpreter) and supporting different platforms. data Backend -- | Native code generator backend. -- -- Compiles Cmm code into textual assembler, then relies on an external -- assembler toolchain to produce machine code. -- -- Only supports a few platforms (X86, PowerPC, SPARC). -- -- See GHC.CmmToAsm. NCG :: Backend -- | LLVM backend. -- -- Compiles Cmm code into LLVM textual IR, then relies on LLVM toolchain -- to produce machine code. -- -- It relies on LLVM support for the calling convention used by the NCG -- backend to produce code objects ABI compatible with it (see "cc 10" or -- "ghccc" calling convention in -- https://llvm.org/docs/LangRef.html#calling-conventions). -- -- Support a few platforms (X86, AArch64, s390x, ARM). -- -- See GHC.CmmToLlvm LLVM :: Backend -- | Via-C backend. -- -- Compiles Cmm code into C code, then relies on a C compiler to produce -- machine code. -- -- It produces code objects that are *not* ABI compatible with those -- produced by NCG and LLVM backends. -- -- Produced code is expected to be less efficient than the one produced -- by NCG and LLVM backends because STG registers are not pinned into -- real registers. On the other hand, it supports more target platforms -- (those having a valid C toolchain). -- -- See GHC.CmmToC ViaC :: Backend -- | ByteCode interpreter. -- -- Produce ByteCode objects (BCO, see GHC.ByteCode) that can be -- interpreted. It is used by GHCi. -- -- Currently some extensions are not supported (foreign primops). -- -- See GHC.StgToByteCode Interpreter :: Backend -- | No code generated. -- -- Use this to disable code generation. It is particularly useful when -- GHC is used as a library for other purpose than generating code (e.g. -- to generate documentation with Haddock) or when the user requested it -- (via -fno-code) for some reason. NoBackend :: Backend -- | Test whether a GeneralFlag is set -- -- Note that dynamicNow (i.e., dynamic objects built with -- `-dynamic-too`) always implicitly enables Opt_PIC, -- Opt_ExternalDynamicRefs, and disables Opt_SplitSections. gopt :: GeneralFlag -> DynFlags -> Bool -- | The GhcMode tells us whether we're doing multi-module -- compilation (controlled via the GHC API) or one-shot -- (single-module) compilation. This makes a difference primarily to the -- GHC.Unit.Finder: in one-shot mode we look for interface files -- for imported modules, but in multi-module mode we look for source -- files in order to check whether they need to be recompiled. data GhcMode -- | --make, GHCi, etc. CompManager :: GhcMode -- |
-- ghc -c Foo.hs --OneShot :: GhcMode -- | ghc -M, see GHC.Unit.Finder for why we need this MkDepend :: GhcMode -- | What to do in the link step, if there is one. data GhcLink -- | Don't link at all NoLink :: GhcLink -- | Link object code into a binary LinkBinary :: GhcLink -- | Use the in-memory dynamic linker (works for both bytecode and object -- code). LinkInMemory :: GhcLink -- | Link objects into a dynamic lib (DLL on Windows, DSO on ELF platforms) LinkDynLib :: GhcLink -- | Link objects into a static lib LinkStaticLib :: GhcLink parseDynamicFlags :: MonadIO m => Logger -> DynFlags -> [Located String] -> m (DynFlags, [Located String], [Warn]) -- | Parse command line arguments that look like files. First normalises -- its arguments and then splits them into source files and object files. -- A source file can be turned into a Target via -- guessTarget parseTargetFiles :: DynFlags -> [String] -> (DynFlags, [(String, Maybe Phase)], [String]) -- | Grabs the DynFlags from the Session getSessionDynFlags :: GhcMonad m => m DynFlags -- | Updates both the interactive and program DynFlags in a Session. This -- also reads the package database (unless it has already been read), and -- prepares the compilers knowledge about packages. It can be called -- again to load new packages: just add new package flags to -- (packageFlags dflags). setSessionDynFlags :: GhcMonad m => DynFlags -> m () -- | Returns the program DynFlags. getProgramDynFlags :: GhcMonad m => m DynFlags -- | Sets the program DynFlags. Note: this invalidates the internal -- cached module graph, causing more work to be done the next time -- load is called. -- -- Returns a boolean indicating if preload units have changed and need to -- be reloaded. setProgramDynFlags :: GhcMonad m => DynFlags -> m Bool -- | Get the DynFlags used to evaluate interactive expressions. getInteractiveDynFlags :: GhcMonad m => m DynFlags -- | Set the DynFlags used to evaluate interactive expressions. Also -- initialise (load) plugins. -- -- Note: this cannot be used for changes to packages. Use -- setSessionDynFlags, or setProgramDynFlags and then copy -- the unitState into the interactive DynFlags. setInteractiveDynFlags :: GhcMonad m => DynFlags -> m () -- | Find the package environment (if one exists) -- -- We interpret the package environment as a set of package flags; to be -- specific, if we find a package environment file like -- --
-- clear-package-db -- global-package-db -- package-db blah/package.conf.d -- package-id id1 -- package-id id2 ---- -- we interpret this as -- --
-- [ -hide-all-packages -- , -clear-package-db -- , -global-package-db -- , -package-db blah/package.conf.d -- , -package-id id1 -- , -package-id id2 -- ] ---- -- There's also an older syntax alias for package-id, which is just an -- unadorned package id -- --
-- id1 -- id2 --interpretPackageEnv :: Logger -> DynFlags -> IO DynFlags data Logger getLogger :: HasLogger m => m Logger -- | Push a log hook pushLogHook :: (LogAction -> LogAction) -> Logger -> Logger -- | Pop a log hook popLogHook :: Logger -> Logger -- | Push a log hook on the stack pushLogHookM :: GhcMonad m => (LogAction -> LogAction) -> m () -- | Pop a log hook from the stack popLogHookM :: GhcMonad m => m () -- | Modify the logger modifyLogger :: GhcMonad m => (Logger -> Logger) -> m () -- | Put a log message putMsgM :: GhcMonad m => SDoc -> m () -- | Put a log message putLogMsgM :: GhcMonad m => WarnReason -> Severity -> SrcSpan -> SDoc -> m () -- | A compilation target. -- -- A target may be supplied with the actual text of the module. If so, -- use this instead of the file contents (this is for use in an IDE where -- the file hasn't been saved by the user yet). data Target Target :: !TargetId -> !Bool -> !Maybe (InputFileBuffer, UTCTime) -> Target -- | module or filename [targetId] :: Target -> !TargetId -- | object code allowed? [targetAllowObjCode] :: Target -> !Bool -- | Optional in-memory buffer containing the source code GHC should use -- for this target instead of reading it from disk. -- -- Since GHC version 8.10 modules which require preprocessors such as -- Literate Haskell or CPP to run are also supported. -- -- If a corresponding source file does not exist on disk this will result -- in a SourceError exception if targetId = TargetModule -- _ is used. However together with targetId = TargetFile _ -- GHC will not complain about the file missing. [targetContents] :: Target -> !Maybe (InputFileBuffer, UTCTime) data TargetId -- | A module name: search for the file TargetModule :: !ModuleName -> TargetId -- | A filename: preprocess & parse it to find the module name. If -- specified, the Phase indicates how to compile this file (which phase -- to start from). Nothing indicates the starting phase should be -- determined from the suffix of the filename. TargetFile :: !FilePath -> !Maybe Phase -> TargetId data Phase -- | Sets the targets for this session. Each target may be a module name or -- a filename. The targets correspond to the set of root modules for the -- program/library. Unloading the current program is achieved by setting -- the current set of targets to be empty, followed by load. setTargets :: GhcMonad m => [Target] -> m () -- | Returns the current set of targets getTargets :: GhcMonad m => m [Target] -- | Add another target. addTarget :: GhcMonad m => Target -> m () -- | Remove a target removeTarget :: GhcMonad m => TargetId -> m () -- | Attempts to guess what Target a string refers to. This function -- implements the --make/GHCi command-line syntax for filenames: -- --
-- `bar` -- ( ~ ) ---- --
-- T :: forall a b. a -> b -> T [a] ---- -- rather than: -- --
-- T :: forall a c. forall b. (c~[a]) => a -> b -> T c ---- -- The type variables are quantified in the order that the user wrote -- them. See Note [DataCon user type variable binders]. -- -- NB: If the constructor is part of a data instance, the result type -- mentions the family tycon, not the internal one. dataConWrapperType :: DataCon -> Type -- | Strictness/unpack annotations, from user; or, for imported DataCons, -- from the interface file The list is in one-to-one correspondence with -- the arity of the DataCon dataConSrcBangs :: DataCon -> [HsSrcBang] data StrictnessMark MarkedStrict :: StrictnessMark NotMarkedStrict :: StrictnessMark isMarkedStrict :: StrictnessMark -> Bool data Class classMethods :: Class -> [Id] classSCTheta :: Class -> [PredType] classTvsFds :: Class -> ([TyVar], [FunDep TyVar]) classATs :: Class -> [TyCon] pprFundeps :: Outputable a => [FunDep a] -> SDoc -- | A type-class instance. Note that there is some tricky laziness at work -- here. See Note [ClsInst laziness and the rough-match fields] for more -- details. data ClsInst instanceDFunId :: ClsInst -> DFunId pprInstance :: ClsInst -> SDoc pprInstanceHdr :: ClsInst -> SDoc -- | Pretty-prints a FamInst (type/data family instance) with its -- defining location. pprFamInst :: FamInst -> SDoc data FamInst data Type -- | Take a ForAllTy apart, returning the list of tycovars and the result -- type. This always succeeds, even if it returns only an empty list. -- Note that the result type returned may have free variables that were -- bound by a forall. splitForAllTyCoVars :: Type -> ([TyCoVar], Type) -- | Extract the function result type and panic if that is not possible funResultTy :: Type -> Type pprParendType :: Type -> SDoc pprTypeApp :: TyCon -> [Type] -> SDoc -- | The key type representing kinds in the compiler. type Kind = Type -- | A type of the form p of constraint kind represents a value -- whose type is the Haskell predicate p, where a predicate is -- what occurs before the => in a Haskell type. -- -- We use PredType as documentation to mark those types that we -- guarantee to have this kind. -- -- It can be expanded into its representation, but: -- --
-- f :: (Eq a) => a -> Int
-- g :: (?x :: Int -> Int) => a -> Int
-- h :: (r\l) => {r} => {l::Int | r}
--
--
-- Here the Eq a and ?x :: Int -> Int and
-- rl are all called "predicates"
type PredType = Type
-- | A collection of PredTypes
type ThetaType = [PredType]
pprForAll :: [TyCoVarBinder] -> SDoc
pprThetaArrowTy :: ThetaType -> SDoc
parseInstanceHead :: GhcMonad m => String -> m Type
getInstancesForType :: GhcMonad m => Type -> m [ClsInst]
-- | A global typecheckable-thing, essentially anything that has a name.
-- Not to be confused with a TcTyThing, which is also a
-- typecheckable thing but in the *local* context. See
-- GHC.Tc.Utils.Env for how to retrieve a TyThing given a
-- Name.
data TyThing
AnId :: Id -> TyThing
AConLike :: ConLike -> TyThing
ATyCon :: TyCon -> TyThing
ACoAxiom :: CoAxiom Branched -> TyThing
data FixityDirection
InfixL :: FixityDirection
InfixR :: FixityDirection
InfixN :: FixityDirection
defaultFixity :: Fixity
maxPrecedence :: Int
negateFixity :: Fixity
compareFixity :: Fixity -> Fixity -> (Bool, Bool)
-- | Captures the fixity of declarations as they are parsed. This is not
-- necessarily the same as the fixity declaration, as the normal fixity
-- may be overridden using parens or backticks.
data LexicalFixity
Prefix :: LexicalFixity
Infix :: LexicalFixity
-- | Source Location
data SrcLoc
RealSrcLoc :: !RealSrcLoc -> !Maybe BufPos -> SrcLoc
UnhelpfulLoc :: FastString -> SrcLoc
-- | Real Source Location
--
-- Represents a single point within a file
data RealSrcLoc
mkSrcLoc :: FastString -> Int -> Int -> SrcLoc
-- | Built-in "bad" SrcLoc values for particular locations
noSrcLoc :: SrcLoc
-- | Gives the filename of the SrcLoc
srcLocFile :: RealSrcLoc -> FastString
-- | Raises an error when used on a "bad" SrcLoc
srcLocLine :: RealSrcLoc -> Int
-- | Raises an error when used on a "bad" SrcLoc
srcLocCol :: RealSrcLoc -> Int
-- | Source Span
--
-- A SrcSpan identifies either a specific portion of a text file
-- or a human-readable description of a location.
data SrcSpan
RealSrcSpan :: !RealSrcSpan -> !Maybe BufSpan -> SrcSpan
UnhelpfulSpan :: !UnhelpfulSpanReason -> SrcSpan
-- | A SrcSpan delimits a portion of a text file. It could be
-- represented by a pair of (line,column) coordinates, but in fact we
-- optimise slightly by using more compact representations for
-- single-line and zero-length spans, both of which are quite common.
--
-- The end position is defined to be the column after the end of
-- the span. That is, a span of (1,1)-(1,2) is one character long, and a
-- span of (1,1)-(1,1) is zero characters long.
--
-- Real Source Span
data RealSrcSpan
-- | Create a SrcSpan between two points in a file
mkSrcSpan :: SrcLoc -> SrcLoc -> SrcSpan
-- | Create a SrcSpan corresponding to a single point
srcLocSpan :: SrcLoc -> SrcSpan
-- | Test if a SrcSpan is "good", i.e. has precise location
-- information
isGoodSrcSpan :: SrcSpan -> Bool
-- | Built-in "bad" SrcSpans for common sources of location
-- uncertainty
noSrcSpan :: SrcSpan
-- | Returns the location at the start of the SrcSpan or a "bad"
-- SrcSpan if that is unavailable
srcSpanStart :: SrcSpan -> SrcLoc
-- | Returns the location at the end of the SrcSpan or a "bad"
-- SrcSpan if that is unavailable
srcSpanEnd :: SrcSpan -> SrcLoc
srcSpanFile :: RealSrcSpan -> FastString
srcSpanStartLine :: RealSrcSpan -> Int
srcSpanEndLine :: RealSrcSpan -> Int
srcSpanStartCol :: RealSrcSpan -> Int
srcSpanEndCol :: RealSrcSpan -> Int
-- | We attach SrcSpans to lots of things, so let's have a datatype for it.
data GenLocated l e
L :: l -> e -> GenLocated l e
type Located = GenLocated SrcSpan
type RealLocated = GenLocated RealSrcSpan
noLoc :: e -> Located e
mkGeneralLocated :: String -> e -> Located e
getLoc :: GenLocated l e -> l
unLoc :: GenLocated l e -> e
getRealSrcSpan :: RealLocated a -> RealSrcSpan
unRealSrcSpan :: RealLocated a -> a
-- | Tests whether the two located things are equal
eqLocated :: Eq a => GenLocated l a -> GenLocated l a -> Bool
-- | Tests the ordering of the two located things
cmpLocated :: Ord a => GenLocated l a -> GenLocated l a -> Ordering
combineLocs :: Located a -> Located b -> SrcSpan
-- | Combine locations from two Located things and add them to a
-- third thing
addCLoc :: Located a -> Located b -> c -> Located c
-- | Strategies for ordering SrcSpans
leftmost_smallest :: SrcSpan -> SrcSpan -> Ordering
-- | Strategies for ordering SrcSpans
leftmost_largest :: SrcSpan -> SrcSpan -> Ordering
-- | Strategies for ordering SrcSpans
rightmost_smallest :: SrcSpan -> SrcSpan -> Ordering
-- | Determines whether a span encloses a given line and column index
spans :: SrcSpan -> (Int, Int) -> Bool
-- | Determines whether a span is enclosed by another one
isSubspanOf :: SrcSpan -> SrcSpan -> Bool
-- | GHC's own exception type error messages all take the form:
--
-- -- <location>: <error> -- ---- -- If the location is on the command line, or in GHC itself, then -- <location>="ghc". All of the error types below correspond to a -- <location> of "ghc", except for ProgramError (where the string -- is assumed to contain a location already, so we don't print one). data GhcException -- | Some other fatal signal (SIGHUP,SIGTERM) Signal :: Int -> GhcException -- | Prints the short usage msg after the error UsageError :: String -> GhcException -- | A problem with the command line arguments, but don't print usage. CmdLineError :: String -> GhcException -- | The impossible happened. Panic :: String -> GhcException PprPanic :: String -> SDoc -> GhcException -- | The user tickled something that's known not to work yet, but we're not -- counting it as a bug. Sorry :: String -> GhcException PprSorry :: String -> SDoc -> GhcException -- | An installation problem. InstallationError :: String -> GhcException -- | An error in the user's code, probably. ProgramError :: String -> GhcException PprProgramError :: String -> SDoc -> GhcException -- | Append a description of the given exception to this string. showGhcException :: SDocContext -> GhcException -> ShowS -- | An error thrown if the GHC API is used in an incorrect fashion. newtype GhcApiError GhcApiError :: String -> GhcApiError data Token -- | Return module source as token stream, including comments. -- -- The module must be in the module graph and its source must be -- available. Throws a SourceError on parse error. getTokenStream :: GhcMonad m => Module -> m [Located Token] -- | Give even more information on the source than getTokenStream -- This function allows reconstructing the source completely with -- showRichTokenStream. getRichTokenStream :: GhcMonad m => Module -> m [(Located Token, String)] -- | Take a rich token stream such as produced from -- getRichTokenStream and return source code almost identical to -- the original code (except for insignificant whitespace.) showRichTokenStream :: [(Located Token, String)] -> String -- | Given a source location and a StringBuffer corresponding to this -- location, return a rich token stream with the source associated to the -- tokens. addSourceToTokens :: RealSrcLoc -> StringBuffer -> [Located Token] -> [(Located Token, String)] -- | A pure interface to the module parser. parser :: String -> DynFlags -> FilePath -> (WarningMessages, Either ErrorMessages (Located HsModule)) -- | Exact print annotations exist so that tools can perform source to -- source conversions of Haskell code. They are used to keep track of the -- various syntactic keywords that are not otherwise captured in the AST. -- -- The wiki page describing this feature is -- https://gitlab.haskell.org/ghc/ghc/wikis/api-annotations -- https://gitlab.haskell.org/ghc/ghc/-/wikis/implementing-trees-that-grow/in-tree-api-annotations -- -- Note: in general the names of these are taken from the corresponding -- token, unless otherwise noted See note [exact print annotations] above -- for details of the usage data AnnKeywordId AnnAnyclass :: AnnKeywordId AnnAs :: AnnKeywordId AnnAt :: AnnKeywordId -- | ! AnnBang :: AnnKeywordId -- | '`' AnnBackquote :: AnnKeywordId AnnBy :: AnnKeywordId -- | case or lambda case AnnCase :: AnnKeywordId AnnClass :: AnnKeywordId -- | '#)' or '#-}' etc AnnClose :: AnnKeywordId -- | '|)' AnnCloseB :: AnnKeywordId -- | '|)', unicode variant AnnCloseBU :: AnnKeywordId -- | '}' AnnCloseC :: AnnKeywordId -- | '|]' AnnCloseQ :: AnnKeywordId -- | '|]', unicode variant AnnCloseQU :: AnnKeywordId -- | ')' AnnCloseP :: AnnKeywordId -- | '#)' AnnClosePH :: AnnKeywordId -- | ']' AnnCloseS :: AnnKeywordId AnnColon :: AnnKeywordId -- | as a list separator AnnComma :: AnnKeywordId -- | in a RdrName for a tuple AnnCommaTuple :: AnnKeywordId -- | '=>' AnnDarrow :: AnnKeywordId -- | '=>', unicode variant AnnDarrowU :: AnnKeywordId AnnData :: AnnKeywordId -- | '::' AnnDcolon :: AnnKeywordId -- | '::', unicode variant AnnDcolonU :: AnnKeywordId AnnDefault :: AnnKeywordId AnnDeriving :: AnnKeywordId AnnDo :: AnnKeywordId -- | . AnnDot :: AnnKeywordId -- | '..' AnnDotdot :: AnnKeywordId AnnElse :: AnnKeywordId AnnEqual :: AnnKeywordId AnnExport :: AnnKeywordId AnnFamily :: AnnKeywordId AnnForall :: AnnKeywordId -- | Unicode variant AnnForallU :: AnnKeywordId AnnForeign :: AnnKeywordId -- | for function name in matches where there are multiple equations for -- the function. AnnFunId :: AnnKeywordId AnnGroup :: AnnKeywordId -- | for CType AnnHeader :: AnnKeywordId AnnHiding :: AnnKeywordId AnnIf :: AnnKeywordId AnnImport :: AnnKeywordId AnnIn :: AnnKeywordId -- | 'infix' or 'infixl' or 'infixr' AnnInfix :: AnnKeywordId AnnInstance :: AnnKeywordId AnnLam :: AnnKeywordId -- | '<-' AnnLarrow :: AnnKeywordId -- | '<-', unicode variant AnnLarrowU :: AnnKeywordId AnnLet :: AnnKeywordId -- | The ⊸ unicode arrow AnnLollyU :: AnnKeywordId AnnMdo :: AnnKeywordId -- | - AnnMinus :: AnnKeywordId AnnModule :: AnnKeywordId AnnNewtype :: AnnKeywordId -- | where a name loses its location in the AST, this carries it AnnName :: AnnKeywordId AnnOf :: AnnKeywordId -- | '{-# DEPRECATED' etc. Opening of pragmas where the capitalisation of -- the string can be changed by the user. The actual text used is stored -- in a SourceText on the relevant pragma item. AnnOpen :: AnnKeywordId -- | '(|' AnnOpenB :: AnnKeywordId -- | '(|', unicode variant AnnOpenBU :: AnnKeywordId -- | '{' AnnOpenC :: AnnKeywordId -- | '[e|' or '[e||' AnnOpenE :: AnnKeywordId -- | '[|' AnnOpenEQ :: AnnKeywordId -- | '[|', unicode variant AnnOpenEQU :: AnnKeywordId -- | '(' AnnOpenP :: AnnKeywordId -- | '[' AnnOpenS :: AnnKeywordId -- | '(#' AnnOpenPH :: AnnKeywordId -- | prefix $ -- TemplateHaskell AnnDollar :: AnnKeywordId -- | prefix $$ -- TemplateHaskell AnnDollarDollar :: AnnKeywordId AnnPackageName :: AnnKeywordId AnnPattern :: AnnKeywordId -- | % -- for HsExplicitMult AnnPercent :: AnnKeywordId -- | '%1' -- for HsLinearArrow AnnPercentOne :: AnnKeywordId AnnProc :: AnnKeywordId AnnQualified :: AnnKeywordId -- | -> AnnRarrow :: AnnKeywordId -- | ->, unicode variant AnnRarrowU :: AnnKeywordId AnnRec :: AnnKeywordId AnnRole :: AnnKeywordId AnnSafe :: AnnKeywordId -- | ';' AnnSemi :: AnnKeywordId -- | ''' AnnSimpleQuote :: AnnKeywordId AnnSignature :: AnnKeywordId -- | static AnnStatic :: AnnKeywordId AnnStock :: AnnKeywordId AnnThen :: AnnKeywordId -- | double ''' AnnThTyQuote :: AnnKeywordId -- | ~ AnnTilde :: AnnKeywordId AnnType :: AnnKeywordId -- | () for types AnnUnit :: AnnKeywordId AnnUsing :: AnnKeywordId -- | e.g. INTEGER AnnVal :: AnnKeywordId -- | String value, will need quotes when output AnnValStr :: AnnKeywordId -- | '|' AnnVbar :: AnnKeywordId -- | via AnnVia :: AnnKeywordId AnnWhere :: AnnKeywordId -- | -< Annlarrowtail :: AnnKeywordId -- | -<, unicode variant AnnlarrowtailU :: AnnKeywordId -- | -> Annrarrowtail :: AnnKeywordId -- | ->, unicode variant AnnrarrowtailU :: AnnKeywordId -- | -<< AnnLarrowtail :: AnnKeywordId -- | -<<, unicode variant AnnLarrowtailU :: AnnKeywordId -- | >>- AnnRarrowtail :: AnnKeywordId -- | >>-, unicode variant AnnRarrowtailU :: AnnKeywordId data EpaComment EpaComment :: EpaCommentTok -> RealSrcSpan -> EpaComment [ac_tok] :: EpaComment -> EpaCommentTok -- | The location of the prior token, used in exact printing. The -- EpaComment appears as an LEpaComment containing its -- location. The difference between the end of the prior token and the -- start of this location is used for the spacing when exact printing the -- comment. [ac_prior_tok] :: EpaComment -> RealSrcSpan cyclicModuleErr :: [ModuleGraphNode] -> SDoc instance GHC.Show.Show GHC.GhcApiError instance GHC.Exception.Type.Exception GHC.GhcApiError instance GHC.DesugaredMod GHC.DesugaredModule instance GHC.TypecheckedMod GHC.TypecheckedModule instance GHC.TypecheckedMod GHC.DesugaredModule instance GHC.ParsedMod GHC.DesugaredModule instance GHC.ParsedMod GHC.TypecheckedModule instance GHC.Utils.Outputable.Outputable GHC.CoreModule instance GHC.ParsedMod GHC.ParsedModule module GHC.Runtime.Debugger -- | The :print & friends commands pprintClosureCommand :: GhcMonad m => Bool -> Bool -> String -> m () showTerm :: GhcMonad m => Term -> m SDoc pprTypeAndContents :: GhcMonad m => Id -> m SDoc module GHC.Driver.MakeFile doMkDependHS :: GhcMonad m => [FilePath] -> m () -- | This is the driver for the 'ghc --backpack' mode, which is a -- reimplementation of the "package manager" bits of Backpack directly in -- GHC. The basic method of operation is to compile packages and then -- directly insert them into GHC's in memory database. -- -- The compilation products of this mode aren't really suitable for -- Cabal, because GHC makes up component IDs for the things it builds and -- doesn't serialize out the database contents. But it's still handy for -- constructing tests. module GHC.Driver.Backpack -- | Entry point to compile a Backpack file. doBackpack :: [FilePath] -> Ghc () instance GHC.Classes.Eq GHC.Driver.Backpack.SessionType instance GHC.Driver.Session.HasDynFlags GHC.Driver.Backpack.BkpM instance GHC.Utils.Logger.HasLogger GHC.Driver.Backpack.BkpM instance GHC.Driver.Monad.GhcMonad GHC.Driver.Backpack.BkpM