[#630] Use pretty-printer in PRINT instruction
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 forValue'
that is basically equivalent to the currentBuildable
instance. - Use
buildRenderDoc
from this new instance instead ofbuild
/pretty
where needed (i.e. outside otherBuildable
instances, whereHasNoOp
constraint makes sense). - Make a new
Buildable
instance forValue'
, closely mirroring the behaviour of the old one, but handlingVOp
viaBuildable Operation
instance. - Use
Fmt.pretty
instead ofshow
inPRINT
- Use
Fmt.build
in theBuildable 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
Holding off on updating changelog in case implementation changes drastically after review.
Stylistic guide (mandatory)
-
My commits comply with the following policy. -
My code complies with the style guide.