Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Development.IDE.GHC.Util
Contents
Description
General utility functions, mostly focused around GHC operations.
Synopsis
- modifyDynFlags :: GhcMonad m => (DynFlags -> DynFlags) -> m ()
- evalGhcEnv :: HscEnv -> Ghc b -> IO b
- printRdrName :: RdrName -> String
- printName :: Name -> String
- data ParseResult a :: TYPE ('SumRep '['TupleRep '[LiftedRep, LiftedRep], LiftedRep]) where
- pattern PFailed :: PState -> ParseResult a
- pattern POk :: PState -> a -> ParseResult a
- runParser :: DynFlags -> String -> P a -> ParseResult a
- lookupPackageConfig :: Unit -> HscEnv -> Maybe UnitInfo
- textToStringBuffer :: Text -> StringBuffer
- bytestringToStringBuffer :: ByteString -> StringBuffer
- stringBufferToByteString :: StringBuffer -> ByteString
- moduleImportPath :: NormalizedFilePath -> ModuleName -> Maybe FilePath
- cgGutsToCoreModule :: SafeHaskellMode -> CgGuts -> ModDetails -> CoreModule
- fingerprintToBS :: Fingerprint -> ByteString
- fingerprintFromByteString :: ByteString -> IO Fingerprint
- fingerprintFromStringBuffer :: StringBuffer -> IO Fingerprint
- fingerprintFromPut :: Put -> IO Fingerprint
- readFileUtf8 :: FilePath -> IO Text
- hDuplicateTo' :: Handle -> Handle -> IO ()
- setHieDir :: FilePath -> DynFlags -> DynFlags
- dontWriteHieFiles :: DynFlags -> DynFlags
- disableWarningsAsErrors :: DynFlags -> DynFlags
- printOutputable :: Outputable a => a -> Text
- getExtensions :: ParsedModule -> [Extension]
Documentation
modifyDynFlags :: GhcMonad m => (DynFlags -> DynFlags) -> m () #
Used to modify dyn flags in preference to calling setSessionDynFlags
,
since that function also reloads packages (which is very slow).
evalGhcEnv :: HscEnv -> Ghc b -> IO b #
GHC wrappers
printRdrName :: RdrName -> String #
Pretty print a RdrName
wrapping operators in parens
data ParseResult a :: TYPE ('SumRep '['TupleRep '[LiftedRep, LiftedRep], LiftedRep]) where #
Bundled Patterns
pattern PFailed :: PState -> ParseResult a | |
pattern POk :: PState -> a -> ParseResult a |
lookupPackageConfig :: Unit -> HscEnv -> Maybe UnitInfo #
Given a Unit
try and find the associated PackageConfig
in the environment.
textToStringBuffer :: Text -> StringBuffer #
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 #
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 #
Convert from a CgGuts
to a CoreModule
.
fingerprintToBS :: Fingerprint -> ByteString #
Convert a Fingerprint
to a ByteString
by copying the byte across.
Will produce an 8 byte unreadable ByteString.
fingerprintFromByteString :: ByteString -> IO Fingerprint #
fingerprintFromStringBuffer :: StringBuffer -> IO Fingerprint #
Take the Fingerprint
of a StringBuffer
.
fingerprintFromPut :: Put -> IO Fingerprint #
General utilities
readFileUtf8 :: FilePath -> IO Text #
Read a UTF8 file, with lenient decoding, so it will never raise a decoding error.
hDuplicateTo' :: Handle -> Handle -> IO () #
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 #
printOutputable :: Outputable a => a -> Text #
Print a GHC value in defaultUserStyle
without unique symbols.
It uses showSDocUnsafe
with unsafeGlobalDynFlags
internally.
This is the most common print utility.
It will do something additionally compared to what the Outputable
instance does.
- print with a user-friendly style:
a_a4ME
asa
. - unescape escape sequences of printable unicode characters within a pair of double quotes
getExtensions :: ParsedModule -> [Extension] #