numeric-domains-0.1.0.0: Numeric Domains

Copyright(c) Michael Szvetits 2019
LicenseBSD3 (see the file LICENSE)
Maintainertypedbyte@qualified.name
Stabilitystable
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

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
Dist Double Source # 
Instance details

Defined in Numeric.Distance

Dist Float Source # 
Instance details

Defined in Numeric.Distance

Dist Int Source # 
Instance details

Defined in Numeric.Distance

Dist Int8 Source # 
Instance details

Defined in Numeric.Distance

Dist Int16 Source # 
Instance details

Defined in Numeric.Distance

Dist Int32 Source # 
Instance details

Defined in Numeric.Distance

Dist Int64 Source # 
Instance details

Defined in Numeric.Distance

Dist Integer Source # 
Instance details

Defined in Numeric.Distance

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.

Instances
Eq Distance Source # 
Instance details

Defined in Numeric.Distance

Ord Distance Source # 
Instance details

Defined in Numeric.Distance

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

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