-
Notifications
You must be signed in to change notification settings - Fork 52
[Feature] Module Tweaks
oskgo edited this page Apr 25, 2025
·
8 revisions
Module tweaks is a feature that allows one to make small changes to previously defined modules.
The general syntax for module tweaks is as follows:
module N = M with {
(* add module variables *)
var x, y, z : t
var a, b : s
(* remove module variables (they can no longer be referenced using code positions) *)
- var f, g
(* update procedures *)
proc f [
(* introduce new local variables *)
var h, i : v
var j : w
(* updates *)
_stmt_update_
_cond_update_
] res ~ (e) (* Change the return expression of `g` *)
}.
There are two types of procedure updates:
- Statement updates:
-
cp -
: delete the statement(s) at code-position (or code-position range)cp
-
cp + { s }
: add the statements
after code-positioncp
-
cp + ^ { s }
: add the statements
before code-positioncp
-
cp ~ { s }
: change the statement(s)s
at code-position (or code-position range)cp
-
- Condition updates:
-
cp - .
: collapse a conditional at code-positioncp
to it's true branch -
cp - ?
: collapse a conditional at code-positioncp
to it's false branch -
cp - #C.
: collapse a match at code-positioncp
to the C constructor branch -
cp ~ (e)
: change the condition of the conditional at code-positioncp
toe
-
cp + (e)
: introduce an if statement with conditione
around the code-position after (or excluding start of code-position range)cp
with the true branch the statement (or block). -
cp + (e)
: introduce an if statement with conditione
around the code-position at (or including start of code-position range)cp
with the true branch the statement (or block).
-
Note: Updates are applied one after the other, from bottom to top. Listing changes in chronological order is simplest way to apply updates safely.
For more detail on the structure of code positions, see here
For more examples see: tests/fine-grained-module-defs.ec