numerals-0.4.1: Convert numbers to number words

Safe HaskellSafe
LanguageHaskell98

Text.Numeral.Exp

Synopsis

Documentation

data Exp Source #

An expression that represents the structure of a numeral.

Constructors

Unknown

An unknown value. This is used to signal that a value can not be represented in the expression language.

Lit Integer

A literal value.

Example in English:

"three" = Lit 3
Neg Exp

Negation of an expression.

Example in English:

"minus two" = Neg (Lit 2)
Add Exp Exp infixl 6

Addition of two expressions.

Example in English:

"fifteen" = Lit 5 `Add` Lit 10
Mul Exp Exp infixl 7

Multiplication of two expressions.

Example in English:

"thirty" = Lit 3 `Mul` Lit 10
Sub Exp Exp infixl 6

One expression subtracted from another expression.

Example in Latin:

"duodēvīgintī" = Lit 2 `Sub` (Lit 2 `Mul` Lit 10)
Frac Exp Exp

A fraction.

Example in English:

"two thirds" = `Frac` (Lit 2) (Lit 3)
Scale Integer Integer Exp

A step in a scale of large values.

Should be interpreted as 10 ^ (rank * base + offset).

Example in English:

"quadrillion" = Scale 3 3 4
ChangeCase (Maybe Case) Exp 
ChangeGender (Maybe Gender) Exp

A change of grammatical gender.

This is used in a language like Spanish where the inflection of a number word is not always constant. Specifically, in Spanish, large number names always have the masculine gender. So 'millón', 'billón' and the like are all masculine. This can result in the following number word: 10000001 = "un (masculine) millón una (feminine)"

Example in Spanish (with the context being Feminine):

"un millón una" = ChangeGender (Just Masculine) (Lit 1) `Mul` Scale 3 3 1 `Add` Lit 1
ChangeNumber (Maybe Number) Exp 

evalScale :: Integral a => a -> a -> a -> a Source #

data Side Source #

A side or direction, either Left or Right.

Constructors

L

Left.

R

Right.

Instances

Eq Side Source # 

Methods

(==) :: Side -> Side -> Bool #

(/=) :: Side -> Side -> Bool #

Show Side Source # 

Methods

showsPrec :: Int -> Side -> ShowS #

show :: Side -> String #

showList :: [Side] -> ShowS #