on master help sign in
Rename ordinalize and make it easier to use on Index.ZeroBased
2410b83Evan Czaplicki
compiler/src/Reporting/Doc.hs+10−3
@@ -15,7 +15,8 @@ module Reporting.Doc
15 , stack, reflow, commaSep
15 , stack, reflow, commaSep
16 , toSimpleNote, toSimpleHint, toFancyHint
16 , toSimpleNote, toSimpleHint, toFancyHint
17 , link, fancyLink, reflowLink, makeLink
17 , link, fancyLink, reflowLink, makeLink
18− , args, moreArgs, ordinalize
18+ , args, moreArgs
19+ , ordinal, intToOrdinal
19 , cycle
20 , cycle
20 )
21 )
21 where
22 where
@@ -32,6 +33,7 @@ import qualified System.Console.ANSI.Types as Ansi
32import System.IO (Handle)
33import System.IO (Handle)
33import qualified Text.PrettyPrint.ANSI.Leijen as P
34import qualified Text.PrettyPrint.ANSI.Leijen as P
34
35
36+import qualified Data.Index as Index
35import qualified Elm.Compiler.Version as Compiler
37import qualified Elm.Compiler.Version as Compiler
36import qualified Elm.Package as Pkg
38import qualified Elm.Package as Pkg
37import qualified Json.Encode as E
39import qualified Json.Encode as E
@@ -176,8 +178,13 @@ moreArgs n =
176 show n <> " more" <> if n == 1 then " argument" else " arguments"
178 show n <> " more" <> if n == 1 then " argument" else " arguments"
177
179
178
180
181+ordinal :: Index.ZeroBased -> String
182+ordinal index =
183+ intToOrdinal (Index.toHuman index)
184+
185+
179−ordinalize :: Int -> String
186+intToOrdinal :: Int -> String
180−ordinalize number =
187+intToOrdinal number =
181 let
188 let
182 remainder10 =
189 remainder10 =
183 number `mod` 10
190 number `mod` 10
compiler/src/Reporting/Error/Pattern.hs+1−1
@@ -27,7 +27,7 @@ toReport source err =
27 Report.toCodeSnippet source caseRegion (Just patternRegion)
27 Report.toCodeSnippet source caseRegion (Just patternRegion)
28 (
28 (
29 D.reflow $
29 D.reflow $
30− "The " <> D.ordinalize index <> " pattern is redundant:"
30+ "The " <> D.intToOrdinal index <> " pattern is redundant:"
31 ,
31 ,
32 D.reflow $
32 D.reflow $
33 "Any value with this shape will be handled by a previous\
33 "Any value with this shape will be handled by a previous\