Skip to content

[#757] Classified instructions (GADT version)

Nikolay Yakimov requested to merge lierdakil/#757-classified-instrs-gadt into master

I spent more on this than was probably necessary, however the result is somewhat not terrible. How useful is it beyond Morley.Michelson.Typed.Util is debatable, however.

Further work (like #807) can perhaps expand on this.

Description

Problem: we often want to match on a typed instruction that has a certain property. To do that, we either have to match on all 'Instr' constructors, which is an ungodly amount of boilerplate, or use wildcard matches and thus introduce maintainability issues.

Solution: Introduce GADT-based machinery for classifying 'Instr' constructors in a few different ways and matching against those. Defining new classifications isn't much fun, but this seems better than doing the corresponding pattern-matches ad-hoc each time. Apply this machinery where appropriate, where it's not enough use TH (sparingly).

Related issue(s)

Resolves #757 (closed)

Checklist for your Merge Request

Related changes (conditional)

  • Tests (see short guidelines)

    • If I added new functionality, I added tests covering it.
    • If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
  • Documentation

    • I checked whether I should update the docs and did so if necessary:
    • I updated changelog files of all affected packages released to Hackage if my changes are externally visible.

Stylistic guide (mandatory)

Merge request reports

Loading