haskell-tools-daemon-1.1.1.0: Background process for Haskell-tools that editors can connect to.

Safe HaskellNone
LanguageHaskell2010

Language.Haskell.Tools.Daemon.GetModules

Description

Collecting modules contained in a module collection (library, executable, testsuite or benchmark). Gets names, source file locations, compilation and load flags for these modules.

Synopsis

Documentation

getAllModules :: [FilePath] -> IO [ModuleCollection ModuleNameStr] Source #

Gets all ModuleCollections from a list of source directories. It also orders the source directories that are package roots so that they can be loaded in the order they are defined (no backward imports). This matters in those cases because for them there can be special compilation flags.

orderMCs :: [ModuleCollection k] -> [ModuleCollection k] Source #

Sorts model collection in an order to remove all backward references. Works because module collections defined by directories cannot be recursive.

getModules :: FilePath -> IO [ModuleCollection ModuleNameStr] Source #

Get modules of the project with the indicated root directory. If there is a cabal file, it uses that, otherwise it just scans the directory recursively for haskell sourcefiles. Only returns the non-boot haskell modules, the boot modules will be found during loading.

modulesFromDirectory :: FilePath -> FilePath -> IO [String] Source #

Load the module giving a directory. All modules loaded from the folder and subfolders.

modulesFromCabalFile :: FilePath -> FilePath -> IO [ModuleCollection ModuleNameStr] Source #

Load the module using a cabal file. The modules described in the cabal file will be loaded. The flags and extensions set in the cabal file will be used by default.

class ToModuleCollection t where Source #

Extract module-related information from different kind of package components (library, executable, test-suite or benchmark).

Methods

mkModuleCollKey :: PackageName -> t -> ModuleCollectionId Source #

Creates a key for registering this package component.

getBuildInfo :: t -> BuildInfo Source #

Gets the build info field from a package component.

getModuleNames :: t -> [ModuleName] Source #

Get the names of all the modules used by this package component.

getModuleSourceFiles :: t -> [(ModuleName, FilePath)] Source #

Gets if some of the modules are defined is source files that are not in the expected location or named as expected.

needsToCompile :: t -> ModuleName -> Bool Source #

Checks if a module is exposed by the package component, so it is necessary to compile. Some of the components may have modules that are only conditionally imported by other modules.

getMain :: t -> String Source #

Gets the Main module in the case of executables, benchmarks and test suites.

Instances
ToModuleCollection Benchmark Source # 
Instance details

Defined in Language.Haskell.Tools.Daemon.GetModules

ToModuleCollection Executable Source # 
Instance details

Defined in Language.Haskell.Tools.Daemon.GetModules

ToModuleCollection Library Source # 
Instance details

Defined in Language.Haskell.Tools.Daemon.GetModules

ToModuleCollection TestSuite Source # 
Instance details

Defined in Language.Haskell.Tools.Daemon.GetModules

getMain' :: BuildInfo -> String Source #

A default method of getting the main module using the ghc-options field, checking for the option -main-is.

isDirectoryMC :: ModuleCollectionId -> Bool Source #

Checks if the module collection created from a folder without .cabal file.

applyDependencies :: [ModuleCollectionId] -> [ModuleCollectionId] -> DynFlags -> DynFlags Source #

Modify the dynamic flags to match the dependencies requested in the .cabal file.

onlyUseEnabled :: DynFlags -> DynFlags Source #

Only use the dependencies that are explicitely enabled. (As cabal does opposed to as ghc does.)

dependencyToPkgFlag :: [ModuleCollectionId] -> ModuleCollectionId -> Maybe PackageFlag Source #

Transform dependencies of a module collection into the package flags of the GHC API

setupLoadFlags :: [ModuleCollectionId] -> [FilePath] -> [ModuleCollectionId] -> (DynFlags -> IO DynFlags) -> DynFlags -> IO DynFlags Source #

Sets the configuration for loading all the modules from the whole project. Combines the configuration of all package fragments. This solution is not perfect (it would be better to load all package fragments separately), but it is how it works. See loadFlagsFromBuildInfo.

loadFlagsFromBuildInfo :: BuildInfo -> DynFlags -> IO DynFlags Source #

Collects the compilation options and enabled extensions from Cabal's build info representation. This setup will be used when loading all packages in the project. See setupLoadFlags.

flagsFromBuildInfo :: BuildInfo -> DynFlags -> IO DynFlags Source #

Collects the compilation options and enabled extensions from Cabal's build info representation for a single module. See compileInContext.