From 018c9838ed31571b699118ae75b1d62d5527fd77 Mon Sep 17 00:00:00 2001 From: hallgren Date: Wed, 20 Nov 2013 00:45:33 +0000 Subject: Reduced clutter in monadic code + Eliminated vairous ad-hoc coersion functions between specific monads (IO, Err, IOE, Check) in favor of more general lifting functions (liftIO, liftErr). + Generalized many basic monadic operations from specific monads to arbitrary monads in the appropriate class (MonadIO and/or ErrorMonad), thereby completely eliminating the need for lifting functions in lots of places. This can be considered a small step forward towards a cleaner compiler API and more malleable compiler code in general. --- src/compiler/GFI.hs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/compiler/GFI.hs') diff --git a/src/compiler/GFI.hs b/src/compiler/GFI.hs index 1a786a3d2..094b0c787 100644 --- a/src/compiler/GFI.hs +++ b/src/compiler/GFI.hs @@ -8,8 +8,7 @@ import GF.Command.Interpreter(CommandEnv(..),commands,mkCommandEnv,emptyCommandE import GF.Command.Commands(flags,options) import GF.Command.Abstract import GF.Command.Parse(readCommandLine,pCommand) -import GF.Data.ErrM -import GF.Data.Operations (chunks,err) +import GF.Data.Operations (Err(..),chunks,err,raise) import GF.Grammar hiding (Ident,isPrefixOf) import GF.Grammar.Analyse import GF.Grammar.Parser (runP, pExp) @@ -326,7 +325,7 @@ printException e = maybe (print e) (putStrLn . ioErrorText) (fromException e) checkComputeTerm = checkComputeTerm' False checkComputeTerm' new sgr t = do - mo <- maybe (Bad "no source grammar in scope") return $ greatestResource sgr + mo <- maybe (raise "no source grammar in scope") return $ greatestResource sgr ((t,_),_) <- runCheck $ do t <- renameSourceTerm sgr mo t inferLType sgr [] t t1 <- if new -- cgit v1.2.3