summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2012-06-25 15:55:59 +0000
committerhallgren <hallgren@chalmers.se>2012-06-25 15:55:59 +0000
commita38efe70c6aa340242cb25c3b8fd2845f98b1bb8 (patch)
tree3a9cbaea58f789407cf6aa30494ce63a1f7f5f49 /src/compiler
parentbc8ce3f7cae211314f2e64fb4cbe4259c47f4129 (diff)
Fix for warning messages from checkMapRecover
Reimplemented it with the new function accumulateError. Also keeping the formatting of errors and warnings unchanged for now, to avoid potentially causing problems in the GF Eclipse Plugin.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/GF/Infra/CheckM.hs15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/compiler/GF/Infra/CheckM.hs b/src/compiler/GF/Infra/CheckM.hs
index e29dbb321..ea07d06c4 100644
--- a/src/compiler/GF/Infra/CheckM.hs
+++ b/src/compiler/GF/Infra/CheckM.hs
@@ -78,10 +78,13 @@ accumulateError chk a =
-- | Run an error check, report errors and warnings
runCheck :: Check a -> Err (a,String)
runCheck c =
- case unCheck c [] ([],[]) of
- (([],ws),Success v) -> Ok (v, render (vcat (reverse ws)))
- ((es,ws),Success v) -> Bad ( render (vcat (reverse (es++ws))))
- ((es,ws),Fail msg) -> Bad ( render (vcat (reverse (msg:es++ws))))
+ case unCheck c [] ([],[]) of
+ (([],ws),Success v) -> Ok (v,render (list ws))
+ (msgs ,Success v) -> bad msgs
+ ((es,ws),Fail e) -> bad ((e:es),ws)
+ where
+ bad (es,ws) = Bad (render $ list ws $$ list es)
+ list = vcat . reverse
checkMap :: (Ord a) => (a -> b -> Check b) -> Map.Map a b -> Check (Map.Map a b)
checkMap f map = do xs <- mapM (\(k,v) -> do v <- f k v
@@ -89,6 +92,9 @@ checkMap f map = do xs <- mapM (\(k,v) -> do v <- f k v
return (Map.fromAscList xs)
checkMapRecover :: (Ord a) => (a -> b -> Check b) -> Map.Map a b -> Check (Map.Map a b)
+checkMapRecover f mp = checkMap f' mp
+ where f' key info = accumulateError (f key) info
+{-
checkMapRecover f mp = do
let xs = map (\ (k,v) -> (k,runCheck (f k v))) (Map.toList mp)
case [s | (_,Bad s) <- xs] of
@@ -97,6 +103,7 @@ checkMapRecover f mp = do
let (kx,ss) = unzip [((k,x),s) | (k, Ok (x,s)) <- xs]
if not (all null ss) then checkWarn (text (unlines ss)) else return ()
return (Map.fromAscList kx)
+-}
checkErr :: Err a -> Check a
checkErr (Ok x) = return x