Skip to content

[#630] Use pretty-printer in PRINT instruction

Nikolay Yakimov requested to merge lierdakil/#630-no-show-in-print into master

Description

Problem: We use show to display stack values in PRINT, and that's not good. Additionally, Buildable instance for Michelson.Typed.Value' is only defined for values that contain no operations.

Solution:

  • Make a RenderDoc instance for Value' that is basically equivalent to the current Buildable instance.
  • Use buildRenderDoc from this new instance instead of build/ pretty where needed (i.e. outside other Buildable instances, where HasNoOp constraint makes sense).
  • Make a new Buildable instance for Value', closely mirroring the behaviour of the old one, but handling VOp via Buildable Operation instance.
  • Use Fmt.pretty instead of show in PRINT
  • Use Fmt.build in the Buildable MichelsonFailed instance.

One downside is that Buildable Typed.Value' has to duplicate quite a bit of code from Buildable Untyped.Value, together with the conversion code from untypeValueImpl. The alternatives however either require modifying Untyped.Value, or deriving its base functor somehow, a-la recursion-schemes (note that the presence of the Elt type makes this extra tricky)

Related issue(s)

Resolves #630 (closed)

Checklist for your Merge Request

Related changes (conditional)

  • Tests (see short guidelines)
    • If I added new functionality, I added tests covering it.

Perhaps a couple more tests for different Value's wouldn't hurt

  • 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.

Holding off on updating changelog in case implementation changes drastically after review.

Stylistic guide (mandatory)

Edited by Nikolay Yakimov

Merge request reports