egraphs-good / egglog

egraphs + datalog!
https://egraphs-good.github.io/egglog/
MIT License
458 stars 54 forks source link

Syntax proposal: `for` #455

Open yihozhang opened 3 weeks ago

yihozhang commented 3 weeks ago

It is common to define one-off rulesets and run them instantly for debugging purposes, e.g.,

(ruleset debug)
(rule ((= e (__some_conditions__)))
    ((extract e)
     ;; some other stuffs
    )
    :ruleset debug)
(run debug 1)

This is tedious and may interrupt the debugging flow, so here I propose a convenient form of the above snippet:

(for ((= e (__some_conditions__)))
    ((extract e)
      ;; some other stuffs
    ))

(or more generally for running N iterations:

(for N ((= e (__some_conditions__)))
    ((extract e)
      ;; some other stuffs
    ))

)

oflatt commented 3 weeks ago

This does look useful

Perhaps we should have a little library of sugar you can import? We might want to draw a more explicit line between sugar and the egglog language