[Haskell-cafe] ANN: numerals

Roel van Dijk vandijk.roel at gmail.com
Fri Sep 16 12:47:36 CEST 2011


Hello everyone,

I would like to announce the release of the numerals and
numerals-base packages.


* Numerals

The numerals package contains functions to convert numbers to
number words in a number of languages. For now the package only
supports cardinal numbers.

Example:
>>> import qualified Text.Numeral.Language.EN as EN
>>> EN.uk_cardinal 123 :: Maybe String
Just "one hundred and twenty-three"

You can also inspect the underlying structure of a number word:
>>> import Text.Numerals
>>> EN.shortScaleStruct 123 :: Exp
Add (Mul (Lit 1) (Lit 100)) (Add (Mul (Lit 2) (Lit 10)) (Lit 3))

Compare this structure with the number word:
1 (one) * 100 (hundred) + (and) 2 (twen) * 10 (ty) + 3 (three)

The package also comes with a test suite:
>>> cabal configure --enable-tests
>>> cabal build
>>> ./dist/build/test-numerals/test-numerals --hide-successes

I recommend the "--hide-successes" option of test-framework (>=0.4)
because there are many tests (3383).


* Numerals-base

The numerals-base package contains all the machinery upon which
numerals is build. Using this package you can write conversion
functions for your own language(s). It is documented, although
the documentation can be improved. For now the numerals package
is probably the best documentation.


* Resources:

Hackage:
http://hackage.haskell.org/package/numerals
http://hackage.haskell.org/package/numerals-base

Github:
http://github.com/roelvandijk/numerals
http://github.com/roelvandijk/numerals-base


* Help wanted

Currently I support 24 languages. But I only have some experience with
4 of them. The rest is scraped together with information I found
online. For most languages I can find online how to form the first 100
cardinal numbers. But after that information is sparse. You can help
by checking and expanding the test suite. This is very simple because
the test suite consists only of numbers combined with the expected
cardinal number word.


Regards,
Roel van Dijk



More information about the Haskell-Cafe mailing list