beanmachine icon indicating copy to clipboard operation
beanmachine copied to clipboard

Create simple combinators for graph fixers

Open ericlippert opened this issue 2 years ago • 2 comments

Summary: We're getting to the end of this series of refactorings. In this diff I start adding combinators on graph fixers. Recall that a graph fixer is a pass which mutates a graph that has the signature () -> (bool, errors) where the returned values indicate whether progress was made and whether there were fatal errors.

A combinator is a higher-order function that combines multiple fixers into a new fixer; in this diff I add two combinators:

  • take a series of fixers and produce the fixer which runs each of them in turn until one produces an error.

  • take a fixer and a bool and produce the fixer which runs the fixer only if the bool is true; if false then run the trivial fixer (the fixer which never makes progress and never produces an error)

With those two combinators we can then simplify the logic that orchestrates what fixers run in what order.

Reviewed By: yucenli

Differential Revision: D34628046

ericlippert avatar Apr 28 '22 16:04 ericlippert