RuleBook

I’m releasing a new open source library, RuleBook. Inspired by Inform 7‘s rulebook feature, it’s a way to make functions by defining a set of rules to evaluate. RuleBooks let you define functions are easy to mod and update at runtime.

Full Docs

What are rulebooks?

Rulebooks are essentially a fancy form of C#’s Func<> and Action<> generics.

Func<> and Action<> can hold a reference to a C# method, or an lambda expression/statement. But the thing they hold is essentially a black box – you cannot do much with it except run it, or check equality.

RuleBook provies FuncBook<> and ActionBook<>, which work similarly to their counterparts. But these rulebook objects are built out of individual rules, which can be individually inspected and mutated.

Overall, rulebooks give a systematic way of handling a bunch of useful programming patterns, including events, multiple dispatch, modding and code weaving.

Rulebooks are not an elaborate rules evaluation engine, it’s a lightweight way of stitching together bits of functionality.