Language.Haskell.GhcMod.Types

ghc-mod-5.5.0.0: Happy Haskell Programming

Safe Haskell | None
Language | Haskell2010

Language.Haskell.GhcMod.Types

Synopsis

- type IOish m = (Functor m, MonadIO m, MonadBaseControl IO m, ExceptionMonad m)
- type MonadIOC m = MonadIO m
- class MonadIOC m => MonadIO m where
  - liftIO :: IO a -> m a
- data OutputStyle
  - = LispStyle
  - | PlainStyle
- newtype LineSeparator = LineSeparator String
- data FileMapping = FileMapping {
  - fmPath :: FilePath
  - fmTemp :: Bool
  }
- type FileMappingMap = Map FilePath FileMapping
- data ProgramSource
  - = ProgramSourceUser
  - | ProgramSourceStack
- data Programs = Programs {
  - ghcProgram :: FilePath
  - ghcPkgProgram :: FilePath
  - cabalProgram :: FilePath
  - stackProgram :: FilePath
  }
- data OutputOpts = OutputOpts {
  - ooptLogLevel :: GmLogLevel
  - ooptStyle :: OutputStyle
  - ooptLineSeparator :: LineSeparator
  - ooptLinePrefix :: Maybe (String, String)
  }
- data Options = Options {
  - optOutput :: OutputOpts
  - optPrograms :: Programs
  - optGhcUserOptions :: [GHCOption]
  - optFileMappings :: [(FilePath, Maybe FilePath)]
  }
- defaultOptions :: Options
- data Project
  - = CabalProject
  - | SandboxProject
  - | PlainProject
  - | StackProject StackEnv
- isCabalHelperProject :: Project -> Bool
- data StackEnv = StackEnv {
  - seDistDir :: FilePath
  - seBinPath :: [FilePath]
  - seSnapshotPkgDb :: FilePath
  - seLocalPkgDb :: FilePath
  }
- data Cradle = Cradle {
  - cradleProject :: Project
  - cradleCurrentDir :: FilePath
  - cradleRootDir :: FilePath
  - cradleTempDir :: FilePath
  - cradleCabalFile :: Maybe FilePath
  - cradleDistDir :: FilePath
  }
- data GmStream
  - = GmOutStream
  - | GmErrStream
- data GhcModEnv = GhcModEnv {
  - gmOptions :: Options
  - gmCradle :: Cradle
  }
- data GhcModOut = GhcModOut {
  - gmoOptions :: OutputOpts
  - gmoChan :: Chan (Either (MVar ()) (GmStream, String))
  }
- data GhcModLog = GhcModLog {
  - gmLogLevel :: Maybe GmLogLevel
  - gmLogVomitDump :: Last Bool
  - gmLogMessages :: [(GmLogLevel, String, Doc)]
  }
- data GmGhcSession = GmGhcSession {
  - gmgsOptions :: ![GHCOption]
  - gmgsSession :: !(IORef HscEnv)
  }
- data GhcModCaches = GhcModCaches {
  - gmcPackageDbStack :: CacheContents ChCacheData [GhcPkgDb]
  - gmcMergedPkgOptions :: CacheContents ChCacheData [GHCOption]
  - gmcComponents :: CacheContents ChCacheData [GmComponent GMCRaw ChEntrypoint]
  - gmcResolvedComponents :: CacheContents [GmComponent GMCRaw (Set ModulePath)] (Map ChComponentName (GmComponent GMCResolved (Set ModulePath)))
  }
- data GhcModState = GhcModState {
  - gmGhcSession :: !(Maybe GmGhcSession)
  - gmCaches :: !GhcModCaches
  - gmMMappedFiles :: !FileMappingMap
  }
- defaultGhcModState :: GhcModState
- data GhcPkgDb
  - = GlobalDb
  - | UserDb
  - | PackageDb String
- type GHCOption = String
- type IncludeDir = FilePath
- newtype Expression = Expression {
  - getExpression :: String
  }
- newtype ModuleString = ModuleString {
  - getModuleString :: String
  }
