term-rewriting-0.3: Term Rewriting Library

Safe HaskellSafe
LanguageHaskell98

Data.Rewriting.Pos

Contents

Synopsis

Documentation

type Pos = [Int] Source #

A position in a term. Arguments are counted from 0.

A position describes a path in the tree representation of a term. The empty position [] denotes the root of the term. A position [0,1] denotes the 2nd child of the 1st child of the root (counting children from left to right).

Comparing Positions

Note that positions are not totally ordered. Nevertheless there are some commonly useful comparisons between positions.

above :: Pos -> Pos -> Bool Source #

p `above` q checks whether p is above q (in the tree representation of a term). A position p is above a position q, whenever p is a prefix of q.

below :: Pos -> Pos -> Bool Source #

p `below` q checks whether p is below q, that is to say that q is above p.

parallelTo :: Pos -> Pos -> Bool Source #

p `parallelTo` q checks whether p is parallel to q, that is to say that p and q do not lie on the same path.

leftOf :: Pos -> Pos -> Bool Source #

p `leftOf` q checks whether p is left of q. This is only possible if p and q do not lie on the same path (i.e., are parallel to each other).

rightOf :: Pos -> Pos -> Bool Source #

p `rightOf` q checks whether p is right of q.