--
• embed pure expressions (pure), and
• --
• sequence computations and combine their results -- (<*>).
• --
-- -- A minimal complete definition must include implementations of these -- functions satisfying the following laws: -- --
--
• identity
```pure id <*>
--   v = v```
• --
• composition
```pure (.) <*> u
--   <*> v <*> w = u <*> (v
--   <*> w)```
• --
• homomorphism
```pure f <*>
--   pure x = pure (f x)```
• --
• interchange
```u <*> pure y =
--   pure (\$ y) <*> u```
• --
-- -- The other methods have the following default definitions, which may be -- overridden with equivalent specialized implementations: -- --
--
• ```u *> v = pure (const id)
--   <*> u <*> v```
• --
• ```u <* v = pure const <*>
--   u <*> v```
• --
-- -- As a consequence of these laws, the Functor instance for -- f will satisfy -- --
--
• `fmap f x = pure f <*> x`
• --
-- -- If f is also a Monad, it should satisfy -- --
--
• `pure = return`
• --
• `(<*>) = ap`
• --
-- -- (which implies that pure and <*> satisfy the -- applicative functor laws). class Functor f => Applicative (f :: * -> *) pure :: Applicative f => a -> f a (<*>) :: Applicative f => f (a -> b) -> f a -> f b (*>) :: Applicative f => f a -> f b -> f b (<*) :: Applicative f => f a -> f b -> f a -- | An infix synonym for fmap. -- --

#### Examples

