Safe Haskell | None |
---|---|
Language | Haskell2010 |
General utility functions, mostly focused around GHC operations.
Synopsis
- data HscEnvEq
- hscEnv :: HscEnvEq -> HscEnv
- newHscEnvEq :: FilePath -> HscEnv -> [(InstalledUnitId, DynFlags)] -> IO HscEnvEq
- hscEnvWithImportPaths :: HscEnvEq -> HscEnv
- envImportPaths :: HscEnvEq -> Maybe [String]
- modifyDynFlags :: GhcMonad m => (DynFlags -> DynFlags) -> m ()
- evalGhcEnv :: HscEnv -> Ghc b -> IO b
- runGhcEnv :: HscEnv -> Ghc a -> IO (HscEnv, a)
- deps :: HscEnvEq -> [(InstalledUnitId, DynFlags)]
- prettyPrint :: Outputable a => a -> String
- printRdrName :: RdrName -> String
- printName :: Name -> String
- data ParseResult a
- runParser :: DynFlags -> String -> P a -> ParseResult a
- lookupPackageConfig :: UnitId -> HscEnv -> Maybe PackageConfig
- textToStringBuffer :: Text -> StringBuffer
- bytestringToStringBuffer :: ByteString -> StringBuffer
- stringBufferToByteString :: StringBuffer -> ByteString
- moduleImportPath :: NormalizedFilePath -> ModuleName -> Maybe FilePath
- cgGutsToCoreModule :: SafeHaskellMode -> CgGuts -> ModDetails -> CoreModule
- fingerprintToBS :: Fingerprint -> ByteString
- fingerprintFromStringBuffer :: StringBuffer -> IO Fingerprint
- readFileUtf8 :: FilePath -> IO Text
- hDuplicateTo' :: Handle -> Handle -> IO ()
- setHieDir :: FilePath -> DynFlags -> DynFlags
- dontWriteHieFiles :: DynFlags -> DynFlags
- disableWarningsAsErrors :: DynFlags -> DynFlags
- newHscEnvEqPreserveImportPaths :: HscEnv -> [(InstalledUnitId, DynFlags)] -> IO HscEnvEq
HcsEnv and environment
An HscEnv
with equality. Two values are considered equal
if they are created with the same call to newHscEnvEq
.
newHscEnvEq :: FilePath -> HscEnv -> [(InstalledUnitId, DynFlags)] -> IO HscEnvEq Source #
hscEnvWithImportPaths :: HscEnvEq -> HscEnv Source #
Unwrap the HscEnv
with the original import paths.
Used only for locating imports
envImportPaths :: HscEnvEq -> Maybe [String] Source #
If Just, import dirs originally configured in this env If Nothing, the env import dirs are unaltered
modifyDynFlags :: GhcMonad m => (DynFlags -> DynFlags) -> m () Source #
Used to modify dyn flags in preference to calling setSessionDynFlags
,
since that function also reloads packages (which is very slow).
deps :: HscEnvEq -> [(InstalledUnitId, DynFlags)] Source #
In memory components for this HscEnv This is only used at the moment for the import dirs in the DynFlags
GHC wrappers
prettyPrint :: Outputable a => a -> String Source #
Pretty print a GHC value using 'unsafeGlobalDynFlags '.
lookupPackageConfig :: UnitId -> HscEnv -> Maybe PackageConfig Source #
Given a UnitId
try and find the associated PackageConfig
in the environment.
textToStringBuffer :: Text -> StringBuffer Source #
Convert from the text
package to the GHC
StringBuffer
.
Currently implemented somewhat inefficiently (if it ever comes up in a profile).
moduleImportPath :: NormalizedFilePath -> ModuleName -> Maybe FilePath Source #
Given a module location, and its parse tree, figure out what is the include directory implied by it.
For example, given the file /usr/Test/Foo/Bar.hs
with the module name Foo.Bar
the directory
/usr/Test
should be on the include path to find sibling modules.
cgGutsToCoreModule :: SafeHaskellMode -> CgGuts -> ModDetails -> CoreModule Source #
Convert from a CgGuts
to a CoreModule
.
fingerprintToBS :: Fingerprint -> ByteString Source #
Convert a Fingerprint
to a ByteString
by copying the byte across.
Will produce an 8 byte unreadable ByteString.
fingerprintFromStringBuffer :: StringBuffer -> IO Fingerprint Source #
Take the Fingerprint
of a StringBuffer
.
General utilities
readFileUtf8 :: FilePath -> IO Text Source #
Read a UTF8 file, with lenient decoding, so it will never raise a decoding error.
hDuplicateTo' :: Handle -> Handle -> IO () Source #
A slightly modified version of hDuplicateTo
from GHC.
Importantly, it avoids the bug listed in https://gitlab.haskell.org/ghc/ghc/merge_requests/2318.
dontWriteHieFiles :: DynFlags -> DynFlags Source #
newHscEnvEqPreserveImportPaths :: HscEnv -> [(InstalledUnitId, DynFlags)] -> IO HscEnvEq Source #