Rails-like inflections for Haskell
Go to file
2014-03-01 06:05:39 -05:00
test Add decamelize function 2014-03-01 05:45:19 -05:00
Text Rename function 2014-03-01 06:05:39 -05:00
.travis.yml Add travis 2014-02-25 00:06:41 -05:00
inflections.cabal Rename function 2014-03-01 06:05:39 -05:00
LICENSE First commit 2014-02-25 00:00:52 -05:00
README.md Expose transliterate function 2014-02-25 13:39:24 -05:00
Setup.hs First commit 2014-02-25 00:00:52 -05:00

String Inflections for Haskell

Build Status

This library is a partial port of the String Inflector from Ruby on Rails. Specifically, it implements the parameterize and dasherize functions from the Inflector.

Usage

The following examples demonstrate usage of the parameterize and transliterate functions:

λ: parameterize "Hola. ¿Cómo estás?"
"hola-como-estas"

λ: transliterate "Hola. ¿Cómo estás?"
"Hola. ?Como estas?"

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.

TODO

I'd like this library to implement other functions found in the Rails inflections library. If you need one of those functions, please submit a pull request!

Author

Justin Leitgeb justin@stackbuilders.com

Contributing

You may submit pull requests to this repository on GitHub. Please add property tests for any functional changes that you make to this library.

License

MIT - see the LICENSE file.