scion-0.1: Haskell IDE librarySource codeContentsIndex
Scion.Session
Portabilityportable
Stabilityexperimental
Maintainernominolo@gmail.com
Contents
Exception Types
Setting Session Parameters
Cabal Projects
Internal Utilities
Compilation
Background Typechecking
Description
Utilities to manipulate the session state.
Synopsis
data CannotOpenCabalProject = CannotOpenCabalProject String
data NoCurrentCabalProject = NoCurrentCabalProject
data ComponentDoesNotExist = ComponentDoesNotExist Component
initialScionDynFlags :: DynFlags -> DynFlags
resetSessionState :: ScionM ()
setWorkingDir :: FilePath -> ScionM ()
openCabalProject :: FilePath -> FilePath -> ScionM ()
currentCabalPackage :: ScionM PackageDescription
currentCabalFile :: ScionM FilePath
cabalProjectComponents :: FilePath -> ScionM [Component]
cabalConfigurations :: FilePath -> String -> Bool -> ScionM [CabalConfiguration]
preprocessPackage :: FilePath -> ScionM ()
getLocalBuildInfo :: ScionM LocalBuildInfo
projectRootDir :: ScionM FilePath
setComponentDynFlags :: Component -> ScionM [PackageId]
setComponentTargets :: Component -> ScionM ()
cabalModuleNameToTarget :: ModuleName -> Target
loadComponent :: Component -> ScionM CompilationResult
cabalProjectRoot :: ScionM FilePath
setActiveComponent :: Component -> ScionM ()
getActiveComponent :: ScionM (Maybe Component)
noLibError :: ScionM a
noExeError :: String -> ScionM a
load :: LoadHowMuch -> ScionM CompilationResult
unload :: ScionM ()
addCmdLineFlags :: [String] -> ScionM [PackageId]
availableComponents :: ScionM [Component]
setGHCVerbosity :: Int -> ScionM ()
backgroundTypecheckFile :: FilePath -> ScionM (Either String CompilationResult)
isRelativeToProjectRoot :: FilePath -> ScionM Bool
filePathToProjectModule :: FilePath -> ScionM (Maybe ModSummary)
isPartOfProject :: FilePath -> ScionM Bool
setContextForBGTC :: ModSummary -> ScionM (Maybe ModuleName, CompilationResult)
modSummaryForFile :: FilePath -> ModuleGraph -> ModSummary
removeMessagesForFile :: AbsFilePath -> CompilationResult -> ScionM CompilationResult
Exception Types
data CannotOpenCabalProject Source
Constructors
CannotOpenCabalProject String
show/hide Instances
data NoCurrentCabalProject Source
Constructors
NoCurrentCabalProject
show/hide Instances
data ComponentDoesNotExist Source
Constructors
ComponentDoesNotExist Component
show/hide Instances
Setting Session Parameters
initialScionDynFlags :: DynFlags -> DynFlagsSource
resetSessionState :: ScionM ()Source

Reset the state of the session to a defined default state.

Due to some bugs in GHC this isn't completely possible. For example, GHC retains instance declarations which can lead to problems when you load a new module which defines a different instance. (You'll get a conflicting instance error, which can only be resolved by re-starting GHC.)

setWorkingDir :: FilePath -> ScionM ()Source

Sets the current working directory and notifies GHC about the change.

TODO: do we want to adjust certain flags automatically?

Cabal Projects
openCabalProjectSource
:: FilePathProject root directroy
-> FilePathProject dist directory (relative)
-> ScionM ()

Try to open a Cabal project. The project must already be configured using the same version of Cabal that Scion was build against.

