ghc-session-0.1.2.1: Simplified GHC API

Safe HaskellNone
LanguageHaskell2010

Language.Haskell.Session.Session

Contents

Synopsis

Session

run :: (MonadIO m, MonadMask m, Functor m) => GhcT m a -> m a Source

Run a session with default config.

runWith :: Config -> Ghc a -> IO a Source

Run a session with custom GHC config.

Flags

setStrFlags :: GhcMonad m => [String] -> m () Source

Set ghc command line arguments.

Imports

setImports :: GhcMonad m => [Import] -> m () Source

Set imports and replace existing ones.

withImports :: (MonadMask m, GhcMonad m) => [Import] -> m a -> m a Source

Run a code with temporary imports.

GHC extensions

setFlags :: GhcMonad m => [ExtensionFlag] -> m () Source

Set GHC extension flags.

unsetFlags :: GhcMonad m => [ExtensionFlag] -> m () Source

Unset GHC extension flags.

withExtensionFlags :: (MonadMask m, GhcMonad m) => [ExtensionFlag] -> [ExtensionFlag] -> m a -> m a Source

Run a code with temporary GHC extension flags.

Expression evaluation

runStmt :: (MonadCatch m, GhcMonad m) => String -> m () Source

Run a statement as in ghci.

runDecls :: (MonadCatch m, GhcMonad m) => String -> m () Source

Run declarations as in Haskell source file.

runAssignment :: (MonadCatch m, GhcMonad m) => String -> String -> m () Source

Bind an expression to a variable using `let` syntax.

runAssignment' :: (MonadCatch m, GhcMonad m) => String -> String -> m () Source

Bind an expression to a variable using bind syntax. Expression must have type `IO a`.

interpret :: (MonadCatch m, GhcMonad m) => Typeable a => String -> m a Source

Evaluate an expression.

Context and DynFlags protection

sandboxDynFlags :: (MonadMask m, GhcMonad m) => m a -> m a Source

Run a code which can safely modify DynFlags - it will be restored on exit.

sandboxContext :: (MonadMask m, GhcMonad m) => m a -> m a Source

Run a code which can safely modify Context - it will be restored on exit.

interceptErrors :: (MonadCatch m, GhcMonad m) => m a -> m a Source

Restore session when exception will be raised.