tweag / cooked-validators

MIT License
39 stars 11 forks source link

Tweaks that combine modifications #338

Closed carlhammann closed 1 year ago

carlhammann commented 1 year ago

When constructing a tweak from an optic and a modification of foci, there are in principle two options for optics with many foci:

  1. Apply the modification to all foci and return one modified transaction.
  2. Generate a number of transactions that contain different combinations of modified and un-modified foci.

This PR closes #336 by defining combineModsTweak, which enables the second strategy using indexed optics. This function has an argument of type [is] -> [[is]], where is is the index type of the optic, to describe which all the sets of indices of foci from which modifications should be combined. For example,

I also implemented doubleSatAttack in terms of combineModsTweak, which led to a simplification, while also increasing what it can do. (The new features are tested.)