Skip to content

Commit

Permalink
Merge pull request #5192 from unisonweb/topic/numerals
Browse files Browse the repository at this point in the history
  • Loading branch information
aryairani authored Jul 9, 2024
2 parents 60bb91a + 22d4b26 commit 223df40
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 2 deletions.
5 changes: 5 additions & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,14 @@ extra-deps:
- recover-rtti-0.4.2@sha256:c179a303921126d8d782264e14f386c96e54a270df74be002e4c4ec3c8c7aebd,4529
- lsp-2.2.0.0@sha256:82fbf4b69d94d8d22543be71f89986b3e90050032d671fb3de3f8253ea1e5b6f,3550
- lsp-types-2.0.2.0@sha256:a9a51c3cea0726d91fe63fa0670935ee720f7b31bc3f3b33b2483fc538152677,29421
- numerals-0.4.1@sha256:f138b4a0efbde3b3c6cbccb788eff683cb8a5d046f449729712fd174c5ee8a78,11430
- row-types-1.0.1.2@sha256:4d4c7cb95d06a32b28ba977852d52a26b4c1f695ef083a6fd874ab6d79933b64,3071
- network-udp-0.0.0

allow-newer: true
allow-newer-deps:
- numerals

ghc-options:
# All packages
"$locals": -Wall -Werror -Wno-name-shadowing -Wno-missing-pattern-synonym-signatures -fprint-expanded-synonyms -fwrite-ide-info #-freverse-errors
Expand Down
7 changes: 7 additions & 0 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ packages:
size: 45527
original:
hackage: lsp-types-2.0.2.0@sha256:a9a51c3cea0726d91fe63fa0670935ee720f7b31bc3f3b33b2483fc538152677,29421
- completed:
hackage: numerals-0.4.1@sha256:f138b4a0efbde3b3c6cbccb788eff683cb8a5d046f449729712fd174c5ee8a78,11430
pantry-tree:
sha256: c616791b08f1792fd1d4ca03c6d2c773dedb25b24b66454c97864aefd85a5d0a
size: 13751
original:
hackage: numerals-0.4.1@sha256:f138b4a0efbde3b3c6cbccb788eff683cb8a5d046f449729712fd174c5ee8a78,11430
- completed:
hackage: row-types-1.0.1.2@sha256:4d4c7cb95d06a32b28ba977852d52a26b4c1f695ef083a6fd874ab6d79933b64,3071
pantry-tree:
Expand Down
1 change: 1 addition & 0 deletions unison-cli/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ dependencies:
- network-udp
- network-uri
- nonempty-containers
- numerals
- open-browser
- optparse-applicative >= 0.16.1.0
- pretty-simple
Expand Down
8 changes: 7 additions & 1 deletion unison-cli/src/Unison/CommandLine/InputPatterns.hs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ import System.Console.Haskeline.Completion (Completion (Completion))
import System.Console.Haskeline.Completion qualified as Haskeline
import System.Console.Haskeline.Completion qualified as Line
import Text.Megaparsec qualified as Megaparsec
import Text.Numeral (defaultInflection)
import Text.Numeral.Language.ENG qualified as Numeral
import U.Codebase.HashTags (CausalHash (..))
import U.Codebase.Sqlite.DbId (ProjectBranchId)
import U.Codebase.Sqlite.Project qualified as Sqlite
Expand Down Expand Up @@ -342,7 +344,11 @@ wrongStructuredArgument expected actual =

wrongArgsLength :: Text -> [a] -> Either (P.Pretty CT.ColorText) b
wrongArgsLength expected args =
Left . P.text $ "I expected " <> expected <> ", but received " <> Text.pack (show $ length args) <> "."
let foundCount =
case length args of
0 -> "none"
n -> fromMaybe (tShow n) $ Numeral.us_cardinal defaultInflection n
in Left . P.text $ "I expected " <> expected <> ", but received " <> foundCount <> "."

patternName :: InputPattern -> P.Pretty P.ColorText
patternName = fromString . I.patternName
Expand Down
3 changes: 3 additions & 0 deletions unison-cli/unison-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ library
, network-udp
, network-uri
, nonempty-containers
, numerals
, open-browser
, optparse-applicative >=0.16.1.0
, pretty-simple
Expand Down Expand Up @@ -371,6 +372,7 @@ executable transcripts
, network-udp
, network-uri
, nonempty-containers
, numerals
, open-browser
, optparse-applicative >=0.16.1.0
, pretty-simple
Expand Down Expand Up @@ -519,6 +521,7 @@ test-suite cli-tests
, network-udp
, network-uri
, nonempty-containers
, numerals
, open-browser
, optparse-applicative >=0.16.1.0
, pretty-simple
Expand Down
2 changes: 1 addition & 1 deletion unison-src/transcripts/input-parse-errors.output.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ scratch/main> update arg
Sorry, I wasn’t sure how to process your request:
I expected no arguments, but received 1.
I expected no arguments, but received one.
You can run `help update` for more information on using
`update`.
Expand Down

0 comments on commit 223df40

Please sign in to comment.