Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessandro Cheli committed Jun 25, 2024
1 parent 542c46b commit 6a432fd
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Rules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,24 @@ function invert(r::RewriteRule)
)
end

"Turns an EqualityRule into a DirectedRule"
"""
Turns an EqualityRule into a DirectedRule. For example,
```julia
direct(@rule f(~x) == g(~x)) == f(~x) --> g(~x)
```
"""
function direct(r::EqualityRule)
RewriteRule(r.name, -->, (getfield(r,k) for k in fieldnames(DirectedRule)[3:end])...)
end

"""
Turns an EqualityRule into a DirectedRule, but right to left. For example,
```julia
direct(@rule f(~x) == g(~x)) == g(~x) --> f(~x)
```
"""
direct_right_to_left(r::EqualityRule) = invert(direct(r))
direct_left_to_right(r::EqualityRule) = direct(r)

Expand Down

0 comments on commit 6a432fd

Please sign in to comment.