connections-0.1.0: Partial orders, Galois connections, and lattices.

Safe HaskellSafe
LanguageHaskell2010

Data.Connection.Trip

Contents

Synopsis

Triple

data Trip a b Source #

An adjoint triple of Galois connections.

An adjoint triple is a chain of connections of length 2:

\(f \dashv g \dashv h \)

For further information see Property and https://ncatlab.org/nlab/show/adjoint+triple.

Constructors

Trip (a -> b) (b -> a) (a -> b) 
Instances
Category Trip Source # 
Instance details

Defined in Data.Connection.Trip

Methods

id :: Trip a a #

(.) :: Trip b c -> Trip a b -> Trip a c #

tripl :: Trip a b -> Conn a b Source #

tripr :: Trip a b -> Conn b a Source #

unitl :: Trip a b -> a -> a Source #

unitr :: Trip a b -> b -> b Source #

counitl :: Trip a b -> b -> b Source #

counitr :: Trip a b -> a -> a Source #

strong' :: Trip a b -> Trip c d -> Trip (a, c) (b, d) Source #

choice' :: Trip a b -> Trip c d -> Trip (Either a c) (Either b d) Source #

Rounding

half :: (Num a, Prd a) => Trip a b -> a -> Maybe Ordering Source #

Determine which half of the interval between two representations of a a particular value lies.

tied :: (Num a, Prd a) => Trip a b -> a -> Bool Source #

Determine whether x lies exactly halfway between two representations.

 tied t x == (x - unitl t x) =~ (counitr t x - x)

above :: (Num a, Prd a) => Trip a b -> a -> Bool Source #

Determine whether x lies above the halfway point between two representations.

 above t x == (x - unitl t x) 'gt' (counitr t x - x)

below :: (Num a, Prd a) => Trip a b -> a -> Bool Source #

Determine whether x lies below the halfway point between two representations.

 below t x == (x - unitl t x) 'lt' (counitr t x - x)

roundOn :: (Prd a, Num a) => Trip a b -> a -> b Source #

Return the nearest value to x.

If x lies halfway between two values, then return the value with the larger absolute value (i.e. round away from zero).

 roundOn C.id == id

floorOn :: Trip a b -> a -> b Source #

ceilingOn :: Trip a b -> a -> b Source #

truncateOn :: (Num a, Prd a) => Trip a b -> a -> b Source #