countable-inflections: Countable Text Inflections

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]


Provides methods for singularizing and pluralizing text. The library is based on Rails' inflections.

[Skip to Readme]


Versions 0.0.1, 0.1.0, 0.2.0, 0.3.0, 0.3.0
Change log
Dependencies base (>=4.8 && <5), bytestring, exceptions, pcre-utils, regex-pcre-builtin, text [details]
License MIT
Copyright 2016 Brady Ouren
Author Brady Ouren <>
Maintainer Brady Ouren <>
Category Text
Home page
Bug tracker
Source repo head: git clone
Uploaded by tippenein at 2020-12-22T18:24:34Z


[Index] [Quick Jump]


Manual Flags


Turn on development settings.


Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Readme for countable-inflections-0.3.0

[back to package description]

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]


In general you can input a number and singularize or pluralize based on the count, for example:

setReport = do
  sets <- getSets
  n <- length sets
  print $ show n ++ " " ++ inflect "sets" n

This way it'll list as "1 set" or "5 sets" based on the input.


MIT - see the LICENSE file.