From 44dd39dcb277c3a58aae913b0f986f76eaa63b7c Mon Sep 17 00:00:00 2001 From: John David Pressman Date: Mon, 20 Jan 2020 19:42:22 -0800 Subject: [PATCH] Fix examples on front page of ligolang.org, add reminder to change in future --- gitlab-pages/website/core/CodeExamples.js | 42 +++++++++++------------ src/test/contracts/website2.mligo | 12 ++++--- src/test/contracts/website2.religo | 4 +++ 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/gitlab-pages/website/core/CodeExamples.js b/gitlab-pages/website/core/CodeExamples.js index 0b636c356..1180aa9c5 100644 --- a/gitlab-pages/website/core/CodeExamples.js +++ b/gitlab-pages/website/core/CodeExamples.js @@ -24,51 +24,51 @@ ${pre}`; const CAMELIGO_EXAMPLE = `${pre}ocaml type storage = int -(* variant defining pseudo multi-entrypoint - actions *) +(* variant defining pseudo multi-entrypoint actions *) + type action = - | Increment of int - | Decrement of int +| Increment of int +| Decrement of int -let add (a: int) (b: int): int = a + b +let add (a: int) (b: int) : int = a + b +let sub (a: int) (b: int) : int = a - b -let subtract (a: int) (b: int): int = a - b +(* real entrypoint that re-routes the flow based on the action provided *) -(* real entrypoint that re-routes the flow - based on the action provided *) -let%entry main(p : action) storage = - let storage = - match p with - | Increment n -> add storage n - | Decrement n -> subtract storage n - in (([] : operation list), storage) +let main (p,s: action * storage) = + let storage = + match p with + | Increment n -> add s n + | Decrement n -> sub s n + in ([] : operation list), storage ${pre}`; const REASONLIGO_EXAMPLE = `${pre}reasonligo type storage = int; -/* variant defining pseudo multi-entrypoint - actions */ +/* variant defining pseudo multi-entrypoint actions */ + type action = | Increment(int) | Decrement(int); let add = (a: int, b: int): int => a + b; +let sub = (a: int, b: int): int => a - b; -let subtract = (a: int, b: int): int => a - b; +/* real entrypoint that re-routes the flow based on the action provided */ -/* real entrypoint that re-routes the flow - based on the action provided */ -let main = (p: action, storage) => { +let main2 = (p: action, storage) => { let storage = switch (p) { | Increment(n) => add(storage, n) - | Decrement(n) => subtract(storage, n) + | Decrement(n) => sub(storage, n) }; ([]: list(operation), storage); }; +let main = (x: (action, storage)) => main2(x[0],x[1]); + ${pre}`; diff --git a/src/test/contracts/website2.mligo b/src/test/contracts/website2.mligo index 17d4c2bc3..77259ad76 100644 --- a/src/test/contracts/website2.mligo +++ b/src/test/contracts/website2.mligo @@ -1,3 +1,5 @@ +(* IF YOU CHANGE THIS, CHANGE THE EXAMPLE ON THE FRONT PAGE OF THE WEBSITE *) + type storage = int (* variant defining pseudo multi-entrypoint actions *) @@ -11,9 +13,11 @@ let sub (a: int) (b: int) : int = a - b (* real entrypoint that re-routes the flow based on the action provided *) -let main (ps: action * storage) = +let main (p,s: action * storage) = let storage = - match ps.0 with - | Increment n -> add ps.1 n - | Decrement n -> sub ps.1 n + match p with + | Increment n -> add s n + | Decrement n -> sub s n in ([] : operation list), storage + +(* IF YOU CHANGE THIS, CHANGE THE EXAMPLE ON THE FRONT PAGE OF THE WEBSITE *) diff --git a/src/test/contracts/website2.religo b/src/test/contracts/website2.religo index 67e5ac125..fbb4a108d 100644 --- a/src/test/contracts/website2.religo +++ b/src/test/contracts/website2.religo @@ -1,3 +1,5 @@ +(* IF YOU CHANGE THIS, CHANGE THE EXAMPLE ON THE FRONT PAGE OF THE WEBSITE *) + type storage = int; /* variant defining pseudo multi-entrypoint actions */ @@ -21,3 +23,5 @@ let main2 = (p: action, storage) => { }; let main = (x: (action, storage)) => main2(x[0],x[1]); + +(* IF YOU CHANGE THIS, CHANGE THE EXAMPLE ON THE FRONT PAGE OF THE WEBSITE *)