Skip to content

[#793] Extend `Expression` type

Konstantin Ivanov requested to merge martoon/#793-extended-expression into master

Description

LIGO has learned how to add debug output to Michelson code. It does that via Micheline, so we need to extend our Expression type to be able to accept the extra data.

This is the first part of #793 (closed) where I apply the Trees That Grow technique (or something similar to it) and split the current Expression into extendable Exp and a different Expression type with the old behaviour but defined in terms of Exp.

I also add a test matching my use case - a debug metadata attached to each node of Micheline expression.

Please see the commits' descriptions.

In the second part of #793 (closed) I'm planning to extend the untyped representation and typechecking so that I can pass the debug metadata through our dataflow right to Typed.Instr.

Concerns

I'm still unsure regarding this fromExpression @_ @a, the leading @_ is quite annoying. I see 3 ways to handle this:

  1. Avoid type annotations at all in most cases. Use res :: type <- fromExpression ... instead where it does not make the code more verbose.
  2. Flip the order of type arguments in FromExpression typeclass. That seems counter-intuitive to me, I'd like to avoid that.
  3. Treat it as fine.

Related issue(s)

Resolves (partially) #793 (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 Konstantin Ivanov

Merge request reports