--
• 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. (<\$>) :: 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 -- | 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 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 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 -- | The function splits the given string to substrings using the -- searchPathSeparator. parseSearchPath :: String -> [FilePath] 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-presentable 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
--   ```
```--   [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 darrow :: SDoc lparen :: SDoc rparen :: SDoc lbrack :: SDoc rbrack :: SDoc lbrace :: SDoc rbrace :: SDoc underscore :: SDoc blankLine :: 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 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 type PrintUnqualified = (QueryQualifyName, QueryQualifyModule) alwaysQualify :: PrintUnqualified alwaysQualifyNames :: QueryQualifyName alwaysQualifyModules :: QueryQualifyModule neverQualify :: PrintUnqualified neverQualifyNames :: QueryQualifyName neverQualifyModules :: QueryQualifyModule data QualifyName NameUnqual :: QualifyName NameQual :: ModuleName -> QualifyName NameNotInScope1 :: QualifyName NameNotInScope2 :: QualifyName 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 -- | Style for printing error messages mkErrStyle :: DynFlags -> PrintUnqualified -> PprStyle defaultErrStyle :: DynFlags -> PprStyle defaultDumpStyle :: 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
--   ```
module OccName data NameSpace 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 aditional 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 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 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 isLexCon :: FastString -> Bool isLexVar :: FastString -> Bool isLexId :: FastString -> Bool isLexSym :: FastString -> Bool isLexConId :: FastString -> Bool isLexConSym :: FastString -> Bool isLexVarId :: FastString -> Bool isLexVarSym :: FastString -> Bool startsVarSym :: Char -> Bool startsVarId :: Char -> Bool startsConSym :: Char -> Bool startsConId :: Char -> Bool instance Typeable OccName instance Eq NameSpace instance Ord NameSpace instance Binary OccName instance Binary NameSpace instance Outputable a => Outputable (OccEnv a) instance Uniquable OccName instance OutputableBndr OccName instance Outputable OccName instance Data OccName instance Ord OccName instance Eq OccName -- | 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 tidyNameOcc :: Name -> OccName -> Name hashName :: Name -> Int -- | 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. 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 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 Typeable Name instance OutputableBndr Name instance Outputable Name instance Binary Name instance Data Name instance NamedThing Name instance Uniquable Name instance Ord Name instance Eq Name instance HasOccName Name -- | GHC uses several kinds of name internally: -- --
-- -- 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 Typeable Var instance Data Var instance Ord Var instance Eq Var instance Uniquable Var instance NamedThing Var instance Outputable Var 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 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 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 Typeable IsCafCC instance Typeable CostCentre instance Eq IsCafCC instance Ord IsCafCC instance Data IsCafCC instance Data CostCentre instance Eq CostCentreStack instance Ord CostCentreStack instance Binary CostCentre instance Binary IsCafCC instance Outputable CostCentre instance Outputable CostCentreStack instance Ord CostCentre instance Eq CostCentre 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 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 depAnal :: (node -> [Name]) -> (node -> [Name]) -> [node] -> [SCC node] module NameSet type NameSet = UniqSet Name emptyNameSet :: NameSet unitNameSet :: Name -> NameSet mkNameSet :: [Name] -> NameSet unionNameSets :: NameSet -> NameSet -> NameSet unionManyNameSets :: [NameSet] -> NameSet minusNameSet :: NameSet -> NameSet -> NameSet elemNameSet :: Name -> NameSet -> Bool nameSetToList :: NameSet -> [Name] addOneToNameSet :: NameSet -> Name -> NameSet addListToNameSet :: 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 Binary AvailInfo instance Outputable AvailInfo module ConLike -- | A constructor-like thing data ConLike RealDataCon :: DataCon -> ConLike PatSynCon :: PatSyn -> ConLike instance Typeable ConLike instance Data ConLike instance OutputableBndr ConLike instance Outputable ConLike instance NamedThing ConLike instance Uniquable ConLike instance Ord ConLike instance Eq 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 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(..) )
--   ```
```--   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 -- | Same Name as the data constructor tyConName :: TyCon -> Name tyConKind :: TyCon -> Kind -- | Same Unique as the data constructor 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. --
-- -- Note that it does not scope over the data constructors. tyConTyVars :: TyCon -> [TyVar] tyConCType :: TyCon -> Maybe CType tyConCType_maybe :: TyCon -> Maybe CType -- | As tyConDataCons_maybe, but returns the empty list of -- constructors if no constructors could be found tyConDataCons :: TyCon -> [DataCon] -- | Determine the DataCons originating from the given TyCon, -- if the TyCon is the sort that can have any constructors (note: -- this does not include abstract algebraic types) tyConDataCons_maybe :: TyCon -> Maybe [DataCon] -- | If the given TyCon has a single data constructor, i.e. -- it is a data type with one alternative, a tuple type or a -- newtype then that constructor is returned. If the -- TyCon has more than one constructor, or represents a primitive -- or function type constructor then Nothing is returned. In any -- other case, the function panics tyConSingleDataCon_maybe :: TyCon -> Maybe DataCon tyConSingleAlgDataCon_maybe :: TyCon -> Maybe DataCon -- | Determine the number of value constructors a TyCon has. Panics -- if the TyCon is not algebraic or a tuple tyConFamilySize :: TyCon -> Int -- | Find the "stupid theta" of the TyCon. A "stupid theta" is the -- context to the left of an algebraic type declaration, e.g. Eq -- a in the declaration data Eq a => T a ... tyConStupidTheta :: TyCon -> [PredType] -- | n if ty_con :: * -> ... -> * n times tyConArity :: TyCon -> Arity -- | Get the list of roles for the type parameters of a TyCon tyConRoles :: TyCon -> [Role] tyConParent :: TyCon -> TyConParent tyConTuple_maybe :: TyCon -> Maybe TupleSort -- | If this TyCon is that for a class instance, return the class it -- is for. Otherwise returns Nothing tyConClass_maybe :: TyCon -> Maybe Class -- | If this TyCon is that of a family instance, return the family -- in question and the instance types. Otherwise, return Nothing tyConFamInst_maybe :: TyCon -> Maybe (TyCon, [Type]) tyConFamInstSig_maybe :: TyCon -> Maybe (TyCon, [Type], CoAxiom Unbranched) -- | If this TyCon is that of a family instance, return a -- TyCon which represents a coercion identifying the -- representation type with the type instance family. Otherwise, return -- Nothing tyConFamilyCoercion_maybe :: TyCon -> Maybe (CoAxiom Unbranched) -- | Extract the TyVars bound by a vanilla type synonym (not -- familiy) and the corresponding (unsubstituted) right hand side. synTyConDefn_maybe :: TyCon -> Maybe ([TyVar], Type) -- | Extract the information pertaining to the right hand side of a type -- synonym (type) declaration. synTyConRhs_maybe :: TyCon -> Maybe SynTyConRhs -- | Just e for foreign-imported types, holds the name of the -- imported thing tyConExtName :: TyCon -> Maybe FastString -- | Extract an AlgTyConRhs with information about data constructors -- from an algebraic or tuple TyCon. Panics for any other sort of -- TyCon algTyConRhs :: TyCon -> AlgTyConRhs -- | Extract the bound type variables and type expansion of a type synonym -- TyCon. Panics if the TyCon is not a synonym newTyConRhs :: TyCon -> ([TyVar], Type) -- | The number of type parameters that need to be passed to a newtype to -- resolve it. May be less than in the definition if it can be -- eta-contracted. newTyConEtadArity :: TyCon -> Int -- | Extract the bound type variables and type expansion of an -- eta-contracted type synonym TyCon. Panics if the TyCon -- is not a synonym newTyConEtadRhs :: TyCon -> ([TyVar], Type) -- | Take a TyCon apart into the TyVars it scopes over, the -- Type it expands into, and (possibly) a coercion from the -- representation type to the newtype. Returns Nothing -- if this is not possible. unwrapNewTyCon_maybe :: TyCon -> Maybe ([TyVar], Type, CoAxiom Unbranched) -- | Extract the boxity of the given TyCon, if it is a -- TupleTyCon. Panics otherwise tupleTyConBoxity :: TyCon -> Boxity -- | Extract the TupleSort of the given TyCon, if it is a -- TupleTyCon. Panics otherwise tupleTyConSort :: TyCon -> TupleSort -- | Extract the arity of the given TyCon, if it is a -- TupleTyCon. Panics otherwise tupleTyConArity :: TyCon -> Arity -- | Used to create the view Core has on TyCons. We expand -- not only closed synonyms like tcExpandTyCon_maybe, but also -- non-recursive newtypes -- -- Used to create the view the typechecker has on TyCons. -- We expand (closed) synonyms only, cf. coreExpandTyCon_maybe tcExpandTyCon_maybe :: TyCon -> [tyco] -> Maybe ([(TyVar, tyco)], Type, [tyco]) -- | Used to create the view the typechecker has on TyCons. -- We expand (closed) synonyms only, cf. coreExpandTyCon_maybe coreExpandTyCon_maybe :: TyCon -> [tyco] -> Maybe ([(TyVar, tyco)], Type, [tyco]) -- | Make an algebraic TyCon abstract. Panics if the supplied -- TyCon is not algebraic makeTyConAbstract :: TyCon -> TyCon newTyConCo :: TyCon -> CoAxiom Unbranched -- | Extracts the newtype coercion from such a TyCon, which -- can be used to construct something with the newtypes type -- from its representation type (right hand side). If the supplied -- TyCon is not a newtype, returns Nothing newTyConCo_maybe :: TyCon -> Maybe (CoAxiom Unbranched) pprPromotionQuote :: TyCon -> SDoc -- | A PrimRep is an abstraction of a type. It contains information -- that the code generator needs in order to pass arguments, return -- results, and store values of this type. data PrimRep VoidRep :: PrimRep PtrRep :: PrimRep -- | Signed, word-sized value IntRep :: PrimRep -- | Unsigned, word-sized value WordRep :: PrimRep -- | Signed, 64 bit value (with 32-bit words only) Int64Rep :: PrimRep -- | Unsigned, 64 bit value (with 32-bit words only) Word64Rep :: PrimRep -- | A pointer, but not to a Haskell value (use PtrRep) AddrRep :: PrimRep FloatRep :: PrimRep DoubleRep :: PrimRep -- | A vector VecRep :: Int -> PrimElemRep -> PrimRep data PrimElemRep Int8ElemRep :: PrimElemRep Int16ElemRep :: PrimElemRep Int32ElemRep :: PrimElemRep Int64ElemRep :: PrimElemRep Word8ElemRep :: PrimElemRep Word16ElemRep :: PrimElemRep Word32ElemRep :: PrimElemRep Word64ElemRep :: PrimElemRep FloatElemRep :: PrimElemRep DoubleElemRep :: PrimElemRep -- | Find the primitive representation of a TyCon tyConPrimRep :: TyCon -> PrimRep isVoidRep :: PrimRep -> Bool isGcPtrRep :: PrimRep -> Bool -- | Find the size of a PrimRep, in words primRepSizeW :: DynFlags -> PrimRep -> Int primElemRepSizeB :: PrimElemRep -> Int data RecTcChecker initRecTc :: RecTcChecker checkRecTc :: RecTcChecker -> TyCon -> Maybe RecTcChecker instance Typeable TyCon instance Eq PrimElemRep instance Show PrimElemRep instance Eq PrimRep instance Show PrimRep instance Data TyCon instance NamedThing TyCon instance Outputable TyCon instance Uniquable TyCon instance Ord TyCon instance Eq TyCon instance Outputable PrimElemRep instance Outputable PrimRep instance Outputable TyConParent 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 -- | This module defines TyCons that can't be expressed in Haskell. They -- are all, therefore, wired-in TyCons. C.f module TysWiredIn module TysPrim mkPrimTyConName :: FastString -> Unique -> TyCon -> Name tyVarList :: Kind -> [TyVar] alphaTyVars :: [TyVar] betaTyVars :: [TyVar] alphaTyVar :: TyVar betaTyVar :: TyVar gammaTyVar :: TyVar deltaTyVar :: TyVar alphaTy :: Type betaTy :: Type gammaTy :: Type deltaTy :: Type openAlphaTy :: Type openBetaTy :: Type openAlphaTyVar :: TyVar openBetaTyVar :: TyVar openAlphaTyVars :: [TyVar] kKiVar :: KindVar -- | See Type#kind_subtyping for details of the distinction between -- the Kind TyCons superKindTyCon :: 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 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 superKindTyConName :: Name anyKindTyConName :: Name liftedTypeKindTyConName :: Name openTypeKindTyConName :: Name unliftedTypeKindTyConName :: Name constraintKindTyConName :: Name -- | 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 funTyCon :: TyCon funTyConName :: Name primTyCons :: [TyCon] charPrimTyCon :: TyCon charPrimTy :: Type intPrimTyCon :: TyCon intPrimTy :: Type wordPrimTyCon :: TyCon wordPrimTy :: Type addrPrimTyCon :: TyCon addrPrimTy :: Type floatPrimTyCon :: TyCon floatPrimTy :: Type doublePrimTyCon :: TyCon doublePrimTy :: Type voidPrimTyCon :: TyCon voidPrimTy :: Type statePrimTyCon :: TyCon mkStatePrimTy :: Type -> Type realWorldTyCon :: TyCon realWorldTy :: Type realWorldStatePrimTy :: Type proxyPrimTyCon :: TyCon mkProxyPrimTy :: Type -> Type -> Type arrayPrimTyCon :: TyCon mkArrayPrimTy :: Type -> Type byteArrayPrimTyCon :: TyCon byteArrayPrimTy :: Type arrayArrayPrimTyCon :: TyCon mkArrayArrayPrimTy :: Type mutableArrayPrimTyCon :: TyCon mkMutableArrayPrimTy :: Type -> Type -> Type mutableByteArrayPrimTyCon :: TyCon mkMutableByteArrayPrimTy :: Type -> Type mutableArrayArrayPrimTyCon :: TyCon mkMutableArrayArrayPrimTy :: Type -> Type mutVarPrimTyCon :: TyCon mkMutVarPrimTy :: Type -> Type -> Type mVarPrimTyCon :: TyCon mkMVarPrimTy :: Type -> Type -> Type tVarPrimTyCon :: TyCon mkTVarPrimTy :: Type -> Type -> Type stablePtrPrimTyCon :: TyCon mkStablePtrPrimTy :: Type -> Type stableNamePrimTyCon :: TyCon mkStableNamePrimTy :: Type -> Type bcoPrimTyCon :: TyCon bcoPrimTy :: Type weakPrimTyCon :: TyCon mkWeakPrimTy :: Type -> Type threadIdPrimTyCon :: TyCon threadIdPrimTy :: Type int32PrimTyCon :: TyCon int32PrimTy :: Type word32PrimTyCon :: TyCon word32PrimTy :: Type int64PrimTyCon :: TyCon int64PrimTy :: Type word64PrimTyCon :: TyCon word64PrimTy :: Type eqPrimTyCon :: TyCon eqReprPrimTyCon :: TyCon anyTy :: Type anyTyCon :: TyCon anyTypeOfKind :: Kind -> Type int8X16PrimTy :: Type int8X16PrimTyCon :: TyCon int16X8PrimTy :: Type int16X8PrimTyCon :: TyCon int32X4PrimTy :: Type int32X4PrimTyCon :: TyCon int64X2PrimTy :: Type int64X2PrimTyCon :: TyCon int8X32PrimTy :: Type int8X32PrimTyCon :: TyCon int16X16PrimTy :: Type int16X16PrimTyCon :: TyCon int32X8PrimTy :: Type int32X8PrimTyCon :: TyCon int64X4PrimTy :: Type int64X4PrimTyCon :: TyCon int8X64PrimTy :: Type int8X64PrimTyCon :: TyCon int16X32PrimTy :: Type int16X32PrimTyCon :: TyCon int32X16PrimTy :: Type int32X16PrimTyCon :: TyCon int64X8PrimTy :: Type int64X8PrimTyCon :: TyCon word8X16PrimTy :: Type word8X16PrimTyCon :: TyCon word16X8PrimTy :: Type word16X8PrimTyCon :: TyCon word32X4PrimTy :: Type word32X4PrimTyCon :: TyCon word64X2PrimTy :: Type word64X2PrimTyCon :: TyCon word8X32PrimTy :: Type word8X32PrimTyCon :: TyCon word16X16PrimTy :: Type word16X16PrimTyCon :: TyCon word32X8PrimTy :: Type word32X8PrimTyCon :: TyCon word64X4PrimTy :: Type word64X4PrimTyCon :: TyCon word8X64PrimTy :: Type word8X64PrimTyCon :: TyCon word16X32PrimTy :: Type word16X32PrimTyCon :: TyCon word32X16PrimTy :: Type word32X16PrimTyCon :: TyCon word64X8PrimTy :: Type word64X8PrimTyCon :: TyCon floatX4PrimTy :: Type floatX4PrimTyCon :: TyCon doubleX2PrimTy :: Type doubleX2PrimTyCon :: TyCon floatX8PrimTy :: Type floatX8PrimTyCon :: TyCon doubleX4PrimTy :: Type doubleX4PrimTyCon :: TyCon floatX16PrimTy :: Type floatX16PrimTyCon :: TyCon doubleX8PrimTy :: Type doubleX8PrimTyCon :: TyCon module Kind -- | "Super kinds", used to help encode Kinds as types. Invariant: a -- super kind is always of this form: -- --
```--   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 :: 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 -- apppropriate 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 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 isForAllTy :: Type -> Bool -- | 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 noParenPred :: PredType -> Bool 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 :: Type -> Type -> PredTree TuplePred :: [PredType] -> PredTree IrredPred :: PredType -> PredTree 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 funTyCon :: TyCon isTypeVar :: Var -> Bool isKindVar :: Var -> 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. Most of these are -- unlifted, but now that we interact with .NET, we may have primtive -- (foreign-imported) types that are lifted 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 -> [TyCon] -- | Discovers the primitive representation of a more abstract -- UnaryType typePrimRep :: UnaryType -> PrimRep typeRepArity :: Arity -> Type -> RepArity -- | A substitition 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 substition 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 pprSigmaType :: Type -> SDoc pprEqPred :: Pair 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 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 Outputable TvSubst module HsLit type PostTcKind = Kind type PostTcType = Type placeHolderType :: PostTcType placeHolderKind :: PostTcKind data HsLit HsChar :: Char -> HsLit HsCharPrim :: Char -> HsLit HsString :: FastString -> HsLit HsStringPrim :: ByteString -> HsLit HsInt :: Integer -> HsLit HsIntPrim :: Integer -> HsLit HsWordPrim :: Integer -> HsLit HsInt64Prim :: Integer -> HsLit HsWord64Prim :: Integer -> HsLit HsInteger :: Integer -> Type -> HsLit HsRat :: FractionalLit -> Type -> HsLit HsFloatPrim :: FractionalLit -> HsLit HsDoublePrim :: FractionalLit -> HsLit data HsOverLit id OverLit :: OverLitVal -> Bool -> SyntaxExpr id -> PostTcType -> HsOverLit id ol_val :: HsOverLit id -> OverLitVal ol_rebindable :: HsOverLit id -> Bool ol_witness :: HsOverLit id -> SyntaxExpr id ol_type :: HsOverLit id -> PostTcType data OverLitVal HsIntegral :: !Integer -> OverLitVal HsFractional :: !FractionalLit -> OverLitVal HsIsString :: !FastString -> OverLitVal overLitType :: HsOverLit a -> Type instance Typeable HsLit instance Typeable OverLitVal instance Typeable HsOverLit instance Data HsLit instance Data OverLitVal instance Data id => Data (HsOverLit id) instance Outputable OverLitVal instance OutputableBndr id => Outputable (HsOverLit id) instance Outputable HsLit instance Ord OverLitVal instance Ord (HsOverLit id) instance Eq OverLitVal instance Eq (HsOverLit id) instance Eq HsLit 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 Monad UM instance Applicative UM instance Functor 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 :: 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 coercionRole :: Coercion -> 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 a coercion from thin air. Needless to say, this is not -- usually safe, but it is used when we know we are dealing with bottom, -- which is one case in which it is safe. This is also used to implement -- the unsafeCoerce# primitive. Optimise by pushing down through -- type constructors. mkUnsafeCo :: Type -> Type -> Coercion mkUnivCo :: 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 maybeSubCo :: Role -> Coercion -> Coercion maybeSubCo2 :: 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) -- | Sometimes we want to look through a newtype and get its -- associated coercion. This function strips off newtype layers -- enough to reveal something that isn't a newtype. -- Specifically, here's the invariant: -- --
```--   topNormaliseNewType_maybe rec_nts ty = Just (co, ty')
--   ```
-- -- then (a) co : 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) -- | 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] nextRole :: Coercion -> Role 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 Typeable LeftOrRight instance Typeable Coercion instance Eq LeftOrRight instance Data LeftOrRight instance Data Coercion instance Outputable CvSubst instance Outputable LeftOrRight instance Outputable Coercion instance Binary LeftOrRight module DataCon -- | A data constructor data DataCon data DataConRep NoDataConRep :: DataConRep DCR :: Id -> DataConBoxer -> [Type] -> [StrictnessMark] -> [HsBang] -> DataConRep dcr_wrap_id :: DataConRep -> Id dcr_boxer :: DataConRep -> DataConBoxer dcr_arg_tys :: DataConRep -> [Type] dcr_stricts :: DataConRep -> [StrictnessMark] dcr_bangs :: DataConRep -> [HsBang] data HsBang HsUserBang :: (Maybe Bool) -> Bool -> HsBang HsNoBang :: HsBang HsUnpack :: (Maybe Coercion) -> HsBang HsStrict :: 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 decided on by the compiler. Does not include -- those for existential dictionaries. The list is in one-to-one -- correspondence with the arity of the DataCon dataConStrictMarks :: DataCon -> [HsBang] -- | 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] dataConRepBangs :: DataCon -> [HsBang] 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]) -- | All type constructors used in the definition of this type constructor, -- recursively. This is used to find out all the type constructors whose -- data constructors need to be in scope to be allowed to safely coerce -- under this type constructor in Safe Haskell mode. tyConsOfTyCon :: TyCon -> [TyCon] -- | 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 Typeable DataCon instance Typeable HsBang instance Data HsBang instance Outputable StrictnessMark instance Outputable HsBang instance Data DataCon instance OutputableBndr DataCon instance Outputable DataCon instance NamedThing DataCon instance Uniquable DataCon instance Ord DataCon instance Eq DataCon module Vectorise.Type.Classify -- | From a list of type constructors, extract those that can be -- vectorised, returning them in two sets, where the first result list -- must be vectorised and the second result list need not -- be vectorised. The third result list are those type constructors -- that we cannot convert (either because they use language extensions or -- because they dependent on type constructors for which no vectorised -- version is available). -- -- NB: In order to be able to vectorise a type constructor, we require -- members of the depending set (i.e., those type constructors that the -- current one depends on) to be vectorised only if they are also -- parallel (i.e., appear in the second argument to the function). -- -- The first argument determines the conversion status of external -- type constructors as follows: -- --
--
• 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
• --
classifyTyCons :: UniqFM Bool -> NameSet -> [TyCon] -> ([TyCon], [TyCon], [TyCon], [TyCon]) module HsTypes data HsType name HsForAllTy :: HsExplicitFlag -> (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 HsIParamTy :: HsIPName -> (LHsType name) -> HsType name HsEqTy :: (LHsType name) -> (LHsType name) -> HsType name HsKindSig :: (LHsType name) -> (LHsKind name) -> HsType name HsQuasiQuoteTy :: (HsQuasiQuote name) -> HsType name HsSpliceTy :: (HsSplice name) -> PostTcKind -> HsType name HsDocTy :: (LHsType name) -> LHsDocString -> HsType name HsBangTy :: HsBang -> (LHsType name) -> HsType name HsRecTy :: [ConDeclField name] -> HsType name HsCoreTy :: Type -> HsType name HsExplicitListTy :: PostTcKind -> [LHsType name] -> HsType name HsExplicitTupleTy :: [PostTcKind] -> [LHsType name] -> HsType name HsTyLit :: HsTyLit -> HsType name HsWrapTy :: HsTyWrapper -> (HsType name) -> HsType name type LHsType name = Located (HsType name) type HsKind name = HsType name type LHsKind name = Located (HsKind name) data HsTyVarBndr name UserTyVar :: name -> HsTyVarBndr name KindedTyVar :: 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 thing HsWB :: thing -> [Name] -> [Name] -> HsWithBndrs thing hswb_cts :: HsWithBndrs thing -> thing hswb_kvs :: HsWithBndrs thing -> [Name] hswb_tvs :: HsWithBndrs thing -> [Name] data HsTupleSort HsUnboxedTuple :: HsTupleSort HsBoxedTuple :: HsTupleSort HsConstraintTuple :: HsTupleSort HsBoxedOrConstraintTuple :: HsTupleSort data HsExplicitFlag Explicit :: HsExplicitFlag Implicit :: HsExplicitFlag type HsContext name = [LHsType name] type LHsContext name = Located (HsContext name) data HsQuasiQuote id HsQuasiQuote :: id -> SrcSpan -> FastString -> HsQuasiQuote id data HsTyWrapper WpKiApps :: [Kind] -> HsTyWrapper data HsTyLit HsNumTy :: Integer -> HsTyLit HsStrTy :: FastString -> HsTyLit -- | These names are used eary 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 HsUserBang :: (Maybe Bool) -> Bool -> HsBang HsNoBang :: HsBang HsUnpack :: (Maybe Coercion) -> HsBang HsStrict :: HsBang getBangType :: LHsType a -> LHsType a getBangStrictness :: LHsType a -> HsBang data ConDeclField name ConDeclField :: Located name -> LBangType name -> Maybe LHsDocString -> ConDeclField name cd_fld_name :: ConDeclField name -> Located name cd_fld_type :: ConDeclField name -> LBangType name cd_fld_doc :: ConDeclField name -> Maybe LHsDocString pprConDeclFields :: OutputableBndr name => [ConDeclField name] -> SDoc mkHsQTvs :: [LHsTyVarBndr RdrName] -> LHsTyVarBndrs RdrName hsQTvBndrs :: LHsTyVarBndrs name -> [LHsTyVarBndr name] mkExplicitHsForAllTy :: [LHsTyVarBndr RdrName] -> LHsContext RdrName -> LHsType RdrName -> HsType RdrName mkImplicitHsForAllTy :: LHsContext RdrName -> LHsType RdrName -> HsType RdrName hsExplicitTvs :: LHsType Name -> [Name] hsTyVarName :: HsTyVarBndr name -> name mkHsWithBndrs :: thing -> HsWithBndrs 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 pprParendHsType :: OutputableBndr name => HsType name -> SDoc pprHsForAll :: OutputableBndr name => HsExplicitFlag -> LHsTyVarBndrs name -> LHsContext name -> SDoc pprHsContext :: OutputableBndr name => HsContext name -> SDoc pprHsContextNoArrow :: OutputableBndr name => HsContext name -> SDoc ppr_hs_context :: OutputableBndr name => HsContext name -> SDoc instance Typeable HsQuasiQuote instance Typeable HsWithBndrs instance Typeable HsIPName instance Typeable HsTyLit instance Typeable HsTyWrapper instance Typeable HsTupleSort instance Typeable HsExplicitFlag instance Typeable ConDeclField instance Typeable HsType instance Typeable LHsTyVarBndrs instance Typeable HsTyVarBndr instance Data id => Data (HsQuasiQuote id) instance Data thing => Data (HsWithBndrs thing) instance Eq HsIPName instance Data HsIPName instance Data HsTyLit instance Data HsTyWrapper instance Data HsTupleSort instance Data HsExplicitFlag instance Data name => Data (ConDeclField name) instance Data name => Data (HsType name) instance Data name => Data (LHsTyVarBndrs name) instance Data name => Data (HsTyVarBndr name) instance Outputable thing => Outputable (HsWithBndrs thing) instance OutputableBndr name => Outputable (HsTyVarBndr name) instance OutputableBndr name => Outputable (LHsTyVarBndrs name) instance Outputable HsTyLit instance OutputableBndr name => Outputable (HsType name) instance OutputableBndr HsIPName instance Outputable HsIPName instance OutputableBndr id => Outputable (HsQuasiQuote id) -- | 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 integerGmpSDataCon :: DataCon 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
• --
parrFakeCon :: Arity -> DataCon -- | Check whether a type constructor is the constructor for parallel -- arrays isPArrTyCon :: TyCon -> Bool -- | Checks whether a data constructor is a fake constructor for parallel -- arrays isPArrFakeCon :: DataCon -> Bool parrTyCon_RDR :: RdrName parrTyConName :: Name eqTyCon_RDR :: RdrName eqTyCon :: TyCon eqTyConName :: Name eqBoxDataCon :: DataCon coercibleTyCon :: TyCon coercibleDataCon :: DataCon coercibleClass :: Class mkWiredInTyConName :: BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name module HsImpExp type LImportDecl name = Located (ImportDecl name) -- | A single Haskell import declaration. data ImportDecl name ImportDecl :: Located ModuleName -> Maybe FastString -> Bool -> Bool -> Bool -> Bool -> Maybe ModuleName -> Maybe (Bool, [LIE name]) -> ImportDecl name -- | Module name. ideclName :: ImportDecl name -> Located ModuleName -- | Package qualifier. ideclPkgQual :: ImportDecl name -> Maybe FastString -- | True = {--} 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, [LIE name]) simpleImportDecl :: ModuleName -> ImportDecl name type LIE name = Located (IE name) -- | Imported or exported entity. data IE name IEVar :: name -> IE name -- | Class/Type (can't tell) IEThingAbs :: name -> IE name -- | ClassType plus all methodsconstructors IEThingAll :: name -> IE name -- | ClassType plus some methodsconstructors IEThingWith :: name -> [name] -> IE name -- | (Export Only) IEModuleContents :: ModuleName -> IE name -- | Doc section heading IEGroup :: Int -> HsDocString -> IE name -- | Some documentation IEDoc :: HsDocString -> IE name -- | Reference to named doc IEDocNamed :: String -> IE name ieName :: IE name -> name ieNames :: IE a -> [a] pprImpExp :: (HasOccName name, OutputableBndr name) => name -> SDoc instance Typeable IE instance Typeable ImportDecl instance Eq name => Eq (IE name) instance Data name => Data (IE name) instance Data name => Data (ImportDecl name) instance (HasOccName name, OutputableBndr name) => Outputable (IE name) instance (OutputableBndr name, HasOccName name) => Outputable (ImportDecl name) 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)
• --
```--   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 -- apppropriate 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 substition is only applied ONCE! This is because in general -- such application will not reached a fixed point.
6. --
data TvSubst TvSubst :: InScopeSet -> TvSubstEnv -> TvSubst -- | A substitition of Types for TyVars and Kinds for -- KindVars type TvSubstEnv = TyVarEnv Type emptyTvSubst :: 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 unionTvSubst :: TvSubst -> TvSubst -> TvSubst getTvSubstEnv :: TvSubst -> TvSubstEnv setTvSubstEnv :: TvSubst -> TvSubstEnv -> TvSubst getTvInScope :: TvSubst -> InScopeSet extendTvInScope :: TvSubst -> Var -> TvSubst lookupTyVar :: TvSubst -> TyVar -> Maybe Type extendTvSubst :: TvSubst -> TyVar -> Type -> TvSubst substTyVarBndr :: TvSubst -> TyVar -> (TvSubst, TyVar) extendTvSubstList :: TvSubst -> [TyVar] -> [Type] -> TvSubst isInScope :: Var -> TvSubst -> Bool mkTvSubst :: InScopeSet -> TvSubstEnv -> TvSubst zipTyEnv :: [TyVar] -> [Type] -> TvSubstEnv -- | 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 -- | Substitute within a ThetaType substTheta :: TvSubst -> ThetaType -> ThetaType substTyVar :: TvSubst -> TyVar -> Type substTyVars :: TvSubst -> [TyVar] -> [Type] -- | See Type#type_classification for what an unlifted type is isUnLiftedType :: Type -> Bool isUnboxedTupleType :: Type -> Bool -- | Returns true of types that are opaque to Haskell. Most of these are -- unlifted, but now that we interact with .NET, we may have primtive -- (foreign-imported) types that are lifted isPrimitiveType :: Type -> Bool -- | 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 tcTyVarsOfType :: Type -> TcTyVarSet tcTyVarsOfTypes :: [Type] -> TyVarSet pprKind :: Kind -> SDoc pprParendKind :: Kind -> SDoc pprSigmaType :: Type -> SDoc pprType :: Type -> SDoc pprParendType :: Type -> SDoc pprTypeApp :: TyCon -> [Type] -> SDoc pprTyThingCategory :: TyThing -> SDoc pprTheta :: ThetaType -> SDoc pprThetaArrowTy :: ThetaType -> SDoc pprClassPred :: Class -> [Type] -> SDoc instance Monad OccCheckResult instance Applicative OccCheckResult instance Functor OccCheckResult instance Outputable Untouchables instance Outputable MetaDetails 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]] isSingleUsed :: JointDmd -> Bool reuseEnv :: DmdEnv -> DmdEnv zapDemand :: DynFlags -> Demand -> Demand zapStrictSig :: DynFlags -> StrictSig -> StrictSig strictifyDictDmd :: Type -> Demand -> Demand instance Eq MaybeStr instance Show MaybeStr instance Eq StrDmd instance Show StrDmd instance Eq Count instance Show Count instance Eq UseDmd instance Show UseDmd instance Eq MaybeUsed instance Show MaybeUsed instance Eq JointDmd instance Show JointDmd instance Eq CleanDemand instance Show CleanDemand instance Eq r => Eq (Termination r) instance Show r => Show (Termination r) instance Eq CPRResult instance Show CPRResult instance Eq StrictSig instance Binary CPRResult instance Binary DmdResult instance Binary DmdType instance Binary StrictSig instance Binary JointDmd instance Binary UseDmd instance Binary MaybeUsed instance Binary Count instance Binary MaybeStr instance Binary StrDmd instance Outputable StrictSig instance Outputable DmdType instance Eq DmdType instance Outputable CPRResult instance Outputable DmdResult instance Outputable CleanDemand instance Outputable JointDmd instance Outputable Count instance Outputable UseDmd instance Outputable MaybeUsed instance Outputable MaybeStr instance Outputable StrDmd module ErrUtils data ErrMsg type WarnMsg = ErrMsg data Severity SevOutput :: Severity SevDump :: Severity SevInteractive :: Severity SevInfo :: Severity SevWarning :: Severity SevError :: Severity SevFatal :: Severity type Messages = (WarningMessages, ErrorMessages) type ErrorMessages = Bag ErrMsg type WarningMessages = Bag WarnMsg errMsgSpan :: ErrMsg -> SrcSpan errMsgContext :: ErrMsg -> PrintUnqualified errMsgShortDoc :: ErrMsg -> MsgDoc errMsgExtraInfo :: ErrMsg -> MsgDoc type MsgDoc = SDoc mkLocMessage :: Severity -> SrcSpan -> MsgDoc -> MsgDoc pprMessageBag :: Bag MsgDoc -> SDoc pprErrMsgBag :: Bag ErrMsg -> [SDoc] pprErrMsgBagWithLoc :: Bag ErrMsg -> [SDoc] pprLocErrMsg :: ErrMsg -> SDoc makeIntoWarning :: ErrMsg -> ErrMsg errorsFound :: DynFlags -> Messages -> Bool emptyMessages :: Messages isEmptyMessages :: Messages -> Bool mkErrMsg :: DynFlags -> SrcSpan -> PrintUnqualified -> MsgDoc -> ErrMsg mkPlainErrMsg :: DynFlags -> SrcSpan -> MsgDoc -> ErrMsg mkLongErrMsg :: DynFlags -> SrcSpan -> PrintUnqualified -> MsgDoc -> MsgDoc -> ErrMsg mkWarnMsg :: DynFlags -> SrcSpan -> PrintUnqualified -> MsgDoc -> ErrMsg mkPlainWarnMsg :: DynFlags -> SrcSpan -> MsgDoc -> ErrMsg printBagOfErrors :: DynFlags -> Bag ErrMsg -> IO () warnIsErrorMsg :: DynFlags -> ErrMsg mkLongWarnMsg :: DynFlags -> SrcSpan -> PrintUnqualified -> MsgDoc -> MsgDoc -> ErrMsg ghcExit :: DynFlags -> Int -> IO () doIfSet :: Bool -> IO () -> IO () doIfSet_dyn :: DynFlags -> GeneralFlag -> IO () -> IO () dumpIfSet :: DynFlags -> Bool -> String -> SDoc -> IO () dumpIfSet_dyn :: DynFlags -> DumpFlag -> String -> SDoc -> IO () mkDumpDoc :: String -> SDoc -> SDoc -- | Write out a dump. If --dump-to-file is set then this goes to a file. -- otherwise emit to stdout. -- -- When hdr is empty, we print in a more compact format (no separators -- and blank lines) dumpSDoc :: DynFlags -> DumpFlag -> String -> SDoc -> IO () putMsg :: DynFlags -> MsgDoc -> IO () putMsgWith :: DynFlags -> PrintUnqualified -> MsgDoc -> IO () errorMsg :: DynFlags -> MsgDoc -> IO () fatalErrorMsg :: DynFlags -> MsgDoc -> IO () fatalErrorMsg' :: LogAction -> DynFlags -> MsgDoc -> IO () fatalErrorMsg'' :: FatalMessager -> String -> IO () compilationProgressMsg :: DynFlags -> String -> IO () showPass :: DynFlags -> String -> IO () debugTraceMsg :: DynFlags -> Int -> MsgDoc -> IO () prettyPrintGhcErrors :: ExceptionMonad m => DynFlags -> m a -> m a instance Show ErrMsg -- | 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). -- -- The right hand side of of a non-recursive Let _and_ the -- argument of an App, may be of unlifted type, but only if -- the expression is ok-for-speculation. This means that the let can be -- floated around without difficulty. For example, this is OK: -- --
```--   y::Int# = x +# 1#
--   ```
-- -- But this is not, as it may affect termination if the expression is -- floated out: -- --
```--   y::Int# = fac 4#
--   ```
-- -- In this situation you should use case rather than a -- let. The function needsCaseBinding can help you -- determine which to generate, or alternatively use mkCoreLet -- rather than this constructor directly, which will generate a -- case if necessary -- -- 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]
1. The DEFAULT case alternative must be first -- in the list, if it occurs at all.
2. 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.
3. 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.
2. --
-- --
--
• 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 -> Arity -> Bool -> Bool -> Bool -> Bool -> UnfoldingGuidance -> Unfolding uf_tmpl :: Unfolding -> CoreExpr uf_src :: Unfolding -> UnfoldingSource uf_is_top :: Unfolding -> Bool uf_arity :: Unfolding -> Arity 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 :: Bool -> Bool -> UnfoldingGuidance 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 setUnfoldingTemplate :: Unfolding -> CoreExpr -> Unfolding expandUnfolding_maybe :: Unfolding -> Maybe CoreExpr -- | Retrieves the template of an unfolding if possible maybeUnfoldingTemplate :: Unfolding -> Maybe CoreExpr -- | The constructors that the unfolding could never be: returns -- [] if no information is available otherCons :: Unfolding -> [AltCon] unfoldingArity :: Unfolding -> Arity -- | 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 isStableCoreUnfolding_maybe :: Unfolding -> Maybe UnfoldingSource 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]) 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 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 Eq CafInfo instance Ord CafInfo instance Outputable TickBoxOp instance Outputable CafInfo instance Outputable IdDetails -- | GHC uses several kinds of name internally: -- --
```--   fromIntegral T = fromIntegral_T
--   ```
--
• -package pkg causes pkg to become -- exposed, and all other packages with the same name to become -- hidden.
• --
• -hide-package pkg causes pkg to -- become hidden.
• --
• 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.
• --
--
• ordinary statements (assignments, stores etc.)
• --
• jumps
• --
• labels
• --
• out-of-line labelled blocks
• --
-- -- The semantics is that control falls through labels and out-of-line -- blocks. Everything after a jump up to the next label is by definition -- unreachable code, and will be discarded. -- -- Two CmmAGraphs can be stuck together with *, with the meaning -- that control flows from the first to the second. -- -- A CmmAGraph can be turned into a CmmGraph (closed at -- both ends) by providing a label for the entry point; see -- labelAGraph. type CmmAGraph = OrdList CgStmt data CgStmt CgLabel :: BlockId -> CgStmt CgStmt :: (CmmNode O O) -> CgStmt CgLast :: (CmmNode O C) -> CgStmt CgFork :: BlockId -> CmmAGraph -> CgStmt (<*>) :: CmmAGraph -> CmmAGraph -> CmmAGraph catAGraphs :: [CmmAGraph] -> CmmAGraph -- | created a sequence "goto id; id:" as an AGraph mkLabel :: BlockId -> CmmAGraph -- | creates an open AGraph from a given node mkMiddle :: CmmNode O O -> CmmAGraph -- | created a closed AGraph from a given node mkLast :: CmmNode O C -> CmmAGraph -- | A labelled code block; should end in a last node outOfLine :: BlockId -> CmmAGraph -> CmmAGraph -- | allocate a fresh label for the entry point lgraphOfAGraph :: CmmAGraph -> UniqSM CmmGraph -- | use the given BlockId as the label of the entry point labelAGraph :: BlockId -> CmmAGraph -> CmmGraph stackStubExpr :: Width -> CmmExpr mkNop :: CmmAGraph mkAssign :: CmmReg -> CmmExpr -> CmmAGraph mkStore :: CmmExpr -> CmmExpr -> CmmAGraph mkUnsafeCall :: ForeignTarget -> [CmmFormal] -> [CmmActual] -> CmmAGraph mkFinalCall :: DynFlags -> CmmExpr -> CCallConv -> [CmmActual] -> UpdFrameOffset -> CmmAGraph mkCallReturnsTo :: DynFlags -> CmmExpr -> Convention -> [CmmActual] -> BlockId -> ByteOff -> UpdFrameOffset -> [CmmActual] -> CmmAGraph mkJumpReturnsTo :: DynFlags -> CmmExpr -> Convention -> [CmmActual] -> BlockId -> ByteOff -> UpdFrameOffset -> CmmAGraph mkJump :: DynFlags -> Convention -> CmmExpr -> [CmmActual] -> UpdFrameOffset -> CmmAGraph mkJumpExtra :: DynFlags -> Convention -> CmmExpr -> [CmmActual] -> UpdFrameOffset -> [CmmActual] -> CmmAGraph -- | A jump where the caller says what the live GlobalRegs are. Used for -- low-level hand-written Cmm. mkRawJump :: DynFlags -> CmmExpr -> UpdFrameOffset -> [GlobalReg] -> CmmAGraph mkCbranch :: CmmExpr -> BlockId -> BlockId -> CmmAGraph mkSwitch :: CmmExpr -> [Maybe BlockId] -> CmmAGraph mkReturn :: DynFlags -> CmmExpr -> [CmmActual] -> UpdFrameOffset -> CmmAGraph mkComment :: FastString -> CmmAGraph mkCallEntry :: DynFlags -> Convention -> [CmmFormal] -> [CmmFormal] -> (Int, [GlobalReg], CmmAGraph) mkBranch :: BlockId -> CmmAGraph copyInOflow :: DynFlags -> Convention -> Area -> [CmmFormal] -> [CmmFormal] -> (Int, [GlobalReg], CmmAGraph) copyOutOflow :: DynFlags -> Convention -> Transfer -> Area -> [CmmActual] -> UpdFrameOffset -> [CmmActual] -> (Int, [GlobalReg], CmmAGraph) noExtraStack :: [CmmActual] toCall :: CmmExpr -> Maybe BlockId -> UpdFrameOffset -> ByteOff -> ByteOff -> [GlobalReg] -> CmmAGraph data Transfer Call :: Transfer JumpRet :: Transfer Jump :: Transfer Ret :: Transfer instance Eq Transfer module PprC writeCs :: DynFlags -> Handle -> [RawCmmGroup] -> IO () pprStringInCStyle :: [Word8] -> SDoc instance Monad TE instance Applicative TE instance Functor TE 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 Outputable CoreVect instance Outputable id => Outputable (Tickish id) instance Outputable CoreRule instance Outputable Unfolding instance Outputable UnfoldingSource instance Outputable UnfoldingGuidance instance OutputableBndr Var instance OutputableBndr b => Outputable (Expr b) instance OutputableBndr b => Outputable (Bind b) -- | 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 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: -- --
--
• The expression guarantees to terminate,
• --
• soon,
• --
• without raising an exception,
• --
• without causing a side effect (e.g. writing a mutable -- variable)
• --
-- -- Note that if exprIsHNF e, then exprOkForSpecuation -- e. 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: -- --
--
• The expression guarantees to terminate,
• --
• soon,
• --
• without raising an exception,
• --
• without causing a side effect (e.g. writing a mutable -- variable)
• --
-- -- Note that if exprIsHNF e, then exprOkForSpecuation -- e. 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
--   }
--   ```
```--   return (x,y)
--   ```
-- -- If the sequel is AssignTo [p,q] -- --
```--   p=x; q=y;
--   ```
emitReturn :: [CmmExpr] -> FCode ReturnKind adjustHpBackwards :: FCode () emitClosureProcAndInfoTable :: Bool -> Id -> LambdaFormInfo -> CmmInfoTable -> [NonVoid Id] -> ((Int, LocalReg, [LocalReg]) -> FCode ()) -> FCode () emitClosureAndInfoTable :: CmmInfoTable -> Convention -> [LocalReg] -> FCode () -> FCode () slowCall :: CmmExpr -> [StgArg] -> FCode ReturnKind directCall :: Convention -> CLabel -> RepArity -> [StgArg] -> FCode ReturnKind mkVirtHeapOffsets :: DynFlags -> Bool -> [(PrimRep, a)] -> (WordOff, WordOff, [(NonVoid a, VirtualHpOffset)]) mkVirtConstrOffsets :: DynFlags -> [(PrimRep, a)] -> (WordOff, WordOff, [(NonVoid a, VirtualHpOffset)]) getHpRelOffset :: VirtualHpOffset -> FCode CmmExpr hpRel :: VirtualHpOffset -> VirtualHpOffset -> WordOff data ArgRep P :: ArgRep N :: ArgRep L :: ArgRep V :: ArgRep F :: ArgRep D :: ArgRep V16 :: ArgRep V32 :: ArgRep V64 :: ArgRep toArgRep :: PrimRep -> ArgRep argRepSizeW :: DynFlags -> ArgRep -> WordOff module StgCmmHeap getVirtHp :: FCode VirtualHpOffset setVirtHp :: VirtualHpOffset -> FCode () setRealHp :: VirtualHpOffset -> FCode () getHpRelOffset :: VirtualHpOffset -> FCode CmmExpr hpRel :: VirtualHpOffset -> VirtualHpOffset -> WordOff entryHeapCheck :: ClosureInfo -> Maybe LocalReg -> Int -> [LocalReg] -> FCode () -> FCode () altHeapCheck :: [LocalReg] -> FCode a -> FCode a noEscapeHeapCheck :: [LocalReg] -> FCode a -> FCode a altHeapCheckReturnsTo :: [LocalReg] -> Label -> ByteOff -> FCode a -> FCode a heapStackCheckGen :: Maybe CmmExpr -> Maybe CmmExpr -> FCode () -- | lower-level version for CmmParse entryHeapCheck' :: Bool -> CmmExpr -> Int -> [LocalReg] -> FCode () -> FCode () mkVirtHeapOffsets :: DynFlags -> Bool -> [(PrimRep, a)] -> (WordOff, WordOff, [(NonVoid a, VirtualHpOffset)]) mkVirtConstrOffsets :: DynFlags -> [(PrimRep, a)] -> (WordOff, WordOff, [(NonVoid a, VirtualHpOffset)]) mkStaticClosureFields :: DynFlags -> CmmInfoTable -> CostCentreStack -> CafInfo -> [CmmLit] -> [CmmLit] mkStaticClosure :: DynFlags -> CLabel -> CostCentreStack -> [CmmLit] -> [CmmLit] -> [CmmLit] -> [CmmLit] -> [CmmLit] allocDynClosure :: Maybe Id -> CmmInfoTable -> LambdaFormInfo -> CmmExpr -> CmmExpr -> [(NonVoid StgArg, VirtualHpOffset)] -> FCode CmmExpr allocDynClosureCmm :: Maybe Id -> CmmInfoTable -> LambdaFormInfo -> CmmExpr -> CmmExpr -> [(CmmExpr, VirtualHpOffset)] -> FCode CmmExpr emitSetDynHdr :: CmmExpr -> CmmExpr -> CmmExpr -> FCode () module StgCmmForeign -- | emit code for a foreign call, and return the results to the sequel. cgForeignCall :: ForeignCall -> [StgArg] -> Type -> FCode ReturnKind loadThreadState :: DynFlags -> LocalReg -> LocalReg -> CmmAGraph saveThreadState :: DynFlags -> CmmAGraph emitPrimCall :: [CmmFormal] -> CallishMachOp -> [CmmActual] -> FCode () emitCCall :: [(CmmFormal, ForeignHint)] -> CmmExpr -> [(CmmActual, ForeignHint)] -> FCode () emitForeignCall :: Safety -> [CmmFormal] -> ForeignTarget -> [CmmActual] -> FCode ReturnKind emitSaveThreadState :: FCode () emitLoadThreadState :: FCode () emitCloseNursery :: FCode () emitOpenNursery :: FCode () module CmmLayoutStack cmmLayoutStack :: DynFlags -> ProcPointSet -> ByteOff -> CmmGraph -> UniqSM (CmmGraph, BlockEnv StackMap) setInfoTableStackMap :: DynFlags -> BlockEnv StackMap -> CmmDecl -> CmmDecl instance Outputable StackSlot instance Outputable StackMap module StgCmmPrim cgOpApp :: StgOp -> [StgArg] -> Type -> FCode ReturnKind cgPrimOp :: [LocalReg] -> PrimOp -> [StgArg] -> FCode () module StgLint lintStgBindings :: String -> [StgBinding] -> [StgBinding] instance Monad LintM instance Applicative LintM instance Functor LintM module StgStats showStgStats :: [StgBinding] -> String instance Eq CounterType instance Ord CounterType 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 substitition 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 -> Arity -> UnfoldingGuidance -> Unfolding mkTopUnfolding :: DynFlags -> Bool -> CoreExpr -> Unfolding mkSimpleUnfolding :: DynFlags -> CoreExpr -> Unfolding mkInlineUnfolding :: Maybe Arity -> CoreExpr -> Unfolding mkInlinableUnfolding :: DynFlags -> CoreExpr -> Unfolding mkWwInlineRule :: CoreExpr -> Arity -> Unfolding mkCompulsoryUnfolding :: CoreExpr -> Unfolding mkDFunUnfolding :: [Var] -> DataCon -> [CoreExpr] -> Unfolding interestingArg :: CoreExpr -> ArgSummary data ArgSummary TrivArg :: ArgSummary NonTrivArg :: ArgSummary ValueArg :: ArgSummary couldBeSmallEnoughToInline :: DynFlags -> Int -> CoreExpr -> Bool inlineBoringOk :: CoreExpr -> Bool certainlyWillInline :: DynFlags -> Unfolding -> Bool 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 CallCtxt instance Outputable ArgSummary instance Outputable ExprSize 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 CSE cseProgram :: CoreProgram -> CoreProgram module CoreLint lintCoreBindings :: [Var] -> CoreProgram -> (Bag MsgDoc, Bag MsgDoc) lintUnfolding :: SrcLoc -> [Var] -> CoreExpr -> Maybe MsgDoc lintExpr :: [Var] -> CoreExpr -> Maybe MsgDoc instance Monad LintM instance Applicative LintM instance Functor LintM module TcEvidence data HsWrapper WpHole :: HsWrapper WpCompose :: HsWrapper -> HsWrapper -> 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 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 mkEvCast :: EvTerm -> TcCoercion -> EvTerm evVarsOfTerm :: EvTerm -> VarSet data EvLit EvNum :: Integer -> EvLit EvStr :: FastString -> EvLit evTermCoercion :: EvTerm -> TcCoercion 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 data LeftOrRight CLeft :: LeftOrRight CRight :: LeftOrRight pickLR :: LeftOrRight -> (a, a) -> a mkTcReflCo :: Role -> TcType -> TcCoercion mkTcNomReflCo :: 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 mkTcAxiomRuleCo :: CoAxiomRule -> [TcType] -> [TcCoercion] -> TcCoercion tcCoercionKind :: TcCoercion -> Pair Type coVarsOfTcCo :: TcCoercion -> VarSet isEqVar :: Var -> Bool mkTcCoVarCo :: EqVar -> TcCoercion isTcReflCo :: TcCoercion -> Bool isTcReflCo_maybe :: TcCoercion -> Maybe TcType getTcCoVar_maybe :: TcCoercion -> Maybe CoVar tcCoercionRole :: TcCoercion -> Role eqVarRole :: EqVar -> Role coercionToTcCoercion :: Coercion -> TcCoercion instance Typeable EvLit instance Typeable EvTerm instance Typeable TcCoercion instance Typeable TcEvBinds instance Typeable HsWrapper instance Data EvLit instance Data EvTerm instance Data TcCoercion instance Data HsWrapper instance Outputable EvLit instance Outputable EvTerm instance Outputable EvBind instance Outputable EvBindsVar instance Outputable TcEvBinds instance Outputable HsWrapper instance Data TcEvBinds instance Outputable TcCoercion 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) 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) = ... FunBind :: Located idL -> Bool -> MatchGroup idR (LHsExpr idR) -> HsWrapper -> NameSet -> Maybe (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 -> NameSet -- | Tick to put on the rhs, if any fun_tick :: HsBindLR idL idR -> Maybe (Tickish Id) -- | The pattern is never a simple variable; That case is done by FunBind PatBind :: LPat idL -> GRHSs idR (LHsExpr idR) -> PostTcType -> NameSet -> (Maybe (Tickish Id), [Maybe (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 -> PostTcType -- | After the renamer, this contains the locally-bound free variables of -- this defn. See Note [Bind free vars] bind_fvs :: HsBindLR idL idR -> NameSet -- | Tick to put on the rhs, if any, and ticks to put on the bound -- variables. pat_ticks :: HsBindLR idL idR -> (Maybe (Tickish Id), [Maybe (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 :: Located idL -> NameSet -> HsPatSynDetails (Located idR) -> LPat idR -> HsPatSynDir idR -> HsBindLR idL idR -- | Name of the pattern synonym patsyn_id :: HsBindLR idL idR -> Located idL -- | After the renamer, this contains the locally-bound free variables of -- this defn. See Note [Bind free vars] bind_fvs :: HsBindLR idL idR -> NameSet -- | Formal parameter names patsyn_args :: HsBindLR idL idR -> HsPatSynDetails (Located idR) -- | Right-hand side patsyn_def :: HsBindLR idL idR -> LPat idR -- | Directionality patsyn_dir :: HsBindLR idL idR -> HsPatSynDir 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 -- | Used for the NameSet in FunBind and PatBind prior to the renamer placeHolderNames :: NameSet 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 type LIPBind id = Located (IPBind id) -- | Implicit parameter bindings. data IPBind id IPBind :: (Either 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 TypeSig :: [Located name] -> (LHsType name) -> Sig name -- | A pattern synonym type signature @pattern (Eq b) => P a b :: (Num -- a) => T a PatSynSig :: (Located name) -> (HsPatSynDetails (LHsType name)) -> (LHsType name) -> (LHsContext name) -> (LHsContext 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 :: (LHsType name) -> Sig name -- | A minimal complete definition pragma -- --
```--   {-# MINIMAL a | (b, c | (d | e)) #-}
--   ```
```--   type/data family T :: *->*
--   ```
FamDecl :: FamilyDecl name -> TyClDecl name tcdFam :: TyClDecl name -> FamilyDecl name -- | type declaration SynDecl :: Located name -> LHsTyVarBndrs name -> LHsType 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 -> NameSet -- | data declaration DataDecl :: Located name -> LHsTyVarBndrs name -> HsDataDefn 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 -> NameSet ClassDecl :: LHsContext name -> Located name -> LHsTyVarBndrs name -> [Located (FunDep name)] -> [LSig name] -> LHsBinds name -> [LFamilyDecl name] -> [LTyFamInstDecl name] -> [LDocDecl] -> 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 name)] -- | Methods' signatures tcdSigs :: TyClDecl name -> [LSig name] -- | Default methods tcdMeths :: TyClDecl name -> LHsBinds name -- | Associated types; ie tcdATs :: TyClDecl name -> [LFamilyDecl name] -- | Associated type defaults tcdATDefs :: TyClDecl name -> [LTyFamInstDecl name] -- | Haddock docs tcdDocs :: TyClDecl name -> [LDocDecl] tcdFVs :: TyClDecl 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 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 -> NameSet -> TyFamInstDecl name tfid_eqn :: TyFamInstDecl name -> LTyFamInstEqn name tfid_fvs :: TyFamInstDecl name -> NameSet type LTyFamInstDecl name = Located (TyFamInstDecl name) instDeclDataFamInsts :: [LInstDecl name] -> [DataFamInstDecl name] data DataFamInstDecl name DataFamInstDecl :: Located name -> HsWithBndrs [LHsType name] -> HsDataDefn name -> NameSet -> DataFamInstDecl name dfid_tycon :: DataFamInstDecl name -> Located name -- | Type patterns (with kind and type bndrs) See Note [Family instance -- declaration binders] dfid_pats :: DataFamInstDecl name -> HsWithBndrs [LHsType name] dfid_defn :: DataFamInstDecl name -> HsDataDefn name dfid_fvs :: DataFamInstDecl name -> NameSet type LDataFamInstDecl name = Located (DataFamInstDecl name) pprDataFamInstFlavour :: DataFamInstDecl name -> SDoc -- | One equation in a type family instance declaration data TyFamInstEqn name TyFamInstEqn :: Located name -> HsWithBndrs [LHsType name] -> LHsType name -> TyFamInstEqn name tfie_tycon :: TyFamInstEqn name -> Located name -- | Type patterns (with kind and type bndrs) See Note [Family instance -- declaration binders] tfie_pats :: TyFamInstEqn name -> HsWithBndrs [LHsType name] tfie_rhs :: TyFamInstEqn name -> LHsType name type LTyFamInstEqn name = Located (TyFamInstEqn name) type LClsInstDecl name = Located (ClsInstDecl name) data ClsInstDecl name ClsInstDecl :: LHsType name -> LHsBinds name -> [LSig name] -> [LTyFamInstDecl name] -> [LDataFamInstDecl name] -> 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] data DerivDecl name DerivDecl :: LHsType name -> DerivDecl name deriv_type :: DerivDecl name -> LHsType name type LDerivDecl name = Located (DerivDecl name) data RuleDecl name HsRule :: RuleName -> Activation -> [RuleBndr name] -> (Located (HsExpr name)) -> NameSet -> (Located (HsExpr name)) -> NameSet -> RuleDecl name type LRuleDecl name = Located (RuleDecl name) data RuleBndr name RuleBndr :: (Located name) -> RuleBndr name RuleBndrSig :: (Located name) -> (HsWithBndrs (LHsType name)) -> RuleBndr name collectRuleBndrSigTys :: [RuleBndr name] -> [HsWithBndrs (LHsType name)] data VectDecl name HsVect :: (Located name) -> (LHsExpr name) -> VectDecl name HsNoVect :: (Located name) -> VectDecl name HsVectTypeIn :: Bool -> (Located name) -> (Maybe (Located name)) -> VectDecl name HsVectTypeOut :: Bool -> TyCon -> (Maybe TyCon) -> VectDecl name HsVectClassIn :: (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 SpliceDecl id SpliceDecl :: (Located (HsSplice id)) -> HsExplicitFlag -> SpliceDecl id type LSpliceDecl name = Located (SpliceDecl name) data ForeignDecl name ForeignImport :: (Located name) -> (LHsType name) -> Coercion -> ForeignImport -> ForeignDecl name ForeignExport :: (Located name) -> (LHsType name) -> Coercion -> ForeignExport -> ForeignDecl name type LForeignDecl name = Located (ForeignDecl name) data ForeignImport CImport :: CCallConv -> Safety -> (Maybe Header) -> CImportSpec -> ForeignImport data ForeignExport CExport :: CExportSpec -> ForeignExport noForeignImportCoercionYet :: Coercion noForeignExportCoercionYet :: Coercion data CImportSpec CLabel :: CLabelString -> CImportSpec CFunction :: CCallTarget -> CImportSpec CWrapper :: CImportSpec data ConDecl name ConDecl :: Located name -> HsExplicitFlag -> LHsTyVarBndrs name -> LHsContext name -> HsConDeclDetails name -> ResType (LHsType name) -> Maybe LHsDocString -> Bool -> ConDecl name -- | Constructor name. This is used for the DataCon itself, and for the -- user-callable wrapper Id. con_name :: 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
• --
--
• Nothing: export list omitted, so export everything
• --
• Just []: export nothing
• --
• Just [...]: as you would expect...
• --
--
• A regular Haskell source module
• --
• A hi-boot source module
• --
• An external-core source module
• --
data ModSummary ModSummary :: Module -> HscSource -> ModLocation -> 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 -- | 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 ExtCoreFile :: HscSource isHsBoot :: 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 data TcLclEnv TcLclEnv :: SrcSpan -> [ErrCtxt] -> Untouchables -> ThStage -> ThBindEnv -> ArrowCtxt -> LocalRdrEnv -> TcTypeEnv -> [TcIdBinder] -> TidyEnv -> TcRef TcTyVarSet -> TcRef WantedConstraints -> TcRef Messages -> TcLclEnv tcl_loc :: TcLclEnv -> SrcSpan tcl_ctxt :: TcLclEnv -> [ErrCtxt] tcl_untch :: TcLclEnv -> Untouchables 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) -> [PackageId] -> [PackageId] -> 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 } |]
--   ```
--
• 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`
• --
--
• if it succeeds then take the returned value,
• --
• if it fails then run the second computation instead without -- emitting a failure message.
• --
orElseV :: VM a -> VM a -> VM a -- | Try the first computation, -- --
--
• if it succeeds then take the returned value,
• --
• if it fails then run the second computation instead while emitting -- a failure message.
• --
--
• If it's in the global environment we get the vectorised -- version.
• --
• If it's in the local environment we get both the vectorised and -- lifted version.
• --
lookupVar :: Var -> VM (Scope Var (Var, Var)) lookupVar_maybe :: Var -> VM (Maybe (Scope Var (Var, Var))) -- | Mark the given variable as parallel — i.e., executing the associated -- code might involve parallel array computations. addGlobalParallelVar :: Var -> VM () -- | Mark the given type constructor as parallel — i.e., its values might -- embed parallel arrays. addGlobalParallelTyCon :: TyCon -> VM () module Vectorise.Utils.Base voidType :: VM Type newLocalVVar :: FastString -> Type -> VM VVar mkDataConTag :: DynFlags -> DataCon -> CoreExpr dataConTagZ :: DataCon -> Int -- | Make an application of the Wrap type constructor. mkWrapType :: Type -> VM Type -- | Make an application of the closure type constructor. mkClosureTypes :: [Type] -> Type -> VM Type -- | Make an application of the PRepr type constructor. mkPReprType :: Type -> VM Type -- | Make an appliction of the PData tycon to some argument. mkPDataType :: Type -> VM Type -- | Make an application of the PDatas tycon to some argument. mkPDatasType :: Type -> VM Type -- | Checks if a type constructor is defined in Prim (e.g., -- Int#); if so, returns it. splitPrimTyCon :: Type -> Maybe TyCon -- | Make a representational coersion to some builtin type. mkBuiltinCo :: (Builtins -> TyCon) -> VM Coercion -- | Apply the constructor wrapper of the Wrap newtype. wrapNewTypeBodyOfWrap :: CoreExpr -> Type -> VM CoreExpr -- | Strip the constructor wrapper of the Wrap newtype. unwrapNewTypeBodyOfWrap :: CoreExpr -> Type -> VM CoreExpr -- | Apply the constructor wrapper of the PData newtype -- instance of Wrap. wrapNewTypeBodyOfPDataWrap :: CoreExpr -> Type -> VM CoreExpr -- | Strip the constructor wrapper of the PData newtype -- instance of Wrap. unwrapNewTypeBodyOfPDataWrap :: CoreExpr -> Type -> VM CoreExpr -- | Apply the constructor wrapper of the PDatas newtype -- instance of Wrap. wrapNewTypeBodyOfPDatasWrap :: CoreExpr -> Type -> VM CoreExpr -- | Strip the constructor wrapper of the PDatas newtype -- instance of Wrap. unwrapNewTypeBodyOfPDatasWrap :: CoreExpr -> Type -> VM CoreExpr -- | Get the representation tycon of the PData data family for a -- given type. -- -- This tycon does not appear explicitly in the source program — see Note -- [PData TyCons] in Description: -- --
```--   pdataReprTyCon {Sum2} = {PDataSum2}
--   ```
-- -- The type for which we look up a PData instance may be more -- specific than the type in the instance declaration. In that case the -- second component of the result will be more specific than a set of -- distinct type variables. pdataReprTyCon :: Type -> VM (TyCon, [Type]) -- | Get the representation tycon of the PData data family for a -- given type constructor. -- -- For example, for a binary type constructor T, we determine -- the representation type constructor for 'PData (T a b)'. pdataReprTyConExact :: TyCon -> VM TyCon -- | Get the representation tycon of the PDatas data family for a -- given type constructor. -- -- For example, for a binary type constructor T, we determine -- the representation type constructor for 'PDatas (T a b)'. pdatasReprTyConExact :: TyCon -> VM TyCon -- | Unwrap a PData representation scrutinee. pdataUnwrapScrut :: VExpr -> VM (CoreExpr, CoreExpr, DataCon) -- | Get the representation tycon of the PRepr type family for a -- given type. preprSynTyCon :: Type -> VM FamInstMatch module Vectorise.Utils.PADict -- | Construct the PA argument type for the tyvar. For the tyvar (v :: *) -- it's just PA v. For (v :: (* -> *) -> *) it's -- --
```--   forall (a :: * -> *). (forall (b :: *). PA b -> PA (a b)) -> PA (v a)
--   ```
paDictArgType :: TyVar -> VM (Maybe Type) -- | Get the PA dictionary for some type paDictOfType :: Type -> VM CoreExpr -- | Produce code that refers to a method of the PA class. paMethod :: (Builtins -> Var) -> (TyCon -> Builtins -> Var) -> Type -> VM CoreExpr -- | Get the PR dictionary for a type. The argument must be a -- representation type. prDictOfReprType :: Type -> VM CoreExpr -- | Given a type ty, its PRepr synonym tycon and its type -- arguments, return the PR PRepr ty. Suppose we have: -- --
```--   type instance PRepr (T a1 ... an) = t
--   ```
-- -- which is internally translated into -- --
```--   type :R:PRepr a1 ... an = t
--   ```
-- -- and the corresponding coercion. Then, -- --
```--   prDictOfPReprInstTyCon (T a1 ... an) :R:PRepr u1 ... un = PR (T u1 ... un)
--   ```
-- -- Note that ty is only used for error messages prDictOfPReprInstTyCon :: Type -> CoAxiom Unbranched -> [Type] -> VM CoreExpr -- | Auxiliary functions to vectorise type abstractions. module Vectorise.Utils.Poly -- | Vectorise under the PA dictionary variables corresponding to -- a set of type arguments. -- -- The dictionary variables are new local variables that are entered into -- the local vectorisation map. -- -- The purpose of this function is to introduce the additional -- PA dictionary arguments that are needed when vectorising type -- abstractions. polyAbstract :: [TyVar] -> ([Var] -> VM a) -> VM a -- | Apply a expression to its type arguments as well as PA -- dictionaries for these type arguments. polyApply :: CoreExpr -> [Type] -> VM CoreExpr -- | Apply a vectorised expression to a set of type arguments together with -- PA dictionaries for these type arguments. polyVApply :: VExpr -> [Type] -> VM VExpr -- | Determine the number of PA dictionary arguments required for -- a set of type variables (depends on their kinds). polyArity :: [TyVar] -> VM Int module Vectorise.Utils.Hoisting -- | Records whether we should inline a particular binding. data Inline Inline :: Arity -> Inline DontInline :: Inline -- | Add to the arity contained within an Inline, if any. addInlineArity :: Inline -> Int -> Inline -- | Says to always inline a binding. inlineMe :: Inline hoistBinding :: Var -> CoreExpr -> VM () hoistExpr :: FastString -> CoreExpr -> Inline -> VM Var hoistVExpr :: VExpr -> Inline -> VM VVar -- | Hoist a polymorphic vectorised expression into a new top-level binding -- (representing a closure function). -- -- The hoisted expression is parameterised by (1) a set of type variables -- and (2) a set of value variables that are passed as conventional type -- and value arguments. The latter is implicitly extended by the set of -- PA dictionaries required for the type variables. hoistPolyVExpr :: [TyVar] -> [Var] -> Inline -> VM VExpr -> VM VExpr takeHoisted :: VM [(Var, CoreExpr)] -- | Utils concerning closure construction and application. module Vectorise.Utils.Closure -- | Make a closure. mkClosure :: Type -> Type -> Type -> VExpr -> VExpr -> VM VExpr -- | Make a closure application. mkClosureApp :: Type -> Type -> VExpr -> VExpr -> VM VExpr -- | Build a set of n closures corresponding to an n-ary -- vectorised function. The length of the list of types of arguments -- determines the arity. -- -- In addition to a set of type variables, a set of value variables is -- passed during closure construction. In contrast, the closure -- environment and the arguments are passed during closure application. buildClosures :: [TyVar] -> [Var] -> [VVar] -> [Type] -> Type -> VM VExpr -> VM VExpr module Vectorise.Utils collectAnnTypeArgs :: AnnExpr b ann -> (AnnExpr b ann, [Type]) collectAnnDictArgs :: AnnExpr Var ann -> (AnnExpr Var ann, [AnnExpr Var ann]) collectAnnTypeBinders :: AnnExpr Var ann -> ([Var], AnnExpr Var ann) -- | Collect all consecutive value binders that are not dictionaries. collectAnnValBinders :: AnnExpr Var ann -> ([Var], AnnExpr Var ann) isAnnTypeArg :: AnnExpr b ann -> Bool -- | Produce an array containing copies of a given element. replicatePD :: CoreExpr -> CoreExpr -> VM CoreExpr -- | An empty array of the given type. emptyPD :: Type -> VM CoreExpr -- | Select some elements from an array that correspond to a particular tag -- value and pack them into a new array. -- --
```--   packByTagPD Int# [:23, 42, 95, 50, 27, 49:]  3 [:1, 2, 1, 2, 3, 2:] 2
--     ==> [:42, 50, 49:]
--   ```
packByTagPD :: Type -> CoreExpr -> CoreExpr -> CoreExpr -> CoreExpr -> VM CoreExpr -- | Combine some arrays based on a selector. The selector says which -- source array to choose for each element of the resulting array. combinePD :: Type -> CoreExpr -> CoreExpr -> [CoreExpr] -> VM CoreExpr -- | Like replicatePD but use the lifting context in the vectoriser -- state. liftPD :: CoreExpr -> VM CoreExpr isScalar :: Type -> VM Bool zipScalars :: [Type] -> Type -> VM CoreExpr scalarClosure :: [Type] -> Type -> CoreExpr -> CoreExpr -> VM CoreExpr -- | Make a fresh local variable with the given type. The variable's name -- is formed using the given string as the prefix. newLocalVar :: FastString -> Type -> VM Var -- | Compute a description of the generic representation that we use for a -- user defined data type. -- -- During vectorisation, we generate a PRepr and PA instance for each -- user defined data type. The PA dictionary contains methods to convert -- the user type to and from our generic representation. This module -- computes a description of what that generic representation is. module Vectorise.Generic.Description -- | Describes the representation type of a data constructor field. data CompRepr Keep :: Type -> CoreExpr -> CompRepr Wrap :: Type -> CompRepr -- | Describes the representation type of the fields / components of a -- constructor. If the data constructor has multiple fields then we -- bundle them together into a generic product type. data ProdRepr -- | Data constructor has no fields. EmptyProd :: ProdRepr -- | Data constructor has a single field. UnaryProd :: CompRepr -> ProdRepr -- | Data constructor has several fields. Prod :: TyCon -> TyCon -> TyCon -> [Type] -> [CompRepr] -> ProdRepr -- | Representation tycon for the product (eg Tuple2) repr_tup_tc :: ProdRepr -> TyCon -- | PData version of the product tycon (eg PDataTuple2) repr_ptup_tc :: ProdRepr -> TyCon -- | PDatas version of the product tycon (eg PDatasTuple2s) Not all lifted -- backends use PDatas. repr_ptups_tc :: ProdRepr -> TyCon -- | Types of each field. repr_comp_tys :: ProdRepr -> [Type] -- | Generic representation types for each field. repr_comps :: ProdRepr -> [CompRepr] -- | Describes the representation type of a data constructor. data ConRepr ConRepr :: DataCon -> ProdRepr -> ConRepr repr_dc :: ConRepr -> DataCon repr_prod :: ConRepr -> ProdRepr -- | Describes the generic representation of a data type. If the data type -- has multiple constructors then we bundle them together into a generic -- sum type. data SumRepr -- | Data type has no data constructors. EmptySum :: SumRepr -- | Data type has a single constructor. UnarySum :: ConRepr -> SumRepr -- | Data type has multiple constructors. Sum :: TyCon -> TyCon -> TyCon -> Type -> Type -> CoreExpr -> [Type] -> [ConRepr] -> SumRepr -- | Representation tycon for the sum (eg Sum2) repr_sum_tc :: SumRepr -> TyCon -- | PData version of the sum tycon (eg PDataSum2) This TyCon doesn't -- appear explicitly in the source program. See Note [PData TyCons]. repr_psum_tc :: SumRepr -> TyCon -- | PDatas version of the sum tycon (eg PDatasSum2) repr_psums_tc :: SumRepr -> TyCon -- | Type of the selector (eg Sel2) repr_sel_ty :: SumRepr -> Type -- | Type of multi-selector (eg Sel2s) repr_sels_ty :: SumRepr -> Type -- | Function to get the length of a Sels of this type. repr_selsLength_v :: SumRepr -> CoreExpr -- | Type of each data constructor. repr_con_tys :: SumRepr -> [Type] -- | Generic representation types of each data constructor. repr_cons :: SumRepr -> [ConRepr] -- | Determine the generic representation of a data type, given its tycon. tyConRepr :: TyCon -> VM SumRepr -- | Yield the type of this sum representation. sumReprType :: SumRepr -> VM Type -- | Yield the original component type of a data constructor component -- representation. compOrigType :: CompRepr -> Type instance Outputable CompRepr instance Outputable ProdRepr instance Outputable ConRepr instance Outputable SumRepr -- | Generate methods for the PA class. -- -- TODO: there is a large amount of redundancy here between the a, PData -- a, and PDatas a forms. See if we can factor some of this out. module Vectorise.Generic.PAMethods buildPReprTyCon :: TyCon -> TyCon -> SumRepr -> VM FamInst buildPAScAndMethods :: VM [(String, PAInstanceBuilder)] module Vectorise.Generic.PADict -- | Build the PA dictionary function for some type and hoist it to top -- level. -- -- The PA dictionary holds fns that convert values to and from their -- vectorised representations. -- -- @Recall the definition: class PR (PRepr a) => PA a where toPRepr :: -- a -> PRepr a fromPRepr :: PRepr a -> a toArrPRepr :: PData a -- -> PData (PRepr a) fromArrPRepr :: PData (PRepr a) -> PData a -- toArrPReprs :: PDatas a -> PDatas (PRepr a) fromArrPReprs :: PDatas -- (PRepr a) -> PDatas a -- -- Example: df :: forall a. PR (PRepr a) -> PA a -> PA (T a) df = -- /a. (c:PR (PRepr a)) (d:PA a). MkPA c (\$PR_df a d) (\$toPRepr a d) ... -- \$dPR_df :: forall a. PA a -> PR (PRepr (T a)) \$dPR_df = .... -- \$toRepr :: forall a. PA a -> T a -> PRepr (T a) \$toPRepr = ... -- The "..." stuff is filled in by buildPAScAndMethods @ buildPADict :: TyCon -> CoAxiom Unbranched -> TyCon -> TyCon -> SumRepr -> VM Var module Vectorise.Type.Type -- | Vectorise a type constructor. Unless there is a vectorised version -- (stripped of embedded parallel arrays), the vectorised version is the -- same as the original. vectTyCon :: TyCon -> VM TyCon -- | Produce the vectorised and lifted versions of a type. -- -- NB: Here we are limited to properly handle predicates at the toplevel -- only. Anything embedded in what is called the body_ty below -- will end up as an argument to the type family PData. vectAndLiftType :: Type -> VM (Type, Type) -- | Vectorise a type. -- -- For each quantified var we need to add a PA dictionary out the front -- of the type. So forall a. C a => a -> a turns into forall a. PA -- a => Cv a => a :-> a vectType :: Type -> VM Type module Vectorise.Convert -- | Convert a vectorised expression such that it computes the -- non-vectorised equivalent of its value. -- -- For functions, we eta expand the function and convert the arguments -- and result: fromVect :: Type -> CoreExpr -> VM CoreExpr -- | Build instance tycons for the PData and PDatas type families. -- -- TODO: the PData and PDatas cases are very similar. We should be able -- to factor out the common parts. module Vectorise.Generic.PData -- | Build the PData instance tycon for a given type constructor. buildPDataTyCon :: TyCon -> TyCon -> SumRepr -> VM FamInst -- | Build the PDatas instance tycon for a given type constructor. buildPDatasTyCon :: TyCon -> TyCon -> SumRepr -> VM FamInst module Vectorise.Type.TyConDecl -- | Vectorise some (possibly recursively defined) type constructors. vectTyConDecls :: [TyCon] -> VM [TyCon] module Vectorise.Type.Env -- | Vectorise type constructor including class type constructors. vectTypeEnv :: [TyCon] -> [CoreVect] -> [CoreVect] -> VM ([TyCon], [FamInst], [(Var, CoreExpr)]) -- | Vectorise variables and literals. module Vectorise.Var -- | Vectorise a binder variable, along with its attached type. vectBndr :: Var -> VM VVar -- | Vectorise a binder variable, along with its attached type, but give -- the result a new name. vectBndrNew :: Var -> FastString -> VM VVar -- | Vectorise a binder then run a computation with that binder in scope. vectBndrIn :: Var -> VM a -> VM (VVar, a) -- | Vectorise a binder, give it a new name, then run a computation with -- that binder in scope. vectBndrNewIn :: Var -> FastString -> VM a -> VM (VVar, a) -- | Vectorise some binders, then run a computation with them in scope. vectBndrsIn :: [Var] -> VM a -> VM ([VVar], a) -- | Vectorise a variable, producing the vectorised and lifted versions. vectVar :: Var -> VM VExpr -- | Constants are lifted by replication along the integer context in the -- VM state for the number of elements in the result array. vectConst :: CoreExpr -> VM VExpr -- | Vectorisation of expressions. module Vectorise.Exp -- | Vectorise a polymorphic expression that forms a *non-recursive* -- binding. -- -- Return Nothing if the expression is scalar; otherwise, the -- first component of the result (which is of type Bool) indicates -- whether the expression is parallel (i.e., whether it is tagged as -- VIParr). -- -- We have got the non-recursive case as a special case as it doesn't -- require to compute vectorisation information twice. vectTopExpr :: Var -> CoreExpr -> VM (Maybe (Bool, Inline, CoreExpr)) -- | Vectorise a recursive group of top-level polymorphic expressions. -- -- Return Nothing if the expression group is scalar; otherwise, -- the first component of the result (which is of type Bool) -- indicates whether the expressions are parallel (i.e., whether they are -- tagged as VIParr). vectTopExprs :: [(Var, CoreExpr)] -> VM (Maybe (Bool, [(Inline, CoreExpr)])) -- | Vectorise an expression of functional type, where all arguments and -- the result are of primitive types (i.e., Int, Float, -- Double etc., which have instances of the Scalar type -- class) and which does not contain any subcomputations that involve -- parallel arrays. Such functionals do not require the full blown -- vectorisation transformation; instead, they can be lifted by -- application of a member of the zipWith family (i.e., map, -- zipWith, zipWith3', etc.) -- -- Dictionary functions are also scalar functions (as dictionaries -- themselves are not vectorised, instead they become dictionaries of -- vectorised methods). We treat them differently, though see "Note -- [Scalar dfuns]" in Vectorise. vectScalarFun :: CoreExpr -> VM VExpr -- | Vectorise a dictionary function that has a 'VECTORISE SCALAR instance' -- pragma. -- -- In other words, all methods in that dictionary are scalar functions — -- to be vectorised with vectScalarFun. The dictionary "function" -- itself may be a constant, though. -- -- NB: You may think that we could implement this function guided by the -- struture of the Core expression of the right-hand side of the -- dictionary function. We cannot proceed like this as -- vectScalarDFun must also work for *imported* dfuns, where we -- don't necessarily have access to the Core code of the unvectorised -- dfun. -- -- Here an example — assume, -- --
```--   class Eq a where { (==) :: a -> a -> Bool }
--   instance (Eq a, Eq b) => Eq (a, b) where { (==) = ... }
--   {-# VECTORISE SCALAR instance Eq (a, b) }
--   ```
-- -- The unvectorised dfun for the above instance has the following -- signature: -- --
```--   \$dEqPair :: forall a b. Eq a -> Eq b -> Eq (a, b)
--   ```
-- -- We generate the following (scalar) vectorised dfun (liberally using TH -- notation): -- --
```--   \$v\$dEqPair :: forall a b. V:Eq a -> V:Eq b -> V:Eq (a, b)
--   \$v\$dEqPair = /\a b -> \dEqa :: V:Eq a -> \dEqb :: V:Eq b ->
--                  D:V:Eq \$(vectScalarFun True recFns
--                           [| (==) @(a, b) (\$dEqPair @a @b \$(unVect dEqa) \$(unVect dEqb)) |])
--   ```
--
• 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 lookuping up names while handling plugins. This -- was introduced by 57d6798. 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
• --
• --
--
• False: treat the hi-boot summaries as nodes of the graph, -- so the graph must be acyclic
• --
• True: eliminate the hi-boot nodes, and instead pretend -- the a source-import of Foo is an import of Foo The resulting graph has -- no hi-boot nodes, but can be cyclic
• --
topSortModuleGraph :: Bool -> [ModSummary] -> Maybe ModuleName -> [SCC ModSummary] noModError :: DynFlags -> SrcSpan -> ModuleName -> FindResult -> ErrMsg cyclicModuleErr :: [ModSummary] -> SDoc module TcSplice tcSpliceExpr :: HsSplice Name -> TcRhoType -> TcM (HsExpr TcId) tcTypedBracket :: HsBracket Name -> TcRhoType -> TcM (HsExpr TcId) tcUntypedBracket :: HsBracket Name -> [PendingRnSplice] -> TcRhoType -> TcM (HsExpr TcId) runQuasiQuoteExpr :: HsQuasiQuote RdrName -> RnM (LHsExpr RdrName) runQuasiQuotePat :: HsQuasiQuote RdrName -> RnM (LPat RdrName) runQuasiQuoteDecl :: HsQuasiQuote RdrName -> RnM [LHsDecl RdrName] runQuasiQuoteType :: HsQuasiQuote RdrName -> RnM (LHsType RdrName) runAnnotation :: CoreAnnTarget -> LHsExpr Name -> TcM Annotation runMetaE :: LHsExpr Id -> TcM (LHsExpr RdrName) runMetaP :: LHsExpr Id -> TcM (LPat RdrName) runMetaT :: LHsExpr Id -> TcM (LHsType RdrName) runMetaD :: LHsExpr Id -> TcM [LHsDecl RdrName] runQuasi :: Q a -> TcM a tcTopSpliceExpr :: Bool -> TcM (LHsExpr Id) -> TcM (LHsExpr Id) lookupThName_maybe :: Name -> TcM (Maybe Name) instance Quasi (IOEnv (Env TcGblEnv TcLclEnv)) module DebuggerUtils -- | Given a data constructor in the heap, find its Name. The info tables -- for data constructors have a field which records the source name of -- the constructor as a Ptr Word8 (UTF-8 encoded string). The format is: -- --
```--   Package:Module.Name
--   ```
```--   -#includes