Use configureCabalProject to automatically configure a project (if it hasn't been already.)

TODO: Allow other working directories? Would require translating all the search paths from relative to absolute paths. Furthermore, what should the output directory be then?

Throws:

  • CannotOpenCabalProject if an error occurs (e.g., not configured project or configured with incompatible cabal version).
currentCabalPackage :: ScionM PackageDescriptionSource

Return the (configured) package description of the current Cabal project.

Throws:

currentCabalFile :: ScionM FilePathSource

Return path to the .cabal file of the current Cabal package.

This is useful to identify the project when communicating with Scion from foreign code, because this does not require serialising the local build info.

Throws:

cabalProjectComponentsSource
:: FilePathThe .cabal file
-> ScionM [Component]

Return all components of the specified Cabal file.

Throws:

cabalConfigurationsSource
:: FilePathThe .cabal file
-> Stringone of dist config all
-> Bool
-> ScionM [CabalConfiguration]
preprocessPackage :: FilePath -> ScionM ()Source
Run the steps that Cabal would call before building.
getLocalBuildInfo :: ScionM LocalBuildInfoSource

Return the current LocalBuildInfo.

The LocalBuildInfo is the result of configuring a Cabal project, therefore requires that we have a current Cabal project.

Throws:

projectRootDir :: ScionM FilePathSource

Root directory of the current Cabal project.

Throws:

setComponentDynFlagsSource
:: Component
-> ScionM [PackageId]

List of packages that need to be loaded. This corresponds to the build-depends of the loaded component.

TODO: do something with this depending on Scion mode?

Set GHC's dynamic flags for the given component of the current Cabal project (see openCabalProject).

Throws:

setComponentTargets :: Component -> ScionM ()Source

Set the targets for a GHC.load command from the meta data of the current Cabal project.

Throws:

cabalModuleNameToTarget :: ModuleName -> TargetSource
loadComponentSource
:: Component
-> ScionM CompilationResultThe compilation result.

Load the specified component from the current Cabal project.

Throws:

cabalProjectRoot :: ScionM FilePathSource
setActiveComponent :: Component -> ScionM ()Source

Make the specified component the active one. Sets the DynFlags to those specified for the given component. Unloads the possible

Throws:

getActiveComponent :: ScionM (Maybe Component)Source
Return the currently active component.
Internal Utilities
noLibError :: ScionM aSource
noExeError :: String -> ScionM aSource
Compilation
load :: LoadHowMuch -> ScionM CompilationResultSource
Wrapper for GHC.load.
unload :: ScionM ()Source
Unload whatever is currently loaded.
addCmdLineFlags :: [String] -> ScionM [PackageId]Source

Parses the list of Strings as command line arguments and sets the DynFlags accordingly.

Does not set the flags if a parse error occurs. XXX: There's currently no way to find out if there was an error from inside the program.

availableComponents :: ScionM [Component]Source

List all components in the current cabal project.

This can be used to present the user a list of possible items to load.

Throws:

setGHCVerbosity :: Int -> ScionM ()Source
Set the verbosity of the GHC API.
Background Typechecking
backgroundTypecheckFileSource
:: FilePath
-> ScionM (Either String CompilationResult)First element is False = step 1 above failed.

Takes an absolute path to a file and attempts to typecheck it.

This performs the following steps:

1. Check whether the file is actually part of the current project. It's also currently not possible to typecheck a .hs-boot file using this function. We simply bail out if these conditions are not met.

2. Make sure that all dependencies of the module are up to date.

3. Parse, typecheck, desugar and load the module. The last step is necessary so that we can we don't have to recompile in the case that we switch to another module.

4. If the previous step was successful, cache the results in the session for use by source code inspection utilities. Some of the above steps are skipped if we know that they are not necessary.

isRelativeToProjectRoot :: FilePath -> ScionM BoolSource
Return whether the filepath refers to a file inside the current project root. Return False if there is no current project.
filePathToProjectModule :: FilePath -> ScionM (Maybe ModSummary)Source
isPartOfProject :: FilePath -> ScionM BoolSource
setContextForBGTC :: ModSummary -> ScionM (Maybe ModuleName, CompilationResult)Source

Ensure that all dependencies of the module are already loaded.

Sets focusedModule if it was successful.

modSummaryForFile :: FilePath -> ModuleGraph -> ModSummarySource

Return the ModSummary that refers to the source file.

Assumes that there is exactly one such ModSummary.

removeMessagesForFile :: AbsFilePath -> CompilationResult -> ScionM CompilationResultSource
Produced by Haddock version 2.4.2