Module

Data.Top

Package
purescript-higher-order
Repository
matthew-hilty/purescript-higher-order

#Top Source

class Top (a :: Type)  where

The Top typeclass registers partially ordered types that have a greatest element or upper boundary.

Because the notion of maximality entails the notion of comparability, the semantics of an instance of Top must be consistent with the definitional requirements of a partial order. In fact, most instances of Top are also instances of PartialOrd (and likely Ord as well).

In such cases, when a type a is both a registered instance of Top and one of PartialOrd, it must satisfy the following law:

  • maximality: x <=? top == Just true

Likewise, if a is an instance of Top and also an instance of Ord, it must satisfy the following analogous law:

  • maximality: x <= top

However, although the semantics of Top-registered types must be consistent with the laws of partial ordering, a PartialOrd registration may not be possible or suitable for all Top instances. The implementation details of the datatype may preclude an instance declaration. Alternatively, the properties of the type may make such an instance declaration impractical. For these reasons, as well as for consistency with the Bottom typeclass, the Top typeclass does not declare PartialOrd as a prerequisite superclass.

Members

Instances