Hooks

Hooks run before and after each rule and allow automating some housekeeping tasks.

Defining Hooks

Hooks are defined as follows:

hooks pre = {
  rule hook_rule = !() -> ();
}

Hooks defined with pre run before each rule, while hooks defined with post run after each rule.

Besides rules, hooks can contain the following:

Adding to Hooks

To avoid having to repeat previous hook rules, you can add rules to hooks using hooks add. This adds to the end of the hook list, so adding hooks at the beginning still requires rewriting the entire list.

hooks post add {
  rule hook_rule2 = 'a' -> 'b';
  syllables rebuild;
}

Disabling and Enabling Hook Rules

Rules in hooks can be enabled and disabled individually using their names.

hooks enable hook_rule;
hooks disable hook_rule2;