From 6f590a3f2cc26f89057e647966e863097c7d55bb Mon Sep 17 00:00:00 2001 From: hallgren Date: Fri, 29 Nov 2013 14:43:01 +0000 Subject: [PATCH] Move checkPredefError from GF.Compile.Compute.ConcreteLazy to GF.Grammar.Macros Also simplified its type. --- src/compiler/GF/Compile/Compute/ConcreteLazy.hs | 6 ------ src/compiler/GF/Compile/Optimize.hs | 4 ++-- src/compiler/GF/Grammar/Macros.hs | 6 ++++++ src/compiler/GFI.hs | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/compiler/GF/Compile/Compute/ConcreteLazy.hs b/src/compiler/GF/Compile/Compute/ConcreteLazy.hs index cef4c398c..67d21768b 100644 --- a/src/compiler/GF/Compile/Compute/ConcreteLazy.hs +++ b/src/compiler/GF/Compile/Compute/ConcreteLazy.hs @@ -519,12 +519,6 @@ getArgType t = case t of V ty _ -> return ty T (TComp ty) _ -> return ty _ -> fail (render (text "cannot get argument type of table" $$ nest 2 (ppTerm Unqualified 0 t))) - -checkPredefError :: SourceGrammar -> Term -> Err Term -checkPredefError sgr t = - case t of - Error s -> fail ("Error: "++s) - _ -> return t {- -- Old diff --git a/src/compiler/GF/Compile/Optimize.hs b/src/compiler/GF/Compile/Optimize.hs index e5289fe7b..bd75cbc2c 100644 --- a/src/compiler/GF/Compile/Optimize.hs +++ b/src/compiler/GF/Compile/Optimize.hs @@ -119,7 +119,7 @@ partEval opts = if flag optNewComp opts partEvalNew opts gr (context, val) trm = errIn (render (text "partial evaluation" <+> ppTerm Qualified 0 trm)) $ - checkPredefError gr trm + checkPredefError trm partEvalOld opts gr (context, val) trm = errIn (render (text "partial evaluation" <+> ppTerm Qualified 0 trm)) $ do let vars = map (\(bt,x,t) -> x) context @@ -130,7 +130,7 @@ partEvalOld opts gr (context, val) trm = errIn (render (text "partial evaluation trm3 <- if rightType trm2 then computeTerm gr subst trm2 -- compute twice?? else recordExpand val trm2 >>= computeTerm gr subst - trm4 <- checkPredefError gr trm3 + trm4 <- checkPredefError trm3 return $ mkAbs [(Explicit,v) | v <- vars] trm4 where -- don't eta expand records of right length (correct by type checking) diff --git a/src/compiler/GF/Grammar/Macros.hs b/src/compiler/GF/Grammar/Macros.hs index 6798b22d0..e516f0e47 100644 --- a/src/compiler/GF/Grammar/Macros.hs +++ b/src/compiler/GF/Grammar/Macros.hs @@ -225,6 +225,12 @@ isPredefConstant t = case t of Q (mod,_) | mod == cPredef || mod == cPredefAbs -> True _ -> False +checkPredefError :: Monad m => Term -> m Term +checkPredefError t = + case t of + Error s -> fail ("Error: "++s) + _ -> return t + cnPredef :: Ident -> Term cnPredef f = Q (cPredef,f) diff --git a/src/compiler/GFI.hs b/src/compiler/GFI.hs index 8fdc97ecc..070a95384 100644 --- a/src/compiler/GFI.hs +++ b/src/compiler/GFI.hs @@ -332,7 +332,7 @@ checkComputeTerm' new sgr t = do t1 <- if new then return (CN.normalForm (CN.resourceValues sgr) (L NoLoc identW) t) else computeConcrete sgr t - checkPredefError sgr t1 + checkPredefError t1 fetchCommand :: GFEnv -> IO String fetchCommand gfenv = do