Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stackbuilders/inflections-hs
Rails-like inflections for Haskell
https://github.com/stackbuilders/inflections-hs
hacktoberfest hacktoberfest-2023 haskell string-manipulation
Last synced: about 1 month ago
JSON representation
Rails-like inflections for Haskell
- Host: GitHub
- URL: https://github.com/stackbuilders/inflections-hs
- Owner: stackbuilders
- License: mit
- Created: 2014-02-25T04:57:08.000Z (almost 11 years ago)
- Default Branch: main
- Last Pushed: 2024-01-30T14:39:05.000Z (11 months ago)
- Last Synced: 2024-04-25T23:31:20.116Z (8 months ago)
- Topics: hacktoberfest, hacktoberfest-2023, haskell, string-manipulation
- Language: Haskell
- Homepage:
- Size: 586 KB
- Stars: 36
- Watchers: 40
- Forks: 11
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: docs/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: docs/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# String Inflections for Haskell
[![License MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
[![Hackage](https://img.shields.io/hackage/v/inflections.svg)](http://hackage.haskell.org/package/inflections)
[![Stackage Nightly](http://stackage.org/package/inflections/badge/nightly)](http://stackage.org/nightly/package/inflections)
[![Stackage LTS](http://stackage.org/package/inflections/badge/lts)](http://stackage.org/lts/package/inflections)
[![Build](https://github.com/stackbuilders/inflections-hs/actions/workflows/build.yml/badge.svg)](https://github.com/stackbuilders/inflections-hs/actions/workflows/build.yml)[![All Contributors](https://img.shields.io/badge/all_contributors-18-orange.svg?style=flat-square)](#contributors-)
This library is a partial port of the
[String Inflector](http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html)
from Ruby on Rails. It currently implements methods such as `parameterize`,
`transliterate`, `camelize`, `underscore` and `dasherize`. Please see the
haddock documentation for a complete list of the functions implemented by this
library.Unlike the ActiveSupport (Rails) and Ember implementations of inflections, this
library uses a parser to verify the input to functions like `camelize`. This is
done to ensure that the output strings adhere to the syntax that they are
supposed to generate. You can read more about the philosophy behind this library
in the
[Haddock documentation](http://hackage.haskell.org/package/inflections/docs/Text-Inflections.html).## Usage
The following examples demonstrate usage of the `parameterize`, `transliterate`
and `camelize` functions:```haskell
λ: parameterize "Hola. ¿Cómo estás?"
"hola-como-estas"λ: transliterate "Hola. ¿Cómo estás?"
"Hola. ?Como estas?"λ: import Control.Monad (liftM)
λ: liftM camelize $ parseSnakeCase "hey_there"
"HeyThere"
```## Customization
Part of parameterizing strings is approximating all characters in the input
encoding to ASCII characters. This library copies the character approximation
table from the Ruby i18n library. This data structure is provided as
`defaultCharacterTransliterations`. You can provide your own transliteration map
by passing a Map structure (from Data.Map) to the `parameterizeCustom` function.If you want to specify a custom default replacement or approximation table for
the `transliterate` function, you should instead call the `transliterateCustom`
function which accepts a String for replacements and a Map for substitution.## Future work
Ideally, we want to implement other functions found in the Rails
inflections library. If you need one of those functions, please submit a pull request!## Further documentation
For more information, please see the the
[Haddock docs for this module](http://hackage.haskell.org/package/inflections/docs/Text-Inflections.html).## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Cristhian Motoche
💻
Mark Karpov
💻 📖
Justin S. Leitgeb
💻 📖 🤔
Juan Pedro Villa Isaza
💻
Tomas Carnecky
💻
Dmitry Bushev
💻
Daniel Calle
💻 📖
Richard Cook
💻 📖
Phil de Joux
💻
Diego Centeno
💻 📖
Jorge Guerra Landázuri
💻
Luis Fernando Alvarez
💻
Abdelkader Boudih
📖
Juan Paucar
🚇
Alexey Uimanov
💻
Amadeus Folego
💻
Matt Campbell
💻
Jonathan Puglla
📖
Add your contributions
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
## License
MIT, see [the LICENSE file](LICENSE).
## Contributing
Do you want to contribute to this project? Please take a look at our [contributing guideline](/docs/CONTRIBUTING.md) to know how you can help us build it.
---
[Check out our libraries](https://github.com/stackbuilders/) | [Join our team](https://www.stackbuilders.com/join-us/)