Added a new setToMap function to Utils

This commit is contained in:
Neil Brown 2009-05-22 17:19:28 +00:00
parent 014f83d65d
commit 4f0ebbc672
2 changed files with 4 additions and 3 deletions

View File

@ -337,7 +337,7 @@ checkPlainVarUsage sharedAttr (m, p) = check p
where
addBK :: BK -> Vars -> m VarsBK
addBK bk vs
= do let read = Map.fromAscList $ zip (Set.toAscList $ readVars vs) (repeat bk)
= do let read = setToMap (readVars vs) bk
splitUsed <- splitEnds' $ Set.toList $ usedVars vs
splitWritten <- concatMapM splitEnds (Map.toList $ writtenVars vs) >>* Map.fromList
let used = Map.fromList (zip splitUsed (repeat ([], bk)))
@ -418,8 +418,7 @@ checkPlainVarUsage sharedAttr (m, p) = check p
examineVars' <- mapM (filterMapByKeyM (liftM not . isSharedType)) examineVars
checkCREW examineVars'
where
difference m s = m `Map.difference` (Map.fromAscList $ zip (Set.toAscList
s) (repeat ()))
difference m s = m `Map.difference` setToMap s ()
isSharedType :: Var -> m Bool
isSharedType v = do t <- astTypeOf v

View File

@ -433,3 +433,5 @@ replace (find, repl) big
then repl ++ replace (find, repl) (drop (length find) poss)
else head poss : replace (find, repl) (tail poss)
setToMap :: Ord k => Set.Set k -> v -> Map.Map k v
setToMap s v = Map.fromAscList $ zip (Set.toAscList s) (repeat v)