From: simonpj Date: Mon, 11 Jul 2005 10:46:43 +0000 (+0000) Subject: [project @ 2005-07-11 10:46:42 by simonpj] X-Git-Tag: Initial_conversion_from_CVS_complete~382 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=1360bef3d03d7d93e6f14bec4462c8e30626eae6;p=ghc-hetmet.git [project @ 2005-07-11 10:46:42 by simonpj] Improvements to speakN, define speakNOf, move plural from TcSimplify --- diff --git a/ghc/compiler/typecheck/TcSimplify.lhs b/ghc/compiler/typecheck/TcSimplify.lhs index c23e798..187634a 100644 --- a/ghc/compiler/typecheck/TcSimplify.lhs +++ b/ghc/compiler/typecheck/TcSimplify.lhs @@ -2348,9 +2348,6 @@ groupErrs report_err (inst:insts) addInstLoc :: [Inst] -> Message -> Message addInstLoc insts msg = msg $$ nest 2 (pprInstLoc (instLoc (head insts))) -plural [x] = empty -plural xs = char 's' - addTopIPErrs :: [Name] -> [Inst] -> TcM () addTopIPErrs bndrs [] = return () diff --git a/ghc/compiler/utils/Outputable.lhs b/ghc/compiler/utils/Outputable.lhs index a12f46d..d337e7e 100644 --- a/ghc/compiler/utils/Outputable.lhs +++ b/ghc/compiler/utils/Outputable.lhs @@ -33,7 +33,7 @@ module Outputable ( sep, cat, fsep, fcat, hang, punctuate, - speakNth, speakNTimes, speakN, + speakNth, speakNTimes, speakN, speakNOf, plural, printSDoc, printErrs, printDump, printForC, printForAsm, printForUser, @@ -476,7 +476,8 @@ speakNth n = hcat [ int n, text suffix ] last_dig = n `rem` 10 speakN :: Int -> SDoc -speakN 1 = ptext SLIT("one") +speakN 0 = ptext SLIT("none") -- E.g. "he has none" +speakN 1 = ptext SLIT("one") -- E.g. "he has one" speakN 2 = ptext SLIT("two") speakN 3 = ptext SLIT("three") speakN 4 = ptext SLIT("four") @@ -484,10 +485,18 @@ speakN 5 = ptext SLIT("five") speakN 6 = ptext SLIT("six") speakN n = int n +speakNOf :: Int -> SDoc -> SDoc +speakNOf 0 d = ptext SLIT("no") <+> d <> char 's' -- E.g. "no arguments" +speakNOf 1 d = ptext SLIT("one") <+> d -- E.g. "one argument" +speakNOf n d = speakN n <+> d <> char 's' -- E.g. "three arguments" + speakNTimes :: Int {- >=1 -} -> SDoc speakNTimes t | t == 1 = ptext SLIT("once") | t == 2 = ptext SLIT("twice") - | otherwise = int t <+> ptext SLIT("times") + | otherwise = speakN t <+> ptext SLIT("times") + +plural [x] = empty +plural xs = char 's' \end{code}