numeric-domains-0.1.0.0: Numeric Domains

Numeric.Distance

Description

This module exports the types and functions needed to handle distances between two domain values and to determine if two domain values are adjacent.

Synopsis

# Documentation

class Ord a => Dist a where Source #

The class of domain value types for which a distance can be determined.

Methods

distance :: a -> a -> Distance Source #

Calculates the distance between two values.

shift :: Int -> a -> Maybe a Source #

Determines a new value by trying to move a finite distance from a given value.

Returns Nothing if the distance to the new value is infinite.

Instances
 Source # Instance detailsDefined in Numeric.Distance Methods Source # Instance detailsDefined in Numeric.Distance Methods Source # Instance detailsDefined in Numeric.Distance Methods Source # Instance detailsDefined in Numeric.Distance Methods Source # Instance detailsDefined in Numeric.Distance Methods Source # Instance detailsDefined in Numeric.Distance Methods Source # Instance detailsDefined in Numeric.Distance Methods Source # Instance detailsDefined in Numeric.Distance Methods

data Distance Source #

The distance between two elements of a domain is either finite (e.g., the distance between the integers 3 and 5 is 2), negative infinite (e.g., the distance between the double values 3.0 and 1.0) or positive infinite (e.g., the distance between the double values 1.0 and 3.0).

The distance is used to determine if two interval bounds are adjacent, which further allows to merge intervals and convert open to closed intervals based on the used domain value type.

Constructors

 NegativeInfinite Finite Int PositiveInfinite
Instances
 Source # Instance detailsDefined in Numeric.Distance Methods Source # Instance detailsDefined in Numeric.Distance Methods(<) :: Distance -> Distance -> Bool #(>) :: Distance -> Distance -> Bool #

adjacent :: Dist a => a -> a -> Bool Source #

Checks if two domain values are adjacent, i.e. their distance is finite 1.