summaryrefslogtreecommitdiff
path: root/compiler/utils
diff options
context:
space:
mode:
authorMax Bolingbroke <batterseapower@hotmail.com>2011-06-29 17:15:03 +0100
committerMax Bolingbroke <batterseapower@hotmail.com>2011-06-29 17:15:50 +0100
commitc15fef6b83bd594b6ae3b2e586fb07095f5fb995 (patch)
tree682c8e550ff05976b879ab08b9c92ddf3b33c94a /compiler/utils
parentaa40a7d3edba2635d43226f890f735083df7496d (diff)
downloadhaskell-c15fef6b83bd594b6ae3b2e586fb07095f5fb995.tar.gz
New functionality required for the supercompiler plugin
Diffstat (limited to 'compiler/utils')
-rw-r--r--compiler/utils/Outputable.lhs25
-rw-r--r--compiler/utils/UniqFM.lhs10
2 files changed, 34 insertions, 1 deletions
diff --git a/compiler/utils/Outputable.lhs b/compiler/utils/Outputable.lhs
index fc4d919473..8a0c62a2ed 100644
--- a/compiler/utils/Outputable.lhs
+++ b/compiler/utils/Outputable.lhs
@@ -596,6 +596,10 @@ keyword = bold
-- | Class designating that some type has an 'SDoc' representation
class Outputable a where
ppr :: a -> SDoc
+ pprPrec :: Rational -> a -> SDoc
+
+ ppr = pprPrec 0
+ pprPrec _ = ppr
\end{code}
\begin{code}
@@ -656,6 +660,27 @@ instance (Outputable a, Outputable b, Outputable c, Outputable d, Outputable e)
ppr d <> comma,
ppr e])
+instance (Outputable a, Outputable b, Outputable c, Outputable d, Outputable e, Outputable f) =>
+ Outputable (a, b, c, d, e, f) where
+ ppr (a,b,c,d,e,f) =
+ parens (sep [ppr a <> comma,
+ ppr b <> comma,
+ ppr c <> comma,
+ ppr d <> comma,
+ ppr e <> comma,
+ ppr f])
+
+instance (Outputable a, Outputable b, Outputable c, Outputable d, Outputable e, Outputable f, Outputable g) =>
+ Outputable (a, b, c, d, e, f, g) where
+ ppr (a,b,c,d,e,f,g) =
+ parens (sep [ppr a <> comma,
+ ppr b <> comma,
+ ppr c <> comma,
+ ppr d <> comma,
+ ppr e <> comma,
+ ppr f <> comma,
+ ppr g])
+
instance Outputable FastString where
ppr fs = ftext fs -- Prints an unadorned string,
-- no double quotes or anything
diff --git a/compiler/utils/UniqFM.lhs b/compiler/utils/UniqFM.lhs
index 7302b0295e..9c9fdc9bc4 100644
--- a/compiler/utils/UniqFM.lhs
+++ b/compiler/utils/UniqFM.lhs
@@ -64,7 +64,9 @@ import Outputable
import Compiler.Hoopl hiding (Unique)
+import Data.Function (on)
import qualified Data.IntMap as M
+import qualified Data.Foldable as Foldable
\end{code}
%************************************************************************
@@ -161,7 +163,13 @@ ufmToList :: UniqFM elt -> [(Unique, elt)]
%************************************************************************
\begin{code}
-newtype UniqFM ele = UFM (M.IntMap ele)
+newtype UniqFM ele = UFM { unUFM :: M.IntMap ele }
+
+instance Eq ele => Eq (UniqFM ele) where
+ (==) = (==) `on` unUFM
+
+instance Foldable.Foldable UniqFM where
+ foldMap f = Foldable.foldMap f . unUFM
emptyUFM = UFM M.empty
isNullUFM (UFM m) = M.null m