[#2] Added Data & Plated instances to `Expression`
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
Stylistic guide (mandatory)
-
My commits comply with the following policy. -
My code complies with the style guide.