sign-0.4.0: Arithmetic over signs and sets of signs

Portabilitynon-portable (FlexibleInstances, DeriveDataTypeable, CPP)
Safe HaskellSafe-Inferred




This module provides arithmetic over signs (i.e. {-, 0, +}) and set of signs.

For the purpose of abstract interpretation, it might be convenient to use Lattice instance. See also lattices package (


The Sign data type

Operations over signs

negate :: Sign -> SignSource

Unary negation.

abs :: Sign -> SignSource

Absolute value.

mult :: Sign -> Sign -> SignSource


recip :: Sign -> SignSource

Reciprocal fraction.

div :: Sign -> Sign -> SignSource

Fractional division.

pow :: Integral x => Sign -> x -> SignSource

Fractional division.

signOf :: Real a => a -> SignSource

Sign of a number.

symbol :: Sign -> StringSource

Mnemonic symbol of a number.

This function returns "-", "0", "+" respectively for Neg, Zero, Pos.

Operations over sets of signs

Set Sign is equipped with instances of Num and Fractional. Therefore arithmetic operations can be applied to Set Sign.

Instances of Lattice and BoundedLattice are also provided for the purpose of abstract interpretation.