-- -- Convert from a Maybe Int to a -- Maybe String using show: -- --
```--   >>> 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 -- | Monads having fixed points with a 'knot-tying' semantics. Instances of -- MonadFix should satisfy the following laws: -- --
--
• purity mfix (return . h) = -- return (fix h)
• --
• left shrinking (or tightening) -- mfix (\x -> a >>= \y -> f x y) = a >>= \y -- -> mfix (\x -> f x y)
• --
• sliding mfix (liftM h . f) = -- liftM h (mfix (f . h)), for strict h.
• --
• nesting mfix (\x -> mfix (\y -- -> f x y)) = mfix (\x -> f x x)
• --
-- -- This class is used in the translation of the recursive do -- notation supported by GHC and Hugs. class Monad m => MonadFix (m :: * -> *) mfix :: MonadFix m => (a -> m a) -> m a -- | Monads in which IO computations may be embedded. Any monad -- built by applying a sequence of monad transformers to the IO -- monad will be an instance of this class. -- -- Instances should satisfy the following laws, which state that -- liftIO is a transformer of monads: -- --
--
• `liftIO . return = return`
• --
• ```liftIO (m >>= f) = liftIO m >>=
--   (liftIO . f)```
• --
--
• the final result: Left b, or
• --
• Right (a,str), where a is the next element in -- the stream, and str is a computation to get the rest of the -- stream.
• --
```--   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 [PhaseFailed] :: String -> ExitCode -> 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 :: GhcException -> String -> String 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 -- | Panics and asserts. sorry :: String -> a -- | Panic while pretending to return an unboxed int. You can't use the -- regular panic functions in expressions producing unboxed ints because -- they have the wrong kind. panicFastInt :: String -> FastInt -- | Throw an failed assertion exception for a given filename and line -- number. assertPanic :: String -> Int -> 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 but first outputs -- the message. -- --
```--   trace ("calling f with x = " ++ show x) (f x)
--   ```
-- -- 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 panicDoc :: String -> SDoc -> a sorryDoc :: String -> SDoc -> a panicDocFastInt :: String -> SDoc -> FastInt pgmErrorDoc :: String -> SDoc -> a -- | 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, Typeable)
--
--   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
--       deriving Typeable
--
--   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
--       deriving Typeable
--
--   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 (Typeable, 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 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 than it will be propogated up to the next -- enclosing exception handler. -- --
```--   try a = catch (Right `liftM` a) (return . Left)
--   ```
```--   (lengthExceeds xs n) = (length xs > n)
--   ```
lengthExceeds :: [a] -> Int -> Bool lengthIs :: [a] -> Int -> Bool lengthAtLeast :: [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 n
--    | length ls < n = atEndPred (n - length ls)
--    | otherwise     = atLenPred (drop n ls)
--   ```
atLength :: ([a] -> b) -> (Int -> b) -> [a] -> Int -> b equalLength :: [a] -> [b] -> Bool compareLength :: [a] -> [b] -> Ordering -- | True if length xs <= length ys leLength :: [a] -> [b] -> Bool isSingleton :: [a] -> Bool only :: [a] -> a singleton :: a -> [a] notNull :: [a] -> Bool snocView :: [a] -> Maybe ([a], a) isIn :: Eq a => String -> a -> [a] -> Bool isn'tIn :: Eq a => String -> a -> [a] -> Bool fstOf3 :: (a, b, c) -> a sndOf3 :: (a, b, c) -> b thirdOf3 :: (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) third3 :: (c -> d) -> (a, b, c) -> (a, b, d) uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d takeList :: [b] -> [a] -> [a] dropList :: [b] -> [a] -> [a] splitAtList :: [b] -> [a] -> ([a], [a]) split :: Char -> String -> [String] dropTail :: Int -> [a] -> [a] -- | Compose a function with itself n times. (nth rather than twice) nTimes :: Int -> (a -> a) -> (a -> a) sortWith :: Ord b => (a -> b) -> [a] -> [a] minWith :: Ord b => (a -> b) -> [a] -> a nubSort :: 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 cmpList :: (a -> a -> Ordering) -> [a] -> [a] -> Ordering removeSpaces :: String -> String 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 looksLikeModuleName :: String -> Bool getCmd :: String -> Either String (String, String) toCmdArgs :: String -> Either String (String, [String]) toArgs :: String -> Either String [String] readRational :: String -> Rational maybeRead :: Read a => String -> Maybe a maybeReadFuzzy :: Read a => String -> Maybe a doesDirNameExist :: FilePath -> IO Bool getModificationUTCTime :: FilePath -> IO UTCTime modificationTimeIfExists :: FilePath -> IO (Maybe UTCTime) global :: a -> IORef a consIORef :: IORef [a] -> a -> IO () globalM :: IO a -> IORef 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
--   ```
-- -- 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 -- | There are two principal string types used internally by GHC: -- --
-- --
--
• A compact, hash-consed, representation of character strings.
• --
• Comparison is O(1), and you can get a Unique from -- them.
• --
• Generated by fsLit.
• --
• Turn into SDoc with ftext.
• --
-- --
-- --
--
• Just a wrapper for the Addr# of a C string (Ptr -- CChar).
• --
• Practically no operations.
• --
• Outputing them is fast.
• --
• Generated by sLit.
• --
• Turn into SDoc with ptext
• --
-- -- Use LitString unless you want the facilities of -- FastString. module FastString fastStringToByteString :: FastString -> ByteString -- | Create a FastString from an existing ForeignPtr; the -- difference between this and mkFastStringBytes is that we don't -- have to copy the bytes if the string is new to the table. mkFastStringByteString :: ByteString -> FastString fastZStringToByteString :: FastZString -> ByteString unsafeMkByteString :: String -> ByteString hashByteString :: ByteString -> Int data FastZString hPutFZS :: Handle -> FastZString -> IO () zString :: FastZString -> String lengthFZS :: FastZString -> Int -- | A FastString is an array of bytes, hashed to support fast O(1) -- comparison. It is also associated with a character encoding, so that -- we know how to convert a FastString to the local encoding, or -- to the Z-encoding used by the compiler internally. -- -- FastStrings support a memoized conversion to the Z-encoding via -- zEncodeFS. data FastString [FastString] :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !ByteString -> {-# UNPACK #-} !(IORef (Maybe FastZString)) -> FastString [uniq] :: FastString -> {-# UNPACK #-} !Int [n_chars] :: FastString -> {-# UNPACK #-} !Int [fs_bs] :: FastString -> {-# UNPACK #-} !ByteString [fs_ref] :: FastString -> {-# UNPACK #-} !(IORef (Maybe FastZString)) fsLit :: String -> FastString -- | Creates a UTF-8 encoded FastString from a String mkFastString :: String -> FastString mkFastStringBytes :: Ptr Word8 -> Int -> FastString -- | Creates a FastString from a UTF-8 encoded [Word8] mkFastStringByteList :: [Word8] -> FastString -- | Create a FastString from an existing ForeignPtr; the -- difference between this and mkFastStringBytes is that we don't -- have to copy the bytes if the string is new to the table. mkFastStringForeignPtr :: Ptr Word8 -> ForeignPtr Word8 -> Int -> IO FastString mkFastString# :: Addr# -> FastString -- | Unpacks and decodes the FastString unpackFS :: FastString -> String -- | Gives the UTF-8 encoded bytes corresponding to a FastString bytesFS :: FastString -> [Word8] -- | Returns a Z-encoded version of a FastString. This might be the -- original, if it was already Z-encoded. The first time this function is -- applied to a particular FastString, the results are memoized. zEncodeFS :: FastString -> FastZString uniqueOfFS :: FastString -> FastInt -- | Returns the length of the FastString in characters lengthFS :: FastString -> Int -- | Returns True if the FastString is empty nullFS :: FastString -> Bool appendFS :: FastString -> FastString -> FastString headFS :: FastString -> Char tailFS :: FastString -> FastString concatFS :: [FastString] -> FastString consFS :: Char -> FastString -> FastString nilFS :: FastString -- | Outputs a FastString with no decoding at all, that is, -- you get the actual bytes in the FastString written to the -- Handle. hPutFS :: Handle -> FastString -> IO () getFastStringTable :: IO [[FastString]] -- | Returns True if this FastString is not Z-encoded but -- already has a Z-encoding cached (used in producing stats). hasZEncoding :: FastString -> Bool type LitString = Ptr Word8 sLit :: String -> LitString mkLitString# :: Addr# -> LitString mkLitString :: String -> LitString unpackLitString :: LitString -> String lengthLS :: LitString -> Int instance Eq FastString instance Ord FastString instance Show FastString instance Data FastString module BufWrite data BufHandle [BufHandle] :: {-# UNPACK #-} !(Ptr Word8) -> {-# UNPACK #-} !FastMutInt -> Handle -> BufHandle newBufHandle :: Handle -> IO BufHandle bPutChar :: BufHandle -> Char -> IO () bPutStr :: BufHandle -> String -> IO () bPutFS :: BufHandle -> FastString -> IO () bPutFZS :: BufHandle -> FastZString -> IO () bPutLitString :: BufHandle -> LitString -> FastInt -> IO () bFlush :: BufHandle -> IO () module Pretty data Doc data Mode [PageMode] :: Mode [ZigZagMode] :: Mode [LeftMode] :: Mode [OneLineMode] :: Mode data TextDetails [Chr] :: {-# UNPACK #-} !Char -> TextDetails [Str] :: String -> TextDetails [PStr] :: FastString -> TextDetails [ZStr] :: FastZString -> TextDetails [LStr] :: {-# UNPACK #-} !LitString -> FastInt -> TextDetails empty :: Doc isEmpty :: Doc -> Bool nest :: Int -> Doc -> Doc char :: Char -> Doc text :: String -> Doc ftext :: FastString -> Doc ptext :: LitString -> Doc ztext :: FastZString -> Doc -- | Some text, but without any width. Use for non-printing text such as a -- HTML or Latex tags zeroWidthText :: String -> Doc int :: Int -> Doc integer :: Integer -> Doc float :: Float -> Doc double :: Double -> Doc rational :: Rational -> Doc parens :: Doc -> Doc brackets :: Doc -> Doc braces :: Doc -> Doc quotes :: Doc -> Doc quote :: Doc -> Doc doubleQuotes :: Doc -> Doc semi :: Doc comma :: Doc colon :: Doc space :: Doc equals :: Doc lparen :: Doc rparen :: Doc lbrack :: Doc rbrack :: Doc lbrace :: Doc rbrace :: Doc cparen :: Bool -> Doc -> Doc (<>) :: Doc -> Doc -> Doc (<+>) :: Doc -> Doc -> Doc hcat :: [Doc] -> Doc hsep :: [Doc] -> Doc (\$\$) :: Doc -> Doc -> Doc (\$+\$) :: Doc -> Doc -> Doc vcat :: [Doc] -> Doc sep :: [Doc] -> Doc cat :: [Doc] -> Doc fsep :: [Doc] -> Doc fcat :: [Doc] -> Doc hang :: Doc -> Int -> Doc -> Doc punctuate :: Doc -> [Doc] -> [Doc] fullRender :: Mode -> Int -> Float -> (TextDetails -> a -> a) -> a -> Doc -> a printDoc :: Mode -> Int -> Handle -> Doc -> IO () printDoc_ :: Mode -> Int -> Handle -> Doc -> IO () showDoc :: Mode -> Int -> Doc -> String bufLeftRender :: BufHandle -> Doc -> IO () instance Show Doc -- | This module defines classes and functions for pretty-printing. It also -- exports a number of helpful debugging and other utilities such as -- trace and panic. -- -- The interface to this module is very similar to the standard Hughes-PJ -- pretty printing module, except that it exports a number of additional -- functions that are rarely used, and works over the SDoc type. module Outputable -- | Class designating that some type has an SDoc representation class Outputable a where ppr = pprPrec 0 pprPrec _ = ppr ppr :: Outputable a => a -> SDoc pprPrec :: Outputable a => Rational -> a -> SDoc -- | When we print a binder, we often want to print its type too. The -- OutputableBndr class encapsulates this idea. class Outputable a => OutputableBndr a where pprBndr _b x = ppr x pprBndr :: OutputableBndr a => BindingSite -> a -> SDoc pprPrefixOcc, pprInfixOcc :: OutputableBndr a => a -> SDoc data SDoc runSDoc :: SDoc -> SDocContext -> Doc initSDocContext :: DynFlags -> PprStyle -> SDocContext docToSDoc :: Doc -> SDoc -- | Returns the separated concatenation of the pretty printed things. interppSP :: Outputable a => [a] -> SDoc -- | Returns the comma-separated concatenation of the pretty printed -- things. interpp'SP :: Outputable a => [a] -> SDoc -- | Returns the comma-separated concatenation of the quoted pretty printed -- things. -- --
```--   [x,y,z]  ==>  `x', `y', `z'
--   ```
pprQuotedList :: Outputable a => [a] -> SDoc pprWithCommas :: (a -> SDoc) -> [a] -> SDoc quotedListWithOr :: [SDoc] -> SDoc empty :: SDoc -- | Indent SDoc some specified amount nest :: Int -> SDoc -> SDoc char :: Char -> SDoc text :: String -> SDoc ftext :: FastString -> SDoc ptext :: LitString -> SDoc ztext :: FastZString -> SDoc int :: Int -> SDoc intWithCommas :: Integral a => a -> SDoc integer :: Integer -> SDoc float :: Float -> SDoc double :: Double -> SDoc rational :: Rational -> 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 paBrackets :: SDoc -> SDoc semi :: SDoc comma :: SDoc colon :: SDoc dcolon :: SDoc space :: SDoc equals :: SDoc dot :: SDoc arrow :: SDoc larrow :: SDoc darrow :: SDoc arrowt :: SDoc larrowt :: SDoc arrowtt :: SDoc larrowtt :: SDoc lparen :: SDoc rparen :: SDoc lbrack :: SDoc rbrack :: SDoc lbrace :: SDoc rbrace :: SDoc underscore :: SDoc blankLine :: SDoc forAllLit :: 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 punctuate :: SDoc -> [SDoc] -> [SDoc] ppWhen :: Bool -> SDoc -> SDoc ppUnless :: 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 a strictly positive integer into a number of times: -- --
```--   speakNTimes 1 = text "once"
--   speakNTimes 2 = text "twice"
--   speakNTimes 4 = text "4 times"
--   ```
speakNTimes :: 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 [] = ptext (sLit "are")
--   isOrAre ["Hello"] = ptext (sLit "is")
--   isOrAre ["Hello", "World"] = ptext (sLit "are")
--   ```
isOrAre :: [a] -> SDoc -- | Apply the given colour/style for the argument. -- -- Only takes effect if colours are enabled. coloured :: PprColour -> SDoc -> SDoc -- | A colour/style for use with coloured. data PprColour colType :: PprColour colCoerc :: PprColour colDataCon :: PprColour colBinder :: PprColour bold :: SDoc -> SDoc keyword :: SDoc -> SDoc printForC :: DynFlags -> Handle -> SDoc -> IO () printForAsm :: DynFlags -> Handle -> SDoc -> IO () printForUser :: DynFlags -> Handle -> PrintUnqualified -> SDoc -> IO () printForUserPartWay :: DynFlags -> Handle -> Int -> PrintUnqualified -> SDoc -> IO () pprCode :: CodeStyle -> SDoc -> SDoc mkCodeStyle :: CodeStyle -> PprStyle showSDoc :: DynFlags -> SDoc -> String showSDocUnsafe :: SDoc -> String showSDocOneLine :: DynFlags -> SDoc -> String showSDocForUser :: DynFlags -> PrintUnqualified -> SDoc -> String showSDocDebug :: DynFlags -> SDoc -> String showSDocDump :: DynFlags -> SDoc -> String showSDocDumpOneLine :: DynFlags -> SDoc -> String showSDocUnqual :: DynFlags -> SDoc -> String showPpr :: Outputable a => DynFlags -> a -> String renderWithStyle :: DynFlags -> SDoc -> PprStyle -> 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 string literals. pprHsBytes :: ByteString -> SDoc pprFastFilePath :: FastString -> 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. data BindingSite [LambdaBind] :: BindingSite [CaseBind] :: BindingSite [LetBind] :: BindingSite data PprStyle data CodeStyle [CStyle] :: CodeStyle [AsmStyle] :: CodeStyle -- | 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 an original name, this function tells you which module -- name it should be qualified with when printing for the user, if any. -- For example, given Control.Exception.catch, which is in scope -- as Exception.catch, this fuction will return Just -- Exception. Note that the return value is a ModuleName, not -- a Module, because in source code, names are qualified by ModuleNames. 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 -- package key to disambiguate it. type QueryQualifyPackage = PackageKey -> 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 data QualifyName [NameUnqual] :: QualifyName [NameQual] :: ModuleName -> QualifyName [NameNotInScope1] :: QualifyName [NameNotInScope2] :: QualifyName queryQual :: PprStyle -> PrintUnqualified sdocWithDynFlags :: (DynFlags -> SDoc) -> SDoc sdocWithPlatform :: (Platform -> SDoc) -> SDoc getPprStyle :: (PprStyle -> SDoc) -> SDoc withPprStyle :: PprStyle -> SDoc -> SDoc withPprStyleDoc :: DynFlags -> PprStyle -> SDoc -> Doc pprDeeper :: SDoc -> SDoc pprDeeperList :: ([SDoc] -> SDoc) -> [SDoc] -> SDoc pprSetDepth :: Depth -> SDoc -> SDoc codeStyle :: PprStyle -> Bool userStyle :: PprStyle -> Bool debugStyle :: PprStyle -> Bool dumpStyle :: PprStyle -> Bool asmStyle :: PprStyle -> Bool ifPprDebug :: SDoc -> SDoc qualName :: PprStyle -> QueryQualifyName qualModule :: PprStyle -> QueryQualifyModule qualPackage :: PprStyle -> QueryQualifyPackage -- | Style for printing error messages mkErrStyle :: DynFlags -> PrintUnqualified -> PprStyle defaultErrStyle :: DynFlags -> PprStyle defaultDumpStyle :: PprStyle mkDumpStyle :: PrintUnqualified -> PprStyle defaultUserStyle :: PprStyle mkUserStyle :: PrintUnqualified -> Depth -> PprStyle cmdlineParserStyle :: PprStyle data Depth [AllTheWay] :: Depth [PartWay] :: Int -> Depth -- | Throw an exception saying "bug in GHC" pprPanic :: String -> SDoc -> a -- | Throw an exception saying "this isn't finished yet" pprSorry :: String -> SDoc -> a -- | Panic with an assertation failure, recording the given file and line -- number. Should typically be accessed with the ASSERT family of macros assertPprPanic :: String -> Int -> SDoc -> a -- | Specialization of pprPanic that can be safely used with FastInt pprPanicFastInt :: String -> SDoc -> FastInt -- | Throw an exception saying "bug in pgm being compiled" (used for -- unusual program errors) pprPgmError :: String -> SDoc -> a -- | If debug output is on, show some SDoc on the screen pprTrace :: String -> SDoc -> a -> a -- | Just warn about an assertion failure, recording the given file and -- line number. Should typically be accessed with the WARN macros warnPprTrace :: Bool -> String -> Int -> SDoc -> a -> 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 but first outputs -- the message. -- --
```--   trace ("calling f with x = " ++ show x) (f x)
--   ```
```--   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 }
--   ```
```--   -#includes
--   ```
--
• If a program uses Template Haskell the typechecker may try to run -- code from an imported module. This will fail if no code has been -- generated for this module. You can use needsTemplateHaskell to -- detect whether this might be the case and choose to either switch to a -- different target or avoid typechecking such modules. (The latter may -- be preferable for security reasons.)
• --
data HscTarget -- | Generate C code. [HscC] :: HscTarget -- | Generate assembly using the native code generator. [HscAsm] :: HscTarget -- | Generate assembly using the llvm code generator. [HscLlvm] :: HscTarget -- | Generate bytecode. (Requires LinkInMemory) [HscInterpreted] :: HscTarget -- | Don't generate any code. See notes above. [HscNothing] :: HscTarget -- | Will this target result in an object file on the disk? isObjectTarget :: HscTarget -> Bool -- | The HscTarget value corresponding to the default way to create -- object files on the current platform. defaultObjectTarget :: Platform -> HscTarget -- | Does this target retain *all* top-level bindings for a module, rather -- than just the exported bindings, in the TypeEnv and compiled code (if -- any)? In interpreted mode we do this, so that GHCi can call functions -- inside a module. In HscNothing mode we also do it, so that Haddock can -- get access to the GlobalRdrEnv for a module after typechecking it. targetRetainsAllBindings :: HscTarget -> 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 -- 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
--   ```
```--   id1
--   id2
--   ..
--   idn
--   ```
-- -- we interpret this as -- --
```--   [ -hide-all-packages
--   , -package-id id1
--   , -package-id id2
--   , ..
--   , -package-id idn
--   ]
--   ```
module OccName data NameSpace nameSpacesRelated :: NameSpace -> NameSpace -> Bool tcName :: NameSpace clsName :: NameSpace tcClsName :: NameSpace dataName :: NameSpace varName :: NameSpace tvName :: NameSpace srcDataName :: NameSpace pprNameSpace :: NameSpace -> SDoc pprNonVarNameSpace :: NameSpace -> SDoc pprNameSpaceBrief :: NameSpace -> SDoc data OccName pprOccName :: OccName -> SDoc mkOccName :: NameSpace -> String -> OccName mkOccNameFS :: NameSpace -> FastString -> OccName mkVarOcc :: String -> OccName mkVarOccFS :: FastString -> OccName mkDataOcc :: String -> OccName mkDataOccFS :: FastString -> OccName mkTyVarOcc :: String -> OccName mkTyVarOccFS :: FastString -> OccName mkTcOcc :: String -> OccName mkTcOccFS :: FastString -> OccName mkClsOcc :: String -> OccName mkClsOccFS :: FastString -> OccName mkDFunOcc :: String -> Bool -> OccSet -> OccName setOccNameSpace :: NameSpace -> OccName -> OccName demoteOccName :: OccName -> Maybe OccName -- | 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 isDerivedOccName :: OccName -> Bool mkDataConWrapperOcc :: OccName -> OccName mkWorkerOcc :: OccName -> OccName mkMatcherOcc :: OccName -> OccName mkBuilderOcc :: OccName -> OccName mkDefaultMethodOcc :: OccName -> OccName mkGenDefMethodOcc :: OccName -> OccName mkDerivedTyConOcc :: OccName -> OccName mkNewTyCoOcc :: OccName -> OccName mkClassOpAuxOcc :: OccName -> OccName mkCon2TagOcc :: OccName -> OccName mkTag2ConOcc :: OccName -> OccName mkMaxTagOcc :: OccName -> OccName mkClassDataConOcc :: OccName -> OccName mkDictOcc :: OccName -> OccName mkIPOcc :: OccName -> OccName mkSpecOcc :: OccName -> OccName mkForeignExportOcc :: OccName -> OccName mkRepEqOcc :: OccName -> OccName mkGenOcc1 :: OccName -> OccName mkGenOcc2 :: OccName -> OccName mkGenD :: OccName -> OccName mkGenR :: OccName -> OccName mkGen1R :: OccName -> OccName mkGenRCo :: OccName -> OccName mkGenC :: OccName -> Int -> OccName mkGenS :: OccName -> Int -> Int -> OccName mkDataTOcc :: OccName -> OccName mkDataCOcc :: OccName -> OccName mkDataConWorkerOcc :: OccName -> OccName mkSuperDictSelOcc :: Int -> OccName -> OccName mkLocalOcc :: Unique -> OccName -> OccName mkMethodOcc :: OccName -> OccName -- | Derive a name for the representation type constructor of a -- data/newtype instance. mkInstTyTcOcc :: String -> OccSet -> OccName mkInstTyCoOcc :: OccName -> OccName mkEqPredCoOcc :: OccName -> OccName mkVectOcc :: Maybe String -> OccName -> OccName mkVectTyConOcc :: Maybe String -> OccName -> OccName mkVectDataConOcc :: Maybe String -> OccName -> OccName mkVectIsoOcc :: Maybe String -> OccName -> OccName mkPDataTyConOcc :: Maybe String -> OccName -> OccName mkPDataDataConOcc :: Maybe String -> OccName -> OccName mkPDatasTyConOcc :: Maybe String -> OccName -> OccName mkPDatasDataConOcc :: Maybe String -> OccName -> OccName mkPReprTyConOcc :: Maybe String -> OccName -> OccName mkPADFunOcc :: Maybe String -> OccName -> OccName occNameFS :: OccName -> FastString occNameString :: OccName -> String occNameSpace :: OccName -> NameSpace isVarOcc :: OccName -> Bool isTvOcc :: OccName -> Bool isTcOcc :: OccName -> Bool isDataOcc :: OccName -> Bool -- | Test if the OccName is a data constructor that starts with a -- symbol (e.g. :, or []) isDataSymOcc :: OccName -> Bool -- | Test if the OccName is that for any operator (whether it is a -- data constructor or variable or whatever) isSymOcc :: OccName -> Bool -- | Value OccNamess are those that are either in the -- variable or data constructor namespaces isValOcc :: OccName -> Bool -- | Wrap parens around an operator parenSymOcc :: OccName -> SDoc -> SDoc -- | Haskell 98 encourages compilers to suppress warnings about unsed names -- in a pattern if they start with _: this implements that test startsWithUnderscore :: OccName -> Bool isTcClsNameSpace :: NameSpace -> Bool isTvNameSpace :: NameSpace -> Bool isDataConNameSpace :: NameSpace -> Bool isVarNameSpace :: NameSpace -> Bool isValNameSpace :: NameSpace -> Bool data OccEnv a emptyOccEnv :: OccEnv a unitOccEnv :: OccName -> a -> OccEnv a extendOccEnv :: OccEnv a -> OccName -> a -> OccEnv a mapOccEnv :: (a -> b) -> OccEnv a -> OccEnv b lookupOccEnv :: OccEnv a -> OccName -> Maybe a mkOccEnv :: [(OccName, a)] -> OccEnv a mkOccEnv_C :: (a -> a -> a) -> [(OccName, a)] -> OccEnv a extendOccEnvList :: OccEnv a -> [(OccName, a)] -> OccEnv a elemOccEnv :: OccName -> OccEnv a -> Bool occEnvElts :: OccEnv a -> [a] foldOccEnv :: (a -> b -> b) -> b -> OccEnv a -> b plusOccEnv :: OccEnv a -> OccEnv a -> OccEnv a plusOccEnv_C :: (a -> a -> a) -> OccEnv a -> OccEnv a -> OccEnv a extendOccEnv_C :: (a -> a -> a) -> OccEnv a -> OccName -> a -> OccEnv a extendOccEnv_Acc :: (a -> b -> b) -> (a -> b) -> OccEnv b -> OccName -> a -> OccEnv b filterOccEnv :: (elt -> Bool) -> OccEnv elt -> OccEnv elt delListFromOccEnv :: OccEnv a -> [OccName] -> OccEnv a delFromOccEnv :: OccEnv a -> OccName -> OccEnv a alterOccEnv :: (Maybe elt -> Maybe elt) -> OccEnv elt -> OccName -> OccEnv elt pprOccEnv :: (a -> SDoc) -> OccEnv a -> SDoc type OccSet = UniqSet OccName emptyOccSet :: OccSet unitOccSet :: OccName -> OccSet mkOccSet :: [OccName] -> OccSet extendOccSet :: OccSet -> OccName -> OccSet extendOccSetList :: OccSet -> [OccName] -> OccSet unionOccSets :: OccSet -> OccSet -> OccSet unionManyOccSets :: [OccSet] -> OccSet minusOccSet :: OccSet -> OccSet -> OccSet elemOccSet :: OccName -> OccSet -> Bool occSetElts :: OccSet -> [OccName] foldOccSet :: (OccName -> b -> b) -> b -> OccSet -> b isEmptyOccSet :: OccSet -> Bool intersectOccSet :: OccSet -> OccSet -> OccSet intersectsOccSet :: OccSet -> OccSet -> Bool type TidyOccEnv = UniqFM Int emptyTidyOccEnv :: TidyOccEnv tidyOccName :: TidyOccEnv -> OccName -> (TidyOccEnv, OccName) initTidyOccEnv :: [OccName] -> TidyOccEnv type FastStringEnv a = UniqFM a emptyFsEnv :: FastStringEnv a lookupFsEnv :: FastStringEnv a -> FastString -> Maybe a extendFsEnv :: FastStringEnv a -> FastString -> a -> FastStringEnv a mkFsEnv :: [(FastString, a)] -> FastStringEnv a instance Ord NameSpace instance Eq NameSpace instance Eq OccName instance Ord OccName instance Data OccName instance HasOccName OccName instance Outputable OccName instance OutputableBndr OccName instance Uniquable OccName instance Outputable a => Outputable (OccEnv a) instance Binary NameSpace instance Binary OccName module HsImpExp type LImportDecl name = Located (ImportDecl name) When in a list this may have - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnSemi' -- | A single Haskell import declaration. data ImportDecl name -- | AnnKeywordIds -- --
[ImportDecl] :: Maybe SourceText -> Located ModuleName -> Maybe FastString -> Bool -> Bool -> Bool -> Bool -> Maybe ModuleName -> Maybe (Bool, Located [LIE name]) -> ImportDecl name [ideclSourceSrc] :: ImportDecl name -> Maybe SourceText -- | Module name. [ideclName] :: ImportDecl name -> Located ModuleName -- | Package qualifier. [ideclPkgQual] :: ImportDecl name -> Maybe FastString -- | True = {-# SOURCE #-} import [ideclSource] :: ImportDecl name -> Bool -- | True => safe import [ideclSafe] :: ImportDecl name -> Bool -- | True => qualified [ideclQualified] :: ImportDecl name -> Bool -- | True => implicit import (of Prelude) [ideclImplicit] :: ImportDecl name -> Bool -- | as Module [ideclAs] :: ImportDecl name -> Maybe ModuleName -- | (True => hiding, names) [ideclHiding] :: ImportDecl name -> Maybe (Bool, Located [LIE name]) simpleImportDecl :: ModuleName -> ImportDecl name type LIE name = Located (IE name) When in a list this may have - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnComma' -- | Imported or exported entity. data IE name -- |
[IEVar] :: (Located name) -> IE name -- | Class/Type (can't tell) - AnnKeywordIds : AnnPattern, -- AnnType,AnnVal [IEThingAbs] :: (Located name) -> IE name -- | ClassType plus all methodsconstructors -- --
[IEThingAll] :: (Located name) -> IE name -- | ClassType plus some methodsconstructors - AnnKeywordIds -- : AnnOpen, AnnClose, AnnComma, AnnType [IEThingWith] :: (Located name) -> [Located name] -> IE name -- | (Export Only) -- --
data CType [CType] :: SourceText -> (Maybe Header) -> FastString -> CType instance Data CType instance Data Header instance Eq Header instance Data CExportSpec instance Eq ForeignCall instance Eq CCallSpec instance Data CCallTarget instance Eq CCallTarget instance Data CCallConv instance Eq CCallConv instance Data Safety instance Show Safety instance Eq Safety instance Outputable ForeignCall instance Outputable Safety instance Outputable CCallConv instance Outputable CExportSpec instance Outputable CCallSpec instance Outputable Header instance Outputable CType instance Binary ForeignCall instance Binary Safety instance Binary CExportSpec instance Binary CCallSpec instance Binary CCallTarget instance Binary CCallConv instance Binary CType instance Binary Header -- | 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 BooleanFormula data BooleanFormula a [Var] :: a -> BooleanFormula a [And] :: [BooleanFormula a] -> BooleanFormula a [Or] :: [BooleanFormula a] -> BooleanFormula a mkFalse :: BooleanFormula a mkTrue :: BooleanFormula a mkAnd :: Eq a => [BooleanFormula a] -> BooleanFormula a mkOr :: Eq a => [BooleanFormula 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 :: Eq 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 Traversable BooleanFormula instance Foldable BooleanFormula instance Functor BooleanFormula instance Data a => Data (BooleanFormula a) instance Eq a => Eq (BooleanFormula a) instance Outputable a => Outputable (BooleanFormula a) instance Binary a => Binary (BooleanFormula a) module Serialized -- | Represents a serialized value of a particular type. Attempts can be -- made to deserialize it at certain types data Serialized -- | Force the contents of the Serialized value so weknow it doesn't -- contain any bottoms seqSerialized :: Serialized -> () -- | Put a Typeable value that we are able to actually turn into bytes into -- a Serialized value ready for deserialization later toSerialized :: Typeable a => (a -> [Word8]) -> a -> Serialized -- | If the Serialized value contains something of the given type, -- then use the specified deserializer to return Just that. -- Otherwise return Nothing. fromSerialized :: Typeable a => ([Word8] -> a) -> Serialized -> Maybe a -- | Use a Data instance to implement a serialization scheme dual to -- that of deserializeWithData serializeWithData :: Data a => a -> [Word8] -- | Use a Data instance to implement a deserialization scheme dual -- to that of serializeWithData deserializeWithData :: Data a => [Word8] -> a instance Outputable Serialized instance Binary Serialized -- | GHC uses several kinds of name internally: -- --
-- -- Names are one of: -- --
--
• External, if they name things declared in other modules. Some -- external Names are wired in, i.e. they name primitives defined in the -- compiler itself
• --
• Internal, if they name things in the module being compiled. Some -- internal Names are system names, if they are names manufactured by the -- compiler
• --
module Name -- | A unique, unambigious name for something, containing information about -- where that thing originated. data Name -- | 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 -- | Create a name brought into being by the compiler mkSystemName :: Unique -> OccName -> Name mkSystemNameAt :: Unique -> OccName -> SrcSpan -> 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 mkClonedInternalName :: Unique -> Name -> Name mkDerivedInternalName :: (OccName -> OccName) -> Unique -> Name -> Name mkSystemVarName :: Unique -> FastString -> Name mkSysTvName :: Unique -> FastString -> Name -- | Make a name for a foreign call mkFCallName :: Unique -> String -> Name -- | Create a name which definitely originates in the given module mkExternalName :: Unique -> Module -> OccName -> SrcSpan -> Name -- | Create a name which is actually defined by the compiler itself mkWiredInName :: Module -> OccName -> Unique -> TyThing -> BuiltInSyntax -> Name nameUnique :: Name -> Unique setNameUnique :: Name -> Unique -> Name nameOccName :: Name -> OccName nameModule :: Name -> Module nameModule_maybe :: Name -> Maybe Module setNameLoc :: Name -> SrcSpan -> Name tidyNameOcc :: Name -> OccName -> Name -- | Make the Name into an internal name, regardless of what it was -- to begin with localiseName :: Name -> Name -- | Create a localised variant of a name. -- -- If the name is external, encode the original's module name to -- disambiguate. SPJ says: this looks like a rather odd-looking function; -- but it seems to be used only during vectorisation, so I'm not going to -- worry mkLocalisedOccName :: Module -> (Maybe String -> OccName -> OccName) -> Name -> OccName nameSrcLoc :: Name -> SrcLoc nameSrcSpan :: Name -> SrcSpan pprNameDefnLoc :: Name -> SDoc pprDefinedAt :: Name -> SDoc isSystemName :: Name -> Bool isInternalName :: Name -> Bool isExternalName :: Name -> Bool isTyVarName :: Name -> Bool isTyConName :: Name -> Bool isDataConName :: Name -> Bool isValName :: Name -> Bool isVarName :: Name -> Bool isWiredInName :: Name -> Bool isBuiltInSyntax :: Name -> Bool wiredInNameTyThing_maybe :: Name -> Maybe TyThing -- | 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 -- GCHi 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 HscTypes nameIsLocalOrFrom :: Module -> Name -> Bool stableNameCmp :: Name -> Name -> Ordering -- | A class allowing convenient access to the Name of various -- datatypes class NamedThing a where getOccName n = nameOccName (getName n) getOccName :: NamedThing a => a -> OccName getName :: NamedThing a => a -> Name getSrcLoc :: NamedThing a => a -> SrcLoc getSrcSpan :: NamedThing a => a -> SrcSpan getOccString :: NamedThing a => a -> String pprInfixName :: (Outputable a, NamedThing a) => a -> SDoc pprPrefixName :: (Outputable a, NamedThing a) => a -> SDoc pprModulePrefix :: PprStyle -> Module -> OccName -> SDoc instance HasOccName Name instance Eq Name instance Ord Name instance Uniquable Name instance NamedThing Name instance Data Name instance Binary Name instance Outputable Name instance OutputableBndr Name module NameEnv type NameEnv a = UniqFM a mkNameEnv :: [(Name, a)] -> NameEnv a emptyNameEnv :: NameEnv a unitNameEnv :: Name -> a -> NameEnv a nameEnvElts :: NameEnv a -> [a] nameEnvUniqueElts :: NameEnv a -> [(Unique, a)] extendNameEnv_C :: (a -> a -> a) -> NameEnv a -> Name -> a -> NameEnv a extendNameEnv_Acc :: (a -> b -> b) -> (a -> b) -> NameEnv b -> Name -> a -> NameEnv b extendNameEnv :: NameEnv a -> Name -> a -> NameEnv a extendNameEnvList :: NameEnv a -> [(Name, a)] -> NameEnv a extendNameEnvList_C :: (a -> a -> a) -> NameEnv a -> [(Name, a)] -> NameEnv a foldNameEnv :: (a -> b -> b) -> b -> NameEnv a -> b filterNameEnv :: (elt -> Bool) -> NameEnv elt -> NameEnv elt anyNameEnv :: (elt -> Bool) -> NameEnv elt -> Bool plusNameEnv :: NameEnv a -> NameEnv a -> NameEnv a plusNameEnv_C :: (a -> a -> a) -> NameEnv a -> NameEnv a -> NameEnv a alterNameEnv :: (Maybe a -> Maybe a) -> NameEnv a -> Name -> NameEnv a lookupNameEnv :: NameEnv a -> Name -> Maybe a lookupNameEnv_NF :: NameEnv a -> Name -> a delFromNameEnv :: NameEnv a -> Name -> NameEnv a delListFromNameEnv :: NameEnv a -> [Name] -> NameEnv a elemNameEnv :: Name -> NameEnv a -> Bool mapNameEnv :: (elt1 -> elt2) -> NameEnv elt1 -> NameEnv elt2 disjointNameEnv :: NameEnv a -> NameEnv a -> Bool depAnal :: (node -> [Name]) -> (node -> [Name]) -> [node] -> [SCC node] module NameSet type NameSet = UniqSet Name emptyNameSet :: NameSet unitNameSet :: Name -> NameSet mkNameSet :: [Name] -> NameSet unionNameSet :: NameSet -> NameSet -> NameSet unionNameSets :: [NameSet] -> NameSet minusNameSet :: NameSet -> NameSet -> NameSet elemNameSet :: Name -> NameSet -> Bool nameSetElems :: NameSet -> [Name] extendNameSet :: NameSet -> Name -> NameSet extendNameSetList :: NameSet -> [Name] -> NameSet delFromNameSet :: NameSet -> Name -> NameSet delListFromNameSet :: NameSet -> [Name] -> NameSet isEmptyNameSet :: NameSet -> Bool foldNameSet :: (Name -> b -> b) -> b -> NameSet -> b filterNameSet :: (Name -> Bool) -> NameSet -> NameSet -- | True if there is a non-empty intersection. s1 -- intersectsNameSet s2 doesn't compute s2 if -- s1 is empty intersectsNameSet :: NameSet -> NameSet -> Bool intersectNameSet :: NameSet -> NameSet -> NameSet type FreeVars = NameSet isEmptyFVs :: NameSet -> Bool emptyFVs :: FreeVars plusFVs :: [FreeVars] -> FreeVars plusFV :: FreeVars -> FreeVars -> FreeVars mkFVs :: [Name] -> FreeVars addOneFV :: FreeVars -> Name -> FreeVars unitFV :: Name -> FreeVars delFV :: Name -> FreeVars -> FreeVars delFVs :: [Name] -> FreeVars -> FreeVars -- | A set of names that are defined somewhere type Defs = NameSet -- | A set of names that are used somewhere type Uses = NameSet -- | (Just ds, us) => The use of any member of the ds -- implies that all the us are used too. Also, us may -- mention ds. -- -- Nothing => Nothing is defined in this group, but -- nevertheless all the uses are essential. Used for instance -- declarations, for example type DefUse = (Maybe Defs, Uses) -- | A number of DefUses in dependency order: earlier Defs -- scope over later Uses In a single (def, use) pair, the defs -- also scope over the uses type DefUses = [DefUse] emptyDUs :: DefUses usesOnly :: Uses -> DefUses mkDUs :: [(Defs, Uses)] -> DefUses plusDU :: DefUses -> DefUses -> DefUses -- | Given some DefUses and some Uses, find all the uses, -- transitively. The result is a superset of the input Uses; and -- includes things defined in the input DefUses (but only if they -- are used) findUses :: DefUses -> Uses -> Uses duDefs :: DefUses -> Defs -- | Collect all Uses, regardless of whether the group is itself -- used, but remove Defs on the way duUses :: DefUses -> Uses -- | Just like duUses, but Defs are not eliminated from the -- Uses returned allUses :: DefUses -> Uses module Avail -- | A collection of AvailInfo - several things that are "available" type Avails = [AvailInfo] -- | Records what things are "available", i.e. in scope data AvailInfo -- | An ordinary identifier in scope [Avail] :: Name -> AvailInfo -- | A type or class in scope. Parameters: -- -- 1) The name of the type or class 2) The available pieces of type or -- class. -- -- The AvailTC Invariant: * If the type or class is itself to be in -- scope, it must be *first* in this list. Thus, typically: AvailTC -- Eq [Eq, ==, /=] [AvailTC] :: Name -> [Name] -> AvailInfo availsToNameSet :: [AvailInfo] -> NameSet availsToNameEnv :: [AvailInfo] -> NameEnv AvailInfo -- | Just the main name made available, i.e. not the available pieces of -- type or class brought into scope by the GenAvailInfo availName :: AvailInfo -> Name -- | All names made available by the availability information availNames :: AvailInfo -> [Name] -- | Compare lexicographically stableAvailCmp :: AvailInfo -> AvailInfo -> Ordering instance Eq AvailInfo instance Outputable AvailInfo instance Binary AvailInfo module ConLike -- | A constructor-like thing data ConLike [RealDataCon] :: DataCon -> ConLike [PatSynCon] :: PatSyn -> ConLike instance Eq ConLike instance Ord ConLike instance Uniquable ConLike instance NamedThing ConLike instance Outputable ConLike instance OutputableBndr ConLike instance Data ConLike -- | GHC uses several kinds of name internally: -- --
module RdrName -- | Do not use the data constructors of RdrName directly: prefer the -- family of functions that creates them, such as mkRdrUnqual -- --
--
• Note: A Located RdrName will only have API Annotations if it is a -- compound one, e.g.
• --
-- --
```--   `bar`
--   ( ~ )
--   ```
-- --
data RdrName -- | Used for ordinary, unqualified occurrences, e.g. x, -- y or Foo. Create such a RdrName with -- mkRdrUnqual [Unqual] :: OccName -> RdrName -- | A qualified name written by the user in source code. The module -- isn't necessarily the module where the thing is defined; just the one -- from which it is imported. Examples are Bar.x, Bar.y -- or Bar.Foo. Create such a RdrName with -- mkRdrQual [Qual] :: ModuleName -> OccName -> RdrName -- | An original name; the module is the defining module. This is -- used when GHC generates code that will be fed into the renamer (e.g. -- from deriving clauses), but where we want to say "Use Prelude.map -- dammit". One of these can be created with mkOrig [Orig] :: Module -> OccName -> RdrName -- | We know exactly the Name. This is used: -- --
--
1. When the parser parses built-in syntax like [] and -- (,), but wants a RdrName from it
2. --
3. By Template Haskell, when TH has generated a unique name
4. --
-- -- Such a RdrName can be created by using getRdrName on a -- Name [Exact] :: Name -> RdrName mkRdrUnqual :: OccName -> RdrName mkRdrQual :: ModuleName -> OccName -> RdrName mkUnqual :: NameSpace -> FastString -> RdrName mkVarUnqual :: FastString -> RdrName -- | Make a qualified RdrName in the given namespace and where the -- ModuleName and the OccName are taken from the first and -- second elements of the tuple respectively mkQual :: NameSpace -> (FastString, FastString) -> RdrName mkOrig :: Module -> OccName -> RdrName nameRdrName :: Name -> RdrName getRdrName :: NamedThing thing => thing -> RdrName rdrNameOcc :: RdrName -> OccName rdrNameSpace :: RdrName -> NameSpace -- | This rather gruesome function is used mainly by the parser. When -- parsing: -- --
```--   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 demoteRdrName :: RdrName -> Maybe RdrName isRdrDataCon :: RdrName -> Bool isRdrTyVar :: RdrName -> Bool isRdrTc :: RdrName -> Bool isQual :: RdrName -> Bool isQual_maybe :: RdrName -> Maybe (ModuleName, OccName) isUnqual :: RdrName -> Bool isOrig :: RdrName -> Bool isOrig_maybe :: RdrName -> Maybe (Module, OccName) isExact :: RdrName -> Bool isExact_maybe :: RdrName -> Maybe Name isSrcRdrName :: RdrName -> Bool -- | This environment is used to store local bindings (let, -- where, lambda, case). It is keyed by OccName, -- because we never use it for qualified names We keep the current -- mapping, *and* the set of all Names in scope Reason: see Note -- [Splicing Exact Names] in RnEnv data LocalRdrEnv emptyLocalRdrEnv :: LocalRdrEnv extendLocalRdrEnv :: LocalRdrEnv -> Name -> LocalRdrEnv extendLocalRdrEnvList :: LocalRdrEnv -> [Name] -> LocalRdrEnv lookupLocalRdrEnv :: LocalRdrEnv -> RdrName -> Maybe Name lookupLocalRdrOcc :: LocalRdrEnv -> OccName -> Maybe Name elemLocalRdrEnv :: RdrName -> LocalRdrEnv -> Bool inLocalRdrEnvScope :: Name -> LocalRdrEnv -> Bool localRdrEnvElts :: LocalRdrEnv -> [Name] delLocalRdrEnvList :: LocalRdrEnv -> [OccName] -> LocalRdrEnv -- | Keyed by OccName; when looking up a qualified name we look up -- the OccName part, and then check the Provenance to see -- if the appropriate qualification is valid. This saves routinely -- doubling the size of the env by adding both qualified and unqualified -- names to the domain. -- -- The list in the codomain is required because there may be name clashes -- These only get reported on lookup, not on construction -- -- INVARIANT: All the members of the list have distinct gre_name -- fields; that is, no duplicate Names -- -- INVARIANT: Imported provenance => Name is an ExternalName However -- LocalDefs can have an InternalName. This happens only when -- type-checking a [d| ... |] Template Haskell quotation; see this note -- in RnNames Note [Top-level Names in Template Haskell decl quotes] type GlobalRdrEnv = OccEnv [GlobalRdrElt] emptyGlobalRdrEnv :: GlobalRdrEnv mkGlobalRdrEnv :: [GlobalRdrElt] -> GlobalRdrEnv plusGlobalRdrEnv :: GlobalRdrEnv -> GlobalRdrEnv -> GlobalRdrEnv lookupGlobalRdrEnv :: GlobalRdrEnv -> OccName -> [GlobalRdrElt] extendGlobalRdrEnv :: Bool -> GlobalRdrEnv -> [AvailInfo] -> GlobalRdrEnv pprGlobalRdrEnv :: Bool -> GlobalRdrEnv -> SDoc globalRdrEnvElts :: GlobalRdrEnv -> [GlobalRdrElt] lookupGRE_RdrName :: RdrName -> GlobalRdrEnv -> [GlobalRdrElt] lookupGRE_Name :: GlobalRdrEnv -> Name -> [GlobalRdrElt] getGRE_NameQualifier_maybes :: GlobalRdrEnv -> Name -> [Maybe [ModuleName]] -- | Apply a transformation function to the GREs for these OccNames transformGREs :: (GlobalRdrElt -> GlobalRdrElt) -> [OccName] -> GlobalRdrEnv -> GlobalRdrEnv -- | For each OccName, see if there are multiple local definitions -- for it; return a list of all such and return a list of the duplicate -- bindings findLocalDupsRdrEnv :: GlobalRdrEnv -> [Name] -> [[GlobalRdrElt]] -- | Take a list of GREs which have the right OccName Pick those GREs that -- are suitable for this RdrName And for those, keep only only the -- Provenances that are suitable Only used for Qual and Unqual, not Orig -- or Exact -- -- Consider: -- --
```--   module A ( f ) where
--   import qualified Foo( f )
--   import Baz( f )
--   f = undefined
--   ```
-- -- Let's suppose that Foo.f and Baz.f are the same -- entity really. The export of f is ambiguous because it's in -- scope from the local def and the import. The lookup of Unqual -- f should return a GRE for the locally-defined f, and a -- GRE for the imported f, with a single provenance, -- namely the one for Baz(f). pickGREs :: RdrName -> [GlobalRdrElt] -> [GlobalRdrElt] -- | make a GlobalRdrEnv where all the elements point to the same -- Provenance (useful for "hiding" imports, or imports with no details). gresFromAvails :: Provenance -> [AvailInfo] -> [GlobalRdrElt] gresFromAvail :: (Name -> Provenance) -> AvailInfo -> [GlobalRdrElt] -- | An element of the GlobalRdrEnv data GlobalRdrElt [GRE] :: Name -> Parent -> Provenance -> GlobalRdrElt [gre_name] :: GlobalRdrElt -> Name [gre_par] :: GlobalRdrElt -> Parent -- | Why it's in scope [gre_prov] :: GlobalRdrElt -> Provenance isLocalGRE :: GlobalRdrElt -> Bool -- | Test if an unqualifed version of this thing would be in scope unQualOK :: GlobalRdrElt -> Bool -- | Is in scope qualified with the given module? qualSpecOK :: ModuleName -> ImportSpec -> Bool -- | Is in scope unqualified? unQualSpecOK :: ImportSpec -> Bool -- | The Provenance of something says how it came to be in scope. -- It's quite elaborate so that we can give accurate unused-name -- warnings. data Provenance -- | The thing was defined locally [LocalDef] :: Provenance -- | The thing was imported. -- -- INVARIANT: the list of ImportSpec is non-empty [Imported] :: [ImportSpec] -> Provenance -- | Print out the place where the name was imported pprNameProvenance :: GlobalRdrElt -> SDoc -- | The children of a Name are the things that are abbreviated by the ".." -- notation in export lists. See Note [Parents] data Parent [NoParent] :: Parent [ParentIs] :: Name -> Parent data ImportSpec [ImpSpec] :: ImpDeclSpec -> ImpItemSpec -> ImportSpec [is_decl] :: ImportSpec -> ImpDeclSpec [is_item] :: ImportSpec -> ImpItemSpec -- | Describes a particular import declaration and is shared among all the -- Provenances for that decl data ImpDeclSpec [ImpDeclSpec] :: ModuleName -> ModuleName -> Bool -> SrcSpan -> ImpDeclSpec -- | Module imported, e.g. import Muggle Note the Muggle -- may well not be the defining module for this thing! [is_mod] :: ImpDeclSpec -> ModuleName -- | Import alias, e.g. from as M (or Muggle if there is -- no as clause) [is_as] :: ImpDeclSpec -> ModuleName -- | Was this import qualified? [is_qual] :: ImpDeclSpec -> Bool -- | The location of the entire import declaration [is_dloc] :: ImpDeclSpec -> SrcSpan -- | Describes import info a particular Name data ImpItemSpec -- | The import had no import list, or had a hiding list [ImpAll] :: ImpItemSpec -- | The import had an import list. The is_explicit field is -- True iff the thing was named explicitly in the import -- specs rather than being imported as part of a "..." group. Consider: -- --
```--   import C( T(..) )
--   ```
--
• -package pkg and -package-id pkg -- cause pkg to become exposed. If -- -hide-all-packages was not specified, these commands also -- cause all other packages with the same name to become hidden.
• --
• -hide-package pkg causes pkg to -- become hidden.
• --
• (there are a few more flags, check below for their semantics)
• --
-- -- The package state has the following properties. -- --
--
• Let exposedPackages be the set of packages thus exposed. -- Let depExposedPackages be the transitive closure from -- exposedPackages of their dependencies.
• --
• When searching for a module from an preload import declaration, -- only the exposed modules in exposedPackages are valid.
• --
• When searching for a module from an implicit import, all modules -- from depExposedPackages are valid.
• --
• When linking in a compilation manager mode, we link in packages -- the program depends on (the compiler knows this list by the time it -- gets to the link step). Also, we link in all packages which were -- mentioned with preload -package flags on the command-line, or -- are a transitive dependency of same, or are "base"/"rts". The reason -- for this is that we might need packages which don't contain any -- Haskell modules, and therefore won't be discovered by the normal -- mechanism of dependency tracking.
• --
-- -- These Var names may either be global or local, see -- Var#globalvslocal -- -- Global Ids and Vars are those that are imported or -- correspond to a data constructor, primitive operation, or record -- selectors. Local Ids and Vars are those bound within an -- expression (e.g. by a lambda) or at the top level of the module being -- compiled. module Var -- | Essentially a typed Name, that may also contain some additional -- information about the Var and it's use sites. data Var type CoVar = Id type Id = Var type DictId = EvId type DFunId = Id type EvVar = EvId type EqVar = EvId type EvId = Id type IpId = EvId type TyVar = Var type TypeVar = Var type KindVar = Var type TKVar = Var varName :: Var -> Name varUnique :: Var -> Unique -- | The type or kind of the Var in question varType :: Var -> Kind setVarName :: Var -> Name -> Var setVarUnique :: Var -> Unique -> Var setVarType :: Id -> Type -> Id mkGlobalVar :: IdDetails -> Name -> Type -> IdInfo -> Id mkLocalVar :: IdDetails -> Name -> Type -> IdInfo -> Id -- | Exported Vars will not be removed as dead code mkExportedLocalVar :: IdDetails -> Name -> Type -> IdInfo -> Id mkCoVar :: Name -> Type -> CoVar idInfo :: Id -> IdInfo idDetails :: Id -> IdDetails lazySetIdInfo :: Id -> IdInfo -> Var setIdDetails :: Id -> IdDetails -> Id -- | If it's a local, make it global globaliseId :: Id -> Id -- | Exports the given local Id. Can also be called on global -- Ids, such as data constructors and class operations, which are -- born as global Ids and automatically exported setIdExported :: Id -> Id -- | We can only do this to LocalIds setIdNotExported :: Id -> Id isId :: Var -> Bool isTKVar :: Var -> Bool isTyVar :: Var -> Bool isTcTyVar :: Var -> Bool -- | isLocalVar returns True for type variables as well as -- local Ids These are the variables that we need to pay attention -- to when finding free variables, or doing dependency analysis. isLocalVar :: Var -> Bool isLocalId :: Var -> Bool isGlobalId :: Var -> Bool -- | isExportedIdVar means "don't throw this away" isExportedId :: Var -> Bool -- | mustHaveLocalBinding returns True of Ids and -- TyVars that must have a binding in this module. The converse is -- not quite right: there are some global Ids that must have -- bindings, such as record selectors. But that doesn't matter, because -- it's only used for assertions mustHaveLocalBinding :: Var -> Bool mkTyVar :: Name -> Kind -> TyVar mkTcTyVar :: Name -> Kind -> TcTyVarDetails -> TyVar mkKindVar :: Name -> SuperKind -> KindVar tyVarName :: TyVar -> Name tyVarKind :: TyVar -> Kind tcTyVarDetails :: TyVar -> TcTyVarDetails setTcTyVarDetails :: TyVar -> TcTyVarDetails -> TyVar setTyVarName :: TyVar -> Name -> TyVar setTyVarUnique :: TyVar -> Unique -> TyVar setTyVarKind :: TyVar -> Kind -> TyVar updateTyVarKind :: (Kind -> Kind) -> TyVar -> TyVar updateTyVarKindM :: (Monad m) => (Kind -> m Kind) -> TyVar -> m TyVar instance Outputable Var instance NamedThing Var instance Uniquable Var instance Eq Var instance Ord Var instance Data Var module CostCentre -- | A Cost Centre is a single {--} annotation. data CostCentre [NormalCC] :: {-# UNPACK #-} !Int -> CcName -> Module -> SrcSpan -> IsCafCC -> CostCentre -- | Two cost centres may have the same name and module but different -- SrcSpans, so we need a way to distinguish them easily and give them -- different object-code labels. So every CostCentre has a Unique that is -- distinct from every other CostCentre in the same module. -- -- XXX: should really be using Unique here, but we need to derive Data -- below and there's no Data instance for Unique. [cc_key] :: CostCentre -> {-# UNPACK #-} !Int -- | Name of the cost centre itself [cc_name] :: CostCentre -> CcName -- | Name of module defining this CC. [cc_mod] :: CostCentre -> Module [cc_loc] :: CostCentre -> SrcSpan [cc_is_caf] :: CostCentre -> IsCafCC [AllCafsCC] :: Module -> SrcSpan -> CostCentre -- | Name of module defining this CC. [cc_mod] :: CostCentre -> Module [cc_loc] :: CostCentre -> SrcSpan type CcName = FastString data IsCafCC [NotCafCC] :: IsCafCC [CafCC] :: IsCafCC -- | A Cost Centre Stack is something that can be attached to a closure. -- This is either: -- --
--
• the current cost centre stack (CCCS)
• --
• a pre-defined cost centre stack (there are several pre-defined -- CCSs, see below).
• --
data CostCentreStack type CollectedCCs = ([CostCentre], [CostCentre], [CostCentreStack]) noCCS :: CostCentreStack currentCCS :: CostCentreStack dontCareCCS :: CostCentreStack noCCSAttached :: CostCentreStack -> Bool isCurrentCCS :: CostCentreStack -> Bool maybeSingletonCCS :: CostCentreStack -> Maybe CostCentre mkUserCC :: FastString -> Module -> SrcSpan -> Unique -> CostCentre mkAutoCC :: Id -> Module -> IsCafCC -> CostCentre mkAllCafsCC :: Module -> SrcSpan -> CostCentre mkSingletonCCS :: CostCentre -> CostCentreStack isCafCCS :: CostCentreStack -> Bool isCafCC :: CostCentre -> Bool -- | Is this a cost-centre which records scc counts isSccCountCC :: CostCentre -> Bool -- | Is this a cost-centre which can be sccd ? sccAbleCC :: CostCentre -> Bool ccFromThisModule :: CostCentre -> Module -> Bool pprCostCentreCore :: CostCentre -> SDoc costCentreUserName :: CostCentre -> String costCentreUserNameFS :: CostCentre -> FastString costCentreSrcSpan :: CostCentre -> SrcSpan cmpCostCentre :: CostCentre -> CostCentre -> Ordering instance Ord CostCentreStack instance Eq CostCentreStack instance Data CostCentre instance Data IsCafCC instance Ord IsCafCC instance Eq IsCafCC instance Eq CostCentre instance Ord CostCentre instance Outputable CostCentreStack instance Outputable CostCentre instance Binary IsCafCC instance Binary CostCentre module Class data Class type ClassOpItem = (Id, DefMeth) data DefMeth [NoDefMeth] :: DefMeth [DefMeth] :: Name -> DefMeth [GenDefMeth] :: Name -> DefMeth data ClassATItem [ATI] :: TyCon -> (Maybe Type) -> ClassATItem type ClassMinimalDef = BooleanFormula Name -- | Convert a DefMethSpec to a DefMeth, which discards the -- name field in the DefMeth constructor of the DefMeth. defMethSpecOfDefMeth :: DefMeth -> DefMethSpec type FunDep a = ([a], [a]) pprFundeps :: Outputable a => [FunDep a] -> SDoc pprFunDep :: Outputable a => FunDep a -> SDoc mkClass :: [TyVar] -> [([TyVar], [TyVar])] -> [PredType] -> [Id] -> [ClassATItem] -> [ClassOpItem] -> ClassMinimalDef -> 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 classMinimalDef :: Class -> ClassMinimalDef instance Eq DefMeth instance Eq Class instance Ord Class instance Uniquable Class instance NamedThing Class instance Outputable Class instance Outputable DefMeth instance Data Class module VarSet type VarSet = UniqSet Var type IdSet = UniqSet Id type TyVarSet = UniqSet TyVar type CoVarSet = UniqSet CoVar emptyVarSet :: VarSet unitVarSet :: Var -> VarSet mkVarSet :: [Var] -> VarSet extendVarSet :: VarSet -> Var -> VarSet extendVarSetList :: VarSet -> [Var] -> VarSet extendVarSet_C :: (Var -> Var -> Var) -> VarSet -> Var -> VarSet elemVarSet :: Var -> VarSet -> Bool varSetElems :: VarSet -> [Var] subVarSet :: VarSet -> VarSet -> Bool unionVarSet :: VarSet -> VarSet -> VarSet unionVarSets :: [VarSet] -> VarSet -- | map the function oer the list, and union the results mapUnionVarSet :: (a -> VarSet) -> [a] -> VarSet intersectVarSet :: VarSet -> VarSet -> VarSet intersectsVarSet :: VarSet -> VarSet -> Bool disjointVarSet :: VarSet -> VarSet -> Bool isEmptyVarSet :: VarSet -> Bool delVarSet :: VarSet -> Var -> VarSet delVarSetList :: VarSet -> [Var] -> VarSet delVarSetByKey :: VarSet -> Unique -> VarSet minusVarSet :: VarSet -> VarSet -> VarSet foldVarSet :: (Var -> a -> a) -> a -> VarSet -> a filterVarSet :: (Var -> Bool) -> VarSet -> VarSet fixVarSet :: (VarSet -> VarSet) -> VarSet -> VarSet lookupVarSet :: VarSet -> Var -> Maybe Var mapVarSet :: (Var -> Var) -> VarSet -> VarSet sizeVarSet :: VarSet -> Int seqVarSet :: VarSet -> () elemVarSetByKey :: Unique -> VarSet -> Bool partitionVarSet :: (Var -> Bool) -> VarSet -> (VarSet, VarSet) module VarEnv type VarEnv elt = UniqFM elt type IdEnv elt = VarEnv elt type TyVarEnv elt = VarEnv elt type CoVarEnv elt = VarEnv elt emptyVarEnv :: VarEnv a unitVarEnv :: Var -> a -> VarEnv a mkVarEnv :: [(Var, a)] -> VarEnv a elemVarEnv :: Var -> VarEnv a -> Bool varEnvElts :: VarEnv a -> [a] varEnvKeys :: VarEnv a -> [Unique] 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 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 intersectsVarEnv :: VarEnv a -> VarEnv a -> Bool 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 a -> Unique -> UniqFM a isEmptyVarEnv :: VarEnv a -> Bool foldVarEnv :: (a -> b -> b) -> b -> VarEnv a -> b elemVarEnvByKey :: Unique -> VarEnv a -> Bool lookupVarEnv_Directly :: VarEnv a -> Unique -> Maybe a filterVarEnv :: (a -> Bool) -> VarEnv a -> VarEnv a filterVarEnv_Directly :: (Unique -> a -> Bool) -> VarEnv a -> VarEnv a restrictVarEnv :: VarEnv a -> VarSet -> VarEnv a partitionVarEnv :: (a -> Bool) -> VarEnv a -> (VarEnv a, VarEnv a) -- | A set of variables that are in scope at some point data InScopeSet emptyInScopeSet :: InScopeSet mkInScopeSet :: VarEnv Var -> InScopeSet delInScopeSet :: InScopeSet -> Var -> InScopeSet extendInScopeSet :: InScopeSet -> Var -> InScopeSet extendInScopeSetList :: InScopeSet -> [Var] -> InScopeSet extendInScopeSetSet :: InScopeSet -> VarEnv Var -> InScopeSet getInScopeVars :: InScopeSet -> VarEnv Var -- | 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. uniqAway :: InScopeSet -> Var -> Var -- | 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: -- --
--
1. A renaming for the left-hand expression
2. --
3. A renaming for the right-hand expressions
4. --
5. An in-scope set
6. --
-- -- Furthermore, when matching, we want to be able to have an 'occurs -- check', to prevent: -- --
```--   \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 -- | 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 delBndrL :: RnEnv2 -> Var -> RnEnv2 delBndrR :: RnEnv2 -> Var -> RnEnv2 delBndrsL :: RnEnv2 -> [Var] -> RnEnv2 delBndrsR :: RnEnv2 -> [Var] -> RnEnv2 addRnInScopeSet :: RnEnv2 -> VarEnv 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 -- | 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 instance Outputable InScopeSet -- | Module for coercion axioms, used to represent type family instances -- and newtypes module CoAxiom data Branched data Unbranched type BranchIndex = Int data BranchList a br [FirstBranch] :: a -> BranchList a br [NextBranch] :: a -> BranchList a br -> BranchList a Branched toBranchList :: [a] -> BranchList a Branched fromBranchList :: BranchList a br -> [a] toBranchedList :: BranchList a br -> BranchList a Branched toUnbranchedList :: BranchList a br -> BranchList a Unbranched brListLength :: BranchList a br -> Int brListNth :: BranchList a br -> BranchIndex -> a brListMap :: (a -> b) -> BranchList a br -> [b] brListFoldr :: (a -> b -> b) -> b -> BranchList a br -> b brListMapM :: Monad m => (a -> m b) -> BranchList a br -> m [b] brListFoldlM_ :: Monad m => (a -> b -> m a) -> a -> BranchList b br -> m () brListZipWith :: (a -> b -> c) -> BranchList a br1 -> BranchList b br2 -> [c] -- | A CoAxiom is a "coercion constructor", i.e. a named equality -- axiom. data CoAxiom br [CoAxiom] :: Unique -> Name -> Role -> TyCon -> BranchList CoAxBranch 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 -> BranchList CoAxBranch br [co_ax_implicit] :: CoAxiom br -> Bool data CoAxBranch [CoAxBranch] :: SrcSpan -> [TyVar] -> [Role] -> [Type] -> Type -> [CoAxBranch] -> CoAxBranch [cab_loc] :: CoAxBranch -> SrcSpan [cab_tvs] :: CoAxBranch -> [TyVar] [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 -> BranchList CoAxBranch 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] 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 -> Int -> [Role] -> Role -> ([Type] -> [Eqn] -> Maybe Eqn) -> CoAxiomRule [coaxrName] :: CoAxiomRule -> FastString [coaxrTypeArity] :: CoAxiomRule -> Int [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 -> [Type] -> [Eqn] -> Maybe Eqn -- | A more explicit representation for `t1 ~ t2`. type Eqn = Pair Type data BuiltInSynFamily [BuiltInSynFamily] :: ([Type] -> Maybe (CoAxiomRule, [Type], Type)) -> ([Type] -> Type -> [Eqn]) -> ([Type] -> Type -> [Type] -> Type -> [Eqn]) -> BuiltInSynFamily [sfMatchFam] :: BuiltInSynFamily -> [Type] -> Maybe (CoAxiomRule, [Type], Type) [sfInteractTop] :: BuiltInSynFamily -> [Type] -> Type -> [Eqn] [sfInteractInert] :: BuiltInSynFamily -> [Type] -> Type -> [Type] -> Type -> [Eqn] trivialBuiltInFamily :: BuiltInSynFamily instance Data Role instance Eq Role instance Outputable a => Outputable (BranchList a br) instance Eq (CoAxiom br) instance Ord (CoAxiom br) instance Uniquable (CoAxiom br) instance Outputable (CoAxiom br) instance NamedThing (CoAxiom br) instance Typeable br => Data (CoAxiom br) instance Outputable Role instance Binary Role instance Data CoAxiomRule instance Uniquable CoAxiomRule instance Eq CoAxiomRule instance Ord CoAxiomRule instance Outputable CoAxiomRule module 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 -- | Names of the fields in an algebraic record type type FieldLabel = Name -- | 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] :: Bool -> AlgTyConRhs -- | 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 T a :: *
--   ```
-- -- Or an associated data type declaration, within a class declaration: -- --
```--   class C a b where
--     data T b :: *
--   ```
--
• Associated families are implicit, as they are re-constructed from -- the class declaration in which they reside, and
• --
• Family instances are not implicit as they represent the -- instance body (similar to a dfun does that for a class -- instance).
• --
isImplicitTyCon :: TyCon -> Bool -- | Name of the constructor tyConName :: TyCon -> Name -- | Kind of this TyCon (full kind, not just the return kind) tyConKind :: TyCon -> Kind -- | A Unique of this TyCon. Invariant: identical to Unique of Name stored -- in tyConName field. tyConUnique :: TyCon -> Unique -- | The kind and type variables used in the type constructor. Invariant: -- length tyvars = arity Precisely, this list scopes over: -- --
--
1. The algTcStupidTheta
2. --
3. The cached types in algTyConRhs.NewTyCon
4. --
5. The family instance types if present
6. --
```--   TyConApp SuperKindTyCon ...
--   ```
type SuperKind = Type -- | The key type representing kinds in the compiler. Invariant: a kind is -- always in one of these forms: -- --
```--   FunTy k1 k2
--   TyConApp PrimTyCon [...]
--   TyVar kv   -- (during inference only)
--   ForAll ... -- (for top-level coercions)
--   ```
type Kind = Type typeKind :: Type -> Kind -- | See Type#kind_subtyping for details of the distinction between -- these Kinds anyKind :: Kind -- | See Type#kind_subtyping for details of the distinction between -- these Kinds liftedTypeKind :: Kind -- | See Type#kind_subtyping for details of the distinction between -- these Kinds unliftedTypeKind :: Kind -- | See Type#kind_subtyping for details of the distinction between -- these Kinds openTypeKind :: Kind -- | See Type#kind_subtyping for details of the distinction between -- these Kinds constraintKind :: Kind -- | Given two kinds k1 and k2, creates the Kind -- k1 -> k2 mkArrowKind :: Kind -> Kind -> Kind -- | Iterated application of mkArrowKind mkArrowKinds :: [Kind] -> Kind -> Kind -- | See Type#kind_subtyping for details of the distinction between -- the Kind TyCons anyKindTyCon :: TyCon -- | See Type#kind_subtyping for details of the distinction between -- the Kind TyCons liftedTypeKindTyCon :: TyCon -- | See Type#kind_subtyping for details of the distinction between -- the Kind TyCons openTypeKindTyCon :: TyCon -- | See Type#kind_subtyping for details of the distinction between -- the Kind TyCons unliftedTypeKindTyCon :: TyCon -- | See Type#kind_subtyping for details of the distinction between -- the Kind TyCons constraintKindTyCon :: TyCon -- | See Type#kind_subtyping for details of the distinction between -- these Kinds superKind :: Kind -- | See Type#kind_subtyping for details of the distinction between -- the Kind TyCons superKindTyCon :: TyCon pprKind :: Kind -> SDoc pprParendKind :: Kind -> SDoc kindAppResult :: SDoc -> Kind -> [Type] -> Kind -- | Find the result Kind of a type synonym, after applying it to -- its arity number of type variables Actually this function -- works fine on data types too, but they'd always return *, so we -- never need to ask synTyConResKind :: TyCon -> Kind -- | Essentially splitFunTys on kinds splitKindFunTys :: Kind -> ([Kind], Kind) -- | Essentially splitFunTysN on kinds splitKindFunTysN :: Int -> Kind -> ([Kind], Kind) splitKindFunTy_maybe :: Kind -> Maybe (Kind, Kind) isLiftedTypeKind :: Kind -> Bool -- | See Type#kind_subtyping for details of the distinction between -- these Kinds isUnliftedTypeKind :: Kind -> Bool -- | See Type#kind_subtyping for details of the distinction between -- these Kinds isOpenTypeKind :: Kind -> Bool -- | See Type#kind_subtyping for details of the distinction between -- these Kinds isConstraintKind :: Kind -> Bool -- | See Type#kind_subtyping for details of the distinction between -- these Kinds isConstraintOrLiftedKind :: Kind -> Bool returnsConstraintKind :: Kind -> Bool -- | Is this a kind (i.e. a type-of-types)? isKind :: Kind -> Bool isKindVar :: Var -> Bool -- | Is this a super-kind (i.e. a type-of-kinds)? isSuperKind :: Type -> Bool isSuperKindTyCon :: TyCon -> Bool isLiftedTypeKindCon :: TyCon -> Bool isConstraintKindCon :: TyCon -> Bool -- | See Type#kind_subtyping for details of the distinction between -- these Kinds isAnyKind :: Kind -> Bool isAnyKindCon :: TyCon -> Bool okArrowArgKind :: Kind -> Bool okArrowResultKind :: Kind -> Bool -- | True of any sub-kind of OpenTypeKind isSubOpenTypeKind :: Kind -> Bool isSubOpenTypeKindKey :: Unique -> Bool -- | k1 `isSubKind` k2 checks that k1 <: k2 -- Sub-kinding is extremely simple and does not look under arrrows or -- type constructors isSubKind :: Kind -> Kind -> Bool -- | kc1 `isSubKindCon` kc2 checks that kc1 <: -- kc2 isSubKindCon :: TyCon -> TyCon -> Bool tcIsSubKind :: Kind -> Kind -> Bool tcIsSubKindCon :: TyCon -> TyCon -> Bool defaultKind :: Kind -> Kind -- | Used when generalising: default OpenKind and ArgKind to *. See -- Type#kind_subtyping for more information on what that means defaultKind_maybe :: Kind -> Maybe Kind kiVarsOfKind :: Kind -> VarSet kiVarsOfKinds :: [Kind] -> VarSet -- | Main functions for manipulating types and type-related things module Type -- | A typecheckable-thing, essentially anything that has a name data TyThing [AnId] :: Id -> TyThing [AConLike] :: ConLike -> TyThing [ATyCon] :: TyCon -> TyThing [ACoAxiom] :: (CoAxiom Branched) -> TyThing -- | The key representation of types within the compiler data Type type KindOrType = Type -- | A type of the form p of kind Constraint 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: -- --
--
• The type checker must treat it as opaque
• --
• The rest of the compiler treats it as transparent
• --
-- -- Consider these examples: -- --
```--   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] -- | Essentially a typed Name, that may also contain some additional -- information about the Var and it's use sites. data Var type TyVar = Var isTyVar :: Var -> Bool 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 -- | 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]) -- | 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 :: Type -> Maybe (Type, Type) -- | Creates a function type from the given argument and result type mkFunTy :: Type -> Type -> Type mkFunTys :: [Type] -> Type -> Type -- | Attempts to extract the argument and result types from a type, and -- panics if that is not possible. See also splitFunTy_maybe splitFunTy :: Type -> (Type, Type) -- | Attempts to extract the argument and result types from a type splitFunTy_maybe :: Type -> Maybe (Type, Type) splitFunTys :: Type -> ([Type], Type) -- | Split off exactly the given number argument types, and panics if that -- is not possible splitFunTysN :: Int -> Type -> ([Type], Type) -- | Extract the function result type and panic if that is not possible funResultTy :: Type -> Type -- | Extract the function argument type and panic if that is not possible funArgTy :: Type -> Type -- | Splits off argument types from the given type and associating them -- with the things in the input list from left to right. The final result -- type is returned, along with the resulting pairs of objects and types, -- albeit with the list of pairs in reverse order. Panics if there are -- not enough argument types for the input list. zipFunTys :: Outputable a => [a] -> Type -> ([(a, 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 -- | The same as fst . splitTyConApp tyConAppTyCon_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 :: 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 -- | What is the role assigned to the next parameter of this type? Usually, -- this will be Nominal, but if the type is a TyConApp, we -- may be able to do better. The type does *not* have to be well-kinded -- when applied for this to work! nextRole :: Type -> Role mkForAllTy :: TyVar -> Type -> Type -- | Wraps foralls over the type using the provided TyVars from left -- to right mkForAllTys :: [TyVar] -> Type -> Type -- | Attempts to take a forall type apart, returning the bound type -- variable and the remainder of the type splitForAllTy_maybe :: Type -> Maybe (TyVar, Type) -- | Attempts to take a forall type apart, returning all the immediate such -- bound type variables and the remainder of the type. Always suceeds, -- even if that means returning an empty list of TyVars splitForAllTys :: Type -> ([TyVar], Type) mkPiKinds :: [TyVar] -> Kind -> Kind -- | Makes a (->) type or a forall type, depending on whether -- it is given a type variable or a term variable. mkPiType :: Var -> Type -> Type -- | mkPiType for multiple type or value arguments mkPiTypes :: [Var] -> Type -> Type -- | Instantiate a forall type with one or more type arguments. Used when -- we have a polymorphic function applied to type args: -- --
```--   f t1 t2
--   ```
-- -- We use applyTys type-of-f [t1,t2] to compute the type of the -- expression. Panics if no application is possible. applyTy :: Type -> KindOrType -> Type -- | This function is interesting because: -- --
--
1. The function may have more for-alls than there are -- args
1. Less obviously, it may have fewer for-alls
2. --
-- -- For case 2. think of: -- --
```--   applyTys (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. applyTys :: Type -> [KindOrType] -> Type applyTysD :: SDoc -> Type -> [Type] -> Type applyTysX :: [TyVar] -> Type -> [Type] -> Type -- | Equivalent to snd . splitForAllTys dropForAlls :: Type -> Type 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 -- | Get the type on the LHS of a coercion induced by a type/data family -- instance. coAxNthLHS :: CoAxiom br -> Int -> 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 -- | 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 isDictLikeTy :: Type -> Bool -- | Creates a type equality predicate mkEqPred :: Type -> Type -> PredType mkCoerciblePred :: Type -> Type -> PredType mkPrimEqPred :: Type -> Type -> Type mkReprPrimEqPred :: Type -> Type -> Type mkClassPred :: Class -> [Type] -> PredType isClassPred :: PredType -> Bool isEqPred :: PredType -> Bool isIPPred :: PredType -> Bool isIPPred_maybe :: Type -> Maybe (FastString, Type) isIPTyCon :: TyCon -> Bool isIPClass :: Class -> Bool data PredTree [ClassPred] :: Class -> [Type] -> PredTree [EqPred] :: EqRel -> Type -> Type -> PredTree [TuplePred] :: [PredType] -> PredTree [IrredPred] :: PredType -> PredTree -- | 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 classifyPredType :: PredType -> PredTree getClassPredTys :: PredType -> (Class, [Type]) getClassPredTys_maybe :: PredType -> Maybe (Class, [Type]) 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 funTyCon :: TyCon isTypeVar :: Var -> Bool isKindVar :: Var -> Bool allDistinctTyVars :: [KindOrType] -> Bool isForAllTy :: Type -> Bool isTyVarTy :: Type -> Bool isFunTy :: Type -> Bool isDictTy :: Type -> Bool isPredTy :: Type -> Bool isVoidTy :: Type -> Bool -- | See Type#type_classification for what an unlifted type is isUnLiftedType :: Type -> Bool isUnboxedTupleType :: Type -> Bool -- | 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 -- | 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. Closed type constructors are those with a -- fixed right hand side, as opposed to e.g. associated types isClosedAlgType :: Type -> Bool -- | Returns true of types that are opaque to Haskell. isPrimitiveType :: Type -> Bool -- | 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. isStrictType :: Type -> Bool -- | The key type representing kinds in the compiler. Invariant: a kind is -- always in one of these forms: -- --
```--   FunTy k1 k2
--   TyConApp PrimTyCon [...]
--   TyVar kv   -- (during inference only)
--   ForAll ... -- (for top-level coercions)
--   ```
type Kind = Type type SimpleKind = Kind type MetaKindVar = TyVar typeKind :: Type -> Kind -- | See Type#kind_subtyping for details of the distinction between -- these Kinds anyKind :: Kind -- | See Type#kind_subtyping for details of the distinction between -- these Kinds liftedTypeKind :: Kind -- | See Type#kind_subtyping for details of the distinction between -- these Kinds unliftedTypeKind :: Kind -- | See Type#kind_subtyping for details of the distinction between -- these Kinds openTypeKind :: Kind -- | See Type#kind_subtyping for details of the distinction between -- these Kinds constraintKind :: Kind -- | See Type#kind_subtyping for details of the distinction between -- these Kinds superKind :: Kind -- | See Type#kind_subtyping for details of the distinction between -- the Kind TyCons liftedTypeKindTyCon :: TyCon -- | See Type#kind_subtyping for details of the distinction between -- the Kind TyCons openTypeKindTyCon :: TyCon -- | See Type#kind_subtyping for details of the distinction between -- the Kind TyCons unliftedTypeKindTyCon :: TyCon -- | See Type#kind_subtyping for details of the distinction between -- the Kind TyCons constraintKindTyCon :: TyCon -- | See Type#kind_subtyping for details of the distinction between -- the Kind TyCons anyKindTyCon :: TyCon -- | NB: for type synonyms tyVarsOfType does not expand the synonym -- tyVarsOfType returns only the free variables of a type For example, -- tyVarsOfType (a::k) returns {a}, not including the kind variable {k} tyVarsOfType :: Type -> VarSet tyVarsOfTypes :: [Type] -> TyVarSet closeOverKinds :: TyVarSet -> TyVarSet -- | 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 :: Type -> Type typeSize :: Type -> Int varSetElemsKvsFirst :: VarSet -> [TyVar] -- | Type equality on source types. Does not look through newtypes -- or PredTypes, but it does look through type synonyms. Watch out -- for horrible hack: See Note [Comparison with OpenTypeKind] eqType :: Type -> Type -> Bool eqTypeX :: RnEnv2 -> Type -> Type -> Bool eqTypes :: [Type] -> [Type] -> Bool cmpType :: Type -> Type -> Ordering cmpTypes :: [Type] -> [Type] -> Ordering eqPred :: PredType -> PredType -> Bool eqPredX :: RnEnv2 -> PredType -> PredType -> Bool cmpPred :: PredType -> PredType -> Ordering eqKind :: Kind -> Kind -> Bool eqTyVarBndrs :: RnEnv2 -> [TyVar] -> [TyVar] -> Maybe RnEnv2 seqType :: Type -> () seqTypes :: [Type] -> () -- | In Core, we "look through" non-recursive newtypes and -- PredTypes: this function tries to obtain a different view of -- the supplied type given this -- -- Strips off the top layer only of a type to give its underlying -- representation type. Returns Nothing if there is nothing to look -- through. -- -- 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 -- | Similar to coreView, but for the type checker, which just looks -- through synonyms tcView :: Type -> Maybe Type type UnaryType = Type data RepType [UbxTupleRep] :: [UnaryType] -> RepType [UnaryRep] :: UnaryType -> RepType flattenRepType :: RepType -> [UnaryType] -- | Looks through: -- --
--
1. For-alls
2. --
3. Synonyms
4. --
5. Predicates
6. --
7. All newtypes, including recursive ones, but not newtype -- families
8. --
-- -- It's useful in the back end of the compiler. repType :: Type -> RepType -- | 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 -> NameEnv TyCon -- | Discovers the primitive representation of a more abstract -- UnaryType typePrimRep :: UnaryType -> PrimRep typeRepArity :: Arity -> Type -> RepArity -- | A substitution of Types for TyVars and Kinds for -- KindVars type TvSubstEnv = TyVarEnv Type -- | Type substitution -- -- The following invariants must hold of a TvSubst: -- --
--
1. The in-scope set is needed only to guide the generation of -- fresh uniques
2. --
3. In particular, the kind of the type variables in the -- in-scope set is not relevant
4. --
5. The substitution is only applied ONCE! This is because in general -- such application will not reached a fixed point.
6. --
data TvSubst [TvSubst] :: InScopeSet -> TvSubstEnv -> TvSubst emptyTvSubstEnv :: TvSubstEnv emptyTvSubst :: TvSubst mkTvSubst :: InScopeSet -> TvSubstEnv -> TvSubst -- | Generates the in-scope set for the TvSubst from the types in -- the incoming environment, hence "open" mkOpenTvSubst :: TvSubstEnv -> TvSubst -- | Generates the in-scope set for the TvSubst from the types in -- the incoming environment, hence "open" zipOpenTvSubst :: [TyVar] -> [Type] -> TvSubst zipTopTvSubst :: [TyVar] -> [Type] -> TvSubst -- | Called when doing top-level substitutions. Here we expect that the -- free vars of the range of the substitution will be empty. mkTopTvSubst :: [(TyVar, Type)] -> TvSubst notElemTvSubst :: CoVar -> TvSubst -> Bool getTvSubstEnv :: TvSubst -> TvSubstEnv setTvSubstEnv :: TvSubst -> TvSubstEnv -> TvSubst zapTvSubstEnv :: TvSubst -> TvSubst getTvInScope :: TvSubst -> InScopeSet extendTvInScope :: TvSubst -> Var -> TvSubst extendTvInScopeList :: TvSubst -> [Var] -> TvSubst extendTvSubst :: TvSubst -> TyVar -> Type -> TvSubst extendTvSubstList :: TvSubst -> [TyVar] -> [Type] -> TvSubst isInScope :: Var -> TvSubst -> Bool -- | (compose env1 env2)(x) is env1(env2(x)); i.e. apply -- env2 then env1. It assumes that both are idempotent. -- Typically, env1 is the refinement to a base substitution -- env2 composeTvSubst :: InScopeSet -> TvSubstEnv -> TvSubstEnv -> TvSubstEnv zipTyEnv :: [TyVar] -> [Type] -> TvSubstEnv isEmptyTvSubst :: TvSubst -> Bool unionTvSubst :: TvSubst -> TvSubst -> TvSubst -- | Substitute within a Type substTy :: TvSubst -> Type -> Type -- | Substitute within several Types substTys :: TvSubst -> [Type] -> [Type] -- | Type substitution making use of an TvSubst that is assumed to -- be open, see zipOpenTvSubst substTyWith :: [TyVar] -> [Type] -> Type -> Type -- | Type substitution making use of an TvSubst that is assumed to -- be open, see zipOpenTvSubst substTysWith :: [TyVar] -> [Type] -> [Type] -> [Type] -- | Substitute within a ThetaType substTheta :: TvSubst -> ThetaType -> ThetaType substTyVar :: TvSubst -> TyVar -> Type substTyVars :: TvSubst -> [TyVar] -> [Type] substTyVarBndr :: TvSubst -> TyVar -> (TvSubst, TyVar) cloneTyVarBndr :: TvSubst -> TyVar -> Unique -> (TvSubst, TyVar) -- | Remove any nested binders mentioning the TyVars in the -- TyVarSet deShadowTy :: TyVarSet -> Type -> Type lookupTyVar :: TvSubst -> TyVar -> Maybe Type substKiWith :: [KindVar] -> [Kind] -> Kind -> Kind substKisWith :: [KindVar] -> [Kind] -> [Kind] -> [Kind] pprType :: Type -> SDoc pprParendType :: Type -> SDoc pprTypeApp :: TyCon -> [Type] -> SDoc pprTyThingCategory :: TyThing -> SDoc pprTyThing :: TyThing -> SDoc pprTvBndr :: TyVar -> SDoc pprTvBndrs :: [TyVar] -> SDoc pprForAll :: [TyVar] -> SDoc pprUserForAll :: [TyVar] -> SDoc pprSigmaType :: Type -> SDoc pprTheta :: ThetaType -> SDoc pprThetaArrowTy :: ThetaType -> SDoc pprClassPred :: Class -> [Type] -> SDoc pprKind :: Kind -> SDoc pprParendKind :: Kind -> SDoc -- | Pretty prints a TyCon, using the family instance in case of a -- representation tycon. For example: -- --
```--   data T [a] = ...
--   ```
-- -- In that case we want to print T [a], where T is the -- family TyCon pprSourceTyCon :: TyCon -> SDoc data TyPrec [TopPrec] :: TyPrec [FunPrec] :: TyPrec [TyOpPrec] :: TyPrec [TyConPrec] :: TyPrec maybeParen :: TyPrec -> TyPrec -> SDoc -> SDoc pprSigmaTypeExtraCts :: Bool -> Type -> SDoc tidyType :: TidyEnv -> Type -> Type tidyTypes :: TidyEnv -> [Type] -> [Type] -- | Grabs the free type variables, tidies them and then uses -- tidyType to work over the type itself tidyOpenType :: TidyEnv -> Type -> (TidyEnv, Type) tidyOpenTypes :: TidyEnv -> [Type] -> (TidyEnv, [Type]) tidyOpenKind :: TidyEnv -> Kind -> (TidyEnv, Kind) tidyTyVarBndr :: TidyEnv -> TyVar -> (TidyEnv, TyVar) -- | 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. tidyTyVarBndrs :: TidyEnv -> [TyVar] -> (TidyEnv, [TyVar]) -- | Add the free TyVars to the env in tidy form, so that we can -- tidy the type they are free in tidyFreeTyVars :: TidyEnv -> TyVarSet -> TidyEnv -- | Treat a new TyVar as a binder, and give it a fresh tidy name -- using the environment if one has not already been allocated. See also -- tidyTyVarBndr tidyOpenTyVar :: TidyEnv -> TyVar -> (TidyEnv, TyVar) tidyOpenTyVars :: TidyEnv -> [TyVar] -> (TidyEnv, [TyVar]) tidyTyVarOcc :: TidyEnv -> TyVar -> TyVar -- | Calls tidyType on a top-level type (i.e. with an empty tidying -- environment) tidyTopType :: Type -> Type tidyKind :: TidyEnv -> Kind -> Kind instance Ord EqRel instance Eq EqRel instance Outputable EqRel instance Eq Type instance Outputable TvSubst module Unify tcMatchTy :: TyVarSet -> Type -> Type -> Maybe TvSubst tcMatchTys :: TyVarSet -> [Type] -> [Type] -> Maybe TvSubst tcMatchTyX :: TyVarSet -> TvSubst -> Type -> Type -> Maybe TvSubst ruleMatchTyX :: MatchEnv -> TvSubstEnv -> Type -> Type -> Maybe TvSubstEnv tcMatchPreds :: [TyVar] -> [PredType] -> [PredType] -> Maybe TvSubstEnv data MatchEnv [ME] :: VarSet -> RnEnv2 -> MatchEnv [me_tmpls] :: MatchEnv -> VarSet [me_env] :: MatchEnv -> RnEnv2 matchList :: (env -> a -> b -> Maybe env) -> env -> [a] -> [b] -> Maybe env typesCantMatch :: [(Type, Type)] -> Bool tcUnifyTy :: Type -> Type -> Maybe TvSubst tcUnifyTys :: (TyVar -> BindFlag) -> [Type] -> [Type] -> Maybe TvSubst data BindFlag [BindMe] :: BindFlag [Skolem] :: BindFlag data UnifyResultM a [Unifiable] :: a -> UnifyResultM a [MaybeApart] :: a -> UnifyResultM a [SurelyApart] :: UnifyResultM a type UnifyResult = UnifyResultM TvSubst tcUnifyTysFG :: (TyVar -> BindFlag) -> [Type] -> [Type] -> UnifyResult instance Functor UM instance Applicative UM instance Monad UM -- | 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 Coercion -- | A Coercion is concrete evidence of the equality/convertibility -- of two types. data Coercion [Refl] :: Role -> Type -> Coercion [TyConAppCo] :: Role -> TyCon -> [Coercion] -> Coercion [AppCo] :: Coercion -> Coercion -> Coercion [ForAllCo] :: TyVar -> Coercion -> Coercion [CoVarCo] :: CoVar -> Coercion [AxiomInstCo] :: (CoAxiom Branched) -> BranchIndex -> [Coercion] -> Coercion [UnivCo] :: FastString -> Role -> Type -> Type -> Coercion [SymCo] :: Coercion -> Coercion [TransCo] :: Coercion -> Coercion -> Coercion [AxiomRuleCo] :: CoAxiomRule -> [Type] -> [Coercion] -> Coercion [NthCo] :: Int -> Coercion -> Coercion [LRCo] :: LeftOrRight -> Coercion -> Coercion [InstCo] :: Coercion -> Type -> Coercion [SubCo] :: Coercion -> Coercion -- | Essentially a typed Name, that may also contain some additional -- information about the Var and it's use sites. data Var type CoVar = Id data LeftOrRight [CLeft] :: LeftOrRight [CRight] :: LeftOrRight pickLR :: LeftOrRight -> (a, a) -> a data Role [Nominal] :: Role [Representational] :: Role [Phantom] :: Role ltRole :: Role -> Role -> Bool coVarKind :: CoVar -> (Type, Type) coVarRole :: CoVar -> Role coercionType :: Coercion -> 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 -- | Apply coercionKind to multiple Coercions coercionKinds :: [Coercion] -> Pair [Type] isReflCo :: Coercion -> Bool isReflCo_maybe :: Coercion -> Maybe Type -- | Retrieve the role from a coercion. coercionRole :: Coercion -> Role -- | Get a coercion's kind and role. Why both at once? See Note [Computing -- a coercion kind and role] coercionKindRole :: Coercion -> (Pair Type, Role) -- | Makes a coercion type from two types: the types whose equality is -- proven by the relevant Coercion mkCoercionType :: Role -> Type -> Type -> Type mkReflCo :: Role -> Type -> Coercion mkCoVarCo :: CoVar -> Coercion mkAxInstCo :: Role -> CoAxiom br -> BranchIndex -> [Type] -> Coercion mkUnbranchedAxInstCo :: Role -> CoAxiom Unbranched -> [Type] -> Coercion mkAxInstLHS :: CoAxiom br -> BranchIndex -> [Type] -> Type mkAxInstRHS :: CoAxiom br -> BranchIndex -> [Type] -> Type mkUnbranchedAxInstRHS :: CoAxiom Unbranched -> [Type] -> Type mkPiCo :: Role -> Var -> Coercion -> Coercion mkPiCos :: Role -> [Var] -> Coercion -> Coercion mkCoCast :: Coercion -> 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. mkTransCo :: Coercion -> Coercion -> Coercion mkNthCo :: Int -> Coercion -> Coercion mkNthCoRole :: Role -> Int -> Coercion -> Coercion mkLRCo :: LeftOrRight -> Coercion -> Coercion -- | Instantiates a Coercion with a Type argument. mkInstCo :: Coercion -> 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 -- | Apply a Coercion to another Coercion. The second -- Coercions role is given, making this more flexible than -- mkAppCo. mkAppCoFlexible :: Coercion -> Role -> 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 :: Role -> TyCon -> [Coercion] -> Coercion -- | Make a function Coercion between two other Coercions mkFunCo :: Role -> Coercion -> Coercion -> Coercion -- | Make a Coercion which binds a variable within an inner -- Coercion mkForAllCo :: Var -> Coercion -> Coercion -- | Manufacture an unsafe coercion from thin air. Currently (May 14) this -- is used only to implement the unsafeCoerce# primitive. -- Optimise by pushing down through type constructors. mkUnsafeCo :: Type -> Type -> Coercion mkUnivCo :: FastString -> Role -> Type -> Type -> Coercion mkSubCo :: Coercion -> Coercion mkPhantomCo :: Coercion -> Coercion -- | Create a coercion constructor (axiom) suitable for the given newtype -- TyCon. The Name should be that of a new coercion -- CoAxiom, the TyVars the arguments expected by the -- newtype and the type the appropriate right hand side of the -- newtype, with the free variables a subset of those -- TyVars. mkNewTypeCo :: Name -> TyCon -> [TyVar] -> [Role] -> Type -> CoAxiom Unbranched downgradeRole :: Role -> Role -> Coercion -> Coercion mkAxiomRuleCo :: CoAxiomRule -> [Type] -> [Coercion] -> Coercion -- | 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_maybe. type NormaliseStepper = RecTcChecker -> TyCon -> [Type] -> NormaliseStepResult -- | The result of stepping in a normalisation function. See -- topNormaliseTypeX_maybe. data NormaliseStepResult -- | nothing more to do [NS_Done] :: NormaliseStepResult -- | utter failure. The outer function should fail too. [NS_Abort] :: NormaliseStepResult -- | we stepped, yielding new bits; ^ co :: old type ~ new type [NS_Step] :: RecTcChecker -> Type -> Coercion -> NormaliseStepResult -- | Try one stepper and then try the next, if the first doesn't make -- progress. composeSteppers :: NormaliseStepper -> NormaliseStepper -> NormaliseStepper modifyStepResultCo :: (Coercion -> Coercion) -> NormaliseStepResult -> NormaliseStepResult -- | 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 -- | 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, or responds -- False to ok_tc. Specifically, here's the invariant: -- --
```--   topNormaliseNewType_maybe ty = Just (co, ty')
--   ```
-- -- then (a) co : ty0 ~ 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 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_maybe. topNormaliseTypeX_maybe :: NormaliseStepper -> Type -> Maybe (Coercion, 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 = [nth 0 c, nth 1 c, nth 2 c]
--   ```
decomposeCo :: Arity -> Coercion -> [Coercion] -- | Attempts to obtain the type variable underlying a Coercion getCoVar_maybe :: Coercion -> Maybe CoVar -- | Attempt to take a coercion application apart. splitAppCo_maybe :: Coercion -> Maybe (Coercion, Coercion) splitForAllCo_maybe :: Coercion -> Maybe (TyVar, Coercion) nthRole :: Role -> TyCon -> Int -> Role tyConRolesX :: Role -> TyCon -> [Role] setNominalRole_maybe :: Coercion -> Maybe Coercion mkCoVar :: Name -> Type -> CoVar isCoVar :: Var -> Bool isCoVarType :: Type -> Bool coVarName :: CoVar -> Name setCoVarName :: CoVar -> Name -> CoVar setCoVarUnique :: CoVar -> Unique -> CoVar tyCoVarsOfCo :: Coercion -> VarSet tyCoVarsOfCos :: [Coercion] -> VarSet coVarsOfCo :: Coercion -> VarSet coercionSize :: Coercion -> Int -- | A substitution of Coercions for CoVars (OR -- TyVars, when doing a "lifting" substitution) type CvSubstEnv = VarEnv Coercion emptyCvSubstEnv :: CvSubstEnv data CvSubst [CvSubst] :: InScopeSet -> TvSubstEnv -> CvSubstEnv -> CvSubst emptyCvSubst :: CvSubst lookupTyVar :: CvSubst -> TyVar -> Maybe Type lookupCoVar :: CvSubst -> Var -> Maybe Coercion isEmptyCvSubst :: CvSubst -> Bool zapCvSubstEnv :: CvSubst -> CvSubst getCvInScope :: CvSubst -> InScopeSet -- | Substitute within a Coercion substCo :: CvSubst -> Coercion -> Coercion -- | Substitute within several Coercions substCos :: CvSubst -> [Coercion] -> [Coercion] substCoVar :: CvSubst -> CoVar -> Coercion substCoVars :: CvSubst -> [CoVar] -> [Coercion] substCoWithTy :: InScopeSet -> TyVar -> Type -> Coercion -> Coercion substCoWithTys :: InScopeSet -> [TyVar] -> [Type] -> Coercion -> Coercion cvTvSubst :: CvSubst -> TvSubst tvCvSubst :: TvSubst -> CvSubst mkCvSubst :: InScopeSet -> [(Var, Coercion)] -> CvSubst zipOpenCvSubst :: [Var] -> [Coercion] -> CvSubst substTy :: CvSubst -> Type -> Type extendTvSubst :: CvSubst -> TyVar -> Type -> CvSubst extendCvSubstAndInScope :: CvSubst -> CoVar -> Coercion -> CvSubst extendTvSubstAndInScope :: CvSubst -> TyVar -> Type -> CvSubst substTyVarBndr :: CvSubst -> TyVar -> (CvSubst, TyVar) substCoVarBndr :: CvSubst -> CoVar -> (CvSubst, CoVar) -- | liftCoMatch is sort of inverse to liftCoSubst. In -- particular, if liftCoMatch vars ty co == Just s, then -- tyCoSubst s ty == co. 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. liftCoMatch :: TyVarSet -> Type -> Coercion -> Maybe LiftCoSubst liftCoSubstTyVar :: LiftCoSubst -> Role -> TyVar -> Maybe Coercion liftCoSubstWith :: Role -> [TyVar] -> [Coercion] -> Type -> Coercion -- | Determines syntactic equality of coercions coreEqCoercion :: Coercion -> Coercion -> Bool coreEqCoercion2 :: RnEnv2 -> Coercion -> Coercion -> Bool seqCo :: Coercion -> () pprCo :: Coercion -> SDoc pprParendCo :: Coercion -> SDoc pprCoAxiom :: CoAxiom br -> SDoc pprCoAxBranch :: TyCon -> CoAxBranch -> SDoc pprCoAxBranchHdr :: CoAxiom br -> BranchIndex -> SDoc tidyCo :: TidyEnv -> Coercion -> Coercion tidyCos :: TidyEnv -> [Coercion] -> [Coercion] applyCo :: Type -> Coercion -> Type instance Data Coercion instance Data LeftOrRight instance Eq LeftOrRight instance Binary LeftOrRight instance Outputable Coercion instance Outputable LeftOrRight instance Outputable CvSubst module PlaceHolder -- | used as place holder in PostTc and PostRn values data PlaceHolder [PlaceHolder] :: PlaceHolder -- | Types that are not defined until after type checking -- | Types that are not defined until after renaming placeHolderKind :: PlaceHolder placeHolderFixity :: PlaceHolder placeHolderType :: PlaceHolder placeHolderTypeTc :: Type placeHolderNames :: PlaceHolder placeHolderNamesTc :: NameSet type DataId id = (Data id, Data (PostRn id NameSet), Data (PostRn id Fixity), Data (PostRn id Bool), Data (PostRn id [Name]), Data (PostTc id Type), Data (PostTc id Coercion)) instance Data PlaceHolder module HsLit data HsLit [HsChar] :: SourceText -> Char -> HsLit [HsCharPrim] :: SourceText -> Char -> HsLit [HsString] :: SourceText -> FastString -> HsLit [HsStringPrim] :: SourceText -> ByteString -> HsLit [HsInt] :: SourceText -> Integer -> HsLit [HsIntPrim] :: SourceText -> Integer -> HsLit [HsWordPrim] :: SourceText -> Integer -> HsLit [HsInt64Prim] :: SourceText -> Integer -> HsLit [HsWord64Prim] :: SourceText -> Integer -> HsLit [HsInteger] :: SourceText -> Integer -> Type -> HsLit [HsRat] :: FractionalLit -> Type -> HsLit [HsFloatPrim] :: FractionalLit -> HsLit [HsDoublePrim] :: FractionalLit -> HsLit data HsOverLit id [OverLit] :: OverLitVal -> PostRn id Bool -> SyntaxExpr id -> PostTc id Type -> HsOverLit id [ol_val] :: HsOverLit id -> OverLitVal [ol_rebindable] :: HsOverLit id -> PostRn id Bool [ol_witness] :: HsOverLit id -> SyntaxExpr id [ol_type] :: HsOverLit id -> PostTc id Type data OverLitVal [HsIntegral] :: !SourceText -> !Integer -> OverLitVal [HsFractional] :: !FractionalLit -> OverLitVal [HsIsString] :: !SourceText -> !FastString -> OverLitVal overLitType :: HsOverLit a -> PostTc a Type instance Data OverLitVal instance Data HsLit instance DataId id => Data (HsOverLit id) instance Eq HsLit instance Eq (HsOverLit id) instance Eq OverLitVal instance Ord (HsOverLit id) instance Ord OverLitVal instance Outputable HsLit instance OutputableBndr id => Outputable (HsOverLit id) instance Outputable OverLitVal module DataCon -- | A data constructor -- --
data DataCon data DataConRep [NoDataConRep] :: DataConRep [DCR] :: Id -> DataConBoxer -> [Type] -> [StrictnessMark] -> [HsImplBang] -> DataConRep [dcr_wrap_id] :: DataConRep -> Id [dcr_boxer] :: DataConRep -> DataConBoxer [dcr_arg_tys] :: DataConRep -> [Type] [dcr_stricts] :: DataConRep -> [StrictnessMark] [dcr_bangs] :: DataConRep -> [HsImplBang] data HsBang [HsNoBang] :: HsBang [HsSrcBang] :: (Maybe SourceText) -> (Maybe Bool) -> Bool -> HsBang [HsUnpack] :: (Maybe Coercion) -> HsBang [HsStrict] :: HsBang type HsSrcBang = HsBang type HsImplBang = HsBang data StrictnessMark [MarkedStrict] :: StrictnessMark [NotMarkedStrict] :: StrictnessMark -- | Type of the tags associated with each constructor possibility type ConTag = Int -- | Build a new data constructor mkDataCon :: Name -> Bool -> [HsBang] -> [FieldLabel] -> [TyVar] -> [TyVar] -> [(TyVar, Type)] -> ThetaType -> [Type] -> Type -> TyCon -> ThetaType -> Id -> DataConRep -> DataCon -- | Tags are allocated from here for real constructors fIRST_TAG :: ConTag buildAlgTyCon :: Name -> [TyVar] -> [Role] -> Maybe CType -> ThetaType -> AlgTyConRhs -> RecFlag -> Bool -> Bool -> TyConParent -> TyCon -- | The representation type of the data constructor, i.e. the sort type -- that will represent values of this type at runtime dataConRepType :: DataCon -> Type -- | The "signature" of the DataCon returns, in order: -- -- 1) The result of dataConAllTyVars, -- -- 2) All the ThetaTypes relating to the DataCon (coercion, -- dictionary, implicit parameter - whatever) -- -- 3) The type arguments to the constructor -- -- 4) The original result type of the DataCon dataConSig :: DataCon -> ([TyVar], ThetaType, [Type], Type) -- | The "full signature" of the DataCon returns, in order: -- -- 1) The result of dataConUnivTyVars -- -- 2) The result of dataConExTyVars -- -- 3) The result of dataConEqSpec -- -- 4) The result of dataConDictTheta -- -- 5) The original argument types to the DataCon (i.e. before any -- change of the representation of the type) -- -- 6) The original result type of the DataCon dataConFullSig :: DataCon -> ([TyVar], [TyVar], [(TyVar, Type)], ThetaType, [Type], Type) -- | The Name of the DataCon, giving it a unique, rooted -- identification dataConName :: DataCon -> Name -- | The string package:module.name identifying a constructor, -- which is attached to its info table and used by the GHCi debugger and -- the heap profiler dataConIdentity :: DataCon -> [Word8] -- | The tag used for ordering DataCons dataConTag :: DataCon -> ConTag -- | The type constructor that we are building via this data constructor dataConTyCon :: DataCon -> TyCon -- | The original type constructor used in the definition of this data -- constructor. In case of a data family instance, that will be the -- family type constructor. dataConOrigTyCon :: DataCon -> TyCon -- | The user-declared type of the data constructor in the nice-to-read -- form: -- --
```--   T :: forall a b. a -> b -> T [a]
--   ```
-- -- rather than: -- --
```--   T :: forall a c. forall b. (c~[a]) => a -> b -> T c
--   ```
-- -- NB: If the constructor is part of a data instance, the result type -- mentions the family tycon, not the internal one. dataConUserType :: DataCon -> Type -- | The universally-quantified type variables of the constructor dataConUnivTyVars :: DataCon -> [TyVar] -- | The existentially-quantified type variables of the constructor dataConExTyVars :: DataCon -> [TyVar] -- | Both the universal and existentiatial type variables of the -- constructor dataConAllTyVars :: DataCon -> [TyVar] -- | Equalities derived from the result type of the data constructor, as -- written by the programmer in any GADT declaration dataConEqSpec :: DataCon -> [(TyVar, Type)] eqSpecPreds :: [(TyVar, Type)] -> ThetaType -- | The *full* constraints on the constructor type dataConTheta :: DataCon -> ThetaType -- | The "stupid theta" of the DataCon, such as data Eq a -- in: -- --
```--   data Eq a => T a = ...
--   ```
dataConStupidTheta :: 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] -> [Type] -- | Returns the argument types of the wrapper, excluding all dictionary -- arguments and without substituting for any type variables dataConOrigArgTys :: DataCon -> [Type] dataConOrigResTy :: DataCon -> Type -- | Returns just the instantiated value argument types of a -- DataCon, (excluding dictionary args) dataConInstOrigArgTys :: DataCon -> [Type] -> [Type] -- | Returns the arg types of the worker, including *all* evidence, after -- any flattening has been done and without substituting for any type -- variables dataConRepArgTys :: DataCon -> [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 -> FieldLabel -> Type -- | The strictness markings written by the porgrammer. 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 -- | The number of fields in the representation of the constructor -- AFTER taking into account the unpacking of any unboxed tuple fields dataConRepRepArity :: DataCon -> RepArity -- | 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 dataConImplicitIds :: DataCon -> [Id] -- | 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 type that is all of: -- --
--
• Concrete (i.e. constructors visible)
• --
• Single-constructor
• --
• Not existentially quantified
• --
-- -- Whether the type is a data type or a newtype splitDataProductType_maybe :: Type -> Maybe (TyCon, [Type], DataCon, [Type]) -- | Return whether there are any argument types for this DataCons -- original source type isNullarySrcDataCon :: DataCon -> Bool -- | Return whether there are any argument types for this DataCons -- runtime representation type isNullaryRepDataCon :: DataCon -> Bool isTupleDataCon :: DataCon -> Bool isUnboxedTupleCon :: DataCon -> Bool -- | Vanilla DataCons are those that are nice boring Haskell 98 -- constructors isVanillaDataCon :: DataCon -> Bool classDataCon :: Class -> DataCon dataConCannotMatch :: [Type] -> DataCon -> Bool isBanged :: HsBang -> Bool isMarkedStrict :: StrictnessMark -> Bool eqHsBang :: HsBang -> HsBang -> Bool promoteKind :: Kind -> SuperKind promoteDataCon :: DataCon -> TyCon promoteDataCon_maybe :: DataCon -> Maybe TyCon instance Data HsBang instance Eq DataCon instance Ord DataCon instance Uniquable DataCon instance NamedThing DataCon instance Outputable DataCon instance OutputableBndr DataCon instance Data DataCon instance Outputable HsBang instance Outputable StrictnessMark module Demand data StrDmd data UseDmd [UCall] :: Count -> UseDmd -> UseDmd [UProd] :: [MaybeUsed] -> UseDmd [UHead] :: UseDmd [Used] :: UseDmd data Count [One] :: Count [Many] :: Count countOnce :: Count countMany :: Count type Demand = JointDmd data CleanDemand mkProdDmd :: [JointDmd] -> CleanDemand mkOnceUsedDmd :: CleanDemand -> JointDmd mkManyUsedDmd :: CleanDemand -> JointDmd mkHeadStrict :: CleanDemand -> CleanDemand oneifyDmd :: JointDmd -> JointDmd getUsage :: CleanDemand -> UseDmd toCleanDmd :: Demand -> Type -> (CleanDemand, DeferAndUseM) absDmd :: JointDmd topDmd :: JointDmd botDmd :: JointDmd seqDmd :: JointDmd lubDmd :: JointDmd -> JointDmd -> JointDmd bothDmd :: JointDmd -> JointDmd -> JointDmd apply1Dmd :: Demand apply2Dmd :: Demand isTopDmd :: JointDmd -> Bool isBotDmd :: JointDmd -> Bool isAbsDmd :: JointDmd -> Bool isSeqDmd :: JointDmd -> Bool peelUseCall :: UseDmd -> Maybe (Count, UseDmd) cleanUseDmd_maybe :: JointDmd -> Maybe UseDmd strictenDmd :: JointDmd -> CleanDemand bothCleanDmd :: CleanDemand -> CleanDemand -> CleanDemand data DmdType [DmdType] :: DmdEnv -> [Demand] -> DmdResult -> DmdType dmdTypeDepth :: DmdType -> Arity lubDmdType :: DmdType -> DmdType -> DmdType bothDmdType :: DmdType -> BothDmdArg -> DmdType nopDmdType :: DmdType botDmdType :: DmdType mkDmdType :: DmdEnv -> [Demand] -> DmdResult -> DmdType addDemand :: Demand -> DmdType -> DmdType removeDmdTyArgs :: DmdType -> DmdType type BothDmdArg = (DmdEnv, Termination ()) mkBothDmdArg :: DmdEnv -> BothDmdArg toBothDmdArg :: DmdType -> BothDmdArg type DmdEnv = VarEnv Demand emptyDmdEnv :: VarEnv Demand peelFV :: DmdType -> Var -> (DmdType, Demand) type DmdResult = Termination CPRResult data CPRResult isBotRes :: DmdResult -> Bool isTopRes :: DmdResult -> Bool topRes :: DmdResult botRes :: DmdResult cprProdRes :: [DmdType] -> DmdResult vanillaCprProdRes :: Arity -> DmdResult cprSumRes :: ConTag -> DmdResult appIsBottom :: StrictSig -> Int -> Bool isBottomingSig :: StrictSig -> Bool pprIfaceStrictSig :: StrictSig -> SDoc trimCPRInfo :: Bool -> Bool -> DmdResult -> DmdResult returnsCPR_maybe :: DmdResult -> Maybe ConTag newtype StrictSig [StrictSig] :: DmdType -> StrictSig mkStrictSig :: DmdType -> StrictSig mkClosedStrictSig :: [Demand] -> DmdResult -> StrictSig nopSig :: StrictSig botSig :: StrictSig cprProdSig :: Arity -> StrictSig isNopSig :: StrictSig -> Bool splitStrictSig :: StrictSig -> ([Demand], DmdResult) increaseStrictSigArity :: Int -> StrictSig -> StrictSig seqDemand :: JointDmd -> () seqDemandList :: [JointDmd] -> () seqDmdType :: DmdType -> () seqStrictSig :: StrictSig -> () evalDmd :: JointDmd cleanEvalDmd :: CleanDemand cleanEvalProdDmd :: Arity -> CleanDemand isStrictDmd :: Demand -> Bool splitDmdTy :: DmdType -> (Demand, DmdType) splitFVs :: Bool -> DmdEnv -> (DmdEnv, DmdEnv) deferAfterIO :: DmdType -> DmdType postProcessUnsat :: DeferAndUse -> DmdType -> DmdType postProcessDmdTypeM :: DeferAndUseM -> DmdType -> BothDmdArg splitProdDmd_maybe :: JointDmd -> Maybe [JointDmd] peelCallDmd :: CleanDemand -> (CleanDemand, DeferAndUse) mkCallDmd :: CleanDemand -> CleanDemand dmdTransformSig :: StrictSig -> CleanDemand -> DmdType dmdTransformDataConSig :: Arity -> StrictSig -> CleanDemand -> DmdType dmdTransformDictSelSig :: StrictSig -> CleanDemand -> DmdType argOneShots :: OneShotInfo -> JointDmd -> [OneShotInfo] argsOneShots :: StrictSig -> Arity -> [[OneShotInfo]] trimToType :: JointDmd -> TypeShape -> JointDmd data TypeShape [TsFun] :: TypeShape -> TypeShape [TsProd] :: [TypeShape] -> TypeShape [TsUnk] :: TypeShape isSingleUsed :: JointDmd -> Bool reuseEnv :: DmdEnv -> DmdEnv zapDemand :: DynFlags -> Demand -> Demand zapStrictSig :: DynFlags -> StrictSig -> StrictSig strictifyDictDmd :: Type -> Demand -> Demand instance Eq StrictSig instance Show CPRResult instance Eq CPRResult instance Show r => Show (Termination r) instance Eq r => Eq (Termination r) instance Show CleanDemand instance Eq CleanDemand instance Show JointDmd instance Eq JointDmd instance Show MaybeUsed instance Eq MaybeUsed instance Show UseDmd instance Eq UseDmd instance Show Count instance Eq Count instance Show StrDmd instance Eq StrDmd instance Show MaybeStr instance Eq MaybeStr instance Outputable StrDmd instance Outputable MaybeStr instance Outputable MaybeUsed instance Outputable UseDmd instance Outputable Count instance Outputable JointDmd instance Outputable CleanDemand instance Outputable TypeShape instance Outputable DmdResult instance Outputable CPRResult instance Eq DmdType instance Outputable DmdType instance Outputable StrictSig instance Binary StrDmd instance Binary MaybeStr instance Binary Count instance Binary MaybeUsed instance Binary UseDmd instance Binary JointDmd instance Binary StrictSig instance Binary DmdType instance Binary DmdResult instance Binary CPRResult module Literal -- | So-called Literals are one of: -- --
--
• An unboxed (machine) literal (MachInt, -- MachFloat, etc.), which is presumed to be surrounded by -- appropriate constructors (Int#, etc.), so that the overall -- thing makes sense.
• --
• The literal derived from the label mentioned in a "foreign label" -- declaration (MachLabel)
• --
data Literal -- | Char# - at least 31 bits. Create with mkMachChar [MachChar] :: Char -> Literal -- | A string-literal: stored and emitted UTF-8 encoded, we'll arrange to -- decode it at runtime. Also emitted with a '\0' terminator. -- Create with mkMachString [MachStr] :: ByteString -> Literal -- | The NULL pointer, the only pointer value that can be -- represented as a Literal. Create with nullAddrLit [MachNullAddr] :: Literal -- | Int# - at least WORD_SIZE_IN_BITS bits. Create with -- mkMachInt [MachInt] :: Integer -> Literal -- | Int64# - at least 64 bits. Create with mkMachInt64 [MachInt64] :: Integer -> Literal -- | Word# - at least WORD_SIZE_IN_BITS bits. Create with -- mkMachWord [MachWord] :: Integer -> Literal -- | Word64# - at least 64 bits. Create with mkMachWord64 [MachWord64] :: Integer -> Literal -- | Float#. Create with mkMachFloat [MachFloat] :: Rational -> Literal -- | Double#. Create with mkMachDouble [MachDouble] :: Rational -> Literal -- | A label literal. Parameters: -- -- 1) The name of the symbol mentioned in the declaration -- -- 2) The size (in bytes) of the arguments the label expects. Only -- applicable with stdcall labels. Just x => -- <x> will be appended to label name when emitting -- assembly. [MachLabel] :: FastString -> (Maybe Int) -> FunctionOrData -> Literal [LitInteger] :: Integer -> Type -> Literal -- | Creates a Literal of type Int# mkMachInt :: DynFlags -> Integer -> Literal -- | Creates a Literal of type Word# mkMachWord :: DynFlags -> Integer -> Literal -- | Creates a Literal of type Int64# mkMachInt64 :: Integer -> Literal -- | Creates a Literal of type Word64# mkMachWord64 :: Integer -> Literal -- | Creates a Literal of type Float# mkMachFloat :: Rational -> Literal -- | Creates a Literal of type Double# mkMachDouble :: Rational -> Literal -- | Creates a Literal of type Char# mkMachChar :: Char -> Literal -- | Creates a Literal of type Addr#, which is appropriate -- for passing to e.g. some of the "error" functions in GHC.Err such as -- GHC.Err.runtimeError mkMachString :: String -> Literal mkLitInteger :: Integer -> Type -> Literal -- | Find the Haskell Type the literal occupies literalType :: Literal -> Type hashLiteral :: Literal -> Int absentLiteralOf :: TyCon -> Maybe Literal pprLiteral :: (SDoc -> SDoc) -> Literal -> SDoc -- | True if code space does not go bad if we duplicate this literal -- Currently we treat it just like litIsTrivial litIsDupable :: DynFlags -> Literal -> Bool -- | True if there is absolutely no penalty to duplicating the literal. -- False principally of strings litIsTrivial :: Literal -> Bool litIsLifted :: Literal -> Bool inIntRange :: DynFlags -> Integer -> Bool inWordRange :: DynFlags -> Integer -> Bool tARGET_MAX_INT :: DynFlags -> Integer inCharRange :: Char -> Bool -- | Tests whether the literal represents a zero of whatever type it is isZeroLit :: Literal -> Bool litFitsInChar :: Literal -> Bool word2IntLit :: DynFlags -> Literal -> Literal int2WordLit :: DynFlags -> Literal -> Literal narrow8IntLit :: Literal -> Literal narrow16IntLit :: Literal -> Literal narrow32IntLit :: Literal -> Literal narrow8WordLit :: Literal -> Literal narrow16WordLit :: Literal -> Literal narrow32WordLit :: Literal -> Literal char2IntLit :: Literal -> Literal int2CharLit :: Literal -> Literal float2IntLit :: Literal -> Literal int2FloatLit :: Literal -> Literal double2IntLit :: Literal -> Literal int2DoubleLit :: Literal -> Literal nullAddrLit :: Literal float2DoubleLit :: Literal -> Literal double2FloatLit :: Literal -> Literal instance Data Literal instance Binary Literal instance Outputable Literal instance Eq Literal instance Ord Literal -- | CoreSyn holds all the main data types for use by for the Glasgow -- Haskell Compiler midsection module CoreSyn -- | This is the data type that represents GHCs core intermediate language. -- Currently GHC uses System FC -- http://research.microsoft.com/~simonpj/papers/ext-f/ 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: -- --
--
1. The source code is parsed into an abstract syntax tree, which is -- represented by the data type HsExpr with the names being -- RdrNames
2. --
3. This syntax tree is renamed, which attaches a Unique -- to every RdrName (yielding a Name) to disambiguate -- identifiers which are lexically identical. For example, this -- program:
4. --
-- --
```--   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. -- --
--
1. The resulting syntax tree undergoes type checking (which also -- deals with instantiating type class arguments) to yield a -- HsExpr type that has Id as it's names.
2. --
3. Finally the syntax tree is desugared from the expressive -- HsExpr type into this Expr type, which has far fewer -- constructors and hence is easier to perform optimization, analysis and -- code generation on.
4. --
-- -- The type parameter b is for the type of binders in the -- expression tree. -- -- The language consists of the following elements: -- --
--
• Variables
• --
• Primitive literals
• --
• Applications: note that the argument may be a Type.See -- CoreSyn#let_app_invariant for another invariant
• --
• Lambda abstraction
• --
• Recursive and non recursive lets. Operationally this -- corresponds to allocating a thunk for the things bound and then -- executing the sub-expression. The right hand sides of all top-level -- and recursive lets must be of lifted type (see -- Type#type_classification for the meaning of lifted vs. -- unlifted).See Note [CoreSyn let/app invariant] We allow a -- non-recursive let to bind a type variable, thus:
```Let
--   (NonRec tv (Type ty)) body```
This can be very convenient for -- postponing type substitutions until the next run of the simplifier.At -- the moment, the rest of the compiler only deals with type-let in a Let -- expression, rather than at top level. We may want to revist this -- choice.
• --
• Case split. Operationally this corresponds to evaluating the -- scrutinee (expression examined) to weak head normal form and then -- examining at most one level of resulting constructor (i.e. you cannot -- do nested pattern matching directly with this).The binder gets bound -- to the value of the scrutinee, and the Type must be that of all -- the case alternatives This is one of the more complicated elements of -- the Core language, and comes with a number of restrictions:
1. The -- list of alternatives may be empty; See Note [Empty case -- alternatives]
2. The DEFAULT case alternative must be -- first in the list, if it occurs at all.
3. The remaining cases -- are in order of increasing tag (for DataAlts) or lit (for -- LitAlts). This makes finding the relevant constructor easy, -- and makes comparison easier too.
4. The list of alternatives must -- be exhaustive. An exhaustive case does not necessarily mention -- all constructors:
``` data Foo = Red | Green | Blue ...
--   case x of Red -> True other -> f (case x of Green -> ... Blue
--   -> ... ) ... ```
The inner case does not need a Red -- alternative, because x can't be Red at that program -- point.
• --
• Cast an expression to a particular type. This is used to implement -- newtypes (a newtype constructor or destructor just -- becomes a Cast in Core) and GADTs.
• --
• Notes. These allow general information to be added to expressions -- in the syntax tree
• --
• A type: this should only show up at the top level of an Arg
• --
• A coercion
• --
```--   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 -- | 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 hasStableCoreUnfolding_maybe :: Unfolding -> Maybe Bool isClosedUnfolding :: Unfolding -> Bool -- | Only returns False if there is no unfolding information available at -- all hasSomeUnfolding :: Unfolding -> Bool canUnfold :: Unfolding -> Bool neverUnfoldGuidance :: UnfoldingGuidance -> Bool isStableSource :: UnfoldingSource -> Bool seqExpr :: CoreExpr -> () seqExprs :: [CoreExpr] -> () seqUnfolding :: Unfolding -> () -- | 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] :: (Tickish Id) -> (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 type AnnAlt bndr annot = (AltCon, [bndr], AnnExpr bndr annot) -- | Takes a nested application expression and returns the the function -- being applied and the arguments to which it is applied collectAnnArgs :: AnnExpr b a -> (AnnExpr b a, [AnnExpr b a]) collectAnnArgsTicks :: (Tickish Var -> Bool) -> AnnExpr b a -> (AnnExpr b a, [AnnExpr b a], [Tickish Var]) deAnnotate :: AnnExpr bndr annot -> Expr bndr deAnnotate' :: AnnExpr' bndr annot -> Expr bndr deAnnAlt :: AnnAlt bndr annot -> Alt bndr -- | As collectBinders but for AnnExpr rather than -- Expr collectAnnBndrs :: AnnExpr bndr annot -> ([bndr], AnnExpr bndr annot) -- | A CoreRule is: -- --
--
• "Local" if the function it is a rule for is defined in the same -- module as the rule itself.
• --
• "Orphan" if nothing on the LHS is defined in the same module as -- the rule itself
• --
```--   (\x1. \x2. e) arg1
--   ```
zapLamInfo :: IdInfo -> Maybe IdInfo -- | Zap info that depends on free variables zapFragileInfo :: IdInfo -> Maybe IdInfo -- | Remove demand info on the IdInfo if it is present, otherwise -- return Nothing zapDemandInfo :: IdInfo -> Maybe IdInfo -- | 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 arityInfo :: IdInfo -> ArityInfo setArityInfo :: IdInfo -> ArityInfo -> IdInfo ppArityInfo :: Int -> SDoc -- | How this is called. n = all calls have at least n arguments callArityInfo :: IdInfo -> ArityInfo setCallArityInfo :: IdInfo -> ArityInfo -> IdInfo strictnessInfo :: IdInfo -> StrictSig setStrictnessInfo :: IdInfo -> StrictSig -> IdInfo -- | ID demand information demandInfo :: IdInfo -> Demand setDemandInfo :: IdInfo -> Demand -> IdInfo pprStrictness :: StrictSig -> SDoc -- | The Ids unfolding unfoldingInfo :: IdInfo -> Unfolding setUnfoldingInfo :: IdInfo -> Unfolding -> IdInfo setUnfoldingInfoLazily :: IdInfo -> Unfolding -> IdInfo -- | 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 atached to the Id inlinePragInfo :: IdInfo -> InlinePragma setInlinePragInfo :: IdInfo -> InlinePragma -> IdInfo -- | Identifier occurrence information data OccInfo -- | There are many occurrences, or unknown occurrences [NoOccInfo] :: OccInfo -- | Marks unused variables. Sometimes useful for lambda and case-bound -- variables. [IAmDead] :: OccInfo -- | Occurs exactly once, not inside a rule [OneOcc] :: !InsideLam -> !OneBranch -> !InterestingCxt -> OccInfo -- | 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 -> OccInfo isDeadOcc :: OccInfo -> Bool isStrongLoopBreaker :: OccInfo -> Bool isWeakLoopBreaker :: OccInfo -> Bool -- | How the Id occurs in the program occInfo :: IdInfo -> OccInfo setOccInfo :: IdInfo -> OccInfo -> IdInfo type InsideLam = Bool type OneBranch = Bool insideLam :: InsideLam notInsideLam :: InsideLam oneBranch :: OneBranch notOneBranch :: OneBranch -- | Records the specializations of this Id that we know about in -- the form of rewrite CoreRules that target them data SpecInfo [SpecInfo] :: [CoreRule] -> VarSet -> SpecInfo -- | Assume that no specilizations exist: always safe emptySpecInfo :: SpecInfo isEmptySpecInfo :: SpecInfo -> Bool -- | Retrieve the locally-defined free variables of both the left and right -- hand sides of the specialization rules specInfoFreeVars :: SpecInfo -> VarSet specInfoRules :: SpecInfo -> [CoreRule] seqSpecInfo :: SpecInfo -> () -- | Change the name of the function the rule is keyed on on all of the -- CoreRules setSpecInfoHead :: Name -> SpecInfo -> SpecInfo -- | Specialisations of the Ids function which exist See Note -- [Specialisations and RULES in IdInfo] specInfo :: IdInfo -> SpecInfo setSpecInfo :: IdInfo -> SpecInfo -> IdInfo -- | Records whether an Id makes Constant Applicative Form -- references data CafInfo -- | Indicates that the Id is for either: -- --
--
1. A function or static constructor that refers to one or more CAFs, -- or
2. --
3. A real live CAF
4. --
[MayHaveCafRefs] :: CafInfo -- | A function or static constructor that refers to no CAFs. [NoCafRefs] :: CafInfo ppCafInfo :: CafInfo -> SDoc mayHaveCafRefs :: CafInfo -> Bool -- | Id CAF info cafInfo :: IdInfo -> CafInfo setCafInfo :: IdInfo -> CafInfo -> IdInfo -- | Tick box for Hpc-style coverage data TickBoxOp [TickBox] :: Module -> {-# UNPACK #-} !TickBoxId -> TickBoxOp type TickBoxId = Int instance Ord CafInfo instance Eq CafInfo instance Outputable IdDetails instance Outputable CafInfo instance Outputable TickBoxOp -- | GHC uses several kinds of name internally: -- --
module Id -- | Essentially a typed Name, that may also contain some additional -- information about the Var and it's use sites. data Var type Id = Var isId :: Var -> Bool -- | For an explanation of global vs. local Ids, see -- Var#globalvslocal mkGlobalId :: IdDetails -> Name -> Type -> IdInfo -> 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 -- | For an explanation of global vs. local Ids, see -- Var#globalvslocal mkLocalId :: Name -> Type -> Id mkLocalIdWithInfo :: Name -> Type -> IdInfo -> 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 -- | 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 -> Type -> Id mkSysLocalM :: MonadUnique m => FastString -> Type -> m Id -- | Create a user local Id. These are local Ids (see -- Var#globalvslocal) with a name and location that the user might -- recognize mkUserLocal :: OccName -> Unique -> Type -> SrcSpan -> Id mkUserLocalM :: MonadUnique m => OccName -> Type -> SrcSpan -> m Id mkDerivedLocalM :: MonadUnique m => (OccName -> OccName) -> Id -> Type -> m 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 template local: a family of system local Ids in -- bijection with Ints, typically used in unfoldings mkTemplateLocal :: Int -> Type -> Id -- | Workers get local names. CoreTidy will externalise these if -- necessary mkWorkerId :: Unique -> Id -> Type -> Id mkWiredInIdName :: Module -> FastString -> Unique -> Id -> Name idName :: Id -> Name idType :: Id -> Kind idUnique :: Id -> Unique idInfo :: Id -> IdInfo idDetails :: Id -> IdDetails idRepArity :: Id -> RepArity -- | If the Id is that for a record selector, extract the -- sel_tycon and label. Panic otherwise recordSelectorFieldLabel :: Id -> (TyCon, FieldLabel) setIdName :: Id -> Name -> Id setIdUnique :: Id -> Unique -> Id -- | Not only does this set the Id Type, it also evaluates -- the type to try and reduce space usage setIdType :: Id -> Type -> Id setIdExported :: Id -> Id setIdNotExported :: Id -> Id -- | If it's a local, make it global globaliseId :: Id -> Id localiseId :: Id -> Id setIdInfo :: Id -> IdInfo -> Id lazySetIdInfo :: Id -> IdInfo -> Id modifyIdInfo :: (IdInfo -> IdInfo) -> Id -> Id maybeModifyIdInfo :: Maybe IdInfo -> Id -> Id zapLamIdInfo :: Id -> Id zapDemandIdInfo :: Id -> Id zapFragileIdInfo :: Id -> Id transferPolyIdInfo :: Id -> [Var] -> Id -> Id zapIdStrictness :: Id -> Id -- | 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 isDeadBinder :: Id -> 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 -- | isExportedIdVar means "don't throw this away" isExportedId :: Var -> Bool isLocalId :: Var -> Bool isGlobalId :: Var -> Bool isRecordSelector :: Id -> Bool isNaughtyRecordSelector :: Id -> Bool isClassOpId_maybe :: Id -> Maybe Class isDFunId :: Id -> Bool isPrimOpId :: Id -> Bool isPrimOpId_maybe :: Id -> Maybe PrimOp isFCallId :: Id -> Bool isFCallId_maybe :: Id -> Maybe ForeignCall isDataConWorkId :: Id -> Bool isDataConWorkId_maybe :: Id -> Maybe DataCon isDataConId_maybe :: Id -> Maybe DataCon -- | 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 isConLikeId :: Id -> Bool -- | Returns true if an application to n args would diverge isBottomingId :: Id -> Bool idIsFrom :: Module -> Id -> Bool -- | Returns True of an Id which may not have a binding, -- even though it is defined in this module. hasNoBinding :: Id -> Bool type DictId = EvId isDictId :: Id -> Bool dfunNSilent :: Id -> Int isEvVar :: Var -> Bool idInlinePragma :: Id -> InlinePragma setInlinePragma :: Id -> InlinePragma -> Id modifyInlinePragma :: Id -> (InlinePragma -> InlinePragma) -> Id idInlineActivation :: Id -> Activation setInlineActivation :: Id -> Activation -> Id idRuleMatchInfo :: Id -> RuleMatchInfo -- | 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 isOneShotBndr :: Var -> Bool -- | Returns whether the lambda associated with the Id is certainly -- applied at most once. You probably want to use isOneShotBndr -- instead isOneShotLambda :: Id -> Bool isProbablyOneShotLambda :: Id -> Bool setOneShotLambda :: Id -> Id clearOneShotLambda :: Id -> Id updOneShotInfo :: Id -> OneShotInfo -> Id setIdOneShotInfo :: Id -> OneShotInfo -> Id isStateHackType :: Type -> Bool -- | Should we apply the state hack to values of this Type? stateHackOneShot :: OneShotInfo typeOneShot :: Type -> OneShotInfo idArity :: Id -> Arity idCallArity :: Id -> Arity idUnfolding :: Id -> Unfolding realIdUnfolding :: Id -> Unfolding idSpecialisation :: Id -> SpecInfo idCoreRules :: Id -> [CoreRule] idHasRules :: Id -> Bool idCafInfo :: Id -> CafInfo idOneShotInfo :: Id -> OneShotInfo idOccInfo :: Id -> OccInfo setIdUnfoldingLazily :: Id -> Unfolding -> Id setIdUnfolding :: Id -> Unfolding -> Id setIdArity :: Id -> Arity -> Id setIdCallArity :: Id -> Arity -> Id setIdSpecialisation :: Id -> SpecInfo -> Id setIdCafInfo :: Id -> CafInfo -> Id setIdOccInfo :: Id -> OccInfo -> Id zapIdOccInfo :: Id -> Id setIdDemandInfo :: Id -> Demand -> Id setIdStrictness :: Id -> StrictSig -> Id idDemandInfo :: Id -> Demand idStrictness :: Id -> StrictSig module UnVarGraph data UnVarSet emptyUnVarSet :: UnVarSet mkUnVarSet :: [Var] -> UnVarSet varEnvDom :: VarEnv a -> UnVarSet unionUnVarSet :: UnVarSet -> UnVarSet -> UnVarSet unionUnVarSets :: [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 delNode :: UnVarGraph -> Var -> UnVarGraph instance Eq UnVarSet instance Outputable UnVarSet instance Outputable Gen instance Outputable UnVarGraph -- | Simple vectorised constructors and projections. module Vectorise.Vect -- | Contains the vectorised and lifted versions of some thing. type Vect a = (a, a) type VVar = Vect Var type VExpr = Vect CoreExpr type VBind = Vect CoreBind -- | Get the vectorised version of a thing. vectorised :: Vect a -> a -- | Get the lifted version of a thing. lifted :: Vect a -> a -- | Apply some function to both the vectorised and lifted versions of a -- thing. mapVect :: (a -> b) -> Vect a -> Vect b -- | Get the type of a vectorised variable. vVarType :: VVar -> Type -- | Make a vectorised non-recursive binding. vNonRec :: VVar -> VExpr -> VBind -- | Make a vectorised recursive binding. vRec :: [VVar] -> [VExpr] -> VBind -- | Wrap a vectorised variable as a vectorised expression. vVar :: VVar -> VExpr -- | Wrap a vectorised type as a vectorised expression. vType :: Type -> VExpr -- | Make a vectorised note. vTick :: Tickish Id -> VExpr -> VExpr -- | Make a vectorised let expresion. vLet :: VBind -> VExpr -> VExpr -- | Make a vectorised lambda abstraction. -- -- The lifted version also binds the lifting context lc. vLams :: Var -> [VVar] -> VExpr -> VExpr -- | Apply an expression to a set of argument variables. -- -- The lifted version is also applied to the variable of the lifting -- context. vVarApps :: Var -> VExpr -> [VVar] -> VExpr vCaseDEFAULT :: VExpr -> VVar -> Type -> Type -> VExpr -> VExpr module PprCore 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 => (AltCon, [a], Expr a) -> SDoc pprRules :: [CoreRule] -> SDoc instance OutputableBndr b => Outputable (Bind b) instance OutputableBndr b => Outputable (Expr b) instance OutputableBndr Var instance Outputable UnfoldingGuidance instance Outputable UnfoldingSource instance Outputable Unfolding instance Outputable CoreRule instance Outputable id => Outputable (Tickish id) instance Outputable CoreVect module HsTypes data HsType name -- |
[HsForAllTy] :: HsExplicitFlag -> (Maybe SrcSpan) -> (LHsTyVarBndrs name) -> (LHsContext name) -> (LHsType name) -> HsType name -- |
[HsTyVar] :: name -> HsType name -- |
[HsAppTy] :: (LHsType name) -> (LHsType name) -> HsType name -- |
[HsFunTy] :: (LHsType name) -> (LHsType name) -> HsType name -- |
[HsListTy] :: (LHsType name) -> HsType name -- |
[HsPArrTy] :: (LHsType name) -> HsType name -- |
[HsTupleTy] :: HsTupleSort -> [LHsType name] -> HsType name -- |
[HsOpTy] :: (LHsType name) -> (LHsTyOp name) -> (LHsType name) -> HsType name -- |
[HsParTy] :: (LHsType name) -> HsType name -- |
```--   (?x :: ty)
--   ```
-- --
[HsIParamTy] :: HsIPName -> (LHsType name) -> HsType name -- |
```--   ty1 ~ ty2
--   ```
-- --
[HsEqTy] :: (LHsType name) -> (LHsType name) -> HsType name -- |
```--   (ty :: kind)
--   ```
-- --
[HsKindSig] :: (LHsType name) -> (LHsKind name) -> HsType name -- |
[HsQuasiQuoteTy] :: (HsQuasiQuote name) -> HsType name -- |
[HsSpliceTy] :: (HsSplice name) -> (PostTc name Kind) -> HsType name -- |
[HsDocTy] :: (LHsType name) -> LHsDocString -> HsType name -- |
[HsBangTy] :: HsSrcBang -> (LHsType name) -> HsType name -- |
[HsRecTy] :: [LConDeclField name] -> HsType name -- |
[HsCoreTy] :: Type -> HsType name -- |
[HsExplicitListTy] :: (PostTc name Kind) -> [LHsType name] -> HsType name -- |
[HsExplicitTupleTy] :: [PostTc name Kind] -> [LHsType name] -> HsType name -- |
[HsTyLit] :: HsTyLit -> HsType name -- |
[HsWrapTy] :: HsTyWrapper -> (HsType name) -> HsType name -- |
[HsWildcardTy] :: HsType name -- |
[HsNamedWildcardTy] :: name -> HsType name type LHsType name = Located (HsType name) May have 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnComma' when in a list type HsKind name = HsType name type LHsKind name = Located (HsKind name) type HsTyOp name = (HsTyWrapper, name) type LHsTyOp name = HsTyOp (Located name) data HsTyVarBndr name [UserTyVar] :: name -> HsTyVarBndr name -- |
[KindedTyVar] :: (Located name) -> (LHsKind name) -> HsTyVarBndr name type LHsTyVarBndr name = Located (HsTyVarBndr name) data LHsTyVarBndrs name [HsQTvs] :: [Name] -> [LHsTyVarBndr name] -> LHsTyVarBndrs name [hsq_kvs] :: LHsTyVarBndrs name -> [Name] [hsq_tvs] :: LHsTyVarBndrs name -> [LHsTyVarBndr name] data HsWithBndrs name thing [HsWB] :: thing -> PostRn name [Name] -> PostRn name [Name] -> PostRn name [Name] -> HsWithBndrs name thing [hswb_cts] :: HsWithBndrs name thing -> thing [hswb_kvs] :: HsWithBndrs name thing -> PostRn name [Name] [hswb_tvs] :: HsWithBndrs name thing -> PostRn name [Name] [hswb_wcs] :: HsWithBndrs name thing -> PostRn name [Name] data HsTupleSort [HsUnboxedTuple] :: HsTupleSort [HsBoxedTuple] :: HsTupleSort [HsConstraintTuple] :: HsTupleSort [HsBoxedOrConstraintTuple] :: HsTupleSort data HsExplicitFlag [Qualified] :: HsExplicitFlag [Implicit] :: HsExplicitFlag [Explicit] :: HsExplicitFlag type HsContext name = [LHsType name] type LHsContext name = Located (HsContext name) 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnUnit' data HsQuasiQuote id [HsQuasiQuote] :: id -> SrcSpan -> FastString -> HsQuasiQuote id data HsTyWrapper [WpKiApps] :: [Kind] -> HsTyWrapper data HsTyLit [HsNumTy] :: SourceText -> Integer -> HsTyLit [HsStrTy] :: SourceText -> FastString -> 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 type LBangType name = Located (BangType name) type BangType name = HsType name data HsBang [HsNoBang] :: HsBang [HsSrcBang] :: (Maybe SourceText) -> (Maybe Bool) -> Bool -> HsBang [HsUnpack] :: (Maybe Coercion) -> HsBang [HsStrict] :: HsBang type HsSrcBang = HsBang type HsImplBang = HsBang getBangType :: LHsType a -> LHsType a getBangStrictness :: LHsType a -> HsSrcBang data ConDeclField name -- |
[ConDeclField] :: [Located name] -> LBangType name -> Maybe LHsDocString -> ConDeclField name [cd_fld_names] :: ConDeclField name -> [Located name] [cd_fld_type] :: ConDeclField name -> LBangType name [cd_fld_doc] :: ConDeclField name -> Maybe LHsDocString type LConDeclField name = Located (ConDeclField name) May have 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnComma' when in a list pprConDeclFields :: OutputableBndr name => [LConDeclField name] -> SDoc mkHsQTvs :: [LHsTyVarBndr RdrName] -> LHsTyVarBndrs RdrName hsQTvBndrs :: LHsTyVarBndrs name -> [LHsTyVarBndr name] -- | Does this HsTyVarBndr come with an explicit kind annotation? isHsKindedTyVar :: HsTyVarBndr name -> Bool -- | Do all type variables in this LHsTyVarBndr come with kind -- annotations? hsTvbAllKinded :: LHsTyVarBndrs name -> Bool mkExplicitHsForAllTy :: [LHsTyVarBndr RdrName] -> LHsContext RdrName -> LHsType RdrName -> HsType RdrName mkImplicitHsForAllTy :: LHsContext RdrName -> LHsType RdrName -> HsType RdrName mkQualifiedHsForAllTy :: LHsContext RdrName -> LHsType RdrName -> HsType RdrName hsExplicitTvs :: LHsType Name -> [Name] hsTyVarName :: HsTyVarBndr name -> name mkHsWithBndrs :: thing -> HsWithBndrs RdrName thing hsLKiTyVarNames :: LHsTyVarBndrs Name -> [Name] hsLTyVarName :: LHsTyVarBndr name -> name hsLTyVarNames :: LHsTyVarBndrs name -> [name] hsLTyVarLocName :: LHsTyVarBndr name -> Located name hsLTyVarLocNames :: LHsTyVarBndrs name -> [Located name] splitLHsInstDeclTy_maybe :: LHsType name -> Maybe (LHsTyVarBndrs name, HsContext name, Located name, [LHsType name]) splitHsClassTy_maybe :: HsType name -> Maybe (name, [LHsType name]) splitLHsClassTy_maybe :: LHsType name -> Maybe (Located name, [LHsType name]) splitHsFunType :: LHsType Name -> ([LHsType Name], LHsType Name) splitHsAppTys :: LHsType n -> [LHsType n] -> (LHsType n, [LHsType n]) hsTyGetAppHead_maybe :: LHsType n -> Maybe (n, [LHsType n]) mkHsAppTys :: OutputableBndr n => LHsType n -> [LHsType n] -> HsType n mkHsOpTy :: LHsType name -> Located name -> LHsType name -> HsType name isWildcardTy :: HsType a -> Bool isNamedWildcardTy :: HsType a -> Bool pprParendHsType :: (OutputableBndr name) => HsType name -> SDoc pprHsForAll :: OutputableBndr name => HsExplicitFlag -> LHsTyVarBndrs name -> LHsContext name -> SDoc -- | Version of pprHsForAll that can also print an extra-constraints -- wildcard, e.g. _ => a -> Bool or (Show a, _) => -- a -> String. This underscore will be printed when the 'Maybe -- SrcSpan' argument is a Just containing the location of the -- extra-constraints wildcard. A special function for this is needed, as -- the extra-constraints wildcard is removed from the actual context and -- type, and stored in a separate field, thus just printing the type will -- not print the extra-constraints wildcard. pprHsForAllExtra :: OutputableBndr name => HsExplicitFlag -> Maybe SrcSpan -> LHsTyVarBndrs name -> LHsContext name -> SDoc pprHsContext :: (OutputableBndr name) => HsContext name -> SDoc pprHsContextNoArrow :: (OutputableBndr name) => HsContext name -> SDoc pprHsContextMaybe :: (OutputableBndr name) => HsContext name -> Maybe SDoc instance Data HsExplicitFlag instance Data HsTupleSort instance Data HsTyWrapper instance Data HsTyLit instance Data HsIPName instance Eq HsIPName instance Data id => Data (HsQuasiQuote id) instance DataId name => Data (LHsTyVarBndrs name) instance (Data name, Data thing, Data (PostRn name [Name])) => Data (HsWithBndrs name thing) instance DataId name => Data (HsTyVarBndr name) instance DataId name => Data (HsType name) instance DataId name => Data (ConDeclField name) instance OutputableBndr id => Outputable (HsQuasiQuote id) instance Outputable HsIPName instance OutputableBndr HsIPName instance OutputableBndr name => Outputable (HsType name) instance Outputable HsTyLit instance OutputableBndr name => Outputable (LHsTyVarBndrs name) instance OutputableBndr name => Outputable (HsTyVarBndr name) instance Outputable thing => Outputable (HsWithBndrs name thing) -- | This module is about types that can be defined in Haskell, but which -- must be wired into the compiler nonetheless. C.f module TysPrim module TysWiredIn wiredInTyCons :: [TyCon] 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 promotedBoolTyCon :: TyCon promotedFalseDataCon :: TyCon promotedTrueDataCon :: TyCon ltDataCon :: DataCon ltDataConId :: Id eqDataCon :: DataCon eqDataConId :: Id gtDataCon :: DataCon gtDataConId :: Id promotedOrderingTyCon :: TyCon promotedLTDataCon :: TyCon promotedEQDataCon :: TyCon promotedGTDataCon :: TyCon charTyCon :: TyCon charDataCon :: DataCon charTyCon_RDR :: RdrName charTy :: Type stringTy :: Type charTyConName :: Name 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 listTyCon :: TyCon nilDataCon :: DataCon nilDataConName :: Name consDataCon :: DataCon consDataConName :: Name listTyCon_RDR :: RdrName consDataCon_RDR :: RdrName listTyConName :: Name mkListTy :: Type -> Type mkPromotedListTy :: Type -> Type mkTupleTy :: TupleSort -> [Type] -> Type -- | Build the type of a small tuple that holds the specified type of thing mkBoxedTupleTy :: [Type] -> Type tupleTyCon :: TupleSort -> Arity -> TyCon tupleCon :: TupleSort -> Arity -> DataCon promotedTupleTyCon :: TupleSort -> Arity -> TyCon promotedTupleDataCon :: TupleSort -> Arity -> TyCon unitTyCon :: TyCon unitDataCon :: DataCon unitDataConId :: Id pairTyCon :: TyCon unboxedUnitTyCon :: TyCon unboxedUnitDataCon :: DataCon unboxedSingletonTyCon :: TyCon unboxedSingletonDataCon :: DataCon unboxedPairTyCon :: TyCon unboxedPairDataCon :: DataCon unitTy :: Type typeNatKindCon :: TyCon typeNatKind :: Kind typeSymbolKindCon :: TyCon typeSymbolKind :: Kind -- | Construct a type representing the application of the parallel array -- constructor mkPArrTy :: Type -> Type -- | Represents the type constructor of parallel arrays -- --
--
• This must match the definition in PrelPArr
• --
-- -- NB: Although the constructor is given here, it will not be accessible -- in user code as it is not in the environment of any compiled module -- except PrelPArr. parrTyCon :: TyCon -- | Fake array constructors -- --
--
• These constructors are never really used to represent array -- values; however, they are very convenient during desugaring (and, in -- particular, in the pattern matching compiler) to treat array pattern -- just like yet another constructor pattern
• --
--
• ordinary statements (assignments, stores etc.)
• --
• jumps
• --
• labels
• --
• out-of-line labelled blocks
• --
```--   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_sptEntryZC0_closure;
--     hs_spt_insert(k0, &Main_sptEntryZC0_closure);
--
--     static StgWord64 k1[2] = {12545634534567898ULL,5409674567544151ULL};
--     extern StgPtr Main_sptEntryZC1_closure;
--     hs_spt_insert(k1, &Main_sptEntryZC1_closure);
--
--   }
--   ```
-- -- where the constants are fingerprints produced from the static forms. -- -- 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);
--
--   }
--   ```
--
• tycons which have converted versions are mapped to -- True
• --
• tycons which are not changed by vectorisation are mapped to -- False
• --
• tycons which haven't been converted (because they can't or weren't -- vectorised) are not elements of the map
• --
```--   FunTy k1 k2
--   TyConApp PrimTyCon [...]
--   TyVar kv   -- (during inference only)
--   ForAll ... -- (for top-level coercions)
--   ```
type Kind = Type typeKind :: Type -> Kind -- | See Type#kind_subtyping for details of the distinction between -- these Kinds unliftedTypeKind :: Kind -- | See Type#kind_subtyping for details of the distinction between -- these Kinds liftedTypeKind :: Kind -- | See Type#kind_subtyping for details of the distinction between -- these Kinds openTypeKind :: Kind -- | See Type#kind_subtyping for details of the distinction between -- these Kinds constraintKind :: Kind -- | Given two kinds k1 and k2, creates the Kind -- k1 -> k2 mkArrowKind :: Kind -> Kind -> Kind -- | Iterated application of mkArrowKind mkArrowKinds :: [Kind] -> Kind -> Kind isLiftedTypeKind :: Kind -> Bool -- | See Type#kind_subtyping for details of the distinction between -- these Kinds isUnliftedTypeKind :: Kind -> Bool -- | True of any sub-kind of OpenTypeKind isSubOpenTypeKind :: Kind -> Bool tcIsSubKind :: Kind -> Kind -> Bool -- | Essentially splitFunTys on kinds splitKindFunTys :: Kind -> ([Kind], Kind) defaultKind :: Kind -> Kind -- | The key representation of types within the compiler data Type -- | A type of the form p of kind Constraint 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: -- --
--
• The type checker must treat it as opaque
• --
• The rest of the compiler treats it as transparent
• --
-- -- Consider these examples: -- --
```--   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] mkForAllTy :: TyVar -> Type -> Type -- | Wraps foralls over the type using the provided TyVars from left -- to right mkForAllTys :: [TyVar] -> Type -> Type -- | Creates a function type from the given argument and result type mkFunTy :: Type -> Type -> Type mkFunTys :: [Type] -> Type -> Type -- | Splits off argument types from the given type and associating them -- with the things in the input list from left to right. The final result -- type is returned, along with the resulting pairs of objects and types, -- albeit with the list of pairs in reverse order. Panics if there are -- not enough argument types for the input list. zipFunTys :: Outputable a => [a] -> Type -> ([(a, 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 -- | Instantiate a forall type with one or more type arguments. Used when -- we have a polymorphic function applied to type args: -- --
```--   f t1 t2
--   ```
-- -- We use applyTys type-of-f [t1,t2] to compute the type of the -- expression. Panics if no application is possible. applyTy :: Type -> KindOrType -> Type -- | This function is interesting because: -- --
--
1. The function may have more for-alls than there are -- args
1. Less obviously, it may have fewer for-alls
2. --
-- -- For case 2. think of: -- --
```--   applyTys (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. applyTys :: Type -> [KindOrType] -> Type mkTyVarTy :: TyVar -> Type mkTyVarTys :: [TyVar] -> [Type] -- | Create the plain type constructor type which has been applied to no -- type arguments at all. mkTyConTy :: TyCon -> Type isClassPred :: PredType -> Bool isEqPred :: PredType -> Bool isIPPred :: PredType -> Bool mkClassPred :: Class -> [Type] -> PredType isDictLikeTy :: Type -> Bool tcSplitDFunTy :: Type -> ([TyVar], [Type], Class, [Type]) tcSplitDFunHead :: Type -> (Class, [Type]) -- | Creates a type equality predicate mkEqPred :: Type -> Type -> PredType -- | Type substitution -- -- The following invariants must hold of a TvSubst: -- --
--
1. The in-scope set is needed only to guide the generation of -- fresh uniques
2. --
3. In particular, the kind of the type variables in the -- in-scope set is not relevant
4. --
5. The substitution is only applied ONCE! This is because in general -- such application will not reached a fixed point.
6. --
```--   return (x,y)
--   ```
-- -- If the sequel is AssignTo [p,q] -- --
```--   p=x; q=y;
--   ```
```--   fromIntegral T = fromIntegral_T
--   ```
-- -- is an orphan. Of course it isn't, and declaring it an orphan would -- make the whole module an orphan module, which is bad. ruleLhsOrphNames :: CoreRule -> NameSet -- | This finds all locally-defined free Ids on the left hand side of a -- rule ruleLhsFreeIds :: CoreRule -> VarSet -- | Free variables of a vectorisation declaration vectsFreeVars :: [CoreVect] -> VarSet -- | Every node in an expression annotated with its (non-global) free -- variables, both Ids and TyVars type CoreExprWithFVs = AnnExpr Id VarSet -- | Every node in a binding group annotated with its (non-global) free -- variables, both Ids and TyVars type CoreBindWithFVs = AnnBind Id VarSet -- | Annotate a CoreExpr with its (non-global) free type and value -- variables at every tree node freeVars :: CoreExpr -> CoreExprWithFVs -- | Inverse function to freeVars freeVarsOf :: CoreExprWithFVs -> IdSet -- | Commonly useful utilites for manipulating the Core language module CoreUtils -- | Wrap the given expression in the coercion safely, dropping identity -- coercions and coalescing nested coercions mkCast :: CoreExpr -> Coercion -> CoreExpr -- | Wraps the given expression in the source annotation, dropping the -- annotation if possible. mkTick :: Tickish Id -> CoreExpr -> CoreExpr mkTicks :: [Tickish Id] -> CoreExpr -> CoreExpr mkTickNoHNF :: Tickish Id -> CoreExpr -> CoreExpr tickHNFArgs :: Tickish Id -> 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 CoreSyn#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 -- | Extract the default case alternative findDefault :: [(AltCon, [a], b)] -> ([(AltCon, [a], b)], Maybe b) -- | Find the case alternative corresponding to a particular constructor: -- panics if no such constructor exists findAlt :: AltCon -> [(AltCon, a, b)] -> Maybe (AltCon, a, b) isDefaultAlt :: (AltCon, a, b) -> Bool -- | Merge alternatives preserving order; alternatives in the first -- argument shadow ones in the second mergeAlts :: [(AltCon, a, b)] -> [(AltCon, a, b)] -> [(AltCon, a, b)] -- | 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 agains the pattern trimConArgs :: AltCon -> [CoreArg] -> [CoreArg] filterAlts :: [Unique] -> Type -> [AltCon] -> [(AltCon, [Var], a)] -> ([AltCon], Bool, [(AltCon, [Var], a)]) -- | 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 exprIsDupable :: DynFlags -> CoreExpr -> Bool exprIsTrivial :: CoreExpr -> Bool getIdFromTrivialExpr :: CoreExpr -> Id exprIsBottom :: CoreExpr -> Bool exprIsCheap :: CoreExpr -> Bool exprIsExpandable :: CoreExpr -> Bool exprIsCheap' :: CheapAppFun -> CoreExpr -> Bool type CheapAppFun = Id -> Int -> 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 CoreSyn#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: -- --
--
• Safe to evaluate even if normal order eval might not evaluate the -- expression at all, or
• --
• Safe not to evaluate even if normal order would do so
• --
-- -- It is usually called on arguments of unlifted type, but not always In -- particular, Simplify.rebuildCase calls it on lifted types when a -- 'case' is a plain seq. See the example in Note -- [exprOkForSpeculation: case expressions] below -- -- Precisely, it returns True iff: a) The expression guarantees -- to terminate, b) soon, c) without causing a write side effect (e.g. -- writing a mutable variable) d) without throwing a Haskell exception e) -- without risking an unchecked runtime exception (array out of bounds, -- divide by zero) -- -- For exprOkForSideEffects the list is the same, but omitting -- (e). -- -- Note that exprIsHNF implies exprOkForSpeculation exprOkForSpeculation -- implies exprOkForSideEffects -- -- See Note [PrimOp can_fail and has_side_effects] in PrimOp and Note -- [Implementation: how can_fail/has_side_effects affect transformations] -- -- As an example of the considerations in this test, consider: -- --
```--   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 :: Expr b -> Bool -- | exprOkForSpeculation returns True of an expression that is: -- --
--
• Safe to evaluate even if normal order eval might not evaluate the -- expression at all, or
• --
• Safe not to evaluate even if normal order would do so
• --
-- -- It is usually called on arguments of unlifted type, but not always In -- particular, Simplify.rebuildCase calls it on lifted types when a -- 'case' is a plain seq. See the example in Note -- [exprOkForSpeculation: case expressions] below -- -- Precisely, it returns True iff: a) The expression guarantees -- to terminate, b) soon, c) without causing a write side effect (e.g. -- writing a mutable variable) d) without throwing a Haskell exception e) -- without risking an unchecked runtime exception (array out of bounds, -- divide by zero) -- -- For exprOkForSideEffects the list is the same, but omitting -- (e). -- -- Note that exprIsHNF implies exprOkForSpeculation exprOkForSpeculation -- implies exprOkForSideEffects -- -- See Note [PrimOp can_fail and has_side_effects] in PrimOp and Note -- [Implementation: how can_fail/has_side_effects affect transformations] -- -- As an example of the considerations in this test, consider: -- --
```--   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 :: Expr b -> Bool exprIsWorkFree :: CoreExpr -> Bool -- | Returns True of expressions that are too big to be compared -- by cheapEqExpr exprIsBig :: Expr b -> Bool -- | Similar to exprIsHNF but includes CONLIKE functions as well as -- data constructors. Conlike arguments are considered interesting by the -- inliner. exprIsConLike :: CoreExpr -> Bool -- | This function is called only on *top-level* right-hand sides. Returns -- True if the RHS can be allocated statically in the output, -- with no thunks involved at all. rhsIsStatic :: Platform -> (Name -> Bool) -> (Integer -> CoreExpr) -> CoreExpr -> Bool isCheapApp :: CheapAppFun isExpandableApp :: CheapAppFun coreBindsSize :: [CoreBind] -> Int -- | A measure of the size of the expressions, strictly greater than 0 It -- also forces the expression pretty drastically as a side effect Counts -- *leaves*, not internal nodes. Types and coercions are not counted. exprSize :: CoreExpr -> Int data CoreStats [CS] :: Int -> Int -> Int -> CoreStats [cs_tm] :: CoreStats -> Int [cs_ty] :: CoreStats -> Int [cs_co] :: CoreStats -> Int coreBindsStats :: [CoreBind] -> CoreStats -- | 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. -- -- See also exprIsBig cheapEqExpr :: Expr b -> Expr b -> Bool -- | Cheap expression equality test, can ignore ticks by type. cheapEqExpr' :: (Tickish Id -> 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 -- specuatively 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 -- | A more efficient version of applyTypeToArg when we have several -- arguments. The first argument is just for debugging, and gives some -- context applyTypeToArgs :: CoreExpr -> 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] -> DataCon -> [Type] -> ([TyVar], [Id]) dataConRepFSInstPat :: [FastString] -> [Unique] -> DataCon -> [Type] -> ([TyVar], [Id]) -- | Strip ticks satisfying a predicate from top of an expression stripTicksTop :: (Tickish Id -> Bool) -> Expr b -> ([Tickish Id], Expr b) -- | Strip ticks satisfying a predicate from top of an expression, -- returning the remaining expresion stripTicksTopE :: (Tickish Id -> Bool) -> Expr b -> Expr b -- | Strip ticks satisfying a predicate from top of an expression, -- returning the ticks stripTicksTopT :: (Tickish Id -> Bool) -> Expr b -> [Tickish Id] -- | Completely strip ticks satisfying a predicate from an expression. Note -- this is O(n) in the size of the expression! stripTicksE :: (Tickish Id -> Bool) -> Expr b -> Expr b stripTicksT :: (Tickish Id -> Bool) -> Expr b -> [Tickish Id] instance Outputable CoreStats module SAT doStaticArgs :: UniqSupply -> CoreProgram -> CoreProgram module OccurAnal occurAnalysePgm :: Module -> (Activation -> Bool) -> [CoreRule] -> [CoreVect] -> VarSet -> CoreProgram -> CoreProgram occurAnalyseExpr :: CoreExpr -> CoreExpr occurAnalyseExpr_NoBinderSwap :: CoreExpr -> CoreExpr instance Outputable Details instance Outputable OccEncl module InstEnv type DFunId = Id type InstMatch = (ClsInst, [DFunInstType]) type ClsInstLookupResult = ([InstMatch], [ClsInst], Bool) -- | The semantics allowed for overlapping instances for a particular -- instance. See Note [Safe Haskell isSafeOverlap] (in lhs) for a -- explanation of the isSafeOverlap field. -- --
data OverlapFlag [OverlapFlag] :: OverlapMode -> Bool -> OverlapFlag [overlapMode] :: OverlapFlag -> OverlapMode [isSafeOverlap] :: OverlapFlag -> Bool data OverlapMode -- | This instance must not overlap another NoOverlap instance. -- However, it may be overlapped by Overlapping instances, and it -- may overlap Overlappable instances. [NoOverlap] :: SourceText -> OverlapMode -- | Silently ignore this instance if you find a more specific one that -- matches the constraint you are trying to resolve -- -- Example: constraint (Foo [Int]) instance Foo [Int] instance {--} Foo -- [a] -- -- Since the second instance has the Overlappable flag, the first -- instance will be chosen (otherwise its ambiguous which to choose) [Overlappable] :: SourceText -> OverlapMode -- | Silently ignore any more general instances that may be used to solve -- the constraint. -- -- Example: constraint (Foo [Int]) instance {--} Foo [Int] instance Foo -- [a] -- -- Since the first instance has the Overlapping flag, the second---more -- general---instance will be ignored (otherwise it is ambiguous which to -- choose) [Overlapping] :: SourceText -> OverlapMode -- | Equivalent to having both Overlapping and Overlappable -- flags. [Overlaps] :: SourceText -> OverlapMode -- | Behave like Overlappable and Overlapping, and in addition pick an an -- arbitrary one if there are multiple matching candidates, and don't -- worry about later instantiation -- -- Example: constraint (Foo [b]) instance {-# INCOHERENT -} Foo [Int] -- instance Foo [a] Without the Incoherent flag, we'd complain that -- instantiating b would change which instance was chosen. See -- also note [Incoherent instances] in InstEnv [Incoherent] :: SourceText -> OverlapMode setOverlapModeMaybe :: OverlapFlag -> Maybe OverlapMode -> OverlapFlag data ClsInst [ClsInst] :: Name -> [Maybe Name] -> [TyVar] -> Class -> [Type] -> DFunId -> OverlapFlag -> IsOrphan -> ClsInst [is_cls_nm] :: ClsInst -> Name [is_tcs] :: ClsInst -> [Maybe Name] [is_tvs] :: ClsInst -> [TyVar] [is_cls] :: ClsInst -> Class [is_tys] :: ClsInst -> [Type] [is_dfun] :: ClsInst -> DFunId [is_flag] :: ClsInst -> OverlapFlag [is_orphan] :: ClsInst -> IsOrphan type DFunInstType = Maybe Type pprInstance :: ClsInst -> SDoc pprInstanceHdr :: ClsInst -> SDoc pprInstances :: [ClsInst] -> SDoc instanceHead :: ClsInst -> ([TyVar], Class, [Type]) instanceSig :: ClsInst -> ([TyVar], [Type], Class, [Type]) mkLocalInstance :: DFunId -> OverlapFlag -> [TyVar] -> Class -> [Type] -> ClsInst mkImportedInstance :: Name -> [Maybe Name] -> DFunId -> OverlapFlag -> IsOrphan -> ClsInst instanceDFunId :: ClsInst -> DFunId tidyClsInstDFun :: (DFunId -> DFunId) -> ClsInst -> ClsInst instanceRoughTcs :: ClsInst -> [Maybe Name] -- | A fuzzy comparison function for class instances, intended for sorting -- instances before displaying them to the user. fuzzyClsInstCmp :: ClsInst -> ClsInst -> Ordering -- | 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 -- | InstEnvs represents the combination of the global type class -- instance environment, the local type class instance environment, and -- the set of transitively reachable orphan modules (according to what -- modules have been directly imported) used to test orphan instance -- visibility. data InstEnvs [InstEnvs] :: InstEnv -> InstEnv -> VisibleOrphanModules -> InstEnvs [ie_global] :: InstEnvs -> InstEnv [ie_local] :: InstEnvs -> InstEnv [ie_visible] :: InstEnvs -> VisibleOrphanModules -- | Set of visible orphan modules, according to what modules have been -- directly imported. This is based off of the dep_orphs field, which -- records transitively reachable orphan modules (modules that define -- orphan instances). type VisibleOrphanModules = ModuleSet type InstEnv = UniqFM ClsInstEnv emptyInstEnv :: InstEnv extendInstEnv :: InstEnv -> ClsInst -> InstEnv deleteFromInstEnv :: InstEnv -> ClsInst -> InstEnv -- | True when when the instance heads are the same e.g. both are Eq -- [(a,b)] Used for overriding in GHCi Obviously should be insenstive to -- alpha-renaming identicalClsInstHead :: ClsInst -> ClsInst -> Bool extendInstEnvList :: InstEnv -> [ClsInst] -> InstEnv -- | Look up an instance in the given instance environment. The given class -- application must match exactly one instance and the match may not -- contain any flexi type variables. If the lookup is unsuccessful, yield -- 'Left errorMessage'. lookupUniqueInstEnv :: InstEnvs -> Class -> [Type] -> Either MsgDoc (ClsInst, [Type]) lookupInstEnv' :: InstEnv -> VisibleOrphanModules -> Class -> [Type] -> ([InstMatch], [ClsInst]) -- | See Note [Rules for instance lookup] lookupInstEnv :: InstEnvs -> Class -> [Type] -> ClsInstLookupResult instEnvElts :: InstEnv -> [ClsInst] -- | Checks for an exact match of ClsInst in the instance environment. We -- use this when we do signature checking in TcRnDriver memberInstEnv :: InstEnv -> ClsInst -> Bool -- | Test if an instance is visible, by checking that its origin module is -- in VisibleOrphanModules. See Note [Instance lookup and orphan -- instances] instIsVisible :: VisibleOrphanModules -> ClsInst -> Bool classInstances :: InstEnvs -> Class -> [ClsInst] -- | Collects the names of concrete types and type constructors that make -- up the head of a class instance. For instance, given `class Foo a b`: -- -- `instance Foo (Either (Maybe Int) a) Bool` would yield [Either, Maybe, -- Int, Bool] -- -- Used in the implementation of ":info" in GHCi. orphNamesOfClsInst :: ClsInst -> NameSet instanceBindFun :: TyVar -> BindFlag instanceCantMatch :: [Maybe Name] -> [Maybe Name] -> Bool roughMatchTcs :: [Type] -> [Maybe Name] instance Data ClsInst instance Data IsOrphan instance NamedThing ClsInst instance Outputable ClsInst instance Binary IsOrphan instance Outputable ClsInstEnv module FunDeps data FDEq [FDEq] :: Int -> Type -> Type -> FDEq [fd_pos] :: FDEq -> Int [fd_ty_left] :: FDEq -> Type [fd_ty_right] :: FDEq -> Type data Equation loc [FDEqn] :: [TyVar] -> [FDEq] -> PredType -> loc -> Equation loc [fd_qtvs] :: Equation loc -> [TyVar] [fd_eqs] :: Equation loc -> [FDEq] [fd_pred1, fd_pred2] :: Equation loc -> PredType [fd_loc] :: Equation loc -> loc pprEquation :: Equation a -> SDoc improveFromInstEnv :: InstEnvs -> PredType -> [Equation SrcSpan] improveFromAnother :: PredType -> PredType -> [Equation ()] checkInstCoverage :: Bool -> Class -> [PredType] -> [Type] -> Validity checkFunDeps :: InstEnvs -> ClsInst -> Maybe [ClsInst] pprFundeps :: Outputable a => [FunDep a] -> SDoc instance Outputable FDEq module TrieMap data CoreMap a emptyCoreMap :: CoreMap a extendCoreMap :: CoreMap a -> CoreExpr -> a -> CoreMap a lookupCoreMap :: CoreMap a -> CoreExpr -> Maybe a foldCoreMap :: (a -> b -> b) -> b -> CoreMap a -> b 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 data CoercionMap a data MaybeMap m a data ListMap m a class TrieMap m where type family Key m :: * emptyTM :: TrieMap m => m a lookupTM :: TrieMap m => Key m -> m b -> Maybe b alterTM :: TrieMap m => Key m -> XT b -> m b -> m b mapTM :: TrieMap m => (a -> b) -> m a -> m b 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 lookupTypeMapTyCon :: TypeMap a -> TyCon -> [a] instance TrieMap IntMap instance Ord k => TrieMap (Map k) instance TrieMap UniqFM instance TrieMap m => TrieMap (MaybeMap m) instance TrieMap m => TrieMap (ListMap m) instance TrieMap CoreMap instance Outputable a => Outputable (CoreMap a) instance TrieMap AltMap instance TrieMap CoercionMap instance TrieMap RoleMap instance Outputable a => Outputable (TypeMap a) instance TrieMap TypeMap instance TrieMap TyLitMap instance TrieMap VarMap module FamInstEnv data FamInst [FamInst] :: CoAxiom Unbranched -> FamFlavor -> Name -> [Maybe Name] -> [TyVar] -> [Type] -> Type -> FamInst [fi_axiom] :: FamInst -> CoAxiom Unbranched [fi_flavor] :: FamInst -> FamFlavor [fi_fam] :: FamInst -> Name [fi_tcs] :: FamInst -> [Maybe Name] [fi_tvs] :: FamInst -> [TyVar] [fi_tys] :: FamInst -> [Type] [fi_rhs] :: FamInst -> Type data FamFlavor [SynFamilyInst] :: FamFlavor [DataFamilyInst] :: TyCon -> FamFlavor famInstAxiom :: FamInst -> CoAxiom Unbranched famInstTyCon :: FamInst -> TyCon famInstRHS :: FamInst -> Type famInstsRepTyCons :: [FamInst] -> [TyCon] famInstRepTyCon_maybe :: FamInst -> Maybe TyCon dataFamInstRepTyCon :: FamInst -> TyCon pprFamInst :: FamInst -> SDoc pprFamInsts :: [FamInst] -> SDoc mkImportedFamInst :: Name -> [Maybe Name] -> CoAxiom Unbranched -> FamInst type FamInstEnvs = (FamInstEnv, FamInstEnv) type FamInstEnv = UniqFM FamilyInstEnv emptyFamInstEnv :: FamInstEnv emptyFamInstEnvs :: (FamInstEnv, FamInstEnv) extendFamInstEnv :: FamInstEnv -> FamInst -> FamInstEnv deleteFromFamInstEnv :: FamInstEnv -> FamInst -> FamInstEnv extendFamInstEnvList :: FamInstEnv -> [FamInst] -> FamInstEnv -- | True when the LHSs are identical Used for overriding in GHCi identicalFamInstHead :: FamInst -> FamInst -> Bool famInstEnvElts :: FamInstEnv -> [FamInst] familyInstances :: (FamInstEnv, FamInstEnv) -> TyCon -> [FamInst] -- | Collects the names of the concrete types and type constructors that -- make up the LHS of a type family instance, including the family name -- itself. -- -- For instance, given `type family Foo a b`: `type instance Foo (F (G (H -- a))) b = ...` would yield [Foo,F,G,H] -- -- Used in the implementation of ":info" in GHCi. orphNamesOfFamInst :: FamInst -> NameSet mkCoAxBranch :: [TyVar] -> [Type] -> Type -> SrcSpan -> CoAxBranch mkBranchedCoAxiom :: Name -> TyCon -> [CoAxBranch] -> CoAxiom Branched mkUnbranchedCoAxiom :: Name -> TyCon -> CoAxBranch -> CoAxiom Unbranched mkSingleCoAxiom :: Name -> [TyVar] -> TyCon -> [Type] -> Type -> CoAxiom Unbranched computeAxiomIncomps :: CoAxiom br -> CoAxiom br data FamInstMatch [FamInstMatch] :: FamInst -> [Type] -> FamInstMatch [fim_instance] :: FamInstMatch -> FamInst [fim_tys] :: FamInstMatch -> [Type] lookupFamInstEnv :: FamInstEnvs -> TyCon -> [Type] -> [FamInstMatch] lookupFamInstEnvConflicts :: FamInstEnvs -> FamInst -> [FamInstMatch] isDominatedBy :: CoAxBranch -> [CoAxBranch] -> Bool topNormaliseType :: FamInstEnvs -> Type -> Type -- | Get rid of *outermost* (or toplevel) * type function redex * newtypes -- using appropriate coercions. Specifically, if topNormaliseType_maybe -- env ty = Maybe (co, ty') then (a) co :: ty ~ ty' (b) ty' is not a -- newtype, and is not a type-family redex -- -- However, ty' can be something like (Maybe (F ty)), where (F ty) is a -- redex. -- -- Its a bit like Type.repType, but handles type families too The -- coercion returned is always an R coercion topNormaliseType_maybe :: FamInstEnvs -> Type -> Maybe (Coercion, Type) normaliseType :: FamInstEnvs -> Role -> Type -> (Coercion, Type) normaliseTcApp :: FamInstEnvs -> Role -> TyCon -> [Type] -> (Coercion, Type) reduceTyFamApp_maybe :: FamInstEnvs -> Role -> TyCon -> [Type] -> Maybe (Coercion, Type) chooseBranch :: CoAxiom Branched -> [Type] -> Maybe (BranchIndex, [Type]) flattenTys :: InScopeSet -> [Type] -> [Type] instance NamedThing FamInst instance Outputable FamInst instance Outputable FamilyInstEnv instance Outputable FamInstMatch module OptCoercion -- | optCoercion applies a substitution to a coercion, *and* optimises it -- to reduce its size optCoercion :: CvSubst -> 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 module CoreSubst -- | A substitution environment, containing both Id and TyVar -- substitutions. -- -- Some invariants apply to how you use the substitution: -- --
--
1. The in-scope set contains at least those Ids and -- TyVars that will be in scope after applying the -- substitution to a term. Precisely, the in-scope set must be a superset -- of the free vars of the substitution range that might possibly clash -- with locally-bound variables in the thing being substituted in.
2. --
3. You may apply the substitution only once
4. --
-- -- There are various ways of setting up the in-scope set such that the -- first of these invariants hold: -- --
--
• Arrange that the in-scope set really is all the things in -- scope
• --
• Arrange that it's the free vars of the range of the -- substitution
• --
• Make it empty, if you know that all the free vars of the -- substitution are fresh, and hence can't possibly clash
• --
data Subst [Subst] :: InScopeSet -> IdSubstEnv -> TvSubstEnv -> CvSubstEnv -> Subst -- | A substitution of Types for TyVars and Kinds for -- KindVars type TvSubstEnv = TyVarEnv Type -- | An environment for substituting for Ids type IdSubstEnv = IdEnv CoreExpr -- | A set of variables that are in scope at some point data InScopeSet -- | 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.) -- --
--
• Aug 09 This function is not used in GHC at the moment, but -- seems so short and simple that I'm going to leave it here
• --
```--   e' = etaExpand n us e ty
--   ```
-- -- We should have that: -- --
```--   ty = exprType e = exprType e'
--   ```
etaExpand :: Arity -> CoreExpr -> CoreExpr instance Outputable EtaInfo module CoreUnfold -- | Records the unfolding of an identifier, which is approximately -- the form the identifier would have if we substituted its definition in -- for the identifier. This type should be treated as abstract everywhere -- except in CoreUnfold data Unfolding -- | UnfoldingGuidance says when unfolding should take place data UnfoldingGuidance -- | There is no known Unfolding noUnfolding :: Unfolding mkImplicitUnfolding :: DynFlags -> CoreExpr -> Unfolding mkUnfolding :: DynFlags -> UnfoldingSource -> Bool -> Bool -> CoreExpr -> Unfolding mkCoreUnfolding :: UnfoldingSource -> Bool -> CoreExpr -> UnfoldingGuidance -> Unfolding mkTopUnfolding :: DynFlags -> Bool -> CoreExpr -> Unfolding mkSimpleUnfolding :: DynFlags -> CoreExpr -> Unfolding mkWorkerUnfolding :: DynFlags -> (CoreExpr -> CoreExpr) -> Unfolding -> Unfolding mkInlineUnfolding :: Maybe Arity -> CoreExpr -> Unfolding mkInlinableUnfolding :: DynFlags -> CoreExpr -> Unfolding mkWwInlineRule :: CoreExpr -> Arity -> Unfolding mkCompulsoryUnfolding :: CoreExpr -> Unfolding mkDFunUnfolding :: [Var] -> DataCon -> [CoreExpr] -> Unfolding specUnfolding :: DynFlags -> Subst -> [Var] -> [CoreExpr] -> Unfolding -> Unfolding interestingArg :: CoreExpr -> ArgSummary data ArgSummary [TrivArg] :: ArgSummary [NonTrivArg] :: ArgSummary [ValueArg] :: ArgSummary couldBeSmallEnoughToInline :: DynFlags -> Int -> CoreExpr -> Bool inlineBoringOk :: CoreExpr -> Bool certainlyWillInline :: DynFlags -> Unfolding -> Maybe Unfolding smallEnoughToInline :: DynFlags -> Unfolding -> Bool callSiteInline :: DynFlags -> Id -> Bool -> Bool -> [ArgSummary] -> CallCtxt -> Maybe CoreExpr data CallCtxt [BoringCtxt] :: CallCtxt [RhsCtxt] :: CallCtxt [DiscArgCtxt] :: CallCtxt [RuleArgCtxt] :: CallCtxt [ValAppCtxt] :: CallCtxt [CaseCtxt] :: CallCtxt -- | Returns Just (dc, [t1..tk], [x1..xn]) if the argument -- expression is a *saturated* constructor application of the form dc -- t1..tk x1 .. xn, where t1..tk are the *universally-qantified* -- type args of dc exprIsConApp_maybe :: InScopeEnv -> CoreExpr -> Maybe (DataCon, [Type], [CoreExpr]) exprIsLiteral_maybe :: InScopeEnv -> CoreExpr -> Maybe Literal instance Outputable ExprSize instance Outputable ArgSummary instance Outputable CallCtxt module LiberateCase liberateCase :: DynFlags -> CoreProgram -> CoreProgram module CoreTidy tidyExpr :: TidyEnv -> CoreExpr -> CoreExpr tidyVarOcc :: TidyEnv -> Var -> Var tidyRule :: TidyEnv -> CoreRule -> CoreRule tidyRules :: TidyEnv -> [CoreRule] -> [CoreRule] tidyUnfolding :: TidyEnv -> Unfolding -> Unfolding -> Unfolding -- | Functions for collecting together and applying rewrite rules to a -- module. The CoreRule datatype itself is declared elsewhere. module Rules -- | Gathers a collection of CoreRules. Maps (the name of) an -- Id to its rules type RuleBase = NameEnv [CoreRule] emptyRuleBase :: RuleBase mkRuleBase :: [CoreRule] -> RuleBase extendRuleBaseList :: RuleBase -> [CoreRule] -> RuleBase unionRuleBase :: RuleBase -> RuleBase -> RuleBase pprRuleBase :: RuleBase -> SDoc -- | Report partial matches for rules beginning with the specified string -- for the purposes of error reporting ruleCheckProgram :: CompilerPhase -> String -> RuleBase -> CoreProgram -> SDoc -- | Make a SpecInfo containing a number of CoreRules, -- suitable for putting into an IdInfo mkSpecInfo :: [CoreRule] -> SpecInfo extendSpecInfo :: SpecInfo -> [CoreRule] -> SpecInfo addSpecInfo :: SpecInfo -> SpecInfo -> SpecInfo addIdSpecialisations :: Id -> [CoreRule] -> Id -- | Gather all the rules for locally bound identifiers from the supplied -- bindings rulesOfBinds :: [CoreBind] -> [CoreRule] getRules :: RuleBase -> Id -> [CoreRule] pprRulesForUser :: [CoreRule] -> SDoc -- | The main rule matching function. Attempts to apply all (active) -- supplied rules to this instance of an application in a given context, -- returning the rule applied and the resulting expression if successful. lookupRule :: DynFlags -> InScopeEnv -> (Activation -> Bool) -> Id -> [CoreExpr] -> [CoreRule] -> Maybe (CoreRule, CoreExpr) -- | Used to make CoreRule for an Id defined in the module -- being compiled. See also CoreRule mkRule :: Bool -> Bool -> RuleName -> Activation -> Name -> [CoreBndr] -> [CoreExpr] -> CoreExpr -> CoreRule -- | Find the "top" free names of several expressions. Such names are -- either: -- --
--
1. The function finally being applied to in an application chain (if -- that name is a GlobalId: see Var#globalvslocal), or
2. --
3. The TyCon if the expression is a Type
4. --
-- -- This is used for the fast-match-check for rules; if the top names -- don't match, the rest can't roughTopNames :: [CoreExpr] -> [Maybe Name] module CallArity callArityAnalProgram :: DynFlags -> CoreProgram -> CoreProgram callArityRHS :: CoreExpr -> CoreExpr module CSE cseProgram :: CoreProgram -> CoreProgram module TcEvidence data HsWrapper [WpHole] :: HsWrapper [WpCompose] :: HsWrapper -> HsWrapper -> HsWrapper [WpFun] :: HsWrapper -> HsWrapper -> TcType -> TcType -> HsWrapper [WpCast] :: TcCoercion -> HsWrapper [WpEvLam] :: EvVar -> HsWrapper [WpEvApp] :: EvTerm -> HsWrapper [WpTyLam] :: TyVar -> HsWrapper [WpTyApp] :: KindOrType -> HsWrapper [WpLet] :: TcEvBinds -> HsWrapper (<.>) :: HsWrapper -> HsWrapper -> HsWrapper mkWpTyApps :: [Type] -> HsWrapper mkWpEvApps :: [EvTerm] -> HsWrapper mkWpEvVarApps :: [EvVar] -> HsWrapper mkWpTyLams :: [TyVar] -> HsWrapper mkWpLams :: [Var] -> HsWrapper mkWpLet :: TcEvBinds -> HsWrapper mkWpCast :: TcCoercion -> HsWrapper mkWpFun :: HsWrapper -> HsWrapper -> TcType -> TcType -> HsWrapper idHsWrapper :: HsWrapper isIdHsWrapper :: HsWrapper -> Bool pprHsWrapper :: SDoc -> HsWrapper -> SDoc data TcEvBinds [TcEvBinds] :: EvBindsVar -> TcEvBinds [EvBinds] :: (Bag EvBind) -> TcEvBinds data EvBindsVar [EvBindsVar] :: (IORef EvBindMap) -> Unique -> EvBindsVar newtype EvBindMap [EvBindMap] :: VarEnv EvBind -> EvBindMap [ev_bind_varenv] :: EvBindMap -> VarEnv EvBind emptyEvBindMap :: EvBindMap extendEvBinds :: EvBindMap -> EvVar -> EvTerm -> EvBindMap lookupEvBind :: EvBindMap -> EvVar -> Maybe EvBind evBindMapBinds :: EvBindMap -> Bag EvBind data EvBind [EvBind] :: EvVar -> EvTerm -> EvBind emptyTcEvBinds :: TcEvBinds isEmptyTcEvBinds :: TcEvBinds -> Bool data EvTerm [EvId] :: EvId -> EvTerm [EvCoercion] :: TcCoercion -> EvTerm [EvCast] :: EvTerm -> TcCoercion -> EvTerm [EvDFunApp] :: DFunId -> [Type] -> [EvTerm] -> EvTerm [EvTupleSel] :: EvTerm -> Int -> EvTerm [EvTupleMk] :: [EvTerm] -> EvTerm [EvDelayedError] :: Type -> FastString -> EvTerm [EvSuperClass] :: EvTerm -> Int -> EvTerm [EvLit] :: EvLit -> EvTerm [EvTypeable] :: EvTypeable -> EvTerm mkEvCast :: EvTerm -> TcCoercion -> EvTerm evVarsOfTerm :: EvTerm -> VarSet data EvLit [EvNum] :: Integer -> EvLit [EvStr] :: FastString -> EvLit evTermCoercion :: EvTerm -> TcCoercion -- | Instructions on how to make a Typeable dictionary. data EvTypeable -- | Dicitionary for concrete type constructors. [EvTypeableTyCon] :: TyCon -> [Kind] -> EvTypeable -- | Dictionary for type applications; this is used when we have a type -- expression starting with a type variable (e.g., Typeable (f -- a)) [EvTypeableTyApp] :: (EvTerm, Type) -> (EvTerm, Type) -> EvTypeable -- | Dictionary for a type literal. [EvTypeableTyLit] :: Type -> EvTypeable data TcCoercion [TcRefl] :: Role -> TcType -> TcCoercion [TcTyConAppCo] :: Role -> TyCon -> [TcCoercion] -> TcCoercion [TcAppCo] :: TcCoercion -> TcCoercion -> TcCoercion [TcForAllCo] :: TyVar -> TcCoercion -> TcCoercion [TcCoVarCo] :: EqVar -> TcCoercion [TcAxiomInstCo] :: (CoAxiom Branched) -> Int -> [TcCoercion] -> TcCoercion [TcAxiomRuleCo] :: CoAxiomRule -> [TcType] -> [TcCoercion] -> TcCoercion [TcPhantomCo] :: TcType -> TcType -> TcCoercion [TcSymCo] :: TcCoercion -> TcCoercion [TcTransCo] :: TcCoercion -> TcCoercion -> TcCoercion [TcNthCo] :: Int -> TcCoercion -> TcCoercion [TcLRCo] :: LeftOrRight -> TcCoercion -> TcCoercion [TcSubCo] :: TcCoercion -> TcCoercion [TcCastCo] :: TcCoercion -> TcCoercion -> TcCoercion [TcLetCo] :: TcEvBinds -> TcCoercion -> TcCoercion [TcCoercion] :: Coercion -> TcCoercion data LeftOrRight [CLeft] :: LeftOrRight [CRight] :: LeftOrRight pickLR :: LeftOrRight -> (a, a) -> a mkTcReflCo :: Role -> TcType -> TcCoercion mkTcNomReflCo :: TcType -> TcCoercion mkTcRepReflCo :: TcType -> TcCoercion mkTcTyConAppCo :: Role -> TyCon -> [TcCoercion] -> TcCoercion mkTcAppCo :: TcCoercion -> TcCoercion -> TcCoercion mkTcAppCos :: TcCoercion -> [TcCoercion] -> TcCoercion mkTcFunCo :: Role -> TcCoercion -> TcCoercion -> TcCoercion mkTcAxInstCo :: Role -> CoAxiom br -> Int -> [TcType] -> TcCoercion mkTcUnbranchedAxInstCo :: Role -> CoAxiom Unbranched -> [TcType] -> TcCoercion mkTcForAllCo :: Var -> TcCoercion -> TcCoercion mkTcForAllCos :: [Var] -> TcCoercion -> TcCoercion mkTcSymCo :: TcCoercion -> TcCoercion mkTcTransCo :: TcCoercion -> TcCoercion -> TcCoercion mkTcNthCo :: Int -> TcCoercion -> TcCoercion mkTcLRCo :: LeftOrRight -> TcCoercion -> TcCoercion mkTcSubCo :: TcCoercion -> TcCoercion -- | If the EqRel is ReprEq, makes a TcSubCo; otherwise, does nothing. Note -- that the input coercion should always be nominal. maybeTcSubCo :: EqRel -> TcCoercion -> TcCoercion -- | Change the role of a TcCoercion. Panics if this isn't a -- downgrade. tcDowngradeRole :: Role -> Role -> TcCoercion -> TcCoercion -- | Like mkTcAppCo, but allows the second coercion to be other than -- nominal. See Note [mkTcTransAppCo]. Role r3 cannot be more stringent -- than either r1 or r2. mkTcTransAppCo :: Role -> TcCoercion -> TcType -> TcType -> Role -> TcCoercion -> TcType -> TcType -> Role -> TcCoercion mkTcAxiomRuleCo :: CoAxiomRule -> [TcType] -> [TcCoercion] -> TcCoercion mkTcPhantomCo :: TcType -> TcType -> TcCoercion tcCoercionKind :: TcCoercion -> Pair Type coVarsOfTcCo :: TcCoercion -> VarSet isEqVar :: Var -> Bool mkTcCoVarCo :: EqVar -> TcCoercion isTcReflCo :: TcCoercion -> Bool getTcCoVar_maybe :: TcCoercion -> Maybe CoVar tcCoercionRole :: TcCoercion -> Role eqVarRole :: EqVar -> Role instance Data HsWrapper instance Data TcCoercion instance Data EvTypeable instance Data EvTerm instance Data EvLit instance Outputable TcCoercion instance Data TcEvBinds instance Outputable HsWrapper instance Outputable TcEvBinds instance Outputable EvBindsVar instance Outputable EvBind instance Outputable EvTerm instance Outputable EvLit instance Outputable EvTypeable module HsBinds type HsLocalBinds id = HsLocalBindsLR id id -- | Bindings in a 'let' expression or a 'where' clause data HsLocalBindsLR idL idR [HsValBinds] :: (HsValBindsLR idL idR) -> HsLocalBindsLR idL idR [HsIPBinds] :: (HsIPBinds idR) -> HsLocalBindsLR idL idR [EmptyLocalBinds] :: HsLocalBindsLR idL idR type HsValBinds id = HsValBindsLR id id -- | Value bindings (not implicit parameters) Used for both top level and -- nested bindings May contain pattern synonym bindings data HsValBindsLR idL idR -- | Before renaming RHS; idR is always RdrName Not dependency analysed -- Recursive by default [ValBindsIn] :: (LHsBindsLR idL idR) -> [LSig idR] -> HsValBindsLR idL idR -- | After renaming RHS; idR can be Name or Id Dependency analysed, later -- bindings in the list may depend on earlier ones. [ValBindsOut] :: [(RecFlag, LHsBinds idL)] -> [LSig Name] -> HsValBindsLR idL idR type LHsBind id = LHsBindLR id id type LHsBinds id = LHsBindsLR id id type HsBind id = HsBindLR id id type LHsBindsLR idL idR = Bag (LHsBindLR idL idR) type LHsBindLR idL idR = Located (HsBindLR idL idR) data HsBindLR idL idR -- | FunBind is used for both functions f x = e and variables -- f = x -> e -- -- Reason 1: Special case for type inference: see tcMonoBinds. -- -- Reason 2: Instance decls can only have FunBinds, which is convenient. -- If you change this, you'll need to change e.g. rnMethodBinds -- -- But note that the form f :: a->a = ... parses as a pattern -- binding, just like (f :: a -> a) = ... -- -- AnnKeywordIds -- --
[FunBind] :: Located idL -> Bool -> MatchGroup idR (LHsExpr idR) -> HsWrapper -> PostRn idL NameSet -> [Tickish Id] -> HsBindLR idL idR [fun_id] :: HsBindLR idL idR -> Located idL -- | True => infix declaration [fun_infix] :: HsBindLR idL idR -> Bool -- | The payload [fun_matches] :: HsBindLR idL idR -> MatchGroup idR (LHsExpr idR) -- | Coercion from the type of the MatchGroup to the type of the Id. -- Example: -- --
```--   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_co_fn] :: HsBindLR idL idR -> HsWrapper -- | After the renamer, this contains the locally-bound free variables of -- this defn. See Note [Bind free vars] [bind_fvs] :: HsBindLR idL idR -> PostRn idL NameSet -- | Ticks to put on the rhs, if any [fun_tick] :: HsBindLR idL idR -> [Tickish Id] -- | The pattern is never a simple variable; That case is done by FunBind -- --
[PatBind] :: LPat idL -> GRHSs idR (LHsExpr idR) -> PostTc idR Type -> PostRn idL NameSet -> ([Tickish Id], [[Tickish Id]]) -> HsBindLR idL idR [pat_lhs] :: HsBindLR idL idR -> LPat idL [pat_rhs] :: HsBindLR idL idR -> GRHSs idR (LHsExpr idR) -- | Type of the GRHSs [pat_rhs_ty] :: HsBindLR idL idR -> PostTc idR Type -- | After the renamer, this contains the locally-bound free variables of -- this defn. See Note [Bind free vars] [bind_fvs] :: HsBindLR idL idR -> PostRn idL NameSet -- | Ticks to put on the rhs, if any, and ticks to put on the bound -- variables. [pat_ticks] :: HsBindLR idL idR -> ([Tickish Id], [[Tickish Id]]) -- | Dictionary binding and suchlike. All VarBinds are introduced by the -- type checker [VarBind] :: idL -> LHsExpr idR -> Bool -> HsBindLR idL idR [var_id] :: HsBindLR idL idR -> idL -- | Located only for consistency [var_rhs] :: HsBindLR idL idR -> LHsExpr idR -- | True = inline this binding regardless (used for implication -- constraints only) [var_inline] :: HsBindLR idL idR -> Bool [AbsBinds] :: [TyVar] -> [EvVar] -> [ABExport idL] -> TcEvBinds -> LHsBinds idL -> HsBindLR 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 [abs_ev_binds] :: HsBindLR idL idR -> TcEvBinds -- | Typechecked user bindings [abs_binds] :: HsBindLR idL idR -> LHsBinds idL -- |
[PatSynBind] :: (PatSynBind idL idR) -> HsBindLR idL idR data ABExport id [ABE] :: id -> id -> HsWrapper -> TcSpecPrags -> ABExport id -- | Any INLINE pragmas is attached to this Id [abe_poly] :: ABExport id -> id [abe_mono] :: ABExport id -> id -- | See Note [AbsBinds wrappers] Shape: (forall abs_tvs. abs_ev_vars => -- abe_mono) ~ abe_poly [abe_wrap] :: ABExport id -> HsWrapper -- | SPECIALISE pragmas [abe_prags] :: ABExport id -> TcSpecPrags -- |
data PatSynBind idL idR [PSB] :: Located idL -> PostRn idR NameSet -> HsPatSynDetails (Located idR) -> LPat idR -> HsPatSynDir idR -> PatSynBind idL idR -- | Name of the pattern synonym [psb_id] :: PatSynBind idL idR -> Located idL -- | See Note [Bind free vars] [psb_fvs] :: PatSynBind idL idR -> PostRn idR NameSet -- | Formal parameter names [psb_args] :: PatSynBind idL idR -> HsPatSynDetails (Located idR) -- | Right-hand side [psb_def] :: PatSynBind idL idR -> LPat idR -- | Directionality [psb_dir] :: PatSynBind idL idR -> HsPatSynDir idR pprLHsBinds :: (OutputableBndr idL, OutputableBndr idR) => LHsBindsLR idL idR -> SDoc pprLHsBindsForUser :: (OutputableBndr idL, OutputableBndr idR, OutputableBndr id2) => LHsBindsLR idL idR -> [LSig id2] -> [SDoc] pprDeclList :: [SDoc] -> SDoc emptyLocalBinds :: HsLocalBindsLR a b isEmptyLocalBinds :: HsLocalBindsLR a b -> Bool isEmptyValBinds :: HsValBindsLR a b -> Bool emptyValBindsIn :: HsValBindsLR a b emptyValBindsOut :: HsValBindsLR a b emptyLHsBinds :: LHsBindsLR idL idR isEmptyLHsBinds :: LHsBindsLR idL idR -> Bool plusHsValBinds :: HsValBinds a -> HsValBinds a -> HsValBinds a getTypeSigNames :: HsValBinds a -> NameSet ppr_monobind :: (OutputableBndr idL, OutputableBndr idR) => HsBindLR idL idR -> SDoc pprTicks :: SDoc -> SDoc -> SDoc data HsIPBinds id [IPBinds] :: [LIPBind id] -> TcEvBinds -> HsIPBinds id isEmptyIPBinds :: HsIPBinds id -> Bool -- | May have AnnKeywordId : AnnSemi when in a list type LIPBind id = Located (IPBind id) -- | Implicit parameter bindings. -- -- These bindings start off as (Left "x") in the parser and stay that way -- until after type-checking when they are replaced with (Right d), where -- "d" is the name of the dictionary holding the evidence for the -- implicit parameter. -- --
data IPBind id [IPBind] :: (Either (Located HsIPName) id) -> (LHsExpr id) -> IPBind id type LSig name = Located (Sig name) -- | Signatures and pragmas data Sig name -- | An ordinary type signature -- --
```--   f :: Num a => a -> a
--   ```
-- -- After renaming, this list of Names contains the named and unnamed -- wildcards brought into scope by this signature. For a signature _ -- -> _a -> Bool, the renamer will give the unnamed wildcard -- _ a freshly generated name, e.g. _w. _w and -- the named wildcard _a are then both 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. -- --
[TypeSig] :: [Located name] -> (LHsType name) -> (PostRn name [Name]) -> Sig name -- | A pattern synonym type signature -- --
```--   pattern Single :: () => (Show a) => a -> [a]
--   ```
-- --
[PatSynSig] :: (Located name) -> (HsExplicitFlag, LHsTyVarBndrs name) -> (LHsContext name) -> (LHsContext name) -> (LHsType name) -> Sig name -- | A type signature for a default method inside a class -- --
```--   default eq :: (Representable0 a, GEq (Rep0 a)) => a -> a -> Bool
--   ```
-- --
[GenericSig] :: [Located name] -> (LHsType name) -> Sig name -- | A type signature in generated code, notably the code generated for -- record selectors. We simply record the desired Id itself, replete with -- its name, type and IdDetails. Otherwise it's just like a type -- signature: there should be an accompanying binding [IdSig] :: Id -> Sig name -- | An ordinary fixity declaration -- --
```--   infixl 8 ***
--   ```
-- --
[FixSig] :: (FixitySig name) -> Sig name -- | An inline pragma -- --
```--   {#- INLINE f #-}
--   ```
-- --
[InlineSig] :: (Located name) -> InlinePragma -> Sig name -- | A specialisation pragma -- --
```--   {-# SPECIALISE f :: Int -> Int #-}
--   ```
-- --
[SpecSig] :: (Located name) -> [LHsType name] -> InlinePragma -> Sig name -- | A specialisation pragma for instance declarations only -- --
```--   {-# SPECIALISE instance Eq [Int] #-}
--   ```
-- -- (Class tys); should be a specialisation of the current instance -- declaration -- --
[SpecInstSig] :: SourceText -> (LHsType name) -> Sig name -- | A minimal complete definition pragma -- --
```--   {-# MINIMAL a | (b, c | (d | e)) #-}
--   ```
-- --
[MinimalSig] :: SourceText -> (BooleanFormula (Located name)) -> Sig name type LFixitySig name = Located (FixitySig name) data FixitySig name [FixitySig] :: [Located name] -> Fixity -> FixitySig name -- | TsSpecPrags conveys 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 type LTcSpecPrag = Located TcSpecPrag data TcSpecPrag -- | The Id to be specialised, an 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 :: LSig name -> Bool isVanillaLSig :: LSig name -> Bool isTypeLSig :: LSig name -> Bool isSpecLSig :: LSig name -> Bool isSpecInstLSig :: LSig name -> Bool isPragLSig :: LSig name -> Bool isInlineLSig :: LSig name -> Bool isMinimalLSig :: LSig name -> Bool hsSigDoc :: Sig name -> SDoc ppr_sig :: OutputableBndr name => Sig name -> SDoc pprPatSynSig :: (OutputableBndr name) => name -> Bool -> SDoc -> Maybe SDoc -> Maybe SDoc -> SDoc -> SDoc pragBrackets :: SDoc -> SDoc pprVarSig :: (OutputableBndr id) => [id] -> SDoc -> SDoc pprSpec :: (OutputableBndr id) => id -> SDoc -> InlinePragma -> SDoc pprTcSpecPrags :: TcSpecPrags -> SDoc pprMinimalSig :: OutputableBndr name => BooleanFormula (Located name) -> SDoc data HsPatSynDetails a [InfixPatSyn] :: a -> a -> HsPatSynDetails a [PrefixPatSyn] :: [a] -> HsPatSynDetails a data HsPatSynDir id [Unidirectional] :: HsPatSynDir id [ImplicitBidirectional] :: HsPatSynDir id [ExplicitBidirectional] :: (MatchGroup id (LHsExpr id)) -> HsPatSynDir id instance Data a => Data (HsPatSynDetails a) instance Data id => Data (ABExport id) instance Data TcSpecPrags instance Data TcSpecPrag instance Data name => Data (FixitySig name) instance (DataId idL, DataId idR) => Data (HsLocalBindsLR idL idR) instance (DataId idL, DataId idR) => Data (HsValBindsLR idL idR) instance (DataId idL, DataId idR) => Data (HsBindLR idL idR) instance (DataId idL, DataId idR) => Data (PatSynBind idL idR) instance DataId id => Data (HsIPBinds id) instance DataId name => Data (IPBind name) instance DataId name => Data (Sig name) instance DataId id => Data (HsPatSynDir id) instance (OutputableBndr idL, OutputableBndr idR) => Outputable (HsLocalBindsLR idL idR) instance (OutputableBndr idL, OutputableBndr idR) => Outputable (HsValBindsLR idL idR) instance (OutputableBndr idL, OutputableBndr idR) => Outputable (HsBindLR idL idR) instance OutputableBndr id => Outputable (ABExport id) instance (OutputableBndr idL, OutputableBndr idR) => Outputable (PatSynBind idL idR) instance OutputableBndr id => Outputable (HsIPBinds id) instance OutputableBndr id => Outputable (IPBind id) instance OutputableBndr name => Outputable (Sig name) instance OutputableBndr name => Outputable (FixitySig name) instance Outputable TcSpecPrag instance Functor HsPatSynDetails instance Foldable HsPatSynDetails instance Traversable HsPatSynDetails module PatSyn -- | A pattern synonym See Note [Pattern synonym representation] data PatSyn -- | Build a new pattern synonym mkPatSyn :: Name -> Bool -> ([TyVar], ThetaType) -> ([TyVar], ThetaType) -> [Type] -> Type -> (Id, Bool) -> Maybe (Id, Bool) -> 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 patSynArgs :: PatSyn -> [Type] patSynTyDetails :: PatSyn -> HsPatSynDetails Type patSynType :: PatSyn -> Type patSynMatcher :: PatSyn -> (Id, Bool) patSynBuilder :: PatSyn -> Maybe (Id, Bool) patSynExTyVars :: PatSyn -> [TyVar] patSynSig :: PatSyn -> ([TyVar], [TyVar], ThetaType, ThetaType, [Type], Type) patSynInstArgTys :: PatSyn -> [Type] -> [Type] patSynInstResTy :: PatSyn -> [Type] -> Type tidyPatSynIds :: (Id -> Id) -> PatSyn -> PatSyn instance Eq PatSyn instance Ord PatSyn instance Uniquable PatSyn instance NamedThing PatSyn instance Outputable PatSyn instance OutputableBndr PatSyn instance Data PatSyn module HsPat -- |
data Pat id [WildPat] :: (PostTc id Type) -> Pat id [VarPat] :: id -> Pat id -- |
[LazyPat] :: (LPat id) -> Pat id -- |
[AsPat] :: (Located id) -> (LPat id) -> Pat id -- |
[ParPat] :: (LPat id) -> Pat id -- |
[BangPat] :: (LPat id) -> Pat id -- |
[ListPat] :: [LPat id] -> (PostTc id Type) -> (Maybe (PostTc id Type, SyntaxExpr id)) -> Pat id -- |
[TuplePat] :: [LPat id] -> Boxity -> [PostTc id Type] -> Pat id -- |
[PArrPat] :: [LPat id] -> (PostTc id Type) -> Pat id [ConPatIn] :: (Located id) -> (HsConPatDetails id) -> Pat id [ConPatOut] :: Located ConLike -> [Type] -> [TyVar] -> [EvVar] -> TcEvBinds -> HsConPatDetails id -> HsWrapper -> Pat id [pat_con] :: Pat id -> Located ConLike [pat_arg_tys] :: Pat id -> [Type] [pat_tvs] :: Pat id -> [TyVar] [pat_dicts] :: Pat id -> [EvVar] [pat_binds] :: Pat id -> TcEvBinds [pat_args] :: Pat id -> HsConPatDetails id [pat_wrap] :: Pat id -> HsWrapper -- |
[ViewPat] :: (LHsExpr id) -> (LPat id) -> (PostTc id Type) -> Pat id -- |
[SplicePat] :: (HsSplice id) -> Pat id [QuasiQuotePat] :: (HsQuasiQuote id) -> Pat id [LitPat] :: HsLit -> Pat id [NPat] :: (Located (HsOverLit id)) -> (Maybe (SyntaxExpr id)) -> (SyntaxExpr id) -> Pat id -- |
[NPlusKPat] :: (Located id) -> (Located (HsOverLit id)) -> (SyntaxExpr id) -> (SyntaxExpr id) -> Pat id -- |
[SigPatIn] :: (LPat id) -> (HsWithBndrs id (LHsType id)) -> Pat id [SigPatOut] :: (LPat id) -> Type -> Pat id [CoPat] :: HsWrapper -> (Pat id) -> Type -> Pat id type InPat id = LPat id type OutPat id = LPat id type LPat id = Located (Pat id) data HsConDetails arg rec [PrefixCon] :: [arg] -> HsConDetails arg rec [RecCon] :: rec -> HsConDetails arg rec [InfixCon] :: arg -> arg -> HsConDetails arg rec type HsConPatDetails id = HsConDetails (LPat id) (HsRecFields id (LPat id)) hsConPatArgs :: HsConPatDetails id -> [LPat id] data HsRecFields id arg [HsRecFields] :: [LHsRecField id arg] -> Maybe Int -> HsRecFields id arg [rec_flds] :: HsRecFields id arg -> [LHsRecField id arg] [rec_dotdot] :: HsRecFields id arg -> Maybe Int -- |
[dd_derivs] :: HsDataDefn name -> Maybe (Located [LHsType name]) -- | A type or class declaration. data TyClDecl name -- |
```--   type/data family T :: *->*
--   ```
-- --
[FamDecl] :: FamilyDecl name -> TyClDecl name [tcdFam] :: TyClDecl name -> FamilyDecl name -- | type declaration -- --
[SynDecl] :: Located name -> LHsTyVarBndrs name -> LHsType name -> PostRn name NameSet -> TyClDecl name -- | Type constructor [tcdLName] :: TyClDecl name -> Located name -- | Type variables; for an associated type these include outer binders [tcdTyVars] :: TyClDecl name -> LHsTyVarBndrs name -- | RHS of type declaration [tcdRhs] :: TyClDecl name -> LHsType name [tcdFVs] :: TyClDecl name -> PostRn name NameSet -- | data declaration -- --
[DataDecl] :: Located name -> LHsTyVarBndrs name -> HsDataDefn name -> PostRn name NameSet -> TyClDecl name -- | Type constructor [tcdLName] :: TyClDecl name -> Located name -- | Type variables; for an associated type these include outer binders [tcdTyVars] :: TyClDecl name -> LHsTyVarBndrs name [tcdDataDefn] :: TyClDecl name -> HsDataDefn name [tcdFVs] :: TyClDecl name -> PostRn name NameSet -- |
[ClassDecl] :: LHsContext name -> Located name -> LHsTyVarBndrs name -> [Located (FunDep (Located name))] -> [LSig name] -> LHsBinds name -> [LFamilyDecl name] -> [LTyFamDefltEqn name] -> [LDocDecl] -> PostRn name NameSet -> TyClDecl name -- | Context... [tcdCtxt] :: TyClDecl name -> LHsContext name -- | Type constructor [tcdLName] :: TyClDecl name -> Located name -- | Type variables; for an associated type these include outer binders [tcdTyVars] :: TyClDecl name -> LHsTyVarBndrs name -- | Functional deps [tcdFDs] :: TyClDecl name -> [Located (FunDep (Located name))] -- | Methods' signatures [tcdSigs] :: TyClDecl name -> [LSig name] -- | Default methods [tcdMeths] :: TyClDecl name -> LHsBinds name -- | Associated types; [tcdATs] :: TyClDecl name -> [LFamilyDecl name] -- | Associated type defaults [tcdATDefs] :: TyClDecl name -> [LTyFamDefltEqn name] -- | Haddock docs [tcdDocs] :: TyClDecl name -> [LDocDecl] [tcdFVs] :: TyClDecl name -> PostRn name NameSet type LTyClDecl name = Located (TyClDecl name) data TyClGroup name [TyClGroup] :: [LTyClDecl name] -> [LRoleAnnotDecl name] -> TyClGroup name [group_tyclds] :: TyClGroup name -> [LTyClDecl name] [group_roles] :: TyClGroup name -> [LRoleAnnotDecl name] tyClGroupConcat :: [TyClGroup name] -> [LTyClDecl name] mkTyClGroup :: [LTyClDecl name] -> TyClGroup name -- | type class isClassDecl :: TyClDecl name -> Bool -- | True = argument is a data/newtype -- declaration. isDataDecl :: TyClDecl name -> Bool -- | type or type instance declaration isSynDecl :: TyClDecl name -> Bool tcdName :: TyClDecl name -> name -- | type/data family declaration isFamilyDecl :: TyClDecl name -> Bool -- | type family declaration isTypeFamilyDecl :: TyClDecl name -> Bool -- | data family declaration isDataFamilyDecl :: TyClDecl name -> Bool -- | open type family info isOpenTypeFamilyInfo :: FamilyInfo name -> Bool -- | closed type family info isClosedTypeFamilyInfo :: FamilyInfo name -> Bool tyFamInstDeclName :: OutputableBndr name => TyFamInstDecl name -> name tyFamInstDeclLName :: OutputableBndr name => TyFamInstDecl name -> Located name countTyClDecls :: [TyClDecl name] -> (Int, Int, Int, Int, Int) pprTyClDeclFlavour :: TyClDecl a -> SDoc tyClDeclLName :: TyClDecl name -> Located name tyClDeclTyVars :: OutputableBndr name => TyClDecl name -> LHsTyVarBndrs name -- | Does this declaration have a complete, user-supplied kind signature? -- See Note [Complete user-supplied kind signatures] hsDeclHasCusk :: TyClDecl name -> Bool -- | Does this family declaration have a complete, user-supplied kind -- signature? famDeclHasCusk :: FamilyDecl name -> Bool data FamilyDecl name [FamilyDecl] :: FamilyInfo name -> Located name -> LHsTyVarBndrs name -> Maybe (LHsKind name) -> FamilyDecl name [fdInfo] :: FamilyDecl name -> FamilyInfo name [fdLName] :: FamilyDecl name -> Located name [fdTyVars] :: FamilyDecl name -> LHsTyVarBndrs name [fdKindSig] :: FamilyDecl name -> Maybe (LHsKind name) type LFamilyDecl name = Located (FamilyDecl name) data InstDecl name [ClsInstD] :: ClsInstDecl name -> InstDecl name [cid_inst] :: InstDecl name -> ClsInstDecl name [DataFamInstD] :: DataFamInstDecl name -> InstDecl name [dfid_inst] :: InstDecl name -> DataFamInstDecl name [TyFamInstD] :: TyFamInstDecl name -> InstDecl name [tfid_inst] :: InstDecl name -> TyFamInstDecl name type LInstDecl name = Located (InstDecl name) data NewOrData -- |
```--   newtype Blah ...
--   ```
[NewType] :: NewOrData -- |
```--   data Blah ...
--   ```
[DataType] :: NewOrData data FamilyInfo name [DataFamily] :: FamilyInfo name [OpenTypeFamily] :: FamilyInfo name [ClosedTypeFamily] :: [LTyFamInstEqn name] -> FamilyInfo name data TyFamInstDecl name -- |
[TyFamInstDecl] :: LTyFamInstEqn name -> PostRn name NameSet -> TyFamInstDecl name [tfid_eqn] :: TyFamInstDecl name -> LTyFamInstEqn name [tfid_fvs] :: TyFamInstDecl name -> PostRn name NameSet type LTyFamInstDecl name = Located (TyFamInstDecl name) instDeclDataFamInsts :: [LInstDecl name] -> [DataFamInstDecl name] data DataFamInstDecl name -- |
[DataFamInstDecl] :: Located name -> HsTyPats name -> HsDataDefn name -> PostRn name NameSet -> DataFamInstDecl name [dfid_tycon] :: DataFamInstDecl name -> Located name [dfid_pats] :: DataFamInstDecl name -> HsTyPats name [dfid_defn] :: DataFamInstDecl name -> HsDataDefn name [dfid_fvs] :: DataFamInstDecl name -> PostRn name NameSet type LDataFamInstDecl name = Located (DataFamInstDecl name) pprDataFamInstFlavour :: DataFamInstDecl name -> SDoc -- | One equation in a type family instance declaration See Note [Type -- family instance declarations in HsSyn] data TyFamEqn name pats -- |
[TyFamEqn] :: Located name -> pats -> LHsType name -> TyFamEqn name pats [tfe_tycon] :: TyFamEqn name pats -> Located name [tfe_pats] :: TyFamEqn name pats -> pats [tfe_rhs] :: TyFamEqn name pats -> LHsType name type TyFamInstEqn name = TyFamEqn name (HsTyPats name) type LTyFamInstEqn name = Located (TyFamInstEqn name) May have 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnSemi' when in a list type TyFamDefltEqn name = TyFamEqn name (LHsTyVarBndrs name) type LTyFamDefltEqn name = Located (TyFamDefltEqn name) type HsTyPats name = HsWithBndrs name [LHsType name] Type patterns (with kind and type bndrs) See Note [Family instance declaration binders] type LClsInstDecl name = Located (ClsInstDecl name) data ClsInstDecl name -- |
[ClsInstDecl] :: LHsType name -> LHsBinds name -> [LSig name] -> [LTyFamInstDecl name] -> [LDataFamInstDecl name] -> Maybe (Located OverlapMode) -> ClsInstDecl name [cid_poly_ty] :: ClsInstDecl name -> LHsType name [cid_binds] :: ClsInstDecl name -> LHsBinds name [cid_sigs] :: ClsInstDecl name -> [LSig name] [cid_tyfam_insts] :: ClsInstDecl name -> [LTyFamInstDecl name] [cid_datafam_insts] :: ClsInstDecl name -> [LDataFamInstDecl name] -- |
[cid_overlap_mode] :: ClsInstDecl name -> Maybe (Located OverlapMode) data DerivDecl name [DerivDecl] :: LHsType name -> Maybe (Located OverlapMode) -> DerivDecl name [deriv_type] :: DerivDecl name -> LHsType name -- |
[deriv_overlap_mode] :: DerivDecl name -> Maybe (Located OverlapMode) type LDerivDecl name = Located (DerivDecl name) type LRuleDecls name = Located (RuleDecls name) data RuleDecls name [HsRules] :: SourceText -> [LRuleDecl name] -> RuleDecls name [rds_src] :: RuleDecls name -> SourceText [rds_rules] :: RuleDecls name -> [LRuleDecl name] data RuleDecl name -- |
[HsRule] :: (Located RuleName) -> Activation -> [LRuleBndr name] -> (Located (HsExpr name)) -> (PostRn name NameSet) -> (Located (HsExpr name)) -> (PostRn name NameSet) -> RuleDecl name type LRuleDecl name = Located (RuleDecl name) data RuleBndr name [RuleBndr] :: (Located name) -> RuleBndr name -- |
[RuleBndrSig] :: (Located name) -> (HsWithBndrs name (LHsType name)) -> RuleBndr name type LRuleBndr name = Located (RuleBndr name) collectRuleBndrSigTys :: [RuleBndr name] -> [HsWithBndrs name (LHsType name)] flattenRuleDecls :: [LRuleDecls name] -> [LRuleDecl name] data VectDecl name -- |
[HsVect] :: SourceText -> (Located name) -> (LHsExpr name) -> VectDecl name -- |
[HsNoVect] :: SourceText -> (Located name) -> VectDecl name -- |
[HsVectTypeIn] :: SourceText -> Bool -> (Located name) -> (Maybe (Located name)) -> VectDecl name [HsVectTypeOut] :: Bool -> TyCon -> (Maybe TyCon) -> VectDecl name -- |
[HsVectClassIn] :: SourceText -> (Located name) -> VectDecl name [HsVectClassOut] :: Class -> VectDecl name [HsVectInstIn] :: (LHsType name) -> VectDecl name [HsVectInstOut] :: ClsInst -> VectDecl name type LVectDecl name = Located (VectDecl name) lvectDeclName :: NamedThing name => LVectDecl name -> Name lvectInstDecl :: LVectDecl name -> Bool data DefaultDecl name -- |
[DefaultDecl] :: [LHsType name] -> DefaultDecl name type LDefaultDecl name = Located (DefaultDecl name) data SpliceExplicitFlag [ExplicitSplice] :: SpliceExplicitFlag [ImplicitSplice] :: SpliceExplicitFlag data SpliceDecl id [SpliceDecl] :: (Located (HsSplice id)) -> SpliceExplicitFlag -> SpliceDecl id type LSpliceDecl name = Located (SpliceDecl name) data ForeignDecl name [ForeignImport] :: (Located name) -> (LHsType name) -> (PostTc name Coercion) -> ForeignImport -> ForeignDecl name -- |
[ForeignExport] :: (Located name) -> (LHsType name) -> (PostTc name Coercion) -> ForeignExport -> ForeignDecl name type LForeignDecl name = Located (ForeignDecl name) data ForeignImport [CImport] :: (Located CCallConv) -> (Located Safety) -> (Maybe Header) -> CImportSpec -> (Located SourceText) -> ForeignImport data ForeignExport [CExport] :: (Located CExportSpec) -> (Located SourceText) -> ForeignExport noForeignImportCoercionYet :: PlaceHolder noForeignExportCoercionYet :: PlaceHolder data CImportSpec [CLabel] :: CLabelString -> CImportSpec [CFunction] :: CCallTarget -> CImportSpec [CWrapper] :: CImportSpec -- |
```--   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
--   ```
-- --
data ConDecl name [ConDecl] :: [Located name] -> HsExplicitFlag -> LHsTyVarBndrs name -> LHsContext name -> HsConDeclDetails name -> ResType (LHsType name) -> Maybe LHsDocString -> Bool -> ConDecl name -- | Constructor names. This is used for the DataCon itself, and for the -- user-callable wrapper Id. It is a list to deal with GADT constructors -- of the form T1, T2, T3 :: payload [con_names] :: ConDecl name -> [Located name] -- | Is there an user-written forall? (cf. HsForAllTy) [con_explicit] :: ConDecl name -> HsExplicitFlag -- | Type variables. Depending on con_res this describes the -- following entities -- --
--
• ResTyH98: the constructor's *existential* type variables
• --
• ResTyGADT: *all* the constructor's quantified type variables
• --
-- -- If con_explicit is Implicit, then con_qvars is irrelevant until after -- renaming. [con_qvars] :: ConDecl name -> LHsTyVarBndrs name -- | The context. This does not include the "stupid theta" which -- lives only in the TyData decl. [con_cxt] :: ConDecl name -> LHsContext name -- | The main payload [con_details] :: ConDecl name -> HsConDeclDetails name -- | Result type of the constructor [con_res] :: ConDecl name -> ResType (LHsType name) -- | A possible Haddock comment. [con_doc] :: ConDecl name -> Maybe LHsDocString -- | TEMPORARY field; True = user has employed now-deprecated syntax -- for GADT-style record decl C { blah } :: T a b Remove this when we no -- longer parse this stuff, and hence do not need to report decprecated -- use [con_old_rec] :: ConDecl name -> Bool type LConDecl name = Located (ConDecl name) May have 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnSemi' when in a GADT constructor list data ResType ty [ResTyH98] :: ResType ty [ResTyGADT] :: SrcSpan -> ty -> ResType ty type HsConDeclDetails name = HsConDetails (LBangType name) (Located [LConDeclField name]) hsConDeclArgTys :: HsConDeclDetails name -> [LBangType name] data DocDecl [DocCommentNext] :: HsDocString -> DocDecl [DocCommentPrev] :: HsDocString -> DocDecl [DocCommentNamed] :: String -> HsDocString -> DocDecl [DocGroup] :: Int -> HsDocString -> DocDecl type LDocDecl = Located (DocDecl) docDeclDoc :: DocDecl -> HsDocString data WarnDecl name [Warning] :: [Located name] -> WarningTxt -> WarnDecl name type LWarnDecl name = Located (WarnDecl name) data WarnDecls name [Warnings] :: SourceText -> [LWarnDecl name] -> WarnDecls name [wd_src] :: WarnDecls name -> SourceText [wd_warnings] :: WarnDecls name -> [LWarnDecl name] type LWarnDecls name = Located (WarnDecls name) data AnnDecl name -- |
[HsAnnotation] :: SourceText -> (AnnProvenance name) -> (Located (HsExpr name)) -> AnnDecl name type LAnnDecl name = Located (AnnDecl name) data AnnProvenance name [ValueAnnProvenance] :: (Located name) -> AnnProvenance name [TypeAnnProvenance] :: (Located name) -> AnnProvenance name [ModuleAnnProvenance] :: AnnProvenance name annProvenanceName_maybe :: AnnProvenance name -> Maybe name data RoleAnnotDecl name -- |
[RoleAnnotDecl] :: (Located name) -> [Located (Maybe Role)] -> RoleAnnotDecl name type LRoleAnnotDecl name = Located (RoleAnnotDecl name) roleAnnotDeclName :: RoleAnnotDecl name -> name -- | A HsDecl is categorised into a HsGroup before being fed -- to the renamer. data HsGroup id [HsGroup] :: HsValBinds id -> [LSpliceDecl id] -> [TyClGroup id] -> [LInstDecl id] -> [LDerivDecl id] -> [LFixitySig id] -> [LDefaultDecl id] -> [LForeignDecl id] -> [LWarnDecls id] -> [LAnnDecl id] -> [LRuleDecls id] -> [LVectDecl id] -> [LDocDecl] -> HsGroup id [hs_valds] :: HsGroup id -> HsValBinds id [hs_splcds] :: HsGroup id -> [LSpliceDecl id] [hs_tyclds] :: HsGroup id -> [TyClGroup id] [hs_instds] :: HsGroup id -> [LInstDecl id] [hs_derivds] :: HsGroup id -> [LDerivDecl id] [hs_fixds] :: HsGroup id -> [LFixitySig id] [hs_defds] :: HsGroup id -> [LDefaultDecl id] [hs_fords] :: HsGroup id -> [LForeignDecl id] [hs_warnds] :: HsGroup id -> [LWarnDecls id] [hs_annds] :: HsGroup id -> [LAnnDecl id] [hs_ruleds] :: HsGroup id -> [LRuleDecls id] [hs_vects] :: HsGroup id -> [LVectDecl id] [hs_docs] :: HsGroup id -> [LDocDecl] emptyRdrGroup :: HsGroup a emptyRnGroup :: HsGroup a appendGroups :: HsGroup a -> HsGroup a -> HsGroup a instance Data name => Data (RoleAnnotDecl name) instance Functor AnnProvenance instance Data name => Data (AnnProvenance name) instance Data name => Data (WarnDecls name) instance Data name => Data (WarnDecl name) instance Data DocDecl instance Data ForeignExport instance Data ForeignImport instance Data CImportSpec instance Data ty => Data (ResType ty) instance Data NewOrData instance Eq NewOrData instance Data SpliceExplicitFlag instance DataId id => Data (HsDecl id) instance DataId id => Data (HsGroup id) instance DataId id => Data (SpliceDecl id) instance DataId id => Data (TyClDecl id) instance DataId id => Data (TyClGroup id) instance DataId id => Data (FamilyDecl id) instance DataId name => Data (FamilyInfo name) instance DataId id => Data (HsDataDefn id) instance DataId name => Data (ConDecl name) instance (DataId name, Data pats) => Data (TyFamEqn name pats) instance DataId name => Data (TyFamInstDecl name) instance DataId name => Data (DataFamInstDecl name) instance DataId id => Data (ClsInstDecl id) instance DataId id => Data (InstDecl id) instance DataId name => Data (DerivDecl name) instance DataId name => Data (DefaultDecl name) instance DataId name => Data (ForeignDecl name) instance DataId name => Data (RuleDecls name) instance DataId name => Data (RuleDecl name) instance DataId name => Data (RuleBndr name) instance DataId name => Data (VectDecl name) instance DataId name => Data (AnnDecl name) instance Foldable AnnProvenance instance Traversable AnnProvenance instance OutputableBndr name => Outputable (HsDecl name) instance OutputableBndr name => Outputable (HsGroup name) instance OutputableBndr name => Outputable (SpliceDecl name) instance OutputableBndr name => Outputable (TyClDecl name) instance OutputableBndr name => Outputable (TyClGroup name) instance OutputableBndr name => Outputable (FamilyDecl name) instance Outputable (FamilyInfo name) instance Outputable ty => Outputable (ResType ty) instance OutputableBndr name => Outputable (HsDataDefn name) instance Outputable NewOrData instance OutputableBndr name => Outputable (ConDecl name) instance Outputable name => OutputableBndr [Located name] instance OutputableBndr name => Outputable (TyFamInstDecl name) instance OutputableBndr name => Outputable (DataFamInstDecl name) instance OutputableBndr name => Outputable (ClsInstDecl name) instance OutputableBndr name => Outputable (InstDecl name) instance OutputableBndr name => Outputable (DerivDecl name) instance OutputableBndr name => Outputable (DefaultDecl name) instance OutputableBndr name => Outputable (ForeignDecl name) instance Outputable ForeignImport instance Outputable ForeignExport instance OutputableBndr name => Outputable (RuleDecls name) instance OutputableBndr name => Outputable (RuleDecl name) instance OutputableBndr name => Outputable (RuleBndr name) instance OutputableBndr name => Outputable (VectDecl name) instance Outputable DocDecl instance OutputableBndr name => Outputable (WarnDecls name) instance OutputableBndr name => Outputable (WarnDecl name) instance OutputableBndr name => Outputable (AnnDecl name) instance OutputableBndr name => Outputable (RoleAnnotDecl name) -- | Abstract Haskell syntax for expressions. module HsExpr type LHsExpr id = Located (HsExpr id) May have 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnComma' when in a list -- | PostTcExpr is an evidence expression attached to the syntax tree by -- the type checker (c.f. postTcType). type PostTcExpr = HsExpr Id -- | We use a PostTcTable where there are a bunch of pieces of evidence, -- more than is convenient to keep individually. type PostTcTable = [(Name, PostTcExpr)] noPostTcExpr :: PostTcExpr noPostTcTable :: PostTcTable -- | SyntaxExpr is like PostTcExpr, but it's filled in a little -- earlier, by the renamer. It's used for rebindable syntax. -- -- 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 SyntaxExpr id = HsExpr id noSyntaxExpr :: SyntaxExpr id type CmdSyntaxTable id = [(Name, SyntaxExpr id)] -- | A Haskell expression. data HsExpr id -- | Variable [HsVar] :: id -> HsExpr id -- | Implicit parameter [HsIPVar] :: HsIPName -> HsExpr id -- | Overloaded literals [HsOverLit] :: (HsOverLit id) -> HsExpr id -- | Simple (non-overloaded) literals [HsLit] :: HsLit -> HsExpr id -- | Lambda abstraction. Currently always a single match -- --
[HsLam] :: (MatchGroup id (LHsExpr id)) -> HsExpr id -- | Lambda-case -- --
[HsLamCase] :: (PostTc id Type) -> (MatchGroup id (LHsExpr id)) -> HsExpr id -- | Application [HsApp] :: (LHsExpr id) -> (LHsExpr id) -> HsExpr id -- | Operator applications: NB Bracketed ops such as (+) come out as Vars. [OpApp] :: (LHsExpr id) -> (LHsExpr id) -> (PostRn id Fixity) -> (LHsExpr id) -> HsExpr id -- | Negation operator. Contains the negated expression and the name of -- negate -- --
[NegApp] :: (LHsExpr id) -> (SyntaxExpr id) -> HsExpr id -- | Parenthesised expr; see Note [Parens in HsSyn] [HsPar] :: (LHsExpr id) -> HsExpr id [SectionL] :: (LHsExpr id) -> (LHsExpr id) -> HsExpr id [SectionR] :: (LHsExpr id) -> (LHsExpr id) -> HsExpr id -- | Used for explicit tuples and sections thereof -- --
[ExplicitTuple] :: [LHsTupArg id] -> Boxity -> HsExpr id -- |
[HsCase] :: (LHsExpr id) -> (MatchGroup id (LHsExpr id)) -> HsExpr id -- |
[HsIf] :: (Maybe (SyntaxExpr id)) -> (LHsExpr id) -> (LHsExpr id) -> (LHsExpr id) -> HsExpr id -- | Multi-way if -- --
[HsMultiIf] :: (PostTc id Type) -> [LGRHS id (LHsExpr id)] -> HsExpr id -- | let(rec) -- --
[HsLet] :: (HsLocalBinds id) -> (LHsExpr id) -> HsExpr id -- |
[HsDo] :: (HsStmtContext Name) -> [ExprLStmt id] -> (PostTc id Type) -> HsExpr id -- | Syntactic list: [a,b,c,...] -- --
[ExplicitList] :: (PostTc id Type) -> (Maybe (SyntaxExpr id)) -> [LHsExpr id] -> HsExpr id -- | Syntactic parallel array: [:e1, ..., en:] -- --
[ExplicitPArr] :: (PostTc id Type) -> [LHsExpr id] -> HsExpr id -- | Record construction -- --
[RecordCon] :: (Located id) -> PostTcExpr -> (HsRecordBinds id) -> HsExpr id -- | Record update -- --
[RecordUpd] :: (LHsExpr id) -> (HsRecordBinds id) -> [DataCon] -> [PostTc id Type] -> [PostTc id Type] -> HsExpr id -- | Expression with an explicit type signature. e :: type -- --
[ExprWithTySig] :: (LHsExpr id) -> (LHsType id) -> (PostRn id [Name]) -> HsExpr id [ExprWithTySigOut] :: (LHsExpr id) -> (LHsType Name) -> HsExpr id -- | Arithmetic sequence -- --
[ArithSeq] :: PostTcExpr -> (Maybe (SyntaxExpr id)) -> (ArithSeqInfo id) -> HsExpr id -- | Arithmetic sequence for parallel array -- --
```--   [:e1..e2:] or [:e1, e2..e3:]
--   ```
-- --
[PArrSeq] :: PostTcExpr -> (ArithSeqInfo id) -> HsExpr id -- |
[HsSCC] :: SourceText -> FastString -> (LHsExpr id) -> HsExpr id -- |
[HsCoreAnn] :: SourceText -> FastString -> (LHsExpr id) -> HsExpr id -- |
[HsBracket] :: (HsBracket id) -> HsExpr id [HsRnBracketOut] :: (HsBracket Name) -> [PendingRnSplice] -> HsExpr id [HsTcBracketOut] :: (HsBracket Name) -> [PendingTcSplice] -> HsExpr id -- |
[HsSpliceE] :: Bool -> (HsSplice id) -> HsExpr id [HsQuasiQuoteE] :: (HsQuasiQuote id) -> HsExpr id -- | proc notation for Arrows -- --
[HsProc] :: (LPat id) -> (LHsCmdTop id) -> HsExpr id -- |
[HsStatic] :: (LHsExpr id) -> HsExpr id -- |
[HsArrApp] :: (LHsExpr id) -> (LHsExpr id) -> (PostTc id Type) -> HsArrAppType -> Bool -> HsExpr id -- |
[HsArrForm] :: (LHsExpr id) -> (Maybe Fixity) -> [LHsCmdTop id] -> HsExpr id [HsTick] :: (Tickish id) -> (LHsExpr id) -> HsExpr id [HsBinTick] :: Int -> Int -> (LHsExpr id) -> HsExpr id -- |
[HsTickPragma] :: SourceText -> (FastString, (Int, Int), (Int, Int)) -> (LHsExpr id) -> HsExpr id [EWildPat] :: HsExpr id -- |
[EAsPat] :: (Located id) -> (LHsExpr id) -> HsExpr id -- |
[EViewPat] :: (LHsExpr id) -> (LHsExpr id) -> HsExpr id -- |
[ELazyPat] :: (LHsExpr id) -> HsExpr id [HsType] :: (LHsType id) -> HsExpr id [HsWrap] :: HsWrapper -> (HsExpr id) -> HsExpr id [HsUnboundVar] :: RdrName -> HsExpr id -- | HsTupArg is used for tuple sections (,a,) is represented by -- ExplicitTuple [Missing ty1, Present a, Missing ty3] Which in turn -- stands for (x:ty1 y:ty2. (x,a,y)) type LHsTupArg id = Located (HsTupArg id) -- |
data HsTupArg id -- | The argument [Present] :: (LHsExpr id) -> HsTupArg id -- | The argument is missing, but this is its type [Missing] :: (PostTc id Type) -> HsTupArg id tupArgPresent :: LHsTupArg id -> Bool pprLExpr :: OutputableBndr id => LHsExpr id -> SDoc pprExpr :: OutputableBndr id => HsExpr id -> SDoc isQuietHsExpr :: HsExpr id -> Bool pprBinds :: (OutputableBndr idL, OutputableBndr idR) => HsLocalBindsLR idL idR -> SDoc ppr_lexpr :: OutputableBndr id => LHsExpr id -> SDoc ppr_expr :: OutputableBndr id => HsExpr id -> SDoc pprDebugParendExpr :: OutputableBndr id => LHsExpr id -> SDoc pprParendExpr :: OutputableBndr id => LHsExpr id -> SDoc hsExprNeedsParens :: HsExpr id -> Bool isAtomicHsExpr :: HsExpr id -> Bool type LHsCmd id = Located (HsCmd id) data HsCmd id -- |
[HsCmdArrApp] :: (LHsExpr id) -> (LHsExpr id) -> (PostTc id Type) -> HsArrAppType -> Bool -> HsCmd id -- |
[HsCmdArrForm] :: (LHsExpr id) -> (Maybe Fixity) -> [LHsCmdTop id] -> HsCmd id [HsCmdApp] :: (LHsCmd id) -> (LHsExpr id) -> HsCmd id -- |
[HsCmdLam] :: (MatchGroup id (LHsCmd id)) -> HsCmd id -- |
[HsCmdPar] :: (LHsCmd id) -> HsCmd id -- |
[HsCmdCase] :: (LHsExpr id) -> (MatchGroup id (LHsCmd id)) -> HsCmd id -- |
[HsCmdIf] :: (Maybe (SyntaxExpr id)) -> (LHsExpr id) -> (LHsCmd id) -> (LHsCmd id) -> HsCmd id -- |
[HsCmdLet] :: (HsLocalBinds id) -> (LHsCmd id) -> HsCmd id -- |
[HsCmdDo] :: [CmdLStmt id] -> (PostTc id Type) -> HsCmd id [HsCmdCast] :: TcCoercion -> (HsCmd id) -> HsCmd id data HsArrAppType [HsHigherOrderApp] :: HsArrAppType [HsFirstOrderApp] :: HsArrAppType -- | Top-level command, introducing a new arrow. This may occur inside a -- proc (where the stack is empty) or as an argument of a command-forming -- operator. type LHsCmdTop id = Located (HsCmdTop id) data HsCmdTop id [HsCmdTop] :: (LHsCmd id) -> (PostTc id Type) -> (PostTc id Type) -> (CmdSyntaxTable id) -> HsCmdTop id pprLCmd :: OutputableBndr id => LHsCmd id -> SDoc pprCmd :: OutputableBndr id => HsCmd id -> SDoc isQuietHsCmd :: HsCmd id -> Bool ppr_lcmd :: OutputableBndr id => LHsCmd id -> SDoc ppr_cmd :: OutputableBndr id => HsCmd id -> SDoc pprCmdArg :: OutputableBndr id => HsCmdTop id -> SDoc type HsRecordBinds id = HsRecFields id (LHsExpr id) data MatchGroup id body [MG] :: [LMatch id body] -> [PostTc id Type] -> PostTc id Type -> Origin -> MatchGroup id body [mg_alts] :: MatchGroup id body -> [LMatch id body] [mg_arg_tys] :: MatchGroup id body -> [PostTc id Type] [mg_res_ty] :: MatchGroup id body -> PostTc id Type [mg_origin] :: MatchGroup id body -> Origin -- | May have AnnKeywordId : AnnSemi when in a list type LMatch id body = Located (Match id body) data Match id body [Match] :: (Maybe (Located id, Bool)) -> [LPat id] -> (Maybe (LHsType id)) -> (GRHSs id body) -> Match id body [m_fun_id_infix] :: Match id body -> (Maybe (Located id, Bool)) [m_pats] :: Match id body -> [LPat id] [m_type] :: Match id body -> (Maybe (LHsType id)) [m_grhss] :: Match id body -> (GRHSs id body) isEmptyMatchGroup :: MatchGroup id body -> Bool matchGroupArity :: MatchGroup id body -> Arity hsLMatchPats :: LMatch id body -> [LPat id] -- | GRHSs are used both for pattern bindings and for Matches -- --
data GRHSs id body [GRHSs] :: [LGRHS id body] -> (HsLocalBinds id) -> GRHSs id body -- | Guarded RHSs [grhssGRHSs] :: GRHSs id body -> [LGRHS id body] -- | The where clause [grhssLocalBinds] :: GRHSs id body -> (HsLocalBinds id) type LGRHS id body = Located (GRHS id body) -- | Guarded Right Hand Side. data GRHS id body [GRHS] :: [GuardLStmt id] -> body -> GRHS id body pprMatches :: (OutputableBndr idL, OutputableBndr idR, Outputable body) => HsMatchContext idL -> MatchGroup idR body -> SDoc pprFunBind :: (OutputableBndr idL, OutputableBndr idR, Outputable body) => idL -> Bool -> MatchGroup idR body -> SDoc pprPatBind :: (OutputableBndr bndr, OutputableBndr id, Outputable body) => LPat bndr -> GRHSs id body -> SDoc pprMatch :: (OutputableBndr idL, OutputableBndr idR, Outputable body) => HsMatchContext idL -> Match idR body -> SDoc pprGRHSs :: (OutputableBndr idL, OutputableBndr idR, Outputable body) => HsMatchContext idL -> GRHSs idR body -> SDoc pprGRHS :: (OutputableBndr idL, OutputableBndr idR, Outputable body) => HsMatchContext idL -> GRHS idR body -> SDoc pp_rhs :: Outputable body => HsMatchContext idL -> body -> SDoc type LStmt id body = Located (StmtLR id id body) type LStmtLR idL idR body = Located (StmtLR idL idR body) type Stmt id body = StmtLR id id body type CmdLStmt id = LStmt id (LHsCmd id) type CmdStmt id = Stmt id (LHsCmd id) type ExprLStmt id = LStmt id (LHsExpr id) type ExprStmt id = Stmt id (LHsExpr id) type GuardLStmt id = LStmt id (LHsExpr id) type GuardStmt id = Stmt id (LHsExpr id) type GhciLStmt id = LStmt id (LHsExpr id) type GhciStmt id = Stmt id (LHsExpr id) -- | API Annotations when in qualifier lists or guards - -- AnnKeywordId : AnnVbar, AnnComma,AnnThen, -- AnnBy,AnnBy, AnnGroup,AnnUsing data StmtLR idL idR body [LastStmt] :: body -> (SyntaxExpr idR) -> StmtLR idL idR body -- |
[BindStmt] :: (LPat idL) -> body -> (SyntaxExpr idR) -> (SyntaxExpr idR) -> StmtLR idL idR body [BodyStmt] :: body -> (SyntaxExpr idR) -> (SyntaxExpr idR) -> (PostTc idR Type) -> StmtLR idL idR body -- |
[LetStmt] :: (HsLocalBindsLR idL idR) -> StmtLR idL idR body [ParStmt] :: [ParStmtBlock idL idR] -> (SyntaxExpr idR) -> (SyntaxExpr idR) -> StmtLR idL idR body [TransStmt] :: TransForm -> [ExprLStmt idL] -> [(idR, idR)] -> LHsExpr idR -> Maybe (LHsExpr idR) -> SyntaxExpr idR -> SyntaxExpr idR -> SyntaxExpr idR -> StmtLR idL idR body [trS_form] :: StmtLR idL idR body -> TransForm [trS_stmts] :: StmtLR idL idR body -> [ExprLStmt idL] [trS_bndrs] :: StmtLR idL idR body -> [(idR, idR)] [trS_using] :: StmtLR idL idR body -> LHsExpr idR [trS_by] :: StmtLR idL idR body -> Maybe (LHsExpr idR) [trS_ret] :: StmtLR idL idR body -> SyntaxExpr idR [trS_bind] :: StmtLR idL idR body -> SyntaxExpr idR [trS_fmap] :: StmtLR idL idR body -> SyntaxExpr idR -- |
[RecStmt] :: [LStmtLR idL idR body] -> [idR] -> [idR] -> SyntaxExpr idR -> SyntaxExpr idR -> SyntaxExpr idR -> [PostTcExpr] -> [PostTcExpr] -> PostTc idR Type -> StmtLR idL idR body [recS_stmts] :: StmtLR idL idR body -> [LStmtLR idL idR body] [recS_later_ids] :: StmtLR idL idR body -> [idR] [recS_rec_ids] :: StmtLR idL idR body -> [idR] [recS_bind_fn] :: StmtLR idL idR body -> SyntaxExpr idR [recS_ret_fn] :: StmtLR idL idR body -> SyntaxExpr idR [recS_mfix_fn] :: StmtLR idL idR body -> SyntaxExpr idR [recS_later_rets] :: StmtLR idL idR body -> [PostTcExpr] [recS_rec_rets] :: StmtLR idL idR body -> [PostTcExpr] [recS_ret_ty] :: StmtLR idL idR body -> PostTc idR Type data TransForm [ThenForm] :: TransForm [GroupForm] :: TransForm data ParStmtBlock idL idR [ParStmtBlock] :: [ExprLStmt idL] -> [idR] -> (SyntaxExpr idR) -> ParStmtBlock idL idR pprStmt :: (OutputableBndr idL, OutputableBndr idR, Outputable body) => (StmtLR idL idR body) -> SDoc pprTransformStmt :: OutputableBndr id => [id] -> LHsExpr id -> Maybe (LHsExpr id) -> SDoc pprTransStmt :: Outputable body => Maybe body -> body -> TransForm -> SDoc pprBy :: Outputable body => Maybe body -> SDoc pprDo :: (OutputableBndr id, Outputable body) => HsStmtContext any -> [LStmt id body] -> SDoc ppr_do_stmts :: (OutputableBndr idL, OutputableBndr idR, Outputable body) => [LStmtLR idL idR body] -> SDoc pprComp :: (OutputableBndr id, Outputable body) => [LStmt id body] -> SDoc pprQuals :: (OutputableBndr id, Outputable body) => [LStmt id body] -> SDoc data HsSplice id [HsSplice] :: id -> (LHsExpr id) -> HsSplice id data PendingSplice id [PendSplice] :: Name -> (LHsExpr id) -> PendingSplice id data PendingRnSplice [PendingRnExpSplice] :: (PendingSplice Name) -> PendingRnSplice [PendingRnPatSplice] :: (PendingSplice Name) -> PendingRnSplice [PendingRnTypeSplice] :: (PendingSplice Name) -> PendingRnSplice [PendingRnDeclSplice] :: (PendingSplice Name) -> PendingRnSplice [PendingRnCrossStageSplice] :: Name -> PendingRnSplice type PendingTcSplice = PendingSplice Id pprUntypedSplice :: OutputableBndr id => HsSplice id -> SDoc pprTypedSplice :: OutputableBndr id => HsSplice id -> SDoc pprSplice :: OutputableBndr id => Bool -> HsSplice id -> SDoc data HsBracket id [ExpBr] :: (LHsExpr id) -> HsBracket id [PatBr] :: (LPat id) -> HsBracket id [DecBrL] :: [LHsDecl id] -> HsBracket id [DecBrG] :: (HsGroup id) -> HsBracket id [TypBr] :: (LHsType id) -> HsBracket id [VarBr] :: Bool -> id -> HsBracket id [TExpBr] :: (LHsExpr id) -> HsBracket id isTypedBracket :: HsBracket id -> Bool pprHsBracket :: OutputableBndr id => HsBracket id -> SDoc thBrackets :: SDoc -> SDoc -> SDoc thTyBrackets :: SDoc -> SDoc data ArithSeqInfo id [From] :: (LHsExpr id) -> ArithSeqInfo id [FromThen] :: (LHsExpr id) -> (LHsExpr id) -> ArithSeqInfo id [FromTo] :: (LHsExpr id) -> (LHsExpr id) -> ArithSeqInfo id [FromThenTo] :: (LHsExpr id) -> (LHsExpr id) -> (LHsExpr id) -> ArithSeqInfo id pp_dotdot :: SDoc data HsMatchContext id [FunRhs] :: id -> Bool -> HsMatchContext id [LambdaExpr] :: HsMatchContext id [CaseAlt] :: HsMatchContext id [IfAlt] :: HsMatchContext id [ProcExpr] :: HsMatchContext id [PatBindRhs] :: HsMatchContext id [RecUpd] :: HsMatchContext id [StmtCtxt] :: (HsStmtContext id) -> HsMatchContext id [ThPatSplice] :: HsMatchContext id [ThPatQuote] :: HsMatchContext id [PatSyn] :: HsMatchContext id data HsStmtContext id [ListComp] :: HsStmtContext id [MonadComp] :: HsStmtContext id [PArrComp] :: HsStmtContext id [DoExpr] :: HsStmtContext id [MDoExpr] :: HsStmtContext id [ArrowExpr] :: HsStmtContext id [GhciStmtCtxt] :: HsStmtContext id [PatGuard] :: (HsMatchContext id) -> HsStmtContext id [ParStmtCtxt] :: (HsStmtContext id) -> HsStmtContext id [TransStmtCtxt] :: (HsStmtContext id) -> HsStmtContext id isListCompExpr :: HsStmtContext id -> Bool isMonadCompExpr :: HsStmtContext id -> Bool matchSeparator :: HsMatchContext id -> SDoc pprMatchContext :: Outputable id => HsMatchContext id -> SDoc pprMatchContextNoun :: Outputable id => HsMatchContext id -> SDoc pprAStmtContext :: Outputable id => HsStmtContext id -> SDoc pprStmtContext :: Outputable id => HsStmtContext id -> SDoc matchContextErrString :: Outputable id => HsMatchContext id -> SDoc pprMatchInCtxt :: (OutputableBndr idL, OutputableBndr idR, Outputable body) => HsMatchContext idL -> Match idR body -> SDoc pprStmtInCtxt :: (OutputableBndr idL, OutputableBndr idR, Outputable body) => HsStmtContext idL -> StmtLR idL idR body -> SDoc instance Data PendingRnSplice instance Data id => Data (HsMatchContext id) instance Data id => Data (HsStmtContext id) instance Data TransForm instance Data HsArrAppType instance DataId id => Data (HsExpr id) instance DataId id => Data (HsTupArg id) instance DataId id => Data (HsCmd id) instance DataId id => Data (HsCmdTop id) instance (Data body, DataId id) => Data (MatchGroup id body) instance (Data body, DataId id) => Data (Match id body) instance (Data body, DataId id) => Data (GRHSs id body) instance (Data body, DataId id) => Data (GRHS id body) instance (Data body, DataId idL, DataId idR) => Data (StmtLR idL idR body) instance (DataId idL, DataId idR) => Data (ParStmtBlock idL idR) instance DataId id => Data (HsSplice id) instance DataId id => Data (PendingSplice id) instance DataId id => Data (HsBracket id) instance DataId id => Data (ArithSeqInfo id) instance OutputableBndr id => Outputable (HsExpr id) instance OutputableBndr id => Outputable (HsCmd id) instance OutputableBndr id => Outputable (HsCmdTop id) instance (OutputableBndr idL, OutputableBndr idR) => Outputable (ParStmtBlock idL idR) instance (OutputableBndr idL, OutputableBndr idR, Outputable body) => Outputable (StmtLR idL idR body) instance OutputableBndr id => Outputable (HsSplice id) instance OutputableBndr id => Outputable (PendingSplice id) instance OutputableBndr id => Outputable (HsBracket id) instance Outputable PendingRnSplice instance OutputableBndr id => Outputable (ArithSeqInfo id) module HsUtils mkHsPar :: LHsExpr id -> LHsExpr id mkHsApp :: LHsExpr name -> LHsExpr name -> LHsExpr name mkHsConApp :: DataCon -> [Type] -> [HsExpr Id] -> LHsExpr Id mkSimpleHsAlt :: LPat id -> (Located (body id)) -> LMatch id (Located (body id)) mkSimpleMatch :: [LPat id] -> Located (body id) -> LMatch id (Located (body id)) unguardedGRHSs :: Located (body id) -> GRHSs id (Located (body id)) unguardedRHS :: SrcSpan -> Located (body id) -> [LGRHS id (Located (body id))] mkMatchGroup :: Origin -> [LMatch RdrName (Located (body RdrName))] -> MatchGroup RdrName (Located (body RdrName)) mkMatchGroupName :: Origin -> [LMatch Name (Located (body Name))] -> MatchGroup Name (Located (body Name)) mkMatch :: [LPat id] -> LHsExpr id -> HsLocalBinds id -> LMatch id (LHsExpr id) mkHsLam :: [LPat RdrName] -> LHsExpr RdrName -> LHsExpr RdrName mkHsIf :: LHsExpr id -> LHsExpr id -> LHsExpr id -> HsExpr id mkHsWrap :: HsWrapper -> HsExpr id -> HsExpr id mkLHsWrap :: HsWrapper -> LHsExpr id -> LHsExpr id mkHsWrapCo :: TcCoercion -> HsExpr id -> HsExpr id mkHsWrapCoR :: TcCoercion -> HsExpr id -> HsExpr id mkLHsWrapCo :: TcCoercion -> LHsExpr id -> LHsExpr id coToHsWrapper :: TcCoercion -> HsWrapper mkHsDictLet :: TcEvBinds -> LHsExpr Id -> LHsExpr Id mkHsLams :: [TyVar] -> [EvVar] -> LHsExpr Id -> LHsExpr Id mkHsOpApp :: LHsExpr id -> id -> LHsExpr id -> HsExpr id mkHsDo :: HsStmtContext Name -> [ExprLStmt RdrName] -> HsExpr RdrName mkHsComp :: HsStmtContext Name -> [ExprLStmt RdrName] -> LHsExpr RdrName -> HsExpr RdrName mkHsWrapPat :: HsWrapper -> Pat id -> Type -> Pat id mkHsWrapPatCo :: TcCoercion -> Pat id -> Type -> Pat id mkLHsPar :: LHsExpr name -> LHsExpr name mkHsCmdCast :: TcCoercion -> HsCmd id -> HsCmd id nlHsTyApp :: name -> [Type] -> LHsExpr name nlHsTyApps :: name -> [Type] -> [LHsExpr name] -> LHsExpr name nlHsVar :: id -> LHsExpr id nlHsLit :: HsLit -> LHsExpr id nlHsApp :: LHsExpr id -> LHsExpr id -> LHsExpr id nlHsApps :: id -> [LHsExpr id] -> LHsExpr id nlHsIntLit :: Integer -> LHsExpr id nlHsVarApps :: id -> [id] -> LHsExpr id nlHsDo :: HsStmtContext Name -> [LStmt RdrName (LHsExpr RdrName)] -> LHsExpr RdrName nlHsOpApp :: LHsExpr id -> id -> LHsExpr id -> LHsExpr id nlHsLam :: LMatch RdrName (LHsExpr RdrName) -> LHsExpr RdrName nlHsPar :: LHsExpr id -> LHsExpr id nlHsIf :: LHsExpr id -> LHsExpr id -> LHsExpr id -> LHsExpr id nlHsCase :: LHsExpr RdrName -> [LMatch RdrName (LHsExpr RdrName)] -> LHsExpr RdrName nlList :: [LHsExpr RdrName] -> LHsExpr RdrName mkLHsTupleExpr :: [LHsExpr a] -> LHsExpr a mkLHsVarTuple :: [a] -> LHsExpr a missingTupArg :: HsTupArg RdrName toHsType :: Type -> LHsType RdrName toHsKind :: Kind -> LHsKind RdrName mkFunBind :: Located RdrName -> [LMatch RdrName (LHsExpr RdrName)] -> HsBind RdrName mkVarBind :: id -> LHsExpr id -> LHsBind id mkHsVarBind :: SrcSpan -> RdrName -> LHsExpr RdrName -> LHsBind RdrName mk_easy_FunBind :: SrcSpan -> RdrName -> [LPat RdrName] -> LHsExpr RdrName -> LHsBind RdrName mkTopFunBind :: Origin -> Located Name -> [LMatch Name (LHsExpr Name)] -> HsBind Name mkPatSynBind :: Located RdrName -> HsPatSynDetails (Located RdrName) -> LPat RdrName -> HsPatSynDir RdrName -> HsBind RdrName mkHsIntegral :: String -> Integer -> PostTc RdrName Type -> HsOverLit RdrName mkHsFractional :: FractionalLit -> PostTc RdrName Type -> HsOverLit RdrName mkHsIsString :: String -> FastString -> PostTc RdrName Type -> HsOverLit RdrName mkHsString :: String -> HsLit mkNPat :: Located (HsOverLit id) -> Maybe (SyntaxExpr id) -> Pat id mkNPlusKPat :: Located id -> Located (HsOverLit id) -> Pat id nlVarPat :: id -> LPat id nlLitPat :: HsLit -> LPat id nlConVarPat :: RdrName -> [RdrName] -> LPat RdrName nlConPat :: RdrName -> [LPat RdrName] -> LPat RdrName nlConPatName :: Name -> [LPat Name] -> LPat Name nlInfixConPat :: id -> LPat id -> LPat id -> LPat id nlNullaryConPat :: id -> LPat id nlWildConPat :: DataCon -> LPat RdrName nlWildPat :: LPat RdrName nlWildPatName :: LPat Name nlWildPatId :: LPat Id nlTuplePat :: [LPat id] -> Boxity -> LPat id mkParPat :: LPat name -> LPat name mkHsAppTy :: LHsType name -> LHsType name -> LHsType name userHsTyVarBndrs :: SrcSpan -> [name] -> [Located (HsTyVarBndr name)] nlHsAppTy :: LHsType name -> LHsType name -> LHsType name nlHsTyVar :: name -> LHsType name nlHsFunTy :: LHsType name -> LHsType name -> LHsType name nlHsTyConApp :: name -> [LHsType name] -> LHsType name mkTransformStmt :: [ExprLStmt idL] -> LHsExpr idR -> StmtLR idL idR (LHsExpr idL) mkTransformByStmt :: [ExprLStmt idL] -> LHsExpr idR -> LHsExpr idR -> StmtLR idL idR (LHsExpr idL) mkBodyStmt :: Located (bodyR RdrName) -> StmtLR idL RdrName (Located (bodyR RdrName)) mkBindStmt :: LPat idL -> Located (bodyR idR) -> StmtLR idL idR (Located (bodyR idR)) mkLastStmt :: Located (bodyR idR) -> StmtLR idL idR (Located (bodyR idR)) emptyTransStmt :: StmtLR idL idR (LHsExpr idR) mkGroupUsingStmt :: [ExprLStmt idL] -> LHsExpr idR -> StmtLR idL idR (LHsExpr idL) mkGroupByUsingStmt :: [ExprLStmt idL] -> LHsExpr idR -> LHsExpr idR -> StmtLR idL idR (LHsExpr idL) emptyRecStmt :: StmtLR idL RdrName bodyR emptyRecStmtName :: StmtLR Name Name bodyR emptyRecStmtId :: StmtLR Id Id bodyR mkRecStmt :: [LStmtLR idL RdrName bodyR] -> StmtLR idL RdrName bodyR mkHsSpliceTy :: LHsExpr RdrName -> HsType RdrName mkHsSpliceE :: LHsExpr RdrName -> HsExpr RdrName mkHsSpliceTE :: LHsExpr RdrName -> HsExpr RdrName mkHsSplice :: LHsExpr RdrName -> HsSplice RdrName mkHsQuasiQuote :: RdrName -> SrcSpan -> FastString -> HsQuasiQuote RdrName unqualQuasiQuote :: RdrName noRebindableInfo :: PlaceHolder collectLocalBinders :: HsLocalBindsLR idL idR -> [idL] collectHsValBinders :: HsValBindsLR idL idR -> [idL] collectHsBindListBinders :: [LHsBindLR idL idR] -> [idL] collectHsIdBinders :: HsValBindsLR idL idR -> [idL] collectHsBindsBinders :: LHsBindsLR idL idR -> [idL] collectHsBindBinders :: HsBindLR idL idR -> [idL] collectMethodBinders :: LHsBindsLR RdrName idR -> [Located RdrName] collectPatBinders :: LPat a -> [a] collectPatsBinders :: [LPat a] -> [a] collectLStmtsBinders :: [LStmtLR idL idR body] -> [idL] collectStmtsBinders :: [StmtLR idL idR body] -> [idL] collectLStmtBinders :: LStmtLR idL idR body -> [idL] collectStmtBinders :: StmtLR idL idR body -> [idL] -- | Returns all the binding names of the decl. The first one is -- guaranteed to be the name of the decl. For record fields mentioned in -- multiple constructors, the SrcLoc will be from the first occurrence. -- We use the equality to filter out duplicate field names. -- -- Each returned (Located name) has a SrcSpan for the whole -- declaration. See Note [SrcSpan for binders] hsLTyClDeclBinders :: Eq name => Located (TyClDecl name) -> [Located name] hsTyClForeignBinders :: [TyClGroup Name] -> [LInstDecl Name] -> [LForeignDecl Name] -> [Name] hsPatSynBinders :: LHsBindsLR idL idR -> [Located idL] hsForeignDeclsBinders :: [LForeignDecl name] -> [Located name] hsGroupBinders :: HsGroup Name -> [Name] hsDataFamInstBinders :: Eq name => DataFamInstDecl name -> [Located name] lStmtsImplicits :: [LStmtLR Name idR (Located (body idR))] -> NameSet hsValBindsImplicits :: HsValBindsLR Name idR -> NameSet lPatImplicits :: LPat Name -> NameSet module HsSyn data Fixity -- | All we actually declare here is the top-level structure for a module. data HsModule name -- | AnnKeywordIds -- --
[HsModule] :: Maybe (Located ModuleName) -> Maybe (Located [LIE name]) -> [LImportDecl name] -> [LHsDecl name] -> Maybe (Located WarningTxt) -> Maybe LHsDocString -> HsModule name -- | Nothing: "module X where" is omitted (in which case the next -- field is Nothing too) [hsmodName] :: HsModule name -> Maybe (Located ModuleName) -- | Export list -- --
--
• Nothing: export list omitted, so export everything
• --
• Just []: export nothing
• --
• Just [...]: as you would expect...
• --
• AnnKeywordIds : AnnOpen ,AnnClose
• --
[hsmodExports] :: HsModule name -> Maybe (Located [LIE name]) -- | We snaffle interesting stuff out of the imported interfaces early on, -- adding that info to TyDecls/etc; so this list is often empty, -- downstream. [hsmodImports] :: HsModule name -> [LImportDecl name] -- | Type, class, value, and interface signature decls [hsmodDecls] :: HsModule name -> [LHsDecl name] -- | reason/explanation for warning/deprecation of this module -- --
[hsmodDeprecMessage] :: HsModule name -> Maybe (Located WarningTxt) -- | Haddock module info and description, unparsed -- --
--
• A regular Haskell source module
• --
• A hi-boot source module
• --
• An external-core source module
• --
data ModSummary [ModSummary] :: Module -> HscSource -> ModLocation -> UTCTime -> Maybe UTCTime -> Maybe UTCTime -> [Located (ImportDecl RdrName)] -> [Located (ImportDecl RdrName)] -> FilePath -> DynFlags -> Maybe StringBuffer -> ModSummary -- | Identity of the module [ms_mod] :: ModSummary -> Module -- | The module source either plain Haskell, hs-boot or external core [ms_hsc_src] :: ModSummary -> HscSource -- | Location of the various files belonging to the module [ms_location] :: ModSummary -> ModLocation -- | Timestamp of source file [ms_hs_date] :: ModSummary -> UTCTime -- | Timestamp of object, if we have one [ms_obj_date] :: ModSummary -> Maybe UTCTime -- | Timestamp of hi file, if we *only* are typechecking (it is -- Nothing otherwise. See Note [Recompilation checking when -- typechecking only] and #9243 [ms_iface_date] :: ModSummary -> Maybe UTCTime -- | Source imports of the module [ms_srcimps] :: ModSummary -> [Located (ImportDecl RdrName)] -- | Non-source imports of the module from the module *text* [ms_textual_imps] :: ModSummary -> [Located (ImportDecl RdrName)] -- | Filename of preprocessed source file [ms_hspp_file] :: ModSummary -> FilePath -- | Cached flags from OPTIONS, INCLUDE and -- LANGUAGE pragmas in the modules source code [ms_hspp_opts] :: ModSummary -> DynFlags -- | The actual preprocessed source, if we have it [ms_hspp_buf] :: ModSummary -> Maybe StringBuffer ms_imps :: ModSummary -> [Located (ImportDecl RdrName)] ms_mod_name :: ModSummary -> ModuleName showModMsg :: DynFlags -> HscTarget -> Bool -> ModSummary -> String -- | Did this ModSummary originate from a hs-boot file? isBootSummary :: ModSummary -> Bool msHsFilePath :: ModSummary -> FilePath msHiFilePath :: ModSummary -> FilePath msObjFilePath :: ModSummary -> FilePath -- | Indicates whether a given module's source has been modified since it -- was last compiled. data SourceModified -- | the source has been modified [SourceModified] :: SourceModified -- | the source has not been modified. Compilation may or may not be -- necessary, depending on whether any dependencies have changed since we -- last compiled. [SourceUnmodified] :: SourceModified -- | the source has not been modified, and furthermore all of its -- (transitive) dependencies are up to date; it definitely does not need -- to be recompiled. This is important for two reasons: (a) we can omit -- the version check in checkOldIface, and (b) if the module used TH -- splices we don't need to force recompilation. [SourceUnmodifiedAndStable] :: SourceModified data HscSource [HsSrcFile] :: HscSource [HsBootFile] :: HscSource [HsigFile] :: HscSource isHsBootOrSig :: HscSource -> Bool hscSourceString :: HscSource -> String -- | Helps us find information about modules in the home package type HomePackageTable = ModuleNameEnv HomeModInfo -- | Information about modules in the package being compiled data HomeModInfo [HomeModInfo] :: !ModIface -> !ModDetails -> !(Maybe Linkable) -> HomeModInfo -- | The basic loaded interface file: every loaded module has one of these, -- even if it is imported from another package [hm_iface] :: HomeModInfo -> !ModIface -- | Extra information that has been created from the ModIface for -- the module, typically during typechecking [hm_details] :: HomeModInfo -> !ModDetails -- | The actual artifact we would like to link to access things in this -- module. -- -- hm_linkable might be Nothing: -- --
--
1. If this is an .hs-boot module
2. --
3. Temporarily during compilation if we pruned away the old linkable -- because it was out of date.
4. --
-- -- After a complete compilation (load), all hm_linkable -- fields in the HomePackageTable will be Just. -- -- When re-linking a module (HscNoRecomp), we construct the -- HomeModInfo by building a new ModDetails from the old -- ModIface (only). [hm_linkable] :: HomeModInfo -> !(Maybe Linkable) -- | Constructs an empty HomePackageTable emptyHomePackageTable :: HomePackageTable -- | 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 rules from modules "below" this one (in the dependency sense) hptRules :: HscEnv -> [(ModuleName, IsBootInterface)] -> [CoreRule] -- | Get the combined VectInfo of all modules in the home package table. In -- contrast to instances and rules, we don't care whether the modules are -- "below" us in the dependency sense. The VectInfo of those modules not -- "below" us does not affect the compilation of the current module. hptVectInfo :: HscEnv -> VectInfo pprHPT :: HomePackageTable -> SDoc hptObjs :: HomePackageTable -> [FilePath] -- | Information about other packages that we have slurped in by reading -- their interface files data ExternalPackageState [EPS] :: !(ModuleNameEnv (ModuleName, IsBootInterface)) -> !PackageIfaceTable -> !PackageTypeEnv -> !PackageInstEnv -> !PackageFamInstEnv -> !PackageRuleBase -> !PackageVectInfo -> !PackageAnnEnv -> !(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 (ModuleName, IsBootInterface)) -- | The ModIfaces 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: -- --
--
• The Module
• --
• Fingerprint info
• --
• Its exports
• --
• Fixities
• --
• Deprecations and warnings
• --
--
• An instance declaration in a module other than the definition -- module for one of the type constructors or classes in the instance -- head
• --
• A transformation rule in a module other than the one defining the -- function in the head of the rule
• --
• A vectorisation pragma
• --
```--   handleSourceError printExceptionAndWarnings \$ do
--     ... api calls that may fail ...
--   ```
--
• allows embedding of IO actions,
• --
• can log warnings,
• --
• allows handling of (extensible) exceptions, and
• --
• maintains a current session.
• --
```--   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
--   ```
--
• The to/from functions for generic data types
• --
• Top-level variables appearing free in the RHS of an orphan -- rule
• --
• Top-level variables appearing free in a TH bracket
• --
[tcg_keep] :: TcGblEnv -> TcRef NameSet -- | True = Template Haskell syntax used. -- -- We need this so that we can generate a dependency on the Template -- Haskell package, because the desugarer is going to emit loads of -- references to TH symbols. The reference is implicit rather than -- explicit, so we have to zap a mutable variable. [tcg_th_used] :: TcGblEnv -> TcRef Bool -- | True = A Template Haskell splice was used. -- -- Splices disable recompilation avoidance (see #481) [tcg_th_splice_used] :: TcGblEnv -> TcRef Bool -- | Allows us to choose unique DFun names. [tcg_dfun_n] :: TcGblEnv -> TcRef OccSet [tcg_rn_exports] :: TcGblEnv -> Maybe [Located (IE Name)] [tcg_rn_imports] :: TcGblEnv -> [LImportDecl Name] -- | Renamed decls, maybe. Nothing = Don't retain renamed -- decls. [tcg_rn_decls] :: TcGblEnv -> Maybe (HsGroup Name) -- | dependencies from addDependentFile [tcg_dependent_files] :: TcGblEnv -> TcRef [FilePath] -- | Top-level declarations from addTopDecls [tcg_th_topdecls] :: TcGblEnv -> TcRef [LHsDecl RdrName] -- | Exact names bound in top-level declarations in tcg_th_topdecls [tcg_th_topnames] :: TcGblEnv -> TcRef NameSet -- | Template Haskell module finalizers [tcg_th_modfinalizers] :: TcGblEnv -> TcRef [Q ()] -- | Template Haskell state [tcg_th_state] :: TcGblEnv -> TcRef (Map TypeRep Dynamic) [tcg_ev_binds] :: TcGblEnv -> Bag EvBind [tcg_binds] :: TcGblEnv -> LHsBinds Id [tcg_sigs] :: TcGblEnv -> NameSet [tcg_imp_specs] :: TcGblEnv -> [LTcSpecPrag] [tcg_warns] :: TcGblEnv -> Warnings [tcg_anns] :: TcGblEnv -> [Annotation] [tcg_tcs] :: TcGblEnv -> [TyCon] [tcg_insts] :: TcGblEnv -> [ClsInst] [tcg_fam_insts] :: TcGblEnv -> [FamInst] [tcg_rules] :: TcGblEnv -> [LRuleDecl Id] [tcg_fords] :: TcGblEnv -> [LForeignDecl Id] [tcg_vects] :: TcGblEnv -> [LVectDecl Id] [tcg_patsyns] :: TcGblEnv -> [PatSyn] -- | Maybe Haddock header docs [tcg_doc_hdr] :: TcGblEnv -> Maybe LHsDocString -- | True if any part of the prog uses hpc instrumentation. [tcg_hpc] :: TcGblEnv -> AnyHpcUsage -- | The Name of the main function, if this module is the main module. [tcg_main] :: TcGblEnv -> Maybe Name [tcg_safeInfer] :: TcGblEnv -> TcRef Bool -- | A list of user-defined plugins for the constraint solver. [tcg_tc_plugins] :: TcGblEnv -> [TcPluginSolver] -- | Wanted constraints of static forms. [tcg_static_wc] :: TcGblEnv -> TcRef WantedConstraints data TcLclEnv [TcLclEnv] :: SrcSpan -> [ErrCtxt] -> TcLevel -> ThStage -> ThBindEnv -> ArrowCtxt -> LocalRdrEnv -> TcTypeEnv -> [TcIdBinder] -> TidyEnv -> TcRef TcTyVarSet -> TcRef WantedConstraints -> TcRef Messages -> TcLclEnv [tcl_loc] :: TcLclEnv -> SrcSpan [tcl_ctxt] :: TcLclEnv -> [ErrCtxt] [tcl_tclvl] :: TcLclEnv -> TcLevel [tcl_th_ctxt] :: TcLclEnv -> ThStage [tcl_th_bndrs] :: TcLclEnv -> ThBindEnv [tcl_arrow_ctxt] :: TcLclEnv -> ArrowCtxt [tcl_rdr] :: TcLclEnv -> LocalRdrEnv [tcl_env] :: TcLclEnv -> TcTypeEnv [tcl_bndrs] :: TcLclEnv -> [TcIdBinder] [tcl_tidy] :: TcLclEnv -> TidyEnv [tcl_tyvars] :: TcLclEnv -> TcRef TcTyVarSet [tcl_lie] :: TcLclEnv -> TcRef WantedConstraints [tcl_errs] :: TcLclEnv -> TcRef Messages data IfGblEnv [IfGblEnv] :: Maybe (Module, IfG TypeEnv) -> IfGblEnv [if_rec_types] :: IfGblEnv -> Maybe (Module, IfG TypeEnv) data IfLclEnv [IfLclEnv] :: Module -> SDoc -> UniqFM TyVar -> UniqFM Id -> IfLclEnv [if_mod] :: IfLclEnv -> Module [if_loc] :: IfLclEnv -> SDoc [if_tv_env] :: IfLclEnv -> UniqFM TyVar [if_id_env] :: IfLclEnv -> UniqFM Id type ErrCtxt = (Bool, TidyEnv -> TcM (TidyEnv, MsgDoc)) data RecFieldEnv [RecFields] :: (NameEnv [Name]) -> NameSet -> RecFieldEnv -- | ImportAvails summarises what was imported from where, -- irrespective of whether the imported things are actually used or not. -- It is used: -- --
--
• when processing the export list,
• --
• when constructing usage info for the interface file,
• --
• to identify the list of directly imported modules for -- initialisation purposes and for optimised overlap checking of family -- instances,
• --
• when figuring out what things are really unused
• --
data ImportAvails [ImportAvails] :: ImportedMods -> ModuleNameEnv (ModuleName, IsBootInterface) -> [PackageKey] -> [PackageKey] -> Bool -> [Module] -> [Module] -> ImportAvails -- | Domain is all directly-imported modules The ModuleName is what -- the module was imported as, e.g. in import Foo as Bar it is -- Bar. -- -- The Bool means: -- --
--
• True => import was import Foo ()
• --
• False => import was some other form
• --
```--   mkSmallTupleSelector [x] x v e = [| e |]
--   mkSmallTupleSelector [x,y,z] x v e = [| case e of v { (x,y,z) -> x } |]
--   ```
--
1. When you do a normal package lookup, we first check if the module -- is available in the home module, before looking it up in the package -- database.
2. --
3. When you have a package qualified import with package name "this", -- we shortcut to the home module.
4. --
5. When we look up an exact Module, if the package key -- associated with the module is the current home module do a look up in -- the home module.
6. --
7. Some special-case code in GHCi (ToDo: Figure out why that needs to -- call this.)
8. --
```--   Package:Module.Name
--   ```
--
• if the linkable is stable (and it's the same one -- the user may -- have recompiled the module on the side), we keep it,
• --
• --
• we also implicitly unload all temporary bindings at this -- point.
• --
--
• The interface could not be loaded
• --
• The name is not that of a TyCon
• --
• The name did not exist in the loaded module
• --
forceLoadTyCon :: HscEnv -> Name -> IO TyCon -- | Finds the Name corresponding to the given RdrName in the -- context of the ModuleName. Returns Nothing if no such -- Name could be found. Any other condition results in an -- exception: -- --
--
• If the module could not be found
• --
• If we could not determine the imports of the module
• --
-- -- Can only be used for looking up names while loading plugins (and is -- *not* suitable for use within plugins). The interface file is loaded -- very partially: just enough that it can be used, without its rules and -- instances affecting (and being linked from!) the module being -- compiled. This was introduced by 57d6798. -- -- See Note [Care with plugin imports] in LoadIface. lookupRdrNameInModuleForPlugins :: HscEnv -> ModuleName -> RdrName -> IO (Maybe Name) -- | Loads the value corresponding to a Name if that value has the -- given Type. This only provides limited safety in that it is up -- to the user to ensure that that type corresponds to the type you try -- to use the return value at! -- -- If the value found was not of the correct type, returns -- Nothing. Any other condition results in an exception: -- --
--
• If we could not load the names module
• --
• If the thing being loaded is not a value
• --
• If the Name does not exist in the module
• --
• --
--
• embed pure expressions (pure), and
• --
• sequence computations and combine their results -- (<*>).
• --
-- -- A minimal complete definition must include implementations of these -- functions satisfying the following laws: -- --
--
• identity
```pure id <*>
--   v = v```
• --
• composition
```pure (.) <*> u
--   <*> v <*> w = u <*> (v
--   <*> w)```
• --
• homomorphism
`pure f <*`