ChasingBottoms-1.2.4: For testing partial and infinite values.Source codeContentsIndex
Test.ChasingBottoms.SemanticOrd
Portabilitynon-portable (GHC-specific)
Stabilityexperimental
Maintainerhttp://www.cs.chalmers.se/~nad/
Description

Generic semantic equality and order. The semantic order referred to is that of a typical CPO for Haskell types, where e.g. (True, bottom) <=! (True, False), but where (True, True) and (True, False) are incomparable.

The implementation is based on isBottom, and has the same limitations. Note that non-bottom functions are not handled by any of the functions described below.

One could imagine using QuickCheck for testing equality of functions, but I have not managed to tweak the type system so that it can be done transparently.

Synopsis
data Tweak = Tweak {
approxDepth :: Maybe Nat
timeOutLimit :: Maybe Int
}
noTweak :: Tweak
class SemanticEq a where
(==!) :: a -> a -> Bool
(/=!) :: a -> a -> Bool
semanticEq :: Tweak -> a -> a -> Bool
class SemanticEq a => SemanticOrd a where
(<!) :: a -> a -> Bool
(>!) :: a -> a -> Bool
(>=!) :: a -> a -> Bool
(<=!) :: a -> a -> Bool
semanticCompare :: Tweak -> a -> a -> Maybe Ordering
(\/!) :: a -> a -> Maybe a
(/\!) :: a -> a -> a
semanticJoin :: Tweak -> a -> a -> Maybe a
semanticMeet :: Tweak -> a -> a -> a
Documentation
data Tweak Source
The behaviour of some of the functions below can be tweaked.
Constructors
Tweak
approxDepth :: Maybe NatIf equal to Just n, an approxAll n is performed on all arguments before doing whatever the function is supposed to be doing.
timeOutLimit :: Maybe IntIf equal to Just n, then all computations that take more than n seconds to complete are considered to be equal to bottom. This functionality is implemented using isBottomTimeOut.
show/hide Instances
noTweak :: TweakSource
No tweak (both fields are Nothing).
class SemanticEq a whereSource
SemanticEq contains methods for testing whether two terms are semantically equal.
Methods
(==!) :: a -> a -> BoolSource
(/=!) :: a -> a -> BoolSource
semanticEq :: Tweak -> a -> a -> BoolSource
class SemanticEq a => SemanticOrd a whereSource
SemanticOrd contains methods for testing whether two terms are related according to the semantic domain ordering.
Methods
(<!) :: a -> a -> BoolSource
(>!) :: a -> a -> BoolSource
(>=!) :: a -> a -> BoolSource
(<=!) :: a -> a -> BoolSource
semanticCompare :: Tweak -> a -> a -> Maybe OrderingSource
semanticCompare tweak x y returns Nothing if x and y are incomparable, and Just o otherwise, where o :: Ordering represents the relation between x and y.
(\/!) :: a -> a -> Maybe aSource
(/\!) :: a -> a -> aSource
semanticJoin :: Tweak -> a -> a -> Maybe aSource
semanticMeet :: Tweak -> a -> a -> aSource
x \/! y and x /\! y compute the least upper and greatest lower bounds, respectively, of x and y in the semantical domain ordering. Note that the least upper bound may not always exist. This functionality was implemented just because it was possible (and to provide analogues of max and min in the Ord class). If anyone finds any use for it, please let me know.
Produced by Haddock version 2.4.2