- data GmLogLevel
  - = GmSilent
  - | GmPanic
  - | GmException
  - | GmError
  - | GmWarning
  - | GmInfo
  - | GmDebug
  - | GmVomit
- data GmModuleGraph = GmModuleGraph {
  - gmgGraph :: Map ModulePath (Set ModulePath)
  }
- data GmComponentType
  - = GMCRaw
  - | GMCResolved
- data GmComponent t eps = GmComponent {
  - gmcHomeModuleGraph :: GmModuleGraph
  - gmcName :: ChComponentName
  - gmcGhcOpts :: [GHCOption]
  - gmcGhcPkgOpts :: [GHCOption]
  - gmcGhcSrcOpts :: [GHCOption]
  - gmcGhcLangOpts :: [GHCOption]
  - gmcRawEntrypoints :: ChEntrypoint
  - gmcEntrypoints :: eps
  - gmcSourceDirs :: [FilePath]
  }
- data ModulePath = ModulePath {
  - mpModule :: ModuleName
  - mpPath :: FilePath
  }
- data GhcModError
  - = GMENoMsg
  - | GMEString String
  - | GMECabalConfigure GhcModError
  - | GMEStackConfigure GhcModError
  - | GMEStackBootstrap GhcModError
  - | GMECabalCompAssignment [(Either FilePath ModuleName, Set ChComponentName)]
  - | GMEProcess String String [String] (Either Int GhcModError)
  - | GMENoCabalFile
  - | GMETooManyCabalFiles [FilePath]
- data LintOpts = LintOpts {
  - optLintHlintOpts :: [String]
  }
- defaultLintOpts :: LintOpts
- data BrowseOpts = BrowseOpts {
  - optBrowseOperators :: Bool
  - optBrowseDetailed :: Bool
  - optBrowseQualified :: Bool
  }
- defaultBrowseOpts :: BrowseOpts
- lGmcResolvedComponents :: forall cat. ArrowApply cat => Lens cat GhcModCaches (CacheContents [GmComponent GMCRaw (Set ModulePath)] (Map ChComponentName (GmComponent GMCResolved (Set ModulePath))))
- lGmcPackageDbStack :: forall cat. ArrowApply cat => Lens cat GhcModCaches (CacheContents ChCacheData [GhcPkgDb])
- lGmcMergedPkgOptions :: forall cat. ArrowApply cat => Lens cat GhcModCaches (CacheContents ChCacheData [GHCOption])
- lGmcComponents :: forall cat. ArrowApply cat => Lens cat GhcModCaches (CacheContents ChCacheData [GmComponent GMCRaw ChEntrypoint])
- lGmMMappedFiles :: forall cat. ArrowApply cat => Lens cat GhcModState FileMappingMap
- lGmGhcSession :: forall cat. ArrowApply cat => Lens cat GhcModState (Maybe GmGhcSession)
- lGmCaches :: forall cat. ArrowApply cat => Lens cat GhcModState GhcModCaches
- lOptPrograms :: forall cat. ArrowApply cat => Lens cat Options Programs
- lOptOutput :: forall cat. ArrowApply cat => Lens cat Options OutputOpts
- lOptGhcUserOptions :: forall cat. ArrowApply cat => Lens cat Options [GHCOption]
- lOptFileMappings :: forall cat. ArrowApply cat => Lens cat Options [(FilePath, Maybe FilePath)]
- lOoptStyle :: forall cat. ArrowApply cat => Lens cat OutputOpts OutputStyle
- lOoptLogLevel :: forall cat. ArrowApply cat => Lens cat OutputOpts GmLogLevel
- lOoptLineSeparator :: forall cat. ArrowApply cat => Lens cat OutputOpts LineSeparator
- lOoptLinePrefix :: forall cat. ArrowApply cat => Lens cat OutputOpts (Maybe (String, String))
- lStackProgram :: forall cat. ArrowApply cat => Lens cat Programs FilePath
- lGhcProgram :: forall cat. ArrowApply cat => Lens cat Programs FilePath
- lGhcPkgProgram :: forall cat. ArrowApply cat => Lens cat Programs FilePath
- lCabalProgram :: forall cat. ArrowApply cat => Lens cat Programs FilePath
- data ModuleName :: *
- mkModuleName :: String -> ModuleName
- moduleNameString :: ModuleName -> String

