2019-12-05 20:10:59 +04:00
|
|
|
const React = require('react');
|
|
|
|
|
|
|
|
const pre = '```';
|
|
|
|
|
|
|
|
const PASCALIGO_EXAMPLE = `${pre}pascaligo
|
|
|
|
// variant defining pseudo multi-entrypoint actions
|
|
|
|
type action is
|
|
|
|
| Increment of int
|
|
|
|
| Decrement of int
|
|
|
|
|
|
|
|
function add (const a : int ; const b : int) : int is a + b
|
|
|
|
|
|
|
|
function subtract (const a : int ; const b : int) : int is a - b
|
|
|
|
|
|
|
|
// real entrypoint that re-routes the flow based on the action provided
|
|
|
|
function main (const p : action ; const s : int) : (list(operation) * int) is
|
|
|
|
((nil : list(operation)),
|
|
|
|
case p of
|
|
|
|
| Increment (n) -> add (s, n)
|
|
|
|
| Decrement (n) -> subtract (s, n)
|
|
|
|
end)
|
|
|
|
${pre}`;
|
|
|
|
|
|
|
|
const CAMELIGO_EXAMPLE = `${pre}ocaml
|
|
|
|
type storage = int
|
|
|
|
|
2020-01-21 07:42:22 +04:00
|
|
|
(* variant defining pseudo multi-entrypoint actions *)
|
|
|
|
|
2019-12-05 20:10:59 +04:00
|
|
|
type action =
|
2020-01-21 07:42:22 +04:00
|
|
|
| Increment of int
|
|
|
|
| Decrement of int
|
2019-12-05 20:10:59 +04:00
|
|
|
|
2020-01-22 02:49:42 +04:00
|
|
|
let add (a,b: int * int) : int = a + b
|
|
|
|
let sub (a,b: int * int) : int = a - b
|
2019-12-05 20:10:59 +04:00
|
|
|
|
2020-01-21 07:42:22 +04:00
|
|
|
(* real entrypoint that re-routes the flow based on the action provided *)
|
2019-12-05 20:10:59 +04:00
|
|
|
|
2020-01-21 07:42:22 +04:00
|
|
|
let main (p,s: action * storage) =
|
|
|
|
let storage =
|
|
|
|
match p with
|
2020-01-22 02:49:42 +04:00
|
|
|
| Increment n -> add (s, n)
|
|
|
|
| Decrement n -> sub (s, n)
|
2020-01-21 07:42:22 +04:00
|
|
|
in ([] : operation list), storage
|
2019-12-05 20:10:59 +04:00
|
|
|
${pre}`;
|
|
|
|
|
2019-12-10 17:47:31 +04:00
|
|
|
|
|
|
|
const REASONLIGO_EXAMPLE = `${pre}reasonligo
|
|
|
|
type storage = int;
|
|
|
|
|
2020-01-21 07:42:22 +04:00
|
|
|
/* variant defining pseudo multi-entrypoint actions */
|
|
|
|
|
2019-12-10 17:47:31 +04:00
|
|
|
type action =
|
|
|
|
| Increment(int)
|
|
|
|
| Decrement(int);
|
|
|
|
|
2020-01-22 02:49:42 +04:00
|
|
|
let add = ((a,b): (int, int)): int => a + b;
|
|
|
|
let sub = ((a,b): (int, int)): int => a - b;
|
2019-12-10 17:47:31 +04:00
|
|
|
|
2020-01-21 07:42:22 +04:00
|
|
|
/* real entrypoint that re-routes the flow based on the action provided */
|
2019-12-10 17:47:31 +04:00
|
|
|
|
2020-01-22 02:49:42 +04:00
|
|
|
let main = ((p,storage): (action, storage)) => {
|
2019-12-10 17:47:31 +04:00
|
|
|
let storage =
|
|
|
|
switch (p) {
|
2020-01-22 02:49:42 +04:00
|
|
|
| Increment(n) => add((storage, n))
|
|
|
|
| Decrement(n) => sub((storage, n))
|
2019-12-10 17:47:31 +04:00
|
|
|
};
|
|
|
|
([]: list(operation), storage);
|
|
|
|
};
|
|
|
|
${pre}`;
|
|
|
|
|
|
|
|
|
2019-12-05 20:10:59 +04:00
|
|
|
module.exports = props => {
|
|
|
|
const MarkdownBlock = props.MarkdownBlock;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="tabs">
|
|
|
|
<div className="nav-tabs">
|
|
|
|
<div
|
|
|
|
className="nav-link active"
|
|
|
|
data-group="examples"
|
|
|
|
data-tab="pascaligo"
|
|
|
|
>
|
|
|
|
PascaLIGO
|
|
|
|
</div>
|
|
|
|
<div className="nav-link" data-group="examples" data-tab="cameligo">
|
|
|
|
CameLIGO
|
|
|
|
</div>
|
2019-12-10 17:47:31 +04:00
|
|
|
<div className="nav-link" data-group="examples" data-tab="reasonligo">
|
|
|
|
ReasonLIGO
|
|
|
|
</div>
|
2019-12-05 20:10:59 +04:00
|
|
|
</div>
|
|
|
|
<div className="tab-content">
|
|
|
|
<div id="pascaligo" className="tab-pane active" data-group="examples">
|
|
|
|
<MarkdownBlock>{PASCALIGO_EXAMPLE}</MarkdownBlock>
|
|
|
|
</div>
|
|
|
|
<div id="cameligo" className="tab-pane" data-group="examples">
|
|
|
|
<MarkdownBlock>{CAMELIGO_EXAMPLE}</MarkdownBlock>
|
|
|
|
</div>
|
2019-12-10 17:47:31 +04:00
|
|
|
<div id="reasonligo" className="tab-pane" data-group="examples">
|
|
|
|
<MarkdownBlock>{REASONLIGO_EXAMPLE}</MarkdownBlock>
|
|
|
|
</div>
|
2019-12-05 20:10:59 +04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|