{"id":16339270,"url":"https://github.com/tippenein/countable-inflections","last_synced_at":"2025-08-23T12:34:01.610Z","repository":{"id":62435781,"uuid":"69924234","full_name":"tippenein/countable-inflections","owner":"tippenein","description":"Rails-like text inflections for countables","archived":false,"fork":false,"pushed_at":"2021-02-25T17:30:35.000Z","size":21,"stargazers_count":10,"open_issues_count":0,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-08-10T16:45:48.444Z","etag":null,"topics":["inflections","pluralize","rails","singularize"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tippenein.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-04T01:07:15.000Z","updated_at":"2023-09-22T21:12:37.000Z","dependencies_parsed_at":"2022-11-01T20:46:06.958Z","dependency_job_id":null,"html_url":"https://github.com/tippenein/countable-inflections","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/tippenein/countable-inflections","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tippenein%2Fcountable-inflections","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tippenein%2Fcountable-inflections/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tippenein%2Fcountable-inflections/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tippenein%2Fcountable-inflections/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tippenein","download_url":"https://codeload.github.com/tippenein/countable-inflections/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tippenein%2Fcountable-inflections/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271747022,"owners_count":24813604,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["inflections","pluralize","rails","singularize"],"created_at":"2024-10-10T23:53:55.665Z","updated_at":"2025-08-23T12:34:01.583Z","avatar_url":"https://github.com/tippenein.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Countable Inflections\n\n[![License MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)\n[![Hackage](https://img.shields.io/hackage/v/countable-inflections.svg)](http://hackage.haskell.org/package/countable-inflections)\n[![Stackage LTS](http://stackage.org/package/countable-inflections/badge/lts)](http://stackage.org/lts/package/countable-inflections)\n\n\nThis library implements pluralization and singularization in a similar way to the [rails inflectors](http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html)\n\nIt uses regexes to define the non-standard transformations and therefore\ndoesn't provide much safety. If you need to provide the same pluralization and\nsingularization which rails does out of the box, this will work the same. If\nyou want _more_ you should be using\n[inflections-hs](https://github.com/stackbuilders/inflections-hs) which uses\nmegaparsec to give you more guarantees\n\n## Usage\n\n```haskell\nλ: pluralize \"person\"\n\"people\"\n\nλ: singularize \"branches\"\n\"branch\"\n```\n\nThese can also be given custom inflection matchers\n\n```haskell\nλ: :t singularizeWith\n[Inflection] -\u003e Text -\u003e Text\n```\n\nThere are 3 different types of transformations:\n\n### Match\n\nTakes a PCRE regex and a replacement string.\n\n```haskell\nλ: :t makeMatchMapping\n[(RegexPattern, RegexReplace)] -\u003e [Inflection]\n\nλ: let mapping = makeMatchMapping [(\"(octop)us\", \"\\\\1i\")]\nλ: pluralizeWith mapping \"octopus\"\n\"octopi\"\n```\n\n### Irregular\n\nFrom singular to plural with no greater pattern.\n\n```haskell\nλ: :t makeIrregularMapping\n[(Singular, Plural)] -\u003e [Inflection]\n\nλ: let mapping = makeIrregularMapping [(\"zombie\",\"zombies\")]\nλ: pluralizeWith mapping \"zombie\"\n\"zombies\"\n```\n\n### Uncountable\n\nDoesn't have a mapping, word stays the same) so it has the type:\n\n```haskell\n[Text] -\u003e [Inflection]\n```\n\n### Inflect\n\nIn general you can input a number and singularize or pluralize based on the count, for example:\n\n```haskell\nsetReport = do\n  sets \u003c- getSets\n  n \u003c- length sets\n  print $ show n ++ \" \" ++ inflect \"sets\" n\n```\n\nThis way it'll list as \"1 set\" or \"5 sets\" based on the input.\n\n## License\n\nMIT - see [the LICENSE file](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftippenein%2Fcountable-inflections","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftippenein%2Fcountable-inflections","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftippenein%2Fcountable-inflections/lists"}