From d3fca1d61020620ee4cf99ac2d56d871654e296c Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Tue, 15 Jan 2008 18:08:56 +0000 Subject: [PATCH] Moved showMaybe to the Utils module and added a similar showListCustom function --- common/Utils.hs | 7 +++++++ transformations/ArrayUsageCheckTest.hs | 4 ---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/common/Utils.hs b/common/Utils.hs index d6ba900..6f9f32f 100644 --- a/common/Utils.hs +++ b/common/Utils.hs @@ -265,3 +265,10 @@ zipMap f xs ys = Map.fromList $ mapMaybe f' (Set.elems allKeys) allKeys = Map.keysSet xs `Set.union` Map.keysSet ys f' k = transformMaybe ((,) k) $ f (Map.lookup k xs) (Map.lookup k ys) + +showMaybe :: (a -> String) -> Maybe a -> String +showMaybe showFunc (Just x) = "Just " ++ showFunc x +showMaybe _ Nothing = "Nothing" + +showListCustom :: (a -> String) -> [a] -> String +showListCustom showFunc list = "[" ++ concat (intersperse "," (map showFunc list)) ++ "]" diff --git a/transformations/ArrayUsageCheckTest.hs b/transformations/ArrayUsageCheckTest.hs index c4ee671..7dbe5a2 100644 --- a/transformations/ArrayUsageCheckTest.hs +++ b/transformations/ArrayUsageCheckTest.hs @@ -226,10 +226,6 @@ check s (ind, eq, ineq) = ++ "(VM after pruning was: " ++ showMaybe showTestAnswers (transformMaybe fst sapped) ++ ", ineqs: " ++ showMaybe showInequalities (transformMaybe snd sapped) ++ ")" -showMaybe :: (a -> String) -> Maybe a -> String -showMaybe f (Just x) = f x -showMaybe _ Nothing = "Nothing" - testMakeEquations :: Test testMakeEquations = TestList [