Closed mwm closed 10 years ago
Cherry-picked center
function in ac905d2b90227efaa03e9d0aa19a46941be82d1f.
Cherry-picked group
as groupInt
to avoid conflict with base's Data.List
in 015da066a83541d0d6749eb76655182ebe8f04b3. Good generalization, thanks.
I'm not sure where plural
from a1e90b7d82e5da47af697cfef1eda8105f866daa should go. Seems okay to group it with numbers for now. It doesn't yet handle all cases, I'm not sure it's reasonable to expect to be able to pluralize easily. Check out all the cases here. I see at least the following:
I'm not saying I don't like the idea of the plural
function, but rather it should somehow handle more cases. Perhaps it's even reasonable to have something as simple as:
plural :: (Num a, Eq a) => Text -> Text -> Format a
And then you can write:
λ> format ("cat" % plural "" "s") 12
"cats"
λ> format ("sk" % plural "y" "ies") 12
"skies"
λ> format ("sk" % plural "y" "ies") 1
"sky"
λ> format ("potato" % plural "" "es") 1
"potato"
λ> format ("cal" % plural "f" "ves") 2
"calves"
It's not as snappy as plural True
, but it's not that much longer either. Most important of all it can handle any case. What do you think?
Cherry-picked fitLeft
and fitRight
in as 306707cd45d60621c772b70c42e041d880ddc149.
Apart from the plural
function, pushed to Hackage as 5.3.
Your version of "plural" looks good to me. You can find it in the existing "plural" function.
As for placement, ord also helps create English, so near that makes sense.
I looked at adding"Formatting.EN and putting plurals and ord there, with the eventual goal of adding functions from Text.Numeral.Language.EN in the Numerals package. But without the latter, another module seems like overkill.
On Sat, Sep 20, 2014 at 1:29 PM, Chris Done notifications@github.com wrote:
I'm not sure where plural from a1e90b7 https://github.com/chrisdone/formatting/commit/a1e90b7d82e5da47af697cfef1eda8105f866daa should go. Seems okay to group it with numbers for now. It doesn't yet handle all cases, I'm not sure it's reasonable to expect to be able to pluralize easily. Check out all the cases here http://en.wikipedia.org/wiki/English_plurals. I see at least the following:
- cat -> cats
- sky -> skies
- potato -> potatoes
- fish -> fishes
- calf -> calves
I'm not saying I don't like the idea of the plural function, but rather it should somehow handle more cases. Perhaps it's even reasonable to have something as simple as:
plural :: (Num a, Eq a) => Text -> Text -> Format a
And then you can write:
λ> format ("cat" % plural "" "s") 12"cats"λ> format ("sk" % plural "y" "ies") 12"skies"λ> format ("sk" % plural "y" "ies") 1"sky"λ> format ("potato" % plural "" "es") 1"potato"λ> format ("cal" % plural "f" "ves") 2"calves"
It's not as snappy as plural True, but it's not that much longer either. Most important of all it can handle any case. What do you think?
— Reply to this email directly or view it on GitHub https://github.com/chrisdone/formatting/pull/7#issuecomment-56276122.
Agreed on all counts. If more Englishy things appear, an EN submodule is appropriate.
I'll apply this plural
function.
Pushed plural
(and some doc fix) to Hackage as 5.4.
Hey Chris,
Love the formatting package. It seemed to be missing things I frequently need, and some things to make old LISP hackers like me happy. So I added them. Mostly trivial.