summaryrefslogtreecommitdiff
path: root/compiler/utils
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/utils')
-rw-r--r--compiler/utils/Outputable.hs22
-rw-r--r--compiler/utils/UniqFM.hs3
2 files changed, 24 insertions, 1 deletions
diff --git a/compiler/utils/Outputable.hs b/compiler/utils/Outputable.hs
index 93645d38fe..cb42d75327 100644
--- a/compiler/utils/Outputable.hs
+++ b/compiler/utils/Outputable.hs
@@ -32,7 +32,8 @@ module Outputable (
sep, cat,
fsep, fcat,
hang, punctuate, ppWhen, ppUnless,
- speakNth, speakNTimes, speakN, speakNOf, plural, isOrAre,
+ speakNth, speakNTimes, speakN, speakNOf, plural,
+ thirdPerson, isOrAre, doOrDoes,
coloured, PprColour, colType, colCoerc, colDataCon,
colBinder, bold, keyword,
@@ -994,6 +995,16 @@ plural :: [a] -> SDoc
plural [_] = empty -- a bit frightening, but there you are
plural _ = char 's'
+-- | Determines the suffix to use in 3rd person singular depending on the length
+-- of a list:
+--
+-- > thirdPerson [] = empty
+-- > thirdPerson ["Hello"] = char 's'
+-- > thirdPerson ["Hello", "World"] = empty
+thirdPerson :: [a] -> SDoc
+thirdPerson [_] = char 's'
+thirdPerson _ = empty
+
-- | Determines the form of to be appropriate for the length of a list:
--
-- > isOrAre [] = ptext (sLit "are")
@@ -1003,6 +1014,15 @@ isOrAre :: [a] -> SDoc
isOrAre [_] = ptext (sLit "is")
isOrAre _ = ptext (sLit "are")
+-- | Determines the form of to do appropriate for the length of a list:
+--
+-- > doOrDoes [] = ptext (sLit "do")
+-- > doOrDoes ["Hello"] = ptext (sLit "does")
+-- > doOrDoes ["Hello", "World"] = ptext (sLit "do")
+doOrDoes :: [a] -> SDoc
+doOrDoes [_] = ptext (sLit "does")
+doOrDoes _ = ptext (sLit "do")
+
{-
************************************************************************
* *
diff --git a/compiler/utils/UniqFM.hs b/compiler/utils/UniqFM.hs
index e24c7173b4..db578c37d0 100644
--- a/compiler/utils/UniqFM.hs
+++ b/compiler/utils/UniqFM.hs
@@ -54,6 +54,7 @@ module UniqFM (
minusUFM,
intersectUFM,
intersectUFM_C,
+ disjointUFM,
foldUFM, foldUFM_Directly,
mapUFM, mapUFM_Directly,
elemUFM, elemUFM_Directly,
@@ -164,6 +165,7 @@ minusUFM :: UniqFM elt1 -> UniqFM elt2 -> UniqFM elt1
intersectUFM :: UniqFM elt -> UniqFM elt -> UniqFM elt
intersectUFM_C :: (elt1 -> elt2 -> elt3)
-> UniqFM elt1 -> UniqFM elt2 -> UniqFM elt3
+disjointUFM :: UniqFM elt1 -> UniqFM elt2 -> Bool
foldUFM :: (elt -> a -> a) -> a -> UniqFM elt -> a
foldUFM_Directly:: (Unique -> elt -> a -> a) -> a -> UniqFM elt -> a
@@ -262,6 +264,7 @@ plusUFM_CD f (UFM xm) dx (UFM ym) dy
minusUFM (UFM x) (UFM y) = UFM (M.difference x y)
intersectUFM (UFM x) (UFM y) = UFM (M.intersection x y)
intersectUFM_C f (UFM x) (UFM y) = UFM (M.intersectionWith f x y)
+disjointUFM (UFM x) (UFM y) = M.null (M.intersection x y)
foldUFM k z (UFM m) = M.fold k z m
foldUFM_Directly k z (UFM m) = M.foldWithKey (k . getUnique) z m