sign-0.4.1: Arithmetic over signs and sets of signs

Copyright(c) Masahiro Sakai 2013
LicenseBSD-style
Maintainermasahiro.sakai@gmail.com
Stabilityprovisional
Portabilitynon-portable (FlexibleInstances, DeriveDataTypeable, CPP)
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Sign

Contents

Description

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 (http://hackage.haskell.org/package/lattices).

Synopsis

The Sign data type

Operations over signs

negate :: Sign -> Sign Source

Unary negation.

abs :: Sign -> Sign Source

Absolute value.

mult :: Sign -> Sign -> Sign Source

Multiplication.

recip :: Sign -> Sign Source

Reciprocal fraction.

div :: Sign -> Sign -> Sign Source

Fractional division.

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

Fractional division.

signOf :: Real a => a -> Sign Source

Sign of a number.

symbol :: Sign -> String Source

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.