Countable Text Inflections

Latest on Hackage:0.2.0

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow to host generated Haddocks.

MIT licensed and maintained by Brady Ouren

Countable Inflections

License MIT Hackage Stackage LTS Build Status

This library implements pluralization and singularization in a similar way to the rails inflectors

It uses regexes to define the non-standard transformations and therefore doesn't provide much safety. If you need to provide the same pluralization and singularization which rails does out of the box, this will work the same. If you want more you should be using inflections-hs which uses megaparsec to give you more guarantees


λ: pluralize "person"

λ: singularize "branches"

These can also be given custom inflection matchers

λ: :t singularizeWith
[Inflection] -> Text -> Text

There are 3 different types of transformations:


Takes a PCRE regex and a replacement string.

λ: :t makeMatchMapping
[(RegexPattern, RegexReplace)] -> [Inflection]

λ: let mapping = makeMatchMapping [("(octop)us", "\1i")]
λ: pluralizeWith mapping "octopus"


From singular to plural with no greater pattern.

λ: :t makeIrregularMapping
[(Singular, Plural)] -> [Inflection]

λ: let mapping = makeIrregularMapping [("zombie","zombies")]
λ: pluralizeWith mapping "zombie"


Doesn't have a mapping, word stays the same) so it has the type:

[Text] -> [Inflection]


MIT - see the LICENSE file.

Used by 1 package:
comments powered byDisqus