{-# LANGUAGE QuantifiedConstraints, RankNTypes, UnicodeSyntax #-}
module Data.Equality.Saturation.Rewrites where
import Data.Equality.Graph
import Data.Equality.Matching
import Data.Equality.Matching.Database
data Rewrite anl lang = !(Pattern lang) := !(Pattern lang)
| !(Rewrite anl lang) :| !(RewriteCondition anl lang)
infix 3 :=
infixl 2 :|
type RewriteCondition anl lang = Subst -> EGraph anl lang -> Bool
instance (∀ a. Show a => Show (lang a)) => Show (Rewrite anl lang) where
show :: Rewrite anl lang -> String
show (Rewrite anl lang
rw :| RewriteCondition anl lang
_) = Rewrite anl lang -> String
forall a. Show a => a -> String
show Rewrite anl lang
rw String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" :| <cond>"
show (Pattern lang
lhs := Pattern lang
rhs) = Pattern lang -> String
forall a. Show a => a -> String
show Pattern lang
lhs String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" := " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Pattern lang -> String
forall a. Show a => a -> String
show Pattern lang
rhs