connections-0.1.0: Preorders, Galois connections, and lattices.

Safe HaskellSafe
LanguageHaskell2010

Data.Connection.Interval

Synopsis

Documentation

data Interval a Source #

An interval in a poset P.

An interval in a poset P is a subset I of P with the following property:

\( \forall x, y \in I, z \in P: x \leq z \leq y \Rightarrow z \in I \)

Instances
Eq a => Eq (Interval a) Source # 
Instance details

Defined in Data.Connection.Interval

Methods

(==) :: Interval a -> Interval a -> Bool #

(/=) :: Interval a -> Interval a -> Bool #

Show a => Show (Interval a) Source # 
Instance details

Defined in Data.Connection.Interval

Methods

showsPrec :: Int -> Interval a -> ShowS #

show :: Interval a -> String #

showList :: [Interval a] -> ShowS #

Preorder a => Preorder (Interval a) Source #

Containment order

See https://en.wikipedia.org/wiki/Containment_order.

Instance details

Defined in Data.Connection.Interval

Bounded a => Triple (Interval a) a Source # 
Instance details

Defined in Data.Connection

Methods

triple :: Trip (Interval a) a Source #

imap :: Preorder b => (a -> b) -> Interval a -> Interval b Source #

Map over an interval.

Note this is not a functor, as a non-monotonic map may cause the interval to collapse to the empty interval.

(...) :: Preorder a => a -> a -> Interval a infix 3 Source #

Construct an interval from a pair of points.

empty :: Interval a Source #

The empty interval.

>>> empty
Empty

singleton :: a -> Interval a Source #

Construct an interval containing a single point.

>>> singleton 1
1 ... 1

endpts :: Interval a -> Maybe (a, a) Source #

Obtain the endpoints of an interval.

upper :: UpperBounded a => a -> Interval a Source #

\( X_\geq(x) = \{ y \in X | y \geq x \} \)

Construct the upper set of an element x.

This function is monotone:

x <~ y <=> upper x <~ upper y

by the Yoneda lemma for preorders.

lower :: LowerBounded a => a -> Interval a Source #

\( X_\leq(x) = \{ y \in X | y \leq x \} \)

Construct the lower set of an element x.

This function is antitone:

x <~ y <=> lower x >~ lower y

interval :: Bounded a => Trip (Interval a) a Source #

TODO: Document