AJChapman / formatting

Format strings type-safely with combinators
BSD 3-Clause "New" or "Revised" License
164 stars 39 forks source link

ords behaviour does not match the documentation #48

Closed cleverca22 closed 6 years ago

cleverca22 commented 6 years ago

according to the docs: Add a suffix to an integral, e.g. 1st, 2nd, 3rd, 21st.

λ> format ("prefix "%ords%" suffix") (1 :: Int)
"prefix 1.0st suffix"
"prefix 2.0nd suffix"
"prefix 3.0rd suffix"
"prefix 21.0st suffix"
λ> :q
Leaving GHCi.

[nix-shell:~/Downloads]$ ghc-pkg list | grep formatting
    formatting-6.3.4

i believe its due to the use of shortest in: https://github.com/chrisdone/formatting/blob/a922965aa58d523feb3174ed994f12b4c4788719/src/Formatting/Formatters.hs#L198-L210

chrisdone commented 6 years ago

Thanks, after changing from text-format a bunch of things changed for the worse it seems.

I'll fix and put a regression test in, but I think I'll have to add a test for all the combinators in the package with 100% code coverage and then we can stop running into these cases.

dsh commented 6 years ago

I just made a PR that fixes this and adds tests for ords.