From 69ee6d052158cb99eeaca8d12f637d380bda10cf Mon Sep 17 00:00:00 2001 From: John David Pressman Date: Tue, 21 Jan 2020 14:49:42 -0800 Subject: [PATCH] Update CameLIGO and ReasonLIGO examples on front page so they're usable in the IDE --- gitlab-pages/website/core/CodeExamples.js | 21 +++++++++------------ src/test/contracts/website2.mligo | 8 ++++---- src/test/contracts/website2.religo | 12 +++++------- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/gitlab-pages/website/core/CodeExamples.js b/gitlab-pages/website/core/CodeExamples.js index 1180aa9c5..4ace23b4e 100644 --- a/gitlab-pages/website/core/CodeExamples.js +++ b/gitlab-pages/website/core/CodeExamples.js @@ -30,16 +30,16 @@ type action = | Increment of int | Decrement of int -let add (a: int) (b: int) : int = a + b -let sub (a: int) (b: int) : int = a - b +let add (a,b: int * int) : int = a + b +let sub (a,b: int * int) : int = a - b (* real entrypoint that re-routes the flow based on the action provided *) let main (p,s: action * storage) = let storage = match p with - | Increment n -> add s n - | Decrement n -> sub s n + | Increment n -> add (s, n) + | Decrement n -> sub (s, n) in ([] : operation list), storage ${pre}`; @@ -53,22 +53,19 @@ 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 add = ((a,b): (int, int)): int => a + b; +let sub = ((a,b): (int, int)): int => a - b; /* real entrypoint that re-routes the flow based on the action provided */ -let main2 = (p: action, storage) => { +let main = ((p,storage): (action, storage)) => { let storage = switch (p) { - | Increment(n) => add(storage, n) - | Decrement(n) => sub(storage, n) + | Increment(n) => add((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 77259ad76..73c04cbd5 100644 --- a/src/test/contracts/website2.mligo +++ b/src/test/contracts/website2.mligo @@ -8,16 +8,16 @@ type action = | Increment of int | Decrement of int -let add (a: int) (b: int) : int = a + b -let sub (a: int) (b: int) : int = a - b +let add (a,b: int * int) : int = a + b +let sub (a,b: int * int) : int = a - b (* real entrypoint that re-routes the flow based on the action provided *) let main (p,s: action * storage) = let storage = match p with - | Increment n -> add s n - | Decrement n -> sub s n + | 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 fbb4a108d..ffed8cd90 100644 --- a/src/test/contracts/website2.religo +++ b/src/test/contracts/website2.religo @@ -8,20 +8,18 @@ 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 add = ((a,b): (int, int)): int => a + b; +let sub = ((a,b): (int, int)): int => a - b; /* real entrypoint that re-routes the flow based on the action provided */ -let main2 = (p: action, storage) => { +let main = ((p,storage): (action, storage)) => { let storage = switch (p) { - | Increment(n) => add(storage, n) - | Decrement(n) => sub(storage, n) + | Increment(n) => add((storage, n)) + | Decrement(n) => sub((storage, n)) }; ([]: list(operation), 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 *)