From 87e64a804cbe5848d20f0555dedae42e1516cbbc Mon Sep 17 00:00:00 2001 From: hallgren Date: Thu, 13 Aug 2015 10:49:50 +0000 Subject: 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}. --- src/compiler/GF/Data/Utilities.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/compiler/GF/Data/Utilities.hs') diff --git a/src/compiler/GF/Data/Utilities.hs b/src/compiler/GF/Data/Utilities.hs index 792f7aa4a..eac315508 100644 --- a/src/compiler/GF/Data/Utilities.hs +++ b/src/compiler/GF/Data/Utilities.hs @@ -16,7 +16,7 @@ module GF.Data.Utilities(module GF.Data.Utilities, module PGF.Utilities) where import Data.Maybe import Data.List -import Control.Monad (MonadPlus(..),liftM) +import Control.Monad (MonadPlus(..),liftM,when) import PGF.Utilities -- * functions on lists @@ -136,6 +136,10 @@ mapBoth = map . apBoth whenMP :: MonadPlus m => Bool -> a -> m a whenMP b x = if b then return x else mzero +whenM bm m = flip when m =<< bm + +repeatM m = whenM m (repeatM m) + -- * functions on Maybes -- | Returns true if the argument is Nothing or Just [] -- cgit v1.2.3