From 091acfa8480a4726bd279feb689944b7d1fd3f2e Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Sat, 7 Feb 2009 18:45:56 +0000 Subject: [PATCH] Added a new helper function to Utils for joining pairs of lists with pairs of lists --- checks/ArrayUsageCheck.hs | 2 +- common/Utils.hs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/checks/ArrayUsageCheck.hs b/checks/ArrayUsageCheck.hs index 93ee02f..85251d1 100644 --- a/checks/ArrayUsageCheck.hs +++ b/checks/ArrayUsageCheck.hs @@ -418,7 +418,7 @@ makeSingleEq f e desc = (lift (flatten e) >>* f) >>= makeEquation e ([{-TODO-}], -- | A helper function for joining two problems accumProblem :: (EqualityProblem,InequalityProblem) -> (EqualityProblem,InequalityProblem) -> (EqualityProblem,InequalityProblem) -accumProblem (a,b) (c,d) = (a ++ c, b ++ d) +accumProblem = concatPair -- | Given a list of (written,read) expressions, an expression representing the upper array bound, returns either an error diff --git a/common/Utils.hs b/common/Utils.hs index acf572b..46569df 100644 --- a/common/Utils.hs +++ b/common/Utils.hs @@ -117,6 +117,10 @@ combineCompare (LT:_) = LT combineCompare (GT:_) = GT combineCompare (EQ:os) = combineCompare os +-- Takes two pairs of lists, returns a pair with the fsts join and the snds joined +concatPair :: ([a], [b]) -> ([a], [b]) -> ([a], [b]) +concatPair a b = (fst a ++ fst b, snd a ++ snd b) + -- | Maps two functions over members of a pair transformPair :: (x -> a) -> (y -> b) -> (x,y) -> (a,b) transformPair f g (x,y) = (f x, g y)