setMode and getMode
This commit is contained in:
parent
7b079896b1
commit
6d42354a5b
@ -12,7 +12,9 @@ module Language.Haskell.GhcMod.Monad (
|
|||||||
-- ** Environment, state and logging
|
-- ** Environment, state and logging
|
||||||
, GhcModEnv(..)
|
, GhcModEnv(..)
|
||||||
, newGhcModEnv
|
, newGhcModEnv
|
||||||
, GhcModState(..)
|
, GhcModState
|
||||||
|
, defaultState
|
||||||
|
, Mode(..)
|
||||||
, GhcModWriter
|
, GhcModWriter
|
||||||
-- * Monad utilities
|
-- * Monad utilities
|
||||||
, runGhcMod
|
, runGhcMod
|
||||||
@ -22,9 +24,11 @@ module Language.Haskell.GhcMod.Monad (
|
|||||||
-- ** Conversion
|
-- ** Conversion
|
||||||
, liftGhcMod
|
, liftGhcMod
|
||||||
, toGhcMod
|
, toGhcMod
|
||||||
-- ** Accessing 'GhcModEnv'
|
-- ** Accessing 'GhcModEnv' and 'GhcModState'
|
||||||
, options
|
, options
|
||||||
, cradle
|
, cradle
|
||||||
|
, getMode
|
||||||
|
, setMode
|
||||||
-- ** Exporting convenient modules
|
-- ** Exporting convenient modules
|
||||||
, module Control.Monad.Reader.Class
|
, module Control.Monad.Reader.Class
|
||||||
, module Control.Monad.Writer.Class
|
, module Control.Monad.Writer.Class
|
||||||
@ -101,10 +105,12 @@ data GhcModEnv = GhcModEnv {
|
|||||||
, gmCradle :: Cradle
|
, gmCradle :: Cradle
|
||||||
}
|
}
|
||||||
|
|
||||||
data GhcModState = GhcModState deriving (Eq,Show,Read)
|
data GhcModState = GhcModState Mode deriving (Eq,Show,Read)
|
||||||
|
|
||||||
|
data Mode = Simple | Intelligent deriving (Eq,Show,Read)
|
||||||
|
|
||||||
defaultState :: GhcModState
|
defaultState :: GhcModState
|
||||||
defaultState = GhcModState
|
defaultState = GhcModState Simple
|
||||||
|
|
||||||
type GhcModWriter = ()
|
type GhcModWriter = ()
|
||||||
|
|
||||||
@ -281,6 +287,16 @@ options = gmOptions <$> ask
|
|||||||
cradle :: IOish m => GhcModT m Cradle
|
cradle :: IOish m => GhcModT m Cradle
|
||||||
cradle = gmCradle <$> ask
|
cradle = gmCradle <$> ask
|
||||||
|
|
||||||
|
getMode :: IOish m => GhcModT m Mode
|
||||||
|
getMode = do
|
||||||
|
GhcModState mode <- get
|
||||||
|
return mode
|
||||||
|
|
||||||
|
setMode :: IOish m => Mode -> GhcModT m ()
|
||||||
|
setMode mode = put $ GhcModState mode
|
||||||
|
|
||||||
|
----------------------------------------------------------------
|
||||||
|
|
||||||
instance (MonadBaseControl IO m) => MonadBase IO (GhcModT m) where
|
instance (MonadBaseControl IO m) => MonadBase IO (GhcModT m) where
|
||||||
liftBase = GhcModT . liftBase
|
liftBase = GhcModT . liftBase
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user