Skip to content

These examples would be clearer in a namespace #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: rinderknecht@new_jsligo
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
type storage = int
module Counter = struct
type storage_type = int
type return_type = operation list * storage_type

type ret = operation list * storage
(* Three entrypoints *)

(* Three entrypoints *)
[@entry]
let add (value : int) (store : storage_type) : return_type =
[], store + value

[@entry]
let increment (delta : int) (store : storage) : ret = [], store + delta

[@entry]
let decrement (delta : int) (store : storage) : ret = [], store - delta

[@entry]
let reset (() : unit) (_ : storage) : ret = [], 0
[@entry]
let sub (value : int) (store : storage_type) : return_type =
[], store - value

[@entry]
let reset (_p : unit) (_s : storage_type) : return_type =
[], 0
end
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
type storage = int;
type ret = [list<operation>, storage];
namespace Counter {
type storage_type = int;
type return_type = [list<operation>, storage_type];

// Three entrypoints
// Three entrypoints

// @entry
const increment = (delta: int, store: storage): ret =>
[[], store + delta];
// @entry
const add = (value: int, store: storage_type): return_type =>
[[], store + value];

// @entry
const decrement = (delta: int, store: storage): ret =>
[[], store - delta];
// @entry
const sub = (value: int, store: storage_type): return_type =>
[[], store - value];

// @entry
const reset = (_p: unit, _s: storage): ret => [[], 0]
// @entry
const reset = (_p: unit, _s: storage_type): return_type =>
[[], 0];
}