ghcide-0.1.0: The core of an IDE

Development.IDE.GHC.Util

Description

General utility functions, mostly focused around GHC operations.

Synopsis

# HcsEnv and environment

data HscEnvEq Source #

An HscEnv with equality. Two values are considered equal if they are created with the same call to newHscEnvEq.

Instances
 Source # Instance detailsDefined in Development.IDE.GHC.Util Methods Source # Instance detailsDefined in Development.IDE.GHC.Util MethodsshowList :: [HscEnvEq] -> ShowS # Source # Instance detailsDefined in Development.IDE.GHC.Util Methodsrnf :: HscEnvEq -> () #

Unwrap an HsEnvEq.

Wrap an HscEnv into an HscEnvEq.

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).

A DynFlags value where most things are undefined. It's sufficient to call pretty printing, but not much else.

runGhcEnv :: HscEnv -> Ghc a -> IO a Source #

Run a Ghc monad value using an existing HscEnv. Sets up and tears down all the required pieces, but designed to be more efficient than a standard runGhc.

# GHC wrappers

prettyPrint :: Outputable a => a -> String Source #

Pretty print a GHC value using fakeDynFlags.

Given a UnitId try and find the associated PackageConfig in the environment.

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.

Convert from a CgGuts to a CoreModule.

Convert a Fingerprint to a ByteString by copying the byte across. Will produce an 8 byte unreadable ByteString.

Take the Fingerprint of a StringBuffer.

# General utilities

Convert from the text package to the GHC StringBuffer. Currently implemented somewhat inefficiently (if it ever comes up in a profile).

Read a UTF8 file, with lenient decoding, so it will never raise a decoding error.

A slightly modified version of hDuplicateTo from GHC. Importantly, it avoids the bug listed in https://gitlab.haskell.org/ghc/ghc/merge_requests/2318.