summaryrefslogtreecommitdiff
path: root/compiler/utils
diff options
context:
space:
mode:
authorJoachim Breitner <mail@joachim-breitner.de>2013-09-13 14:09:12 +0200
committerJoachim Breitner <mail@joachim-breitner.de>2013-09-13 21:57:45 +0200
commit1f17065a9aa5391366fc2140d45d29deb1ae6e0b (patch)
tree913a1747ade4ad68abd991b35589f92ff0f9309b /compiler/utils
parent81928d042c35c1ca87de525428646b22ca824ebd (diff)
downloadhaskell-1f17065a9aa5391366fc2140d45d29deb1ae6e0b.tar.gz
Outputable.isOrAre: "is" or "are" for correct grammar
Diffstat (limited to 'compiler/utils')
-rw-r--r--compiler/utils/Outputable.lhs11
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/utils/Outputable.lhs b/compiler/utils/Outputable.lhs
index da8ffb3f10..f357208077 100644
--- a/compiler/utils/Outputable.lhs
+++ b/compiler/utils/Outputable.lhs
@@ -32,7 +32,7 @@ module Outputable (
sep, cat,
fsep, fcat,
hang, punctuate, ppWhen, ppUnless,
- speakNth, speakNTimes, speakN, speakNOf, plural,
+ speakNth, speakNTimes, speakN, speakNOf, plural, isOrAre,
coloured, PprColour, colType, colCoerc, colDataCon,
colBinder, bold, keyword,
@@ -908,6 +908,15 @@ speakNTimes t | t == 1 = ptext (sLit "once")
plural :: [a] -> SDoc
plural [_] = empty -- a bit frightening, but there you are
plural _ = char 's'
+
+-- | Determines the form of to be appropriate for the length of a list:
+--
+-- > isOrAre [] = ptext (sLit "are")
+-- > isOrAre ["Hello"] = ptext (sLit "is")
+-- > isOrAre ["Hello", "World"] = ptext (sLit "are")
+isOrAre :: [a] -> SDoc
+isOrAre [_] = ptext (sLit "is")
+isOrAre _ = ptext (sLit "are")
\end{code}