on master help sign in
Rename ordinalize and make it easier to use on Index.ZeroBased
commit2410b83400dde39009abe4b07e88fe6e410f877c authorEvan Czaplicki <evancz@users.noreply.github.com> dateMon 23 Apr 2018, 00:25 (9 years ago) parent18e97e3
2 files changed+11−4
compiler/src/Reporting/Doc.hs+10−3 compiler/src/Reporting/Error/Pattern.hs+1−1
compiler/src/Reporting/Doc.hs+10−3
@@ -15,7 +15,8 @@ module Reporting.Doc
1515 , stack, reflow, commaSep
1616 , toSimpleNote, toSimpleHint, toFancyHint
1717 , link, fancyLink, reflowLink, makeLink
18− , args, moreArgs, ordinalize
18+ , args, moreArgs
19+ , ordinal, intToOrdinal
1920 , cycle
2021 )
2122 where
@@ -32,6 +33,7 @@ import qualified System.Console.ANSI.Types as Ansi
3233import System.IO (Handle)
3334import qualified Text.PrettyPrint.ANSI.Leijen as P
3435
36+import qualified Data.Index as Index
3537import qualified Elm.Compiler.Version as Compiler
3638import qualified Elm.Package as Pkg
3739import qualified Json.Encode as E
@@ -176,8 +178,13 @@ moreArgs n =
176178 show n <> " more" <> if n == 1 then " argument" else " arguments"
177179
178180
179−ordinalize :: Int -> String
180−ordinalize number =
181+ordinal :: Index.ZeroBased -> String
182+ordinal index =
183+ intToOrdinal (Index.toHuman index)
184+
185+
186+intToOrdinal :: Int -> String
187+intToOrdinal number =
181188 let
182189 remainder10 =
183190 number `mod` 10
compiler/src/Reporting/Error/Pattern.hs+1−1
@@ -27,7 +27,7 @@ toReport source err =
2727 Report.toCodeSnippet source caseRegion (Just patternRegion)
2828 (
2929 D.reflow $
30− "The " <> D.ordinalize index <> " pattern is redundant:"
30+ "The " <> D.intToOrdinal index <> " pattern is redundant:"
3131 ,
3232 D.reflow $
3333 "Any value with this shape will be handled by a previous\