Skip to content

CameLIGO: simple interfaces support

E. Rivas requested to merge er433/signature/middle into dev

Motivation and Context

This MR introduces simple interfaces for contracts, so far only front-end for CameLIGO.

Related Issue: #1785 (closed)

Description

See changelog description below.

TODO in separate MRs:

  • Add support for JsLIGO front-end
  • Write documentation
  • Add lens-like helpers for storage (see GA's comment below)
  • Extend module type construction with modules / modules types inside and abstraction (more involved changes in the typer)
  • Improve support for subsets of entries (after we incorporate include, @lesenechal.remi is already looking into it)

Component

  • compiler
  • website
  • webide
  • vscode-plugin
  • debugger

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Performance improvement (non-breaking change that improves performance)
  • None (change with no changelog)

Changelog

In CameLIGO we introduce module type for describing simple contracts:

module type I = sig
  (* `storage` is a type we don't know at this point *)
  type storage

  (* `result` is a type declaration *)
  type result = operation list * storage

  (* we can declare values to be entries *)
  [@entry] val foo : int -> storage -> result

  (* or just values *)
  val initial_storage : storage
end

We can attach a signature to a module in a module declaration:

module C : I = struct

  type storage = int

  type result = operation list * storage

  [@entry] let foo (x : int) (y : storage) : result = [], x  + y

  let initial_storage : storage = 42

end

Checklist:

  • Changes follow the existing coding style (use dune @fmt to check).
  • Tests for the changes have been added (for bug fixes / feature).
  • Documentation has been updated.
  • Changelog description has been added (if appropriate).
  • Start titles under ## Changelog section with #### (if appropriate).
  • There is no image or uploaded file in changelog
  • Examples in changed behaviour have been added to the changelog (for breaking change / feature).
Edited by E. Rivas

Merge request reports

Loading