[commit: ghc] coercible: Outputable.isOrAre: "is" or "are" for correct grammar (1f17065)

git at git.haskell.org git at git.haskell.org
Fri Sep 13 23:48:15 CEST 2013


Repository : ssh://git@git.haskell.org/ghc

On branch  : coercible
Link       : http://ghc.haskell.org/trac/ghc/changeset/1f17065a9aa5391366fc2140d45d29deb1ae6e0b/ghc

>---------------------------------------------------------------

commit 1f17065a9aa5391366fc2140d45d29deb1ae6e0b
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Fri Sep 13 14:09:12 2013 +0200

    Outputable.isOrAre: "is" or "are" for correct grammar


>---------------------------------------------------------------

1f17065a9aa5391366fc2140d45d29deb1ae6e0b
 compiler/utils/Outputable.lhs |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/compiler/utils/Outputable.lhs b/compiler/utils/Outputable.lhs
index da8ffb3..f357208 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}
 
 




More information about the ghc-commits mailing list