module Data.Rewriting.Term.Pretty (
prettyTerm,
) where
import Data.Rewriting.Term.Type
import Text.PrettyPrint.ANSI.Leijen
prettyTerm :: (f -> Doc) -> (v -> Doc) -> Term f v -> Doc
prettyTerm :: forall f v. (f -> Doc) -> (v -> Doc) -> Term f v -> Doc
prettyTerm f -> Doc
_ v -> Doc
var (Var v
x) = v -> Doc
var v
x
prettyTerm f -> Doc
fun v -> Doc
var (Fun f
f [Term f v]
ts) = f -> Doc
fun f
f Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
args where
args :: Doc
args = Doc -> Doc -> Doc -> [Doc] -> Doc
encloseSep Doc
lparen Doc
rparen Doc
comma [(f -> Doc) -> (v -> Doc) -> Term f v -> Doc
forall f v. (f -> Doc) -> (v -> Doc) -> Term f v -> Doc
prettyTerm f -> Doc
fun v -> Doc
var Term f v
ti | Term f v
ti <- [Term f v]
ts]
instance (Pretty f, Pretty v) => Pretty (Term f v) where
pretty :: Term f v -> Doc
pretty = (f -> Doc) -> (v -> Doc) -> Term f v -> Doc
forall f v. (f -> Doc) -> (v -> Doc) -> Term f v -> Doc
prettyTerm f -> Doc
forall a. Pretty a => a -> Doc
pretty v -> Doc
forall a. Pretty a => a -> Doc
pretty