# Documentation

type IOish m = (Functor m, MonadIO m, MonadBaseControl IO m, ExceptionMonad m)

A constraint alias (-XConstraintKinds) to make functions dealing with `GhcModT` somewhat cleaner.

Basicially an `IOish m => m` is a `Monad` supporting arbitrary `IO` and exception handling. Usually this will simply be `IO` but we parametrise it in the exported API so users have the option to use a custom inner monad.

type MonadIOC m = MonadIO m

class MonadIOC m => MonadIO m where

Methods

liftIO :: IO a -> m a

data OutputStyle

Output style.

Constructors

LispStyle | S expression style.
PlainStyle | Plain textstyle.

Instances

Show OutputStyle |

newtype LineSeparator

The type for line separator. Historically, a Null string is used.

Constructors

LineSeparator String |

Instances

Show LineSeparator |

data FileMapping

Constructors

FileMapping |
Fields fmPath :: FilePath fmTemp :: Bool

Instances

Show FileMapping |

type FileMappingMap = Map FilePath FileMapping

data ProgramSource

Constructors

ProgramSourceUser |
ProgramSourceStack |

data Programs

Constructors

Programs |
Fields ghcProgram :: FilePath `ghc` program name. ghcPkgProgram :: FilePath `ghc-pkg` program name. cabalProgram :: FilePath `cabal` program name. stackProgram :: FilePath `stack` program name.

Instances

Show Programs |

data OutputOpts

Constructors

OutputOpts |
Fields ooptLogLevel :: GmLogLevel Verbosity ooptStyle :: OutputStyle ooptLineSeparator :: LineSeparator Line separator string. ooptLinePrefix :: Maybe (String, String) Stdout/err line multiplexing using prefix encoding. `fst` is stdout, `snd` is stderr prefix.

Instances

Show OutputOpts |

data Options

Constructors

Options |
Fields optOutput :: OutputOpts optPrograms :: Programs optGhcUserOptions :: [GHCOption] GHC command line options set on the `ghc-mod` command line optFileMappings :: [(FilePath, Maybe FilePath)]

Instances

Show Options |

defaultOptions :: Options

A default `Options`.

data Project

Constructors

CabalProject |
SandboxProject |
PlainProject |
StackProject StackEnv |

Instances

Eq Project |
Show Project |

isCabalHelperProject :: Project -> Bool

data StackEnv

Constructors

StackEnv |
Fields seDistDir :: FilePath seBinPath :: [FilePath] seSnapshotPkgDb :: FilePath seLocalPkgDb :: FilePath

Instances

Eq StackEnv |
Show StackEnv |

data Cradle

The environment where this library is used.

Constructors

Cradle |
Fields cradleProject :: Project cradleCurrentDir :: FilePath The directory where this library is executed. cradleRootDir :: FilePath The project root directory. cradleTempDir :: FilePath Per-Project temporary directory cradleCabalFile :: Maybe FilePath The file name of the found cabal file. cradleDistDir :: FilePath The build info directory.

Instances

Eq Cradle |
Show Cradle |

data GmStream

Constructors

GmOutStream |
GmErrStream |

Instances

Show GmStream |

data GhcModEnv

Constructors

GhcModEnv |
Fields gmOptions :: Options gmCradle :: Cradle

data GhcModOut

Constructors

GhcModOut |
Fields gmoOptions :: OutputOpts gmoChan :: Chan (Either (MVar ()) (GmStream, String))

data GhcModLog

Constructors

GhcModLog |
Fields gmLogLevel :: Maybe GmLogLevel gmLogVomitDump :: Last Bool gmLogMessages :: [(GmLogLevel, String, Doc)]

Instances

Show GhcModLog |
Monoid GhcModLog |
Monad m => MonadJournal GhcModLog (GmT m) |
GmEnv m => GmEnv (JournalT GhcModLog m) |
Monad m => GmLog (JournalT GhcModLog m) |

