haskell-gettext-0.1.1.0: GetText runtime library implementation in pure Haskell

Safe HaskellSafe
LanguageHaskell98

Data.Gettext.Plural

Contents

Description

This module contains definitions for plural form selection expressions AST, and an evaluator function for such expressions.

Synopsis

Data types

data BinOp Source #

Supported binary operations

Instances

Eq BinOp Source # 

Methods

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

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

Show BinOp Source # 

Methods

showsPrec :: Int -> BinOp -> ShowS #

show :: BinOp -> String #

showList :: [BinOp] -> ShowS #

data Expr Source #

Plural form selection expression AST

Constructors

N

The n variable

Literal Int

Literal number

If Expr Expr Expr

Ternary operator (... ? ... : ...)

Negate Expr

Unary arithmetic negation (as in -1).

Not Expr

Unary logic negation (as in ! (n == 1))

Binary BinOp Expr Expr

Binary operation

Instances

Eq Expr Source # 

Methods

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

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

Show Expr Source # 

Methods

showsPrec :: Int -> Expr -> ShowS #

show :: Expr -> String #

showList :: [Expr] -> ShowS #

Expressions

eval Source #

Arguments

:: Expr

Expression

-> Int

Number

-> Int

Plural form index defined by expression

Evaluate the expression