summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorCarrieMY <carrie.xmy@gmail.com>2021-07-25 12:20:13 +0800
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-07-28 13:20:17 -0400
commit7dc0dc9962e90ca8dcd01c547adab4f7c43d6090 (patch)
treeb95d911ea5c224a3b19f5f8100d044201f47cb11 /compiler
parent91eb18570fae4e1982e660f6dcb4f7b69de58cf2 (diff)
downloadhaskell-7dc0dc9962e90ca8dcd01c547adab4f7c43d6090.tar.gz
Fix type check error message grammar (fixes #20122)
Remove trailing spaces
Diffstat (limited to 'compiler')
-rw-r--r--compiler/GHC/Tc/Errors.hs4
-rw-r--r--compiler/GHC/Utils/Outputable.hs21
2 files changed, 22 insertions, 3 deletions
diff --git a/compiler/GHC/Tc/Errors.hs b/compiler/GHC/Tc/Errors.hs
index 766b88408d..a504fd44ea 100644
--- a/compiler/GHC/Tc/Errors.hs
+++ b/compiler/GHC/Tc/Errors.hs
@@ -2522,8 +2522,8 @@ mk_dict_err ctxt@(CEC {cec_encl = implics}) (ct, (matches, unifiers, unsafe_over
= vcat [ ppWhen lead_with_ambig $
text "Probable fix: use a type annotation to specify what"
<+> pprQuotedList ambig_tvs <+> text "should be."
- , text "These potential instance" <> plural unifiers
- <+> text "exist:"]
+ , thisOrThese unifiers <+> text "potential instance" <> plural unifiers
+ <+> text "exist" <> singular unifiers <> text ":"]
mb_patsyn_prov :: Maybe SDoc
mb_patsyn_prov
diff --git a/compiler/GHC/Utils/Outputable.hs b/compiler/GHC/Utils/Outputable.hs
index 7d0436f2f2..a6d20a2467 100644
--- a/compiler/GHC/Utils/Outputable.hs
+++ b/compiler/GHC/Utils/Outputable.hs
@@ -44,7 +44,7 @@ module GHC.Utils.Outputable (
fsep, fcat,
hang, hangNotEmpty, punctuate, ppWhen, ppUnless,
ppWhenOption, ppUnlessOption,
- speakNth, speakN, speakNOf, plural, isOrAre, doOrDoes, itsOrTheir,
+ speakNth, speakN, speakNOf, plural, singular, isOrAre, doOrDoes, itsOrTheir, thisOrThese,
unicodeSyntax,
coloured, keyword,
@@ -1425,6 +1425,15 @@ plural :: [a] -> SDoc
plural [_] = empty -- a bit frightening, but there you are
plural _ = char 's'
+-- | Determines the singular verb suffix appropriate for the length of a list:
+--
+-- > singular [] = empty
+-- > singular["Hello"] = char 's'
+-- > singular ["Hello", "World"] = empty
+singular :: [a] -> SDoc
+singular [_] = char 's'
+singular _ = empty
+
-- | Determines the form of to be appropriate for the length of a list:
--
-- > isOrAre [] = text "are"
@@ -1451,3 +1460,13 @@ doOrDoes _ = text "do"
itsOrTheir :: [a] -> SDoc
itsOrTheir [_] = text "its"
itsOrTheir _ = text "their"
+
+
+-- | Determines the form of subject appropriate for the length of a list:
+--
+-- > thisOrThese [x] = text "This"
+-- > thisOrThese [x,y] = text "These"
+-- > thisOrThese [] = text "These" -- probably avoid this
+thisOrThese :: [a] -> SDoc
+thisOrThese [_] = text "This"
+thisOrThese _ = text "These" \ No newline at end of file