CameLIGO: add modules inclusion directive
Motivation and Context
Description
This MR adds support for the include
directive in structures / top-level.
At the signatures level, it allows to extend and restrict modules as contracts.
module IncDec = struct
type storage = int
type return = operation list * storage
let initial_storage : storage = 42
[@entry] let increment (delta : int) (store : storage) : return = [], store + delta
[@entry] let decrement (delta : int) (store : storage) : return = [], store - delta
[@entry] let reset (() : unit) (_ : storage) : return = [], 0
end
module type IIncOne = sig
type storage
type return = operation list * storage
val initial_storage : storage
[@entry] val increment : int -> storage -> return
[@entry] val reset : unit -> storage -> return
[@entry] val one : unit -> storage -> return
end
module IncOne : IIncOne = struct
include IncDec
[@entry] let one (() : unit) (_ : storage) : return = [], 1
end
As it can be seen above, IncOne
takes the implementation from IncDec
(using include IncDec
), implements a new entry point (one
), and restricts the signature (i.e. decrement
is not an entrypoint of the final contract).
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
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