Safe Haskell | None |
---|---|
Language | Haskell2010 |
The ghc-mod library.
- data Cradle = Cradle {}
- data ProjectType
- findCradle :: IO Cradle
- data Options = Options {
- outputStyle :: OutputStyle
- lineSeparator :: LineSeparator
- linePrefix :: Maybe (String, String)
- logLevel :: GmLogLevel
- ghcProgram :: FilePath
- ghcPkgProgram :: FilePath
- cabalProgram :: FilePath
- ghcUserOptions :: [GHCOption]
- operators :: Bool
- detailed :: Bool
- qualified :: Bool
- hlintOpts :: [String]
- newtype LineSeparator = LineSeparator String
- data OutputStyle
- defaultOptions :: Options
- data GmLogLevel
- increaseLogLevel :: GmLogLevel -> GmLogLevel
- decreaseLogLevel :: GmLogLevel -> GmLogLevel
- gmSetLogLevel :: GmLog m => GmLogLevel -> m ()
- gmLog :: (MonadIO m, GmLog m, GmEnv m) => GmLogLevel -> String -> Doc -> m ()
- data ModuleString
- newtype Expression = Expression {}
- data GhcPkgDb
- type Symbol = String
- data SymbolDb
- data GhcModError
- = GMENoMsg
- | GMEString String
- | GMECabalConfigure GhcModError
- | GMECabalFlags GhcModError
- | GMECabalComponent ChComponentName
- | GMECabalCompAssignment [(Either FilePath ModuleName, Set ChComponentName)]
- | GMEProcess String [String] (Either (String, String, Int) GhcModError)
- | GMENoCabalFile
- | GMETooManyCabalFiles [FilePath]
- | GMECabalStateFile GMConfigStateFileError
- data GhcModT m a
- type IOish m = (Functor m, MonadIO m, MonadBaseControl IO m, ExceptionMonad m)
- runGhcModT :: IOish m => Options -> GhcModT m a -> m (Either GhcModError a, GhcModLog)
- withOptions :: GmEnv m => (Options -> Options) -> m a -> m a
- dropSession :: IOish m => GhcModT m ()
- boot :: IOish m => GhcModT m String
- browse :: forall m. IOish m => String -> GhcModT m String
- check :: IOish m => [FilePath] -> GhcModT m (Either String String)
- checkSyntax :: IOish m => [FilePath] -> GhcModT m String
- debugInfo :: IOish m => GhcModT m String
- componentInfo :: IOish m => [String] -> GhcModT m String
- expandTemplate :: IOish m => [FilePath] -> GhcModT m String
- info :: IOish m => FilePath -> Expression -> GhcModT m String
- lint :: IOish m => FilePath -> GhcModT m String
- pkgDoc :: IOish m => String -> GhcModT m String
- rootInfo :: IOish m => GhcModT m String
- types :: IOish m => FilePath -> Int -> Int -> GhcModT m String
- splits :: IOish m => FilePath -> Int -> Int -> GhcModT m String
- sig :: IOish m => FilePath -> Int -> Int -> GhcModT m String
- refine :: IOish m => FilePath -> Int -> Int -> Expression -> GhcModT m String
- auto :: IOish m => FilePath -> Int -> Int -> GhcModT m String
- modules :: (IOish m, GmEnv m, GmState m, GmLog m) => m String
- languages :: IOish m => GhcModT m String
- flags :: IOish m => GhcModT m String
- findSymbol :: IOish m => Symbol -> GhcModT m String
- lookupSymbol :: IOish m => Symbol -> SymbolDb -> GhcModT m String
- dumpSymbol :: IOish m => FilePath -> GhcModT m String
- loadSymbolDb :: IOish m => FilePath -> GhcModT m SymbolDb
- isOutdated :: IOish m => SymbolDb -> GhcModT m Bool
- gmPutStr :: (MonadIO m, GmEnv m) => String -> m ()
- gmErrStr :: (MonadIO m, GmEnv m) => String -> m ()
- gmPutStrLn :: (MonadIO m, GmEnv m) => String -> m ()
- gmErrStrLn :: (MonadIO m, GmEnv m) => String -> m ()
- gmUnsafePutStrLn :: MonadIO m => Options -> String -> m ()
- gmUnsafeErrStrLn :: MonadIO m => Options -> String -> m ()
Cradle
The environment where this library is used.
Cradle | |
|
findCradle :: IO Cradle Source
Finding Cradle
.
Find a cabal file by tracing ancestor directories.
Find a sandbox according to a cabal sandbox config
in a cabal directory.
Options
Options | |
|
newtype LineSeparator Source
The type for line separator. Historically, a Null string is used.
defaultOptions :: Options Source
A default Options
.
Logging
data GmLogLevel Source
gmSetLogLevel :: GmLog m => GmLogLevel -> m () Source
gmLog :: (MonadIO m, GmLog m, GmEnv m) => GmLogLevel -> String -> Doc -> m () Source
>>>
Just GmDebug <= Nothing
False>>>
Just GmException <= Just GmDebug
True>>>
Just GmDebug <= Just GmException
False
Types
data ModuleString Source
Module name.
newtype Expression Source
Haskell expression.
GHC package database flags.
data GhcModError Source
GMENoMsg | Unknown error |
GMEString String | Some Error with a message. These are produced mostly by
|
GMECabalConfigure GhcModError | Configuring a cabal project failed. |
GMECabalFlags GhcModError | Retrieval of the cabal configuration flags failed. |
GMECabalComponent ChComponentName | Cabal component could not be found |
GMECabalCompAssignment [(Either FilePath ModuleName, Set ChComponentName)] | Could not find a consistent component assignment for modules |
GMEProcess String [String] (Either (String, String, Int) GhcModError) | Launching an operating system process failed. Fields in order: command, arguments, (stdout, stderr, exitcode) |
GMENoCabalFile | No cabal file found. |
GMETooManyCabalFiles [FilePath] | Too many cabal files found. |
GMECabalStateFile GMConfigStateFileError | Reading Cabal's state configuration file falied somehow. |
Eq GhcModError | |
Show GhcModError | |
Exception GhcModError | |
Error GhcModError | |
Typeable * GhcModError | |
Monad m => MonadError GhcModError (GmlT m) | |
Monad m => MonadError GhcModError (GhcModT m) |
Monad Types
This is basically a newtype wrapper around StateT
, ErrorT
, JournalT
and ReaderT
with custom instances for GhcMonad
and it's constraints that
means you can run (almost) all functions from the GHC API on top of GhcModT
transparently.
The inner monad m
should have instances for MonadIO
and
MonadBaseControl
IO
, in the common case this is simply IO
. Most mtl
monads already have MonadBaseControl
IO
instances, see the
monad-control
package.
MonadTrans GhcModT | |
MonadTransControl GhcModT | |
MonadBaseControl IO m => MonadBase IO (GhcModT m) | |
MonadBaseControl IO m => MonadBaseControl IO (GhcModT m) | |
Monad m => MonadJournal GhcModLog (GhcModT m) | |
Monad m => MonadError GhcModError (GhcModT m) | |
MonadReader r m => MonadReader r (GhcModT m) | |
MonadState s m => MonadState s (GhcModT m) | |
(Monoid w, MonadWriter w m) => MonadWriter w (GhcModT m) | |
(Monad m, Functor m) => Alternative (GhcModT m) | |
Monad m => Monad (GhcModT m) | |
Functor m => Functor (GhcModT m) | |
Monad m => MonadPlus (GhcModT m) | |
(Monad m, Functor m) => Applicative (GhcModT m) | |
(MonadIO m, MonadBaseControl IO m) => ExceptionMonad (GhcModT m) | |
MonadIO m => MonadIO (GhcModT m) | |
MonadIOC m => MonadIO (GhcModT m) | |
Monad m => GmLog (GhcModT m) | |
Monad m => GmEnv (GhcModT m) | |
type StT GhcModT a = (Either GhcModError (a, GhcModState), GhcModLog) | |
type StM (GhcModT m) a = StM (StateT GhcModState (ErrorT GhcModError (JournalT GhcModLog (ReaderT GhcModEnv m)))) a |
type IOish m = (Functor m, MonadIO m, MonadBaseControl IO m, ExceptionMonad m) Source
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.
Monad utilities
runGhcModT :: IOish m => Options -> GhcModT m a -> m (Either GhcModError a, GhcModLog) Source
Run a GhcModT m
computation.
withOptions :: GmEnv m => (Options -> Options) -> m a -> m a Source
dropSession :: IOish m => GhcModT m () Source
Drop the currently active GHC session, the next that requires a GHC session will initialize a new one.
GhcMod
utilities
Checking syntax of a target file using GHC. Warnings and errors are returned.
Checking syntax of a target file using GHC. Warnings and errors are returned.
Expanding Haskell Template.
:: IOish m | |
=> FilePath | A target file. |
-> Expression | A Haskell expression. |
-> GhcModT m String |
Obtaining information of a target expression. (GHCi's info:)
Checking syntax of a target file using hlint. Warnings and errors are returned.
pkgDoc :: IOish m => String -> GhcModT m String Source
Obtaining the package name and the doc path of a module.
Obtaining type of a target expression. (GHCi's type:)
Splitting a variable in a equation.
Create a initial body from a signature.
findSymbol :: IOish m => Symbol -> GhcModT m String Source
Looking up SymbolDb
with Symbol
to [ModuleString
]
which will be concatenated. loadSymbolDb
is called internally.
lookupSymbol :: IOish m => Symbol -> SymbolDb -> GhcModT m String Source
Looking up SymbolDb
with Symbol
to [ModuleString
]
which will be concatenated.
dumpSymbol :: IOish m => FilePath -> GhcModT m String Source
Dumping a set of (Symbol
,[ModuleString
]) to a file
if the file does not exist or is invalid.
The file name is printed.
SymbolDb
loadSymbolDb :: IOish m => FilePath -> GhcModT m SymbolDb Source
Loading a file and creates SymbolDb
.
Output
gmPutStrLn :: (MonadIO m, GmEnv m) => String -> m () Source
gmErrStrLn :: (MonadIO m, GmEnv m) => String -> m () Source
gmUnsafePutStrLn :: MonadIO m => Options -> String -> m () Source
Only use these when you're sure there are no other writers on stdout
gmUnsafeErrStrLn :: MonadIO m => Options -> String -> m () Source
Only use these when you're sure there are no other writers on stdout