From a1db6f989a322ca426f2a99301f6c7375c61b43b Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 28 Jan 2008 17:24:58 +0000 Subject: [PATCH] Added support for printing out a Set of Var using showCode --- checks/UsageCheckUtils.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/checks/UsageCheckUtils.hs b/checks/UsageCheckUtils.hs index 05568e0..9e297da 100644 --- a/checks/UsageCheckUtils.hs +++ b/checks/UsageCheckUtils.hs @@ -19,6 +19,7 @@ with this program. If not, see . module UsageCheckUtils (customVarCompare, Decl(..), emptyVars, getVarProc, labelFunctions, ParItems(..), transformParItems, Var(..), Vars(..), vars) where import Data.Generics hiding (GT) +import Data.List import Data.Maybe import qualified Data.Set as Set @@ -28,7 +29,7 @@ import FlowGraph import OrdAST() import ShowCode -newtype Var = Var A.Variable deriving (Show) +newtype Var = Var A.Variable deriving (Data, Show, Typeable) customVarCompare :: A.Variable -> A.Variable -> Ordering @@ -48,6 +49,13 @@ instance ShowOccam Var where instance ShowRain Var where showRain (Var v) = showRain v +instance ShowOccam (Set.Set Var) where + showOccamM s + = do ss <- mapM showOccamM (Set.toList s) + return $ "{" ++ concat (intersperse ", " ss) ++ "}" +instance ShowRain (Set.Set Var) where + showRain s = "{" ++ concat (intersperse ", " $ map showRain $ Set.toList s) ++ "}" + data Vars = Vars { readVars :: Set.Set Var ,writtenVars :: Set.Set Var