Skip to content

[#330] add wrap and unwrap expressions for sum types constructors

Pinto Pasquale requested to merge pasqu4le/#330-indigo-make-sum-types into master

Description

Adds expression to Indigo to perform wrapping and unwrapping of values to/from single-field constructors of sum types.

For example:

data T = A Bool | B Natural
  deriving stock Generic
  deriving anyclass (IsoValue, HasAnnotation)

exampleContract :: IndigoContract Bool T
exampleContract param = defContract do
  storageVar @T =: wrap #cA param
  _boolean <- new$ unwrap #cA (storageVar @T)
  return ()

Related issue(s)

Resolves #330 (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 Pinto Pasquale

Merge request reports