mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-26 13:02:50 -06:00
GF Shell: refactoring for improved modularity and reusability:
+ Generalize the CommandInfo type by parameterizing it on the monad
instead of just the environment.
+ Generalize the commands defined in
GF.Command.{Commands,Commands2,CommonCommands,SourceCommands,HelpCommand}
to work in any monad that supports the needed operations.
+ Liberate GF.Command.Interpreter from the IO monad.
Also, move the current PGF from CommandEnv to GFEnv in
GF.Interactive, making the command interpreter even more generic.
+ Use a state monad to maintain the state of the interpreter in
GF.{Interactive,Interactive2}.
This commit is contained in:
@@ -34,8 +34,9 @@ import System.CPUTime
|
||||
--import System.Cmd
|
||||
import Text.Printf
|
||||
--import Control.Applicative(Applicative(..))
|
||||
import Control.Monad
|
||||
import Control.Monad(when,liftM,foldM)
|
||||
import Control.Monad.Trans(MonadIO(..))
|
||||
import Control.Monad.State(StateT,lift)
|
||||
import Control.Exception(evaluate)
|
||||
|
||||
--putIfVerb :: MonadIO io => Options -> String -> io ()
|
||||
@@ -201,6 +202,13 @@ instance Output IOE where
|
||||
putStrLnE = liftIO . putStrLnE
|
||||
putStrE = liftIO . putStrE
|
||||
-}
|
||||
|
||||
instance Output m => Output (StateT s m) where
|
||||
ePutStr = lift . ePutStr
|
||||
ePutStrLn = lift . ePutStrLn
|
||||
putStrE = lift . putStrE
|
||||
putStrLnE = lift . putStrLnE
|
||||
|
||||
--putPointE :: Verbosity -> Options -> String -> IO a -> IO a
|
||||
putPointE v opts msg act = do
|
||||
when (verbAtLeast opts v) $ putStrE msg
|
||||
|
||||
Reference in New Issue
Block a user