data GmGhcSession

Constructors

GmGhcSession |
Fields gmgsOptions :: ![GHCOption] gmgsSession :: !(IORef HscEnv)

data GhcModCaches

Constructors

GhcModCaches |
Fields gmcPackageDbStack :: CacheContents ChCacheData [GhcPkgDb] gmcMergedPkgOptions :: CacheContents ChCacheData [GHCOption] gmcComponents :: CacheContents ChCacheData [GmComponent GMCRaw ChEntrypoint] gmcResolvedComponents :: CacheContents [GmComponent GMCRaw (Set ModulePath)] (Map ChComponentName (GmComponent GMCResolved (Set ModulePath)))

data GhcModState

Constructors

GhcModState |
Fields gmGhcSession :: !(Maybe GmGhcSession) gmCaches :: !GhcModCaches gmMMappedFiles :: !FileMappingMap

Instances

Monad m => GmState (StateT GhcModState m) |

defaultGhcModState :: GhcModState

data GhcPkgDb

GHC package database flags.

Constructors

GlobalDb |
UserDb |
PackageDb String |

Instances

Eq GhcPkgDb |
Show GhcPkgDb |
Generic GhcPkgDb |
Binary GhcPkgDb |
type Rep GhcPkgDb |

type GHCOption = String

A single GHC command line option.

type IncludeDir = FilePath

An include directory for modules.

newtype Expression

Haskell expression.

Constructors

Expression |
Fields getExpression :: String

Instances

Eq Expression |
Ord Expression |
Show Expression |

newtype ModuleString

Module name.

Constructors

ModuleString |
Fields getModuleString :: String

Instances

Eq ModuleString |
Ord ModuleString |
Show ModuleString |
Binary ModuleString |
NFData ModuleString |

data GmLogLevel

Constructors

GmSilent |
GmPanic |
GmException |
GmError |
GmWarning |
GmInfo |
GmDebug |
GmVomit |

Instances

Bounded GmLogLevel |
Enum GmLogLevel |
Eq GmLogLevel |
Ord GmLogLevel |
Read GmLogLevel |
Show GmLogLevel |

data GmModuleGraph

Constructors

GmModuleGraph |
Fields gmgGraph :: Map ModulePath (Set ModulePath)

Instances

Eq GmModuleGraph |
Ord GmModuleGraph |
Read GmModuleGraph |
Show GmModuleGraph |
Generic GmModuleGraph |
Binary GmModuleGraph |
Monoid GmModuleGraph |
type Rep GmModuleGraph |

data GmComponentType

Constructors

GMCRaw |
GMCResolved |

data GmComponent t eps

Constructors

GmComponent |
Fields gmcHomeModuleGraph :: GmModuleGraph gmcName :: ChComponentName gmcGhcOpts :: [GHCOption] gmcGhcPkgOpts :: [GHCOption] gmcGhcSrcOpts :: [GHCOption] gmcGhcLangOpts :: [GHCOption] gmcRawEntrypoints :: ChEntrypoint gmcEntrypoints :: eps gmcSourceDirs :: [FilePath]

Instances

Functor (GmComponent t) |
Eq eps => Eq (GmComponent t eps) |
Ord eps => Ord (GmComponent t eps) |
Read eps => Read (GmComponent t eps) |
Show eps => Show (GmComponent t eps) |
Generic (GmComponent t eps) |
Binary eps => Binary (GmComponent t eps) |
type Rep (GmComponent t eps) |

data ModulePath

Constructors

ModulePath |
Fields mpModule :: ModuleName mpPath :: FilePath

Instances

Eq ModulePath |
Ord ModulePath |
Read ModulePath |
Show ModulePath |
Generic ModulePath |
Binary ModulePath |
type Rep ModulePath |

data GhcModError

Constructors

GMENoMsg | Unknown error
GMEString String | Some Error with a message. These are produced mostly by `fail` calls on GhcModT.
GMECabalConfigure GhcModError | Configuring a cabal project failed.
GMEStackConfigure GhcModError | Configuring a stack project failed.
GMEStackBootstrap GhcModError | Bootstrapping `stack` environment failed (process exited with failure)
GMECabalCompAssignment [(Either FilePath ModuleName, Set ChComponentName)] | Could not find a consistent component assignment for modules
GMEProcess String String [String] (Either Int GhcModError) | Launching an operating system process failed. Fields in order: function, command, arguments, (stdout, stderr, exitcode)
GMENoCabalFile | No cabal file found.
GMETooManyCabalFiles [FilePath] | Too many cabal files found.

Instances

Eq GhcModError |
Show GhcModError |
Exception GhcModError |
Error GhcModError |
Monad m => MonadError GhcModError (GmlT m) |
Monad m => MonadError GhcModError (GmT m) |
GmEnv m => GmEnv (ErrorT GhcModError m) |

data LintOpts

Options for "lintWith" function

Constructors

LintOpts |
Fields optLintHlintOpts :: [String] options that will be passed to hlint executable

Instances

Show LintOpts |

defaultLintOpts :: LintOpts

Default LintOpts instance

data BrowseOpts

Options for "browseWith" function

Constructors

BrowseOpts |
Fields optBrowseOperators :: Bool If `True`, "browseWith" also returns operators. optBrowseDetailed :: Bool If `True`, "browseWith" also returns types. optBrowseQualified :: Bool If `True`, "browseWith" will return fully qualified name

Instances

Show BrowseOpts |

defaultBrowseOpts :: BrowseOpts

Default BrowseOpts instance

lGmcResolvedComponents :: forall cat. ArrowApply cat => Lens cat GhcModCaches (CacheContents [GmComponent GMCRaw (Set ModulePath)] (Map ChComponentName (GmComponent GMCResolved (Set ModulePath))))

lGmcPackageDbStack :: forall cat. ArrowApply cat => Lens cat GhcModCaches (CacheContents ChCacheData [GhcPkgDb])

lGmcMergedPkgOptions :: forall cat. ArrowApply cat => Lens cat GhcModCaches (CacheContents ChCacheData [GHCOption])

lGmcComponents :: forall cat. ArrowApply cat => Lens cat GhcModCaches (CacheContents ChCacheData [GmComponent GMCRaw ChEntrypoint])

lGmMMappedFiles :: forall cat. ArrowApply cat => Lens cat GhcModState FileMappingMap

lGmGhcSession :: forall cat. ArrowApply cat => Lens cat GhcModState (Maybe GmGhcSession)

lGmCaches :: forall cat. ArrowApply cat => Lens cat GhcModState GhcModCaches

lOptPrograms :: forall cat. ArrowApply cat => Lens cat Options Programs

lOptOutput :: forall cat. ArrowApply cat => Lens cat Options OutputOpts

lOptGhcUserOptions :: forall cat. ArrowApply cat => Lens cat Options [GHCOption]

lOptFileMappings :: forall cat. ArrowApply cat => Lens cat Options [(FilePath, Maybe FilePath)]

lOoptStyle :: forall cat. ArrowApply cat => Lens cat OutputOpts OutputStyle

lOoptLogLevel :: forall cat. ArrowApply cat => Lens cat OutputOpts GmLogLevel

lOoptLineSeparator :: forall cat. ArrowApply cat => Lens cat OutputOpts LineSeparator

lOoptLinePrefix :: forall cat. ArrowApply cat => Lens cat OutputOpts (Maybe (String, String))

lStackProgram :: forall cat. ArrowApply cat => Lens cat Programs FilePath

lGhcProgram :: forall cat. ArrowApply cat => Lens cat Programs FilePath

lGhcPkgProgram :: forall cat. ArrowApply cat => Lens cat Programs FilePath

lCabalProgram :: forall cat. ArrowApply cat => Lens cat Programs FilePath

data ModuleName :: *

A ModuleName is essentially a simple string, e.g. `Data.List`.

Instances

Eq ModuleName |
Data ModuleName |
Ord ModuleName |
BinaryStringRep ModuleName |
Binary ModuleName |
Uniquable ModuleName |
Outputable ModuleName |

mkModuleName :: String -> ModuleName

moduleNameString :: ModuleName -> String