Protean-Labs / mesh

The Mesh Engine that implements the Mesh Language, a computational language for web3.
Apache License 2.0
1 stars 0 forks source link

Add basic standard library #54

Closed cvauclair closed 3 years ago

cvauclair commented 3 years ago

Description

The Mesh Engine should have a standard library which is implicitly loaded (i.e.: opened) before each new Mesh expression. The standard library should be defined as a Mesh module. However, most functions in the stdlib would be defined as external.

Example

The following is an example of what a first version of the standard library could look like:

module Stdlib = {
  external cons = "stdlib_cons";

  let (|>) = (x, f) => f(x);

  external add = "stdlib_add";
  external sub = "stdlib_sub";
  external mul = "stdlib_mul";
  external div = "stdlib_div";

  let (+) = app;
  let (-) = sub;
  let (*) = mul;
  let (/) = div;
};