numerals-0.4: Convert numbers to number words

Safe HaskellNone





The general idea behind this package is to take a number, convert that number to an abstract representation of its spoken form and finally render that representation to a Text value.

Expression language

Numerals are represented by a small expression language defined in the Text.Numeral.Exp module. This language is also reified as the concrete type Exp in the Text.Numeral.Exp.Reified module.


Conversion from numbers to numerals is the responsibility of rules. The Rule type itself and a number of useful rules are defined in the Text.Numeral.Rules module. All rules are completely polymorphic in their types. Their result types are only constrained by the type classes that make up the numeral expression language.


Finally, the Text.Numeral.Render module is responsible for converting the numeral expression language to a Text value. This happens via the render function. Render is parametrised with a Repr value and with an Inflection. The Repr contains all the knowledge on how to convert the abstract expression to a concrete Text value. The Inflection is used for languages where number words change based on a number of grammatical categories such as case, gender or number. The expression itself is passed as a concrete Exp value.