term-rewriting-0.3.0.1: Term Rewriting Library

Safe HaskellSafe
LanguageHaskell98

Data.Rewriting.Term

Contents

Synopsis

Documentation

data Term f v Source #

Constructors

Var v

Variable

Fun f [Term f v]

Function application

Instances
(Eq v, Eq f) => Eq (Term f v) Source # 
Instance details

Defined in Data.Rewriting.Term.Type

Methods

(==) :: Term f v -> Term f v -> Bool #

(/=) :: Term f v -> Term f v -> Bool #

(Ord v, Ord f) => Ord (Term f v) Source # 
Instance details

Defined in Data.Rewriting.Term.Type

Methods

compare :: Term f v -> Term f v -> Ordering #

(<) :: Term f v -> Term f v -> Bool #

(<=) :: Term f v -> Term f v -> Bool #

(>) :: Term f v -> Term f v -> Bool #

(>=) :: Term f v -> Term f v -> Bool #

max :: Term f v -> Term f v -> Term f v #

min :: Term f v -> Term f v -> Term f v #

(Show v, Show f) => Show (Term f v) Source # 
Instance details

Defined in Data.Rewriting.Term.Type

Methods

showsPrec :: Int -> Term f v -> ShowS #

show :: Term f v -> String #

showList :: [Term f v] -> ShowS #

(Pretty f, Pretty v) => Pretty (Term f v) # 
Instance details

Defined in Data.Rewriting.Term.Pretty

Methods

pretty :: Term f v -> Doc #

prettyList :: [Term f v] -> Doc #

Important operations

fold :: (v -> a) -> (f -> [a] -> a) -> Term f v -> a Source #

Folding terms.

>>> fold (\v -> 1) (\f xs -> 1 + sum xs) (Fun 'f' [Var 1, Fun 'g' []])
3 -- size of the given term

map :: (f -> f') -> (v -> v') -> Term f v -> Term f' v' Source #

Mapping terms: Rename function symbols and variables.

>>> map succ pred (Fun 'f' [Var 2, Fun 'g' []])
Fun 'e' [Var 3,Fun 'f' []]

vars :: Term f v -> [v] Source #

Return the list of all variables in the term, from left to right.

>>> vars (Fun 'g' [Var 3, Fun 'f' [Var 1, Var 2, Var 3]])
[3,1,2,3]

funs :: Term f v -> [f] Source #

Return the list of all function symbols in the term, from left to right.

>>> funs (Fun 'f' [Var 3, Fun 'g' [Fun 'f' []]])
"fgf"

Reexported modules