Skip to content

[#2] Added Data & Plated instances to `Expression`

Diogo Castro requested to merge diogo/data-plated into master

Description

Problem: sometimes we want to "adjust" a certain node(s) in a micheline expression, which may be deeply nested inside other micheline expressions, or simply check whether a node exists somewhere in a large expression.

This involves traversing the expression tree, and look inside Seq and Prim expressions. It's a bit repetitive to have to write this "looping" code multiple times (I've needed it twice this week alone), so we should somehow provide a way to abstract over this pattern.

Solution: Add Data and Plated instances.

Then we can use the full power of Control.Lens.Plated to look inside all the sub-expressions in a large expression, e.g. using universe :: Expression -> [Expression].

Related issue(s)

Resolves part of morley-metadata#2 (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)

Edited by Diogo Castro

Merge request reports