HORIZON HASKELLDocslts/ghc-10.0.xc62e4de2026-10-19Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · c62e4de · 2026-10-19

Modulealgebraic-graphs-0.8Haskell2010

Algebra.Graph.Relation.Preorder

An abstract implementation of preorder relations. Use Algebra.Graph.Class for polymorphic construction and manipulation.

  • 1 type
  • 2 values

Data structure

3 declarations
newtypenewtype PreorderRelation a
#

The PreorderRelation data type represents a binary relation that is both reflexive and transitive. Preorders satisfy all laws of the Preorder type class and, in particular, the self-loop axiom:

vertex x == vertex x * vertex x

and the closure axiom:

y /= empty ==> x * y + x * z + y * z == x * y + y * z

For example, the following holds:

path xs == (clique xs :: PreorderRelation Int)

The Show instance produces reflexively and transitively closed expressions:

show (1             :: PreorderRelation Int) == "edge 1 1"
show (1 * 2         :: PreorderRelation Int) == "edges [(1,1),(1,2),(2,2)]"
show (1 * 2 + 2 * 3 :: PreorderRelation Int) == "edges [(1,1),(1,2),(1,3),(2,2),(2,3),(3,3)]"
Instances11Eq, Num, Ord, Show, IsString, NFData, …