export minimum Monad stuff from GhcMod.
This commit is contained in:
@@ -15,7 +15,12 @@ module Language.Haskell.GhcMod (
|
||||
, GhcPkgDb
|
||||
, Symbol
|
||||
, SymbolDb
|
||||
, module Language.Haskell.GhcMod.Monad
|
||||
-- * Monad Types
|
||||
, GhcModT
|
||||
, IOish
|
||||
-- * Monad utilities
|
||||
, runGhcModT
|
||||
, withOptions
|
||||
-- * 'GhcMod' utilities
|
||||
, boot
|
||||
, browse
|
||||
|
||||
@@ -79,7 +79,7 @@ withLogger setDF body = ghandle sourceError $ do
|
||||
sourceError :: IOish m => SourceError -> GhcModT m (Either String String)
|
||||
sourceError err = do
|
||||
dflags <- G.getSessionDynFlags
|
||||
style <- toGhcMod getStyle
|
||||
style <- toGhcModT getStyle
|
||||
ret <- convert' (errBagToStrList dflags style . srcErrorMessages $ err)
|
||||
return $ Left ret
|
||||
|
||||
|
||||
@@ -23,12 +23,13 @@ module Language.Haskell.GhcMod.Monad (
|
||||
, withErrorHandler
|
||||
-- ** Conversion
|
||||
, liftGhcMod
|
||||
, toGhcMod
|
||||
, toGhcModT
|
||||
-- ** Accessing 'GhcModEnv' and 'GhcModState'
|
||||
, options
|
||||
, cradle
|
||||
, getMode
|
||||
, setMode
|
||||
, withOptions
|
||||
-- ** Exporting convenient modules
|
||||
, module Control.Monad.Reader.Class
|
||||
, module Control.Monad.Writer.Class
|
||||
@@ -274,8 +275,8 @@ withErrorHandler label = ghandle ignore
|
||||
exitSuccess
|
||||
|
||||
-- | This is only a transitional mechanism don't use it for new code.
|
||||
toGhcMod :: IOish m => Ghc a -> GhcModT m a
|
||||
toGhcMod a = do
|
||||
toGhcModT :: IOish m => Ghc a -> GhcModT m a
|
||||
toGhcModT a = do
|
||||
s <- gmGhcSession <$> ask
|
||||
liftIO $ unGhc a $ Session s
|
||||
|
||||
@@ -297,6 +298,15 @@ setMode mode = put $ GhcModState mode
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
withOptions :: IOish m => (Options -> Options) -> GhcModT m a -> GhcModT m a
|
||||
withOptions changeOpt action = local changeEnv action
|
||||
where
|
||||
changeEnv e = e { gmOptions = changeOpt opt }
|
||||
where
|
||||
opt = gmOptions e
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
instance (MonadBaseControl IO m) => MonadBase IO (GhcModT m) where
|
||||
liftBase = GhcModT . liftBase
|
||||
|
||||
|
||||
Reference in New Issue
Block a user