diff --git a/404.html b/404.html deleted file mode 100644 index e69de29..0000000 diff --git a/README/index.xml b/README/index.xml deleted file mode 100644 index 7f4d5d1..0000000 --- a/README/index.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - READMEs on Eve Documentation - http://docs.witheve.com/readme/ - Recent content in READMEs on Eve Documentation - Hugo -- gohugo.io - en-us - - - - - http://docs.witheve.com/readme/ - Mon, 01 Jan 0001 00:00:00 +0000 - - http://docs.witheve.com/readme/ - <p align="center"> - <img src="http://www.witheve.com/logo.png" alt="Eve logo" width="10%" /> -</p> - -<hr /> - -<h1 id="documentation-for-the-eve-programming-language">Documentation for the Eve programming language.</h1> - -<p>You can learn more about Eve here: <a href="http://witheve.com/">http://witheve.com/</a></p> - -<p>You can play with Eve here: <a href="http://play.witheve.com">http://play.witheve.com</a></p> - -<p>Eve is under active development here: <a href="https://github.com/witheve/Eve">https://github.com/witheve/Eve</a></p> - - - - - \ No newline at end of file diff --git a/guides/for-programmers/index.html b/guides/for-programmers/index.html deleted file mode 100644 index 598144a..0000000 --- a/guides/for-programmers/index.html +++ /dev/null @@ -1,385 +0,0 @@ - - - - - - - - - - - - Eve for Programmers - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Eve for Programmers

- -

As a programmer, you probably find it easy to switch between different programming langauges. If you know Javascript, you probably wouldn’t have a hard time learning similar langauges like C++, Java, or Python. That’s because despite syntactic differences, these languages largely conform to the same programming model. When we program in languages like these, we use similar abstractions between them – loops, functions, and input/output patterns have become a staple of every programmer’s toolbox. When we solve problems, we usually reach a solution in terms of these primitive operations.

- -

Eve is a different kind of programming langauge from Javascript or Python, so programmers new to Eve may feel a little lost at first. How do you get anything done in a language without loops? How do you compose code without functions? The purpose of this guide is to provide a mapping from the common tools you know, to the Eve way of solving problems. We’ll look at some programs written in Javascript, and see how they Eve can solve them.

- -

Functions

- -

Functions are the fundamental unit of code reuse in most conventional programming languages. These langauges typically start from a “main” function, and branch

- -

Looping

- -

Map

- -

Reduce

- -

Recursion

- -

I/O

- - -
-
- -
- diff --git a/guides/index.html b/guides/index.html index 39d7472..252f145 100644 --- a/guides/index.html +++ b/guides/index.html @@ -10,7 +10,7 @@ Guides - Eve Documentation - + @@ -74,15 +74,29 @@ +
+
+ + + +
+ +
+
- +
@@ -356,14 +147,8 @@

Pages in Guide

- -

Eve for Programmers

-
- -
- - -

Style Guide

+
+


diff --git a/guides/index.xml b/guides/index.xml index c597fb1..e724608 100644 --- a/guides/index.xml +++ b/guides/index.xml @@ -2,198 +2,19 @@ Guides on Eve Documentation - http://docs.witheve.com/guides/ + http://docs.witheve.com/guides/index.xml Recent content in Guides on Eve Documentation Hugo -- gohugo.io en-us - Eve for Programmers - http://docs.witheve.com/guides/for-programmers/ + + http://docs.witheve.com/guides/ Mon, 01 Jan 0001 00:00:00 +0000 - http://docs.witheve.com/guides/for-programmers/ - - -<h1 id="eve-for-programmers">Eve for Programmers</h1> - -<p>As a programmer, you probably find it easy to switch between different programming langauges. If you know Javascript, you probably wouldn&rsquo;t have a hard time learning similar langauges like C++, Java, or Python. That&rsquo;s because despite syntactic differences, these languages largely conform to the same programming model. When we program in languages like these, we use similar abstractions between them &ndash; loops, functions, and input/output patterns have become a staple of every programmer&rsquo;s toolbox. When we solve problems, we usually reach a solution in terms of these primitive operations.</p> - -<p>Eve is a different kind of programming langauge from Javascript or Python, so programmers new to Eve may feel a little lost at first. How do you get anything done in a language without loops? How do you compose code without functions? The purpose of this guide is to provide a mapping from the common tools you know, to the Eve way of solving problems. We&rsquo;ll look at some programs written in Javascript, and see how they Eve can solve them.</p> - -<h2 id="functions">Functions</h2> - -<p>Functions are the fundamental unit of code reuse in most conventional programming languages. These langauges typically start from a &ldquo;main&rdquo; function, and branch</p> - -<h2 id="looping">Looping</h2> - -<h3 id="map">Map</h3> - -<h3 id="reduce">Reduce</h3> - -<h3 id="recursion">Recursion</h3> - -<h2 id="i-o">I/O</h2> - - - - - Style Guide - http://docs.witheve.com/guides/style/ - Mon, 01 Jan 0001 00:00:00 +0000 - - http://docs.witheve.com/guides/style/ - - -<h1 id="eve-style-guide">Eve Style Guide</h1> - -<h2 id="comments">Comments</h2> - -<p>Add a space after the comment marker to make comments more readable</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="c1">// This is correct</span><span class="w"></span> -<span class="c1">//This is incorrect</span><span class="w"></span> -</code></pre></div> - -<h2 id="naming">Naming</h2> - -<p>As much as possible, don&rsquo;t abbreviate names. The goal in writing an Eve program is to be as readable as possible. An abbreviation that makes sense to you might not make sense to someone else, or even yourself when you revisit the program in a year.</p> - -<p>Multi-word names should be joined by dashes <code>-</code>, not underscores <code>_</code>.</p> - -<h2 id="program-layout">Program layout</h2> - -<p>Blocks should be preceded by at least a one line comment, indicating the purpose of the block.</p> - -<h2 id="commas">Commas</h2> - -<p>Although Eve treats commas as white-space, they should be used to enhance readability as needed:</p> - -<p>In records, separate attributes with commas after a bind</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="c1">// More readable</span><span class="w"></span> -<span class="p">[</span><span class="nt">#person</span><span class="w"> </span><span class="x">name</span><span class="w"> </span><span class="x">age</span><span class="nf">:</span><span class="w"> </span><span class="m">30</span><span class="p">,</span><span class="w"> </span><span class="x">height</span><span class="nf">:</span><span class="w"> </span><span class="m">5</span><span class="p">,</span><span class="w"> </span><span class="x">hair</span><span class="nf">-</span><span class="x">color</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;brown&quot;</span><span class="p">]</span><span class="w"></span> - -<span class="c1">// Less readable</span><span class="w"></span> -<span class="p">[</span><span class="nt">#person</span><span class="w"> </span><span class="x">name</span><span class="w"> </span><span class="x">age</span><span class="nf">:</span><span class="w"> </span><span class="m">30</span><span class="w"> </span><span class="x">height</span><span class="nf">:</span><span class="w"> </span><span class="m">5</span><span class="w"> </span><span class="x">hair</span><span class="nf">-</span><span class="x">color</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;brown&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>Commas should also be used to separate items contained in parenthesis, such as in a multiple return.</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="c1">// More readable</span><span class="w"></span> -<span class="p">(</span><span class="x">val</span><span class="m">1</span><span class="p">,</span><span class="w"> </span><span class="x">val</span><span class="m">2</span><span class="p">)</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="kr">if</span><span class="w"> </span><span class="p">[</span><span class="nt">#tag1</span><span class="p">]</span><span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="p">(</span><span class="m">1</span><span class="p">,</span><span class="w"> </span><span class="l">false</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="kr">else</span><span class="w"> </span><span class="p">(</span><span class="m">0</span><span class="p">,</span><span class="w"> </span><span class="l">true</span><span class="p">)</span><span class="w"></span> -<span class="x">total</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">count</span><span class="p">[</span><span class="x">given</span><span class="nf">:</span><span class="w"> </span><span class="x">attr</span><span class="m">1</span><span class="p">,</span><span class="w"> </span><span class="x">per</span><span class="nf">:</span><span class="w"> </span><span class="p">(</span><span class="x">attr</span><span class="m">2</span><span class="p">,</span><span class="w"> </span><span class="x">attr</span><span class="m">3</span><span class="p">)]</span><span class="w"></span> - -<span class="c1">// Less readable</span><span class="w"></span> -<span class="p">(</span><span class="x">val</span><span class="m">1</span><span class="w"> </span><span class="x">val</span><span class="m">2</span><span class="p">)</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="kr">if</span><span class="w"> </span><span class="p">[</span><span class="nt">#tag1</span><span class="p">]</span><span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="p">(</span><span class="m">1</span><span class="w"> </span><span class="l">false</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="kr">else</span><span class="w"> </span><span class="p">(</span><span class="m">0</span><span class="w"> </span><span class="l">true</span><span class="p">)</span><span class="w"></span> -<span class="x">total</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">count</span><span class="p">[</span><span class="x">given</span><span class="nf">:</span><span class="w"> </span><span class="x">attr</span><span class="m">1</span><span class="w"> </span><span class="x">per</span><span class="nf">:</span><span class="w"> </span><span class="p">(</span><span class="x">attr</span><span class="m">2</span><span class="w"> </span><span class="x">attr</span><span class="m">3</span><span class="p">)]</span><span class="w"></span> -</code></pre></div> - -<h2 id="indention">Indention</h2> - -<p>Eve does not enforce indention, but it is important for readability</p> - -<h3 id="blocks">Blocks</h3> - -<p><code>search</code>. <code>commit</code>, and <code>bind</code> should be the only lines at zero indention. Everything else should be indented.</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="c1">// Good</span><span class="w"></span> -<span class="kr">search</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="x">...</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="x">...</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>But not this:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="c1">// Not good</span><span class="w"></span> -<span class="kr">search</span><span class="w"></span> -<span class="p">[</span><span class="x">...</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"></span> -<span class="p">[</span><span class="x">...</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<h3 id="if-then">If-Then</h3> - -<p>Each arm of an <code>if-then</code> statement should be at the same indention level. The <code>then</code> portion of the statement can be on a new line if the <code>if</code> portion is exceptionally long, but it should be indented once.</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="c1">// Good if layout</span><span class="w"></span> -<span class="x">value</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="kr">if</span><span class="w"> </span><span class="x">bar</span><span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="x">baz</span><span class="w"></span> -<span class="w"> </span><span class="kr">if</span><span class="w"> </span><span class="x">bar</span><span class="m">2</span><span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="x">baz</span><span class="m">2</span><span class="w"></span> -<span class="w"> </span><span class="kr">else</span><span class="w"> </span><span class="x">baz</span><span class="m">3</span><span class="w"></span> - -<span class="c1">// Okay, especially if the branch is long</span><span class="w"></span> -<span class="x">value</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="kr">if</span><span class="w"> </span><span class="p">[</span><span class="nt">#long-record</span><span class="w"> </span><span class="x">attr</span><span class="m">1</span><span class="w"> </span><span class="x">attr</span><span class="m">2</span><span class="w"> </span><span class="x">attr</span><span class="m">3</span><span class="p">]</span><span class="w"> </span> -<span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="x">baz</span><span class="w"></span> -<span class="w"> </span><span class="kr">if</span><span class="w"> </span><span class="p">[</span><span class="nt">#long-record2</span><span class="w"> </span><span class="x">attr</span><span class="m">1</span><span class="w"> </span><span class="x">attr</span><span class="m">2</span><span class="w"> </span><span class="x">attr</span><span class="m">3</span><span class="p">]</span><span class="w"> </span> -<span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="x">baz</span><span class="m">2</span><span class="w"></span> -<span class="w"> </span><span class="kr">else</span><span class="w"> </span><span class="x">baz</span><span class="m">3</span><span class="w"></span> - -<span class="c1">// Less readable &quot;if&quot; formatting</span><span class="w"></span> -<span class="x">value</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="kr">if</span><span class="w"> </span><span class="x">bar</span><span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="x">baz</span><span class="w"></span> -<span class="kr">if</span><span class="w"> </span><span class="x">bar</span><span class="m">2</span><span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="x">baz</span><span class="m">2</span><span class="w"></span> -<span class="kr">else</span><span class="w"> </span><span class="x">baz</span><span class="m">3</span><span class="w"></span> - -<span class="c1">// Less readable &quot;if&quot; formatting</span><span class="w"></span> -<span class="x">value</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="kr">if</span><span class="w"> </span><span class="x">bar</span><span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="x">baz</span><span class="w"> </span><span class="kr">if</span><span class="w"> </span><span class="x">bar</span><span class="m">2</span><span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="x">baz</span><span class="m">2</span><span class="w"> </span><span class="kr">else</span><span class="w"> </span><span class="x">baz</span><span class="m">3</span><span class="w"></span> -</code></pre></div> - -<h3 id="nested-records">Nested records</h3> - -<p>When nested records are placed on a new line, they should be indented once past the parent record. Where possible, nested records should be the final attribute in the parent record.</p> - -<p>Nested records should appear on their own line if you are nesting more than one.</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="c1">// Okay, but only do this for one level of nesting</span><span class="w"></span> -<span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;hello&quot;</span><span class="p">,</span><span class="w"> </span><span class="x">children</span><span class="nf">:</span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;world&quot;</span><span class="p">]]</span><span class="w"></span> - -<span class="c1">// More readable</span><span class="w"></span> -<span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;hello&quot;</span><span class="p">,</span><span class="w"> </span><span class="x">children</span><span class="nf">:</span><span class="w"> </span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;world&quot;</span><span class="p">]]</span><span class="w"></span> - -<span class="c1">// Also good</span><span class="w"></span> -<span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">children</span><span class="nf">:</span><span class="w"> </span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;div1&quot;</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;div2&quot;</span><span class="w"> </span><span class="x">children</span><span class="nf">:</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;div3&quot;</span><span class="p">]]]</span><span class="w"> </span> - -<span class="c1">// Not good</span><span class="w"></span> -<span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">children</span><span class="nf">:</span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;div2&quot;</span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;div2&quot;</span><span class="p">]]</span><span class="w"></span> - -<span class="c1">// Also not good</span><span class="w"></span> -<span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">children</span><span class="nf">:</span><span class="w"> </span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;world&quot;</span><span class="p">],</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;hello&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<h2 id="newlines">Newlines</h2> - -<p>Newlines should precede and follow every code block.</p> - -<p>Within code blocks, a newline should be added between every action. This enhances readability, especially in the case where multiple actions are needed. For instance, the following code block:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"> </span><span class="nt">@studentDB</span><span class="w"></span> -<span class="w"> </span><span class="x">students</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#students</span><span class="p">]</span><span class="w"></span> - -<span class="kr">search</span><span class="w"> </span><span class="nt">@schoolDB</span><span class="w"></span> -<span class="w"> </span><span class="x">schools</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#school</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="x">schools.name</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">student.school</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="x">students.name</span><span class="p">]</span><span class="w"> </span> - -<span class="kr">commit</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#new-record</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>is more readable than this code block:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"> </span><span class="nt">@studentDB</span><span class="w"></span> -<span class="w"> </span><span class="x">students</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#students</span><span class="p">]</span><span class="w"></span> -<span class="kr">search</span><span class="w"> </span><span class="nt">@schoolDB</span><span class="w"></span> -<span class="w"> </span><span class="x">schools</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#school</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="x">schools.name</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">student.school</span><span class="w"></span> -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="x">students.name</span><span class="p">]</span><span class="w"> </span> -<span class="kr">commit</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#new-record</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - + http://docs.witheve.com/guides/ + diff --git a/guides/style/index.html b/guides/style/index.html deleted file mode 100644 index 871b7e8..0000000 --- a/guides/style/index.html +++ /dev/null @@ -1,513 +0,0 @@ - - - - - - - - - - - - Style Guide - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Eve Style Guide

- -

Comments

- -

Add a space after the comment marker to make comments more readable

-
// This is correct
-//This is incorrect
-
- -

Naming

- -

As much as possible, don’t abbreviate names. The goal in writing an Eve program is to be as readable as possible. An abbreviation that makes sense to you might not make sense to someone else, or even yourself when you revisit the program in a year.

- -

Multi-word names should be joined by dashes -, not underscores _.

- -

Program layout

- -

Blocks should be preceded by at least a one line comment, indicating the purpose of the block.

- -

Commas

- -

Although Eve treats commas as white-space, they should be used to enhance readability as needed:

- -

In records, separate attributes with commas after a bind

-
// More readable
-[#person name age: 30, height: 5, hair-color: "brown"]
-
-// Less readable
-[#person name age: 30 height: 5 hair-color: "brown"]
-
- -

Commas should also be used to separate items contained in parenthesis, such as in a multiple return.

-
// More readable
-(val1, val2) = if [#tag1] then (1, false)
-               else (0, true)
-total = count[given: attr1, per: (attr2, attr3)]
-
-// Less readable
-(val1 val2) = if [#tag1] then (1 false)
-               else (0 true)
-total = count[given: attr1 per: (attr2 attr3)]
-
- -

Indention

- -

Eve does not enforce indention, but it is important for readability

- -

Blocks

- -

search. commit, and bind should be the only lines at zero indention. Everything else should be indented.

-
// Good
-search
-  [...]
-
-bind
-  [...]
-
- -

But not this:

-
// Not good
-search
-[...]
-
-bind
-[...]
-
- -

If-Then

- -

Each arm of an if-then statement should be at the same indention level. The then portion of the statement can be on a new line if the if portion is exceptionally long, but it should be indented once.

-
// Good if layout
-value = if bar then baz
-        if bar2 then baz2
-        else baz3
-
-// Okay, especially if the branch is long
-value = if [#long-record attr1 attr2 attr3] 
-          then baz
-        if [#long-record2 attr1 attr2 attr3] 
-          then baz2
-        else baz3
-
-// Less readable "if" formatting
-value = if bar then baz
-if bar2 then baz2
-else baz3
-
-// Less readable "if" formatting
-value = if bar then baz if bar2 then baz2 else baz3
-
- -

Nested records

- -

When nested records are placed on a new line, they should be indented once past the parent record. Where possible, nested records should be the final attribute in the parent record.

- -

Nested records should appear on their own line if you are nesting more than one.

-
// Okay, but only do this for one level of nesting
-[#div text: "hello", children: [#div text: "world"]]
-
-// More readable
-[#div text: "hello", children: 
-  [#div text: "world"]]
-
-// Also good
-[#div children: 
-  [#div text: "div1"]
-  [#div text: "div2" children:
-    [#div text: "div3"]]]  
-
-// Not good
-[#div children: [#div text: "div2"] [#div text: "div2"]]
-
-// Also not good
-[#div children: 
-  [#div text: "world"], text: "hello"]
-
- -

Newlines

- -

Newlines should precede and follow every code block.

- -

Within code blocks, a newline should be added between every action. This enhances readability, especially in the case where multiple actions are needed. For instance, the following code block:

-
search @studentDB
-  students = [#students]
-
-search @schoolDB
-  schools = [#school]
-  schools.name = student.school
-
-bind @browser
-  [#div text: students.name] 
-
-commit
-  [#new-record]
-
- -

is more readable than this code block:

-
search @studentDB
-  students = [#students]
-search @schoolDB
-  schools = [#school]
-  schools.name = student.school
-bind @browser
-  [#div text: students.name] 
-commit
-  [#new-record]
-
- - -
-
- -
- diff --git a/handbook/actions/index.html b/handbook/actions/index.html deleted file mode 100644 index 531b640..0000000 --- a/handbook/actions/index.html +++ /dev/null @@ -1,389 +0,0 @@ - - - - - - - - - - - - Actions - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Actions

- -

Description

- -

There are three actions in Eve: search, bind, and commit.

- -

search is used when you want to gather records from one or more databases. These records are called “supporting records”, because they are used as a basis for bound or committed records.

- -

bind and commit actions are used when you want to update records in one or more databases, but they differ in the way the updates are performed.

- -
    -
  • bound records last only as long as their supporting records. When supporting records changes, then bound records changes accordingly, replacing any previously bound records.

  • - -
  • committed records persist past the lifetime of their supporting records. When supporting records change, then a new record is committed, leaving any previously committed records still intact.

  • -
- -

Examples

-

-
- -

See Also

- -

search | bind | commit

- - -
-
- -
- diff --git a/handbook/add/index.html b/handbook/add/index.html deleted file mode 100644 index 1d58eb1..0000000 --- a/handbook/add/index.html +++ /dev/null @@ -1,423 +0,0 @@ - - - - - - - - - - - - Add: += - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Add Operator

- -

adds a value to an attribute on a record

- -

Syntax

-
// Add a value to an attribute
-record.attribute += value
-
-// Add a tag to a record
-record += #tag
-
- -

Description

- -

record.attribute += value adds value to attribute. If record already has an attribute with a value, then value will be added to the set. Otherwise, if record doesn’t have an attribute with this name already, then += will create the attribute and set it to value. As Eve variables are sets, if the value already exists on the attribute, the value cannot be added again.

- -

attribute can be an attribute already on the record, or it can be a new attribute.

- -

value can be a string or number literal, a variable bound to one of these, or a record.

- -

record += #tag adds #tag to record. This is shorthand for record.tag += "tag".

- -

Examples

- -

Add the current second to a record. Since Eve works in sets, time-history can only ever hold then numbers 0 through 60. This means after one minute passes, no new elements will be added to tracker.time-history.

-
search
-  tracker = [#seconds-tracker]
-  [#time seconds]
-
-commit
-  tracker.time-history += seconds
-
- -

We can get around this by adding a record:

-
search
-  tracker = [#seconds-tracker]
-  [#time seconds]
-
-commit
-  tracker.time-history += [seconds]
-
- -

Now, instead of adding numbers to time-history we are adding records, which are associated with a unique ID. So after the first minute passes, time-history will contain duplicate seconds, but the record ID will ensure each one is unique.

- -
- -

Add the #honor-student tag to any #student with a GPA greater than 3.75:

-
search
-  student = [#student gpa > 3.75]
-  
-bind
-  student += #honor-student
-
- -

See Also

- -

set operator | remove operator | merge operator | bind | commit

- - -
-
- -
- diff --git a/handbook/aggregates/index.html b/handbook/aggregates/index.html deleted file mode 100644 index 9a63714..0000000 --- a/handbook/aggregates/index.html +++ /dev/null @@ -1,391 +0,0 @@ - - - - - - - - - - - - Aggregates - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Aggregates

- -

aggregates reduce a set of values to a single value

- -

Description

- -

Aggregates are functions that take an input set and produce an output set, typically with a different cardinality than the input set. Examples of aggregates include sum, count, and average. Each of these takes a set of numbers as an input, and typically produces a single number as output.

- -

Aggregates are called just like other functions in Eve. For instance, the count aggregate is called like so:

-
employee-count = count[given: employees]
-
- -

Aggregates don’t always produce a single output value. In some instances, you may want to group your input according to a desired dimension (department, grade, state, country, zip code, etc.) and then aggregate based on those groupings. Extending the example above, we could count the employees in each department:

-
employee-count = count[given: employees, per: department]
-
- -

Now, employee-count will have a count for each department, instead of a single count over all departments. For more complete examples, see the doc files for specific aggregates.

- -

Tip

- -

Aggregates have similar behavior to the reduce() function in many other langauges.

- -

See Also

- -

count

- - -
-
- -
- diff --git a/handbook/bind/index.html b/handbook/bind/index.html deleted file mode 100644 index ef30a3e..0000000 --- a/handbook/bind/index.html +++ /dev/null @@ -1,609 +0,0 @@ - - - - - - - - - - - - bind - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

bind

- -

updates or creates records, syncing them with matched records

- -

Syntax

-
bind
-
-bind @database1, ..., @databaseN
-
- -

Description

- -

bind updates or creates new records with a lifetime equal to matched records within the block. Matched records are any records found in a search action. If matched records change during program execution, all bound records change accordingly. If any matched records are removed (i.e. they no longer match the search), bound records and updates are removed as well.

- -

By default, bound records are directed to a default local database.

- -

bind @database1, ..., @databaseN directs bound records to one or more databases.

- -

Bind vs. Commit

- -

While bind and commit both update records in a database, they do so with slightly different behavior; a bound record has the same lifetime as its supporting records, whereas a committed record exists in the database until it is removed intentionally. Let’s take a closer look at this distinction and what the implications are.

- -

Consider the following block that reads the current time, and prints it to the screen:

-
search
-  [#time seconds]
-
-bind @browser
-  [#div text: seconds]
-
- -

In this block we search for the current time and bind it to a message that displays it. The message exists as long as the current time stays the same (1 second obviously). When the time changes, the current message disappears and is replaced with a new message, displaying the new time. This is the behavior of bind; bound records persist only as long as their matching records.

- -

Now let’s look at what commit does in contrast:

-
search
-  [#time seconds]
-
-commit @browser
-  [#div text: seconds]
-
- -

Compared to the previous block, we only changed bind to commit. When you run this block, at first you’ll see a single message like before. However, you’ll notice that messages begin to accumulate every second. Unlike with bind, committed records persist in the database until they are intentionally removed.

- -

To make things very concrete, we can actually mimic the behavior of a bind using two blocks that commit. We’ve already got the first one (the one just above), that commits messages to @browser. Now all we need is a second block, one that removes old committed messages from @browser:

-
search 
-  [#time seconds]
-
-search @browser
-  s = seconds - 1
-  // Do some math to handle the roll over at 60 seconds
-  last-time = s - 60 * floor[value: s / 60]
-  msg = [#div text: last-time]
-  
-commit @browser
-  msg := none
-
- -

This block searches for the message that was displayed during the previous second, and sets it to none, thereby removing it from @browser. Therefore, only the message bound to the the current time is displayed on the screen. This behavior is identical to that of the block that binds these messages instead of committing them!

- -

An Execution Perspective

- -

Another way to understand bind vs. commit is by looking at how the databases change over each tick of the Eve evaluator. We’ll consider the same program as before, looking at how its state changes over time. First, consider the bind case. When the program starts, there’s nothing in any databases; the program is a blank slate. At t1 the first #time is added to @session. This addition is bound to a #div, which is added to @browser. These changes are summarized in the first column of the table below.

- -

At t2, a new #time is added to @session, and the one from t1 is removed. Since we used a bind, this causes the existing #div to be removed from @browser, but it is replaced with a new #div reflecting the current time. At t3, the same operations takes place, and this process continues until the program is terminated.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -t0 - -t1 - -t2 - -t3 -
-delta - - - -+ [#time seconds: 39] -+ [#div text: "39"] - -+ [#time seconds: 40] -- [#time seconds: 39] -+ [#div text: "40"] -- [#div text: "39"] - -+ [#time seconds: 41] -- [#time seconds: 40] -+ [#div text: "41"] -- [#div text: "40"] -
-@session - -[ ] - -[[#time seconds: 39]] - -[[#time seconds: 40]] - -[[#time seconds: 41]] -
-@browser - -[ ] - -[[#div text: 39]] - -[[#div text: 40]] - -[[#div text: 41]] -
- -

Let’s perform the same analysis in the commit case. In this program, things start off the same; initially the database is empty, and at t1 a #time and a #div are added to their respective databases. At t2, things get more interesting. While the old #time is still replaced, the #div displaying the old time is not replaced since we committed it to @browser. Indeed, in subsequent rounds of execution, the contents of @browser keeps growing.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -t0 - -t1 - -t2 - -t3 -
-delta - - -+ [#time seconds: 39] -+ [#div text: "39"] - -+ [#time seconds: 40] -- [#time seconds: 39] -+ [#div text: "40"] - -+ [#time seconds: 41] -- [#time seconds: 40] -+ [#div text: "41"] -
-@session - -[ ] - -[[#time seconds: 39]] - -[[#time seconds: 40]] - -[[#time seconds: 41]] -
-@browser - -[ ] - -[[#div text: 39]] - -[[#div text: 39], - [#div text: 40]] - -[[#div text: 39], - [#div text: 40], - [#div text: 41]] -
- -

Tips

- -

When you want to display data in an interface element like a #div, a bind is usually the more appropriate choice compared to a commit. A bind will keep the interface element always up-to-date, whereas a commit will leave lingering elements that no longer reflect the current state of the program.

- -

When searching for an event like a #click, a commit is usually more appropriate than bind. When an event occurs, a record representing the event is added to a database. That record exists for exactly one “instant”, and then it is removed from the database. During that “instant”, any block searching for that event will be satisfied and can execute a bind or commit action. If you bind on the event, then the result will disappear as soon as the event does. However, if you commit on the event, then that result will persist after the event has been removed.

- -

Examples

- -

Display a formatted time:

-
search
-  [#time hours minutes seconds]
-  (am/pm, adjusted-hours) = if hours >= 12 then ("PM", hours - 12)
-                            else if hours = 0 then ("AM", 12)
-                            else ("AM", hours)
-bind @browser
-  [#div text: "The current time is {{adjusted-hours}}:{{minutes}}:{{seconds}} {{am/pm}}"]
-
- -

See Also

- -

commit | databases | search

- - -
-
- -
- diff --git a/handbook/blocks/index.html b/handbook/blocks/index.html deleted file mode 100644 index 6bac6db..0000000 --- a/handbook/blocks/index.html +++ /dev/null @@ -1,504 +0,0 @@ - - - - - - - - - - - - Blocks - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Blocks

- -

blocks compose Eve programs

- -

Syntax

-
// Blocks contain Eve code and can execute actions
-```
-search
-  .....
-
-bind
-  .....
-
-commit
-  .....
-```
-
-// Blocks that are disabled are not executed
-```eve disabled
-search
-  ....
-```
-
-// Non-Eve blocks are not parsed or executed
-```javascript
-function() {
-  ...
-}
-```
-
-// Blocks that omit the search action are satisfied by default
-```
-bind
-  .....
-```
-
-```
-commit
-  .....
-```
-
- -

Description

- -

A block is the fundamental unit of Eve code. Eve programs are made up of a series of blocks, each of which can perform actions:

- -
    -
  1. A block searches one or more databases for records.
  2. -
  3. A block binds or commits new records in one or more databases.
  4. -
- -

Blocks execute when the records they search for exist or change. If a block doesn’t search for any records, then the block executes by default, but it can never update bound or committed records.

- -

Blocks can have any number of search, commit, and bind actions, each of which can reference any number of databases. If a block has multiple search actions, it will only execute if all searches are satisfied.

- -

Blocks automatically keep bound and committed records up-to-date with matched records. When a record matching a search changes, those changes are reflected automatically in bound and committed records within that block.

- -

Specifying a Block

- -

Blocks are specified using two fences to delineate the beginning and end of the block. Code fences are matching pairs of either three consecutive ticks (```) or tildes (~~~). This style of code block is the same as supported by CommonMark. However, we don’t currently support specifying code blocks via indentation.

- -

Info Strings

- -

You can specify the type of code within a block with an info string, written directly after the block’s opening code fence. By default, any block without an info string are assumed to contain Eve code.

- -
```
-// An implicit block of Eve code. This block is parsed and executed
-  ...
-```
-
-```eve
-// An explicit block of Eve code. This block is parsed and executed
-  ...
-```
-
-```eve disabled
-// An explicit block of Eve code. This block is parsed, but not executed
-  ...
-```
-
-```javascript
-// An explicit block of Javascript code. This block is ignored
-// by the Eve compiler entirely
-  ...
-```
-
- -

Tips

- -

Although they are similar, it’s important not to think of blocks like functions in other languages. Blocks don’t have a name, and you don’t “call” them like you do functions. Instead, you “use” a block by searching for the records it creates.

- -

Likewise, there is no “main” block. Since Eve is declarative and there is no order, there is no particular starting point for a program. As a close analog, any block that does not search for records will be the first to execute when the program starts. For instance:

-
commit
-  [#student name: "Sally"]
-  [#student name: "Ingrid"]
-
- -

This block has no search action, so it doesn’t depend on any other records. Thus, it can be viewed as a “root” of the program. A program may contain many such root blocks.

- -

Examples

- -

A block with search and bind actions. The bind action adds the #div to the @browser database.

-
search
-  [name]
-
-bind @browser
-  [#div text: name]
-
- -

A block with only a commit action:

-
commit
-  [name: "Roger"]
-
- -
- -

Search for a #click in @event, create a #request in @http

-
search @event
-  [#click]
-
-commit @http
-  [#request #google url: "https://jsonplaceholder.typicode.com/posts/"]
-
- -

Search for a #request with a response, display it in the browser

-
search @http
-  [#request #google response: [json]]
-  json = [#array]
-  lookup[record: json, attribute, value: [title body]]
-
-bind @browser
-  [#div text: "{{title}}"]
-  [#div text: "{{body}}"]
-
- -

See Also

- -

search | bind | commit | databases

- - -
-
- -
- diff --git a/handbook/browser/index.html b/handbook/browser/index.html deleted file mode 100644 index 73db2a0..0000000 --- a/handbook/browser/index.html +++ /dev/null @@ -1,367 +0,0 @@ - - - - - - - - - - - - @browser - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

@browser

- - -
-
- -
- diff --git a/handbook/commit/index.html b/handbook/commit/index.html deleted file mode 100644 index 8ceb112..0000000 --- a/handbook/commit/index.html +++ /dev/null @@ -1,613 +0,0 @@ - - - - - - - - - - - - commit - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

commit

- -

updates or creates records that persist until intentionally removed

- -

Syntax

-
commit
-
-commit @database1, ..., @databaseN
-
- -

Description

- -

commit updates or creates new records that persist in a database until they are intentionally removed. If supporting records change or are removed, the original committed records remain in tact, and can still be searched by other blocks. By default, committed records are directed to a local database.

- -

commit @database1, ..., @databaseN directs committed records one or more databases.

- -

Bind vs. Commit

- -

While bind and commit both update records in a database, they do so with slightly different behavior; a bound record has the same lifetime as its supporting records, whereas a committed record exists in the database until it is removed intentionally. Let’s take a closer look at this distinction and what the implications are.

- -

Consider the following block that reads the current time, and prints it to the screen:

-
search
-  [#time seconds]
-
-bind @browser
-  [#div text: seconds]
-
- -

In this block we search for the current time and bind it to a message that displays it. The message exists as long as the current time stays the same (1 second obviously). When the time changes, the current message disappears and is replaced with a new message, displaying the new time. This is the behavior of bind; bound records persist only as long as their matching records.

- -

Now let’s look at what commit does in contrast:

-
search
-  [#time seconds]
-
-commit @browser
-  [#div text: seconds]
-
- -

Compared to the previous block, we only changed bind to commit. When you run this block, at first you’ll see a single message like before. However, you’ll notice that messages begin to accumulate every second. Unlike with bind, committed records persist in the database until they are intentionally removed.

- -

To make things very concrete, we can actually mimic the behavior of a bind using two blocks that commit. We’ve already got the first one (the one just above), that commits messages to @browser. Now all we need is a second block, one that removes old committed messages from @browser:

-
search 
-  [#time seconds]
-
-search @browser
-  s = seconds - 1
-  // Do some math to handle the roll over at 60 seconds
-  last-time = s - 60 * floor[value: s / 60]
-  msg = [#div text: last-time]
-  
-commit @browser
-  msg := none
-
- -

This block searches for the message that was displayed during the previous second, and sets it to none, thereby removing it from @browser. Therefore, only the message bound to the the current time is displayed on the screen. This behavior is identical to that of the block that binds these messages instead of committing them!

- -

An Execution Perspective

- -

Another way to understand bind vs. commit is by looking at how the databases change over each tick of the Eve evaluator. We’ll consider the same program as before, looking at how its state changes over time. First, consider the bind case. When the program starts, there’s nothing in any databases; the program is a blank slate. At t1 the first #time is added to @session. This addition is bound to a #div, which is added to @browser. These changes are summarized in the first column of the table below.

- -

At t2, a new #time is added to @session, and the one from t1 is removed. Since we used a bind, this causes the existing #div to be removed from @browser, but it is replaced with a new #div reflecting the current time. At t3, the same operations takes place, and this process continues until the program is terminated.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -t0 - -t1 - -t2 - -t3 -
-delta - - - -+ [#time seconds: 39] -+ [#div text: "39"] - -+ [#time seconds: 40] -- [#time seconds: 39] -+ [#div text: "40"] -- [#div text: "39"] - -+ [#time seconds: 41] -- [#time seconds: 40] -+ [#div text: "41"] -- [#div text: "40"] -
-@session - -[ ] - -[[#time seconds: 39]] - -[[#time seconds: 40]] - -[[#time seconds: 41]] -
-@browser - -[ ] - -[[#div text: 39]] - -[[#div text: 40]] - -[[#div text: 41]] -
- -

Let’s perform the same analysis in the commit case. In this program, things start off the same; initially the database is empty, and at t1 a #time and a #div are added to their respective databases. At t2, things get more interesting. While the old #time is still replaced, the #div displaying the old time is not replaced since we committed it to @browser. Indeed, in subsequent rounds of execution, the contents of @browser keeps growing.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -t0 - -t1 - -t2 - -t3 -
-delta - - -+ [#time seconds: 39] -+ [#div text: "39"] - -+ [#time seconds: 40] -- [#time seconds: 39] -+ [#div text: "40"] - -+ [#time seconds: 41] -- [#time seconds: 40] -+ [#div text: "41"] -
-@session - -[ ] - -[[#time seconds: 39]] - -[[#time seconds: 40]] - -[[#time seconds: 41]] -
-@browser - -[ ] - -[[#div text: 39]] - -[[#div text: 39], - [#div text: 40]] - -[[#div text: 39], - [#div text: 40], - [#div text: 41]] -
- -

Tips

- -

When you want to display data in an interface element like a #div, a bind is usually the more appropriate choice compared to a commit. A bind will keep the interface element always up-to-date, whereas a commit will leave lingering elements that no longer reflect the current state of the program.

- -

When searching for an event like a #click, a commit is usually more appropriate than bind. When an event occurs, a record representing the event is added to a database. That record exists for exactly one “instant”, and then it is removed from the database. During that “instant”, any block searching for that event will be satisfied and can execute a bind or commit action. If you bind on the event, then the result will disappear as soon as the event does. However, if you commit on the event, then that result will persist after the event has been removed.

- -

Examples

- -

Initialize a counter when a session connects

-
search
-  [#session-connect]
-
-commit
-  [#counter count: 0]
-
- -

Increment a counter when a button is clicked

-
search
-  [#click element: [#count-button diff counter]]
-
-commit
-  counter.count := counter.count + diff
-
- -

See Also

- -

bind | databases | search

- - -
-
- -
- diff --git a/handbook/commonmark/index.html b/handbook/commonmark/index.html deleted file mode 100644 index c3970e3..0000000 --- a/handbook/commonmark/index.html +++ /dev/null @@ -1,435 +0,0 @@ - - - - - - - - - - - - CommonMark - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

CommonMark

- -

Eve documents are compatible with CommonMark

- -

Syntax

- -

Headings

- -
# heading1
-## heading2
-### heading3
-
- -

Emphasis

- -
*italic*
-_italic_
-**bold**
-__bold__
-
- - - -
[link](address)
-
-[link][ref]
-[ref] : address
-
- -

Lists

- -
- list item
-- list item2
-  - sublist item
-
-* list item
-* list item2
-  * sublist item
-
-1. ordered list1
-2. ordered list2
-
-1) ordered list1
-2) ordered list2
-
- -

Quotes

- -
> blockquote
-
- -

Code

- -
```
-  a block of code
-```
-
-`Inline code` with backticks
-
- -

Description

- -

CommonMark is an effort to standardize and remove ambiguity from the Markdown language. Eve uses CommonMark as the basis for formatting and rendering prose contained in Eve files. Eve code is written as code blocks within a document specified in CommonMark. Code blocks are delinated by code fences, three backtics before and after Eve code. Everything within a code block is treated as Eve code.

- -

Examples

- -

See Also

- -

literate programming | blocks | programming model

- - -
-
- -
- diff --git a/handbook/core/index.html b/handbook/core/index.html deleted file mode 100644 index 60e2b5d..0000000 --- a/handbook/core/index.html +++ /dev/null @@ -1,371 +0,0 @@ - - - - - - - - - - - - - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - -
- diff --git a/handbook/databases/index.html b/handbook/databases/index.html deleted file mode 100644 index 588dd62..0000000 --- a/handbook/databases/index.html +++ /dev/null @@ -1,463 +0,0 @@ - - - - - - - - - - - - - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Databases

- -

Databases contain records

- -

Syntax

-
// search action
-search @database1, ..., @databaseN
-
-// Commit action
-commit @database1, ..., @databaseN
-
-// Bind action
-bind @database1, ..., @databaseN
-
- -

Description

- -

<action> @database performs the given action, one of search, bind, or commit, on the union of the provided databases.

- -

If no database is provided with an action, then that action is performed on the default @session database.

- -

Creating and Searching Databases

- -

You can create databases on-demand by simply committing a record to one. e.g.

- -
commit @my-database
-  [#my-record]
-
- -

This block will create a new database called “my-database”, which will contain the newly committed record. You can now search for this record in your new database:

- -
search @my-database
-  [#my-record]
-
-bind @browser
-  [#div text: "Found a record!"]
-
- -

Special Databases

- -

Eve has some built-in databases that have meaning to the runtime.

- -
    -
  • @session - the default database when no database is specified with an action.
  • -
  • @view - records committed to @view are used to visualize data.
  • -
  • @event - contains events originating from the DOM
  • -
  • @browser - Eve clients running in the browser render applicable records in this @browser as HTML elements.
  • -
  • @http - Stores records representing HTTP requests and responses
  • -
- -

Examples

- -

Display the element that was clicked in the DOM

-
search @event
-  [#click #direct-target element]
-
-commit @browser
-  [#div text: "{{element}} was clicked."]
-
- -

Commit some data in @session, and then display it on a button click.

- -
commit
-  [#for-display text: "Hello"]
-
- -

We are searching over three databases to complete this block.

- -
    -
  • the #click is in @event
  • -
  • the #button is in @browser
  • -
  • the text for display is in @session. This needs to be made explicit; since we are searching in other databases, @session is not searched implicitly.
  • -
- -
search @event @browser @session
-  [#click element: [#button]]
-  [#for-display text]
-
-commit @browser
-  [#div text]
-
- -

This block could have been written with two searches for the same effect:

- -
search @event @browser
-  [#click element: [#button]]
-
-search
-  [#for-display text]
-
-commit @browser
-  [#div text]
-
- -

See Also

- -

search | bind | commit

- - -
-
- -
- diff --git a/handbook/datetime/date/index.html b/handbook/datetime/date/index.html deleted file mode 100644 index eec3f20..0000000 --- a/handbook/datetime/date/index.html +++ /dev/null @@ -1,785 +0,0 @@ - - - - - - - - - - - - - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - - - - - - - - - - - - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - - - - - - - - - - - date - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

date

- -

provides the current date

- -

Syntax

-
[#date day month year]
-
- -

Attributes

- -
    -
  • day - current numeric day
  • -
  • month - current numeric month
  • -
  • year - current numeric year
  • -
- -

Description

- -

Provides the current day as reported by the system clock.

- -

Time updates at the frequency of the smallest selected in the record.

- -

Examples

- -

Prints the current date as a formatted string.

-
search
-  [#date month day year]
-
-bind @browser
-  [#div text: "Today is {{month}}/{{day}}/{{year}}"]
-
- -

See Also

- -

time

- - -
-
- -
- - - -
-
- -
- - - -
-
- -
- diff --git a/handbook/datetime/index.html b/handbook/datetime/index.html deleted file mode 100644 index b33d102..0000000 --- a/handbook/datetime/index.html +++ /dev/null @@ -1,371 +0,0 @@ - - - - - - - - - - - - Date & Time - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Date & Time

- -
    -
  • time - The current system time
  • -
- - -
-
- -
- diff --git a/handbook/datetime/time/index.html b/handbook/datetime/time/index.html deleted file mode 100644 index e3ea73b..0000000 --- a/handbook/datetime/time/index.html +++ /dev/null @@ -1,422 +0,0 @@ - - - - - - - - - - - - time - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

time

- -

provides the current time

- -

Syntax

-
[#time year 
-       month 
-       day 
-       hours 
-       hours-24 
-       minutes 
-       seconds 
-       time-string 
-       time seconds 
-       frames 
-       ampm]
-
- -

Attributes

- -
    -
  • year - the current year
  • -
  • month - the current month from 0 to 11
  • -
  • day - the current day of the month from 1 to 31
  • -
  • hours - current hour from 0 to 11
  • -
  • hours-24 - current hour from 0 to 23
  • -
  • minutes - current minute from 0 to 59
  • -
  • seconds - current second from 0 to 59
  • -
  • time-string - the current time in a string of the form HH:MM AM/PM
  • -
  • timestamp - the number of milliseconds since midnight January 1, 1970
  • -
  • ampm - a string indicating morning or evening
  • -
  • frames - the number of frames elapsed since the program began. This fastest updating attribute on #time, refreshing evey 16 milliseconds.
  • -
- -

Description

- -

Provides the current time as reported by the system clock.

- -

Time updates at the frequency of the smallest unit of time selected in the record.

- -

Examples

- -

Prints the current time as a formatted string.

-
search
-  [#time hours minutes seconds]
-
-bind @browser
-  [#div text: "The time is {{hours}}:{{minutes}}:{{seconds}}"]
-
- -

Example Usage

- - - - -
-
- -
- diff --git a/handbook/docker/index.html b/handbook/docker/index.html deleted file mode 100644 index 25a68c7..0000000 --- a/handbook/docker/index.html +++ /dev/null @@ -1,394 +0,0 @@ - - - - - - - - - - - - Docker - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Eve in Docker

- -

A Docker container for Eve is available on Docker Hub. After installing Docker for your platform, you can download our container with the following command:

- -
docker pull witheve/eve
-
- -

Windows Users - Docker for Windows requires Microsoft Hyper-V, which requires Windows 10.

- -

Examples

- -

To run the Docker container, execute:

- -
docker run -p [port]:8080 witheve/eve
-
- -

[port] is an available port on your local machine. It can be 8080 or any other port you would like. Then direct your browser to http://localhost:[port] to access the editor.

- -

[eve_file] is a path to a *.eve file you would like to build. The working directory of the container is eve/build, so to run a program in the eve/examples directory, you need to provide a relative path e.g.

- -
docker -p 8080:8080 witheve/eve
-
- -

To pass Eve files on your local machine into the container, you’ll need to mount a docker volume.

- -

See also

- -

linux | mac | windows | npm |running

- - -
-
- -
- diff --git a/handbook/ebnf/index.html b/handbook/ebnf/index.html deleted file mode 100644 index 1c56213..0000000 --- a/handbook/ebnf/index.html +++ /dev/null @@ -1,473 +0,0 @@ - - - - - - - - - - - - Grammar - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Eve EBNF grammar

- -

The following specification is expressed in Extended Backus–Naur Form

- -

Basics

-
newline = "\n"
-whitespace =  " " | "\t" | "," | newline;
-unicode = ? all unicode chars - whitespace ?;
-specials = "@" | "#" | "." | "," | "(" | ")" | "[" | "]" | "{" | "}" | "⦑" | "⦒" | ":" | "\"";
-non-special = unicode - specials;
-
- -

Values

-
none = "none";
-boolean = "true" | "false";
-numeric = "0" .. "9";
-number = ["-"] {numeric} ["." {numeric}];
-string-interpolation = "{{" expression "}}";
-string = "\"" {string-interpolation | unicode - "\"" | "\\\"" | whitespace} "\"";
-uuid ="⦑" (unicode - specials)  "⦒"
-
- -

Keywords and Identifiers

-
search = "search";
-action = "bind" | "commit";
-if = "if";
-then = "then";
-else = "else";
-is = "is";
-not = "not";
-none = "none";
-keyword = search | action | if | then | else | boolean | is | not | none
-non-special-non-numeric = non-special - numeric
-identifier = (non-special-non-numeric {non-special}) - keyword - "```";
-
- -

Comparisons

-
equality = ":" | "=";
-comparator = equality | ">" | "<" | ">=" | "<=" | "!=";
-comparison = expression whitespace+ comparator whitespace+ expression;
-
- -

Functions

-
infix-op = "*" | "+" | "-" | "/";
-infix = expression infix-op expression;
-function = identifier "[" [attribute] {whitespace+ attribute} "]";
-
- -

Records and Attributes

-
record = "[" [attribute] {whitespace+ attribute} "]"
-attribute = name | tag | attribute-not | identifier {whitespace+ comparator whitespace+ expression};
-name = "@" (identifier | string);
-tag = "#" (identifier | string);
-attribute-not = not "(" whitespace* identifier [comparator whitespace+ expression] ")";
-attribute-access = identifier whitespace* {"." whitespace* identifier}+
-
- -

Special Forms

-
not-statement = not "(" statement {whitespace+ statement} ")";
-is-expression = is "(" comparison ")";
-
- -

Expression

-
expression = number | identifier | function | infix | record | attribute-access;
-
- -

Statements

-
comment = "//" {unicode | whitespace - newline} newline
-statement = record | function | not-statement | if-statement | comparison | comment
-
- -

Action Statements

-
create-action = (identifier whitespace+ equality whitespace+ record) | record
-merge-action = (identifier | attribute-access) whitespace+ "<-" whitespace+ record
-name-tag-action = (identifier | attribute-access) whitespace+ ("+=" | "-=") whitespace+ (name | tag)
-remove-action = (identifier | attribute-access) whitespace+ ":=" whitespace+ none
-attribute-action = attribute-access whitespace+ (":=" | "+=" | "-=") whitespace+ expression
-action-operation = create-action | merge-action | name-tag-action | remove-action | attribute-action
-
- -

If-Then

-
group = "(" expression {whitespace+ expression} ")"
-binding-group = "(" identifier {whitespace+ identifier} ")"
-if-result = (group | expression);
-if-expression = if whitespace+ {statement whitespace+} then whitespace+ if-result;
-else-if-expression = else whitespace+ if whitespace+ {statement whitespace+} then whitespace+ if-result;
-else-expression = else whitespace+ if-result
-if-statement = (identifier | binding-group) whitespace+ equality whitespace+
-               if-expression
-               {whitespace+ (if-expression | else-if-expression)}
-               [else-expression]
-
- -

Sections

-
database-declaration = name | "(" {name whitespace+} ")"
-match-section = search whitespace+ [database-declaration whitespace+] {statement whitespace}
-action-section = action whitespace+ [database-declaration whitespace+] {action-statement whitespace}
-section = match-sectiong | action-section
-
- -

Program and Blocks

-
fence-symbol = "```"
-start-fence = newline fence-symbol [whitespace* (unicode - newline)] newline
-end-fence = newline fence-symbol newline
-block = start-fence {section} end-fence
-program = {unicode | whitespace | block}
-
- - -
-
- -
- diff --git a/handbook/equality/index.html b/handbook/equality/index.html deleted file mode 100644 index 08ace4e..0000000 --- a/handbook/equality/index.html +++ /dev/null @@ -1,420 +0,0 @@ - - - - - - - - - - - - Equality - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Equality

- -

= and : assert the equality of two values

- -

Syntax

-
// Use : in a record to bind an attribute to a value
-[attribute: value]
-
-// Use = outside a record to bind an attribute to a value
-[attribute]
-attribute = value
-
- -

Description

- -

[attribute: value] binds value to attribute, so that only records with attributes of the given value are returned. For instance, [name: "John"] selects all records with a name attribute equal to “John”. You can achieve the same effect with the = operator by first searching for a record. For instance:

-
[name]
-name = "John"
-
- -

This example further demonstrates that in Eve, variables with the same name are equivalent. Here, name inside the record and name on the second line are the same. This has particular implications, especially in the context of joining records. For instance:

-
search
-  [#student name school: name]
-  [#school name address]
-
- -

This block searches for #students and #schools with the same name. This means if you have a school named “South High School”, it won’t match unless there is also a student named “South High School”. If you want to use attributes, but don’t want to join on them, you can access them via dot notation.

-
search
-  [#student name school: schools.name]
-  schools = [#school address]
-
- -

This will correctly allow us to relate students and the addresses of the schools they attend.

- -

Tips

- -

Eve has two identical equivalency operators, : and =. They have the same semantic meaning, and could be used interchangeably. However, for readability reasons we encourage you to use : to express equality within records, and = outside of records. For example [attribute: value] is good, while we don’t encourage [attribute = value], even though it is semantically equivalent.

- -

Examples

- -

The following block will never execute the bind action because of a contradiction in the search:

-
search
-  x = 10
-  x = 20
-
-bind @browser
-  [#div text: "This will never display"]
-
- -

The search action says that x = 10 and x = 20, which is never true. Since there is no order or assignment in Eve, this statement does not first set x to 10 and then to 20. To see this more clearly, these two statements could be written as one:x = 10 = 20.

- -

See Also

- -

inequality | joins

- - -
-
- -
- diff --git a/handbook/equivalence/index.html b/handbook/equivalence/index.html deleted file mode 100644 index cf3cbeb..0000000 --- a/handbook/equivalence/index.html +++ /dev/null @@ -1,377 +0,0 @@ - - - - - - - - - - - - Equivalence - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Equivalence

- -
    -
  • Equality - Expresses when two statements are equality
  • -
  • Inequality - Expresses the relationship between two statements when they are not equality
  • -
  • Joins - Relate disjoint records by binding attributes from one with the other.
  • -
- -

See Also

- -

equality | inequality | joins

- - -
-
- -
- diff --git a/handbook/event/click/index.html b/handbook/event/click/index.html deleted file mode 100644 index 3f01cfd..0000000 --- a/handbook/event/click/index.html +++ /dev/null @@ -1,391 +0,0 @@ - - - - - - - - - - - - click - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

click

- -

click event

- -

Syntax

- -
[#click]
-[#click element]
-[#click #direct-target element]
-
- -

Attributes

- -
    -
  • #direct-target - selects only directly clicked elements, as opposed to elements to which the event bubbles.
  • -
  • element - the element that was clicked.
  • -
- -

Description

- -

When an element in the DOM is clicked, a #click record is created in the @event database.

- -

Examples

- -

See Also

- - -
-
- -
- diff --git a/handbook/event/index.html b/handbook/event/index.html deleted file mode 100644 index c994fb3..0000000 --- a/handbook/event/index.html +++ /dev/null @@ -1,369 +0,0 @@ - - - - - - - - - - - - @event - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

@event

- -

click - a left-button mouse click event

- - -
-
- -
- diff --git a/handbook/events/click/index.html b/handbook/events/click/index.html deleted file mode 100644 index 766d883..0000000 --- a/handbook/events/click/index.html +++ /dev/null @@ -1,440 +0,0 @@ - - - - - - - - - - - - click - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

click

- -

click event

- -

Syntax

- -
[#click]
-[#click element]
-[#click #direct-target element]
-
- -

Attributes

- -
    -
  • #direct-target - selects only directly clicked elements, as opposed to elements to which the event bubbles.
  • -
  • element - the element that was clicked.
  • -
- -

Description

- -

When an element in the DOM is clicked, a #click record is created in the @event database.

- -

Examples

- -

See Also

- - -
-
- -
- diff --git a/handbook/events/index.html b/handbook/events/index.html deleted file mode 100644 index fd0caaf..0000000 --- a/handbook/events/index.html +++ /dev/null @@ -1,418 +0,0 @@ - - - - - - - - - - - - Events - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Events

- -

click - a left-button mouse click event

- - -
-
- -
- diff --git a/handbook/expressions/index.html b/handbook/expressions/index.html deleted file mode 100644 index 27e0a00..0000000 --- a/handbook/expressions/index.html +++ /dev/null @@ -1,379 +0,0 @@ - - - - - - - - - - - - Expressions - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - -
- diff --git a/handbook/functions/index.html b/handbook/functions/index.html deleted file mode 100644 index 6129749..0000000 --- a/handbook/functions/index.html +++ /dev/null @@ -1,424 +0,0 @@ - - - - - - - - - - - - Functions - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Functions

- -

Functions map one or more arguments to one or more values.

- -

Syntax

-
// A typical function call
-value = fn[argument]
-
-// A function call with multiple arguments
-value = fn[argument1, ..., argumentN]
-
-// A function call with multiple arguments and multiple return values
-(value1, value2) = fn[argument1, ..., argumentN]
-
-// A desugared function call
-[#fn #function argument1, ... argumentN, value1, ..., valueN]
-
- -

Description

- -

Functions as they exist in other languages are mostly obviated by Eve’s tag semantics. Consider the following function call in a C-family language.

-
// A typical function call
-x = sin(1.5);                              
-
- -

In Eve, we could match a record that operates similarly:

-
[#sin #function radians: 1.5, return: x]
-
- -

These statements accomplish the same objective: store the sine of an angle in a result variable. The Eve syntax is at a disadvantage though, because it cannot be composed into an expression like a typical function. Therefore, specific Eve records can be used as traditional functions:

-
x = sin[radians: 1.5]
-
- -

Let’s look at what makes Eve functions different.

- -

Explicit Arguments

- -

A function’s arguments are enclosed in square brackets to draw attention to the fact that functions in Eve are just regular records. Also like records, arguments are stated explicitly. This has several advantages over typical calling patterns:

- -
    -
  • Explicit arguments are self-documenting, so a reader unfamiliar with the function can understand more about the function without looking up exactly how it works. In the case of sin, you don’t have to know whether the inputs have to be in radians or degrees; the call-site tells you.

  • - -
  • Eve provides alternative calling patterns for functions. Some languages have two sin functions, one for angles in radians and another for angles in degrees. By contrast, Eve has a single sin function. If your angles are in radians, you call sin[radians], whereas if your angles are in degrees, you call sin[degrees].

  • - -
  • Like all records, you can state arguments in any order. This opens up an easy path for optional arguments: include the arguments you want and leave out the ones you don’t.

  • -
- -

Referential Transparency

- -

All expressions in Eve are referentially transparent, meaning you can replace the expression with its result and the behavior of the program will not change. This in turn means that expressions are side-effect free, and the only thing they depend on is their input arguments. Referential transparency is key to enabling some key features in Eve, like time travel debugging and provenance.

- -

Set Semantics

- -

In Eve, functions work over sets, meaning that a function will be applied to all elements of the input sets, resulting in an output that is itself a set. For more, see the document on set semantics.

- -

See Also

- -

aggregate | set semantics

- - -
-
- -
- diff --git a/handbook/general/index.html b/handbook/general/index.html deleted file mode 100644 index 936c8fb..0000000 --- a/handbook/general/index.html +++ /dev/null @@ -1,371 +0,0 @@ - - - - - - - - - - - - General - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

General

- -
    -
  • sort - Orders elements in a set
  • -
- - -
-
- -
- diff --git a/handbook/general/sort/index.html b/handbook/general/sort/index.html deleted file mode 100644 index b915f03..0000000 --- a/handbook/general/sort/index.html +++ /dev/null @@ -1,504 +0,0 @@ - - - - - - - - - - - - sort - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

sort

- -

generates an ordering for a set

- -

Syntax

-
// Sort one or more values
-index = sort[value]
-index = sort[value: (value1, value2, ...)]
-
-// Sort one or more values, and specify the direction for each
-index = sort[value direction]
-index = sort[value: (value1, value2, ...), direction: ("up", "down", ...)]
-
-// Sort according to some grouping
-index = sort[value per]
-index = sort[value direction per]
-
- -

Arguments

- -
    -
  • value - one or more variables to sort. More than one variable can be provided using a list e.g. sort[value: (value1, ..., valueN)], and they will be sorted in turn.
  • -
  • direction - _optional_ - one or more directions by which to sort value. If no direction is provided, all variables are sorted from smallest to largest. Possible values are: - -
      -
    • “up” for sorting from smallest to largest.
    • -
    • “down” for sorting from largest to smallest.
    • -
  • -
  • per - _optional_ - Instead of sorting the whole set, per allows you to divide the set into groups and sort each one.
  • -
- -

The output is a set of indices, each of which maps to an element of the sorted variable. For example, if the value is ("A", "C", "D", "B"), then index is (1, 3, 4, 2).

- -

Description

- -

Sort generates an index that describes the ordering of an input value. It’s important to remember that variables in Eve are sets, and therefore have no ordering. Because of this, sort does not reorder value, but it generates a set of indices, each of which maps to an element in value.

- -

Sort is flexible, and can generate an ordering over multiple dimensions, directions, and groupings.

- -

index = sort[value] generates an ordering of value from smallest to largest.

- -

index = sort[value direction] generates an ordering of value in a given direction. Acceptable values are “up” and “down”.

- -

index = sort[value: (value1, ... , valueN)] generates an ordering of a list of values, ordering by value1 first, then value2, and so on. For example, if you have #person records with name, age and height attributes, you could sort as follows:

-
search
-  [#person name age height]
-  index = sort[value: (age, name, height)]
-
- -

This will sort the people first by age, then by name, then by height.

- -

index = sort[value: (value1, ... , valueN), direction: (direction1, ... , directionN)] does the same as above, but you can specify the direction you sort each variable. Acceptable value for direction are “up” and “down”. By default, values are sorted in the “up” direction.

- -

index = sort[value per] sorts value, grouped by per. This divides value into groups according to the elements of per, and each one is sorted.

- -

Examples

- -

We have #student records with grade (1 - 12), teacher, GPA (0.0 - 4.0) attributes. We can sort the students by grade:

-
search
-  [#student name grade]
-  index = sort[value: grade]
-
-bind @browser
-  [#div sort: index, text: "{{index}} - {{name}} {{grade}}"]
-
- -

The browser handles the task of rendering the divs in the order specified by the sortattribute. Taking this further, we can choose the direction of the sortted set, whether “up” or “down”. The default direction is “up” when none is specified.

-
search
-  [#student name grade]
-  index = sort[value: grade, direction: "down"]
-  
-bind @browser
-  [#div sort: index, text: "{{index}} - {{name}} {{grade}}"]
-
- -

You can also sort across multiple axes of a record. For instance, we can sort grade from 9 to 12, then sort by name from Z - A.

-
search
-  [#student name grade]
-  index = sort[value: (grade, name) , direction: ("up","down")]
-
-bind @browser
-  [#div sort: index, text: "{{index}} - {{name}} {{grade}}"]
-
- -

This can be extended to sort any number of attributes

-
search
-  [#student name grade teacher GPA]
-  index = sort[value: (grade, teacher, name, GPA) , direction: ("up", "down", "up", "down")]
-
-bind @browser
-  [#div sort: index, text: "{{index}} - {{name}} {{grade}} {{teacher}} {{GPA}}"]
-
- -

Finally, we can group sorted attributes with the per argument. Here you can see the difference between sorting by name then grade, and sorting by name per grade.

-
search
-  [#student name grade GPA]
-  index = sort[value: (GPA, name), per: grade]
-  
-bind @browser
-  [#div sort: index, text: "{{index}} - {{name}} {{grade}}"]
-
- -

When you sort per grade, then name is first grouped by grade, and each of those groups is then sorted. This is why index goes from 1-6 instead of 1-20 as in the other examples; Although there are still 20 elements in index, the maximum is 6 because no grade has more than 6 students. You might want to sort data this way in order to display it in a nested structure, such as this:

-
search
-    [#student name grade teacher]
-  index = sort[value: name, per: grade]
-  
-bind @browser
-  [#div grade children: 
-    [#h3 sort: 0, text: "Grade: {{grade}}"]
-    [#div sort: index, text: "{{index}} {{name}}"]]
-
- -
- -

Commit some test data

-
commit
-  [#student name: "Mach", grade: 9, teacher: "Mr. Black", GPA: "1.0"]
-  [#student name: "Pok", grade: 9, teacher: "Mrs. Brown", GPA: "3.4"]
-  [#student name: "Karima", grade: 9, teacher: "Mr. Black", GPA: "2.4"]
-  [#student name: "Garth", grade: 9, teacher: "Mrs. Brown", GPA: "2.8"]
-  [#student name: "Berta", grade: 9, teacher: "Mr. Black", GPA: "2.7"]
-  [#student name: "Maxine", grade: 10, teacher: "Mr. Red", GPA: "4.0"]
-  [#student name: "Gwyn", grade: 10, teacher: "Mrs. Blue", GPA: "2.5"]
-  [#student name: "Ilse", grade: 10, teacher: "Mr. Red", GPA: "3.0"]
-  [#student name: "Hobert", grade: 11, teacher: "Ms. Green", GPA: "3.2"]
-  [#student name: "Arlean", grade: 10, teacher: "Mr. Red", GPA: "2.4"]
-  [#student name: "Ty", grade: 10, teacher: "Mrs. Blue", GPA: "1.7"]
-  [#student name: "Kermit", grade: 11, teacher: "Ms. Green", GPA: "2.9"]
-  [#student name: "Cortez", grade: 11, teacher: "Mrs. Orange", GPA: "2.3"]
-  [#student name: "Polly", grade: 11, teacher: "Ms. Green", GPA: "2.1"]
-  [#student name: "Damion", grade: 12, teacher: "Mrs. Purple", GPA: "3.8"]
-  [#student name: "Gretchen", grade: 12, teacher: "Mrs. Yellow", GPA: "2.8"]
-  [#student name: "Octavio", grade: 12, teacher: "Mrs. Purple", GPA: "3.4"]
-  [#student name: "Pa", grade: 12, teacher: "Mrs. Yellow", GPA: "3.5"]
-  [#student name: "Elwanda", grade: 10, teacher: "Mrs. Blue", GPA: "1.3"]
-  [#student name: "Guadalupe", grade: 11, teacher: "Mrs. Orange", GPA: "3.7"]
-
- - -
-
- -
- diff --git a/handbook/glossary/index.html b/handbook/glossary/index.html deleted file mode 100644 index a0c36ea..0000000 --- a/handbook/glossary/index.html +++ /dev/null @@ -1,399 +0,0 @@ - - - - - - - - - - - - Glossary - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Glossary

- -

Cardinality

- -

Cardinality is the number of elements in a set. For example, the set (5, 4, 2) contains three elements, so the cardinality of the set is 3.

- -

Cartesian Product

- -

The Cartesian product A × B of two sets A and B is the set of ordered pairs (a,b) where a ∈ A and b ∈ B. For example, if A = (1, 2) and B = ("A", "B"), then A x B = ((1,"A"), (1, "B"), (2, "A"), (2, "B")).

- -

Entity

- -

Entities are unique IDs in the Eve DB. An entity can represent anything - a person, a business, a message, an application, a button, etc.

- -

Fact

- -

Facts describe entities. Each fact is composed of an attribute and a value, and is associated with a specific entity. Facts might be a person’s age, an employee’s salary, a department’s budget, etc.

- -

Provenance

- -

Provenance is the record and history of data and its place of origin. In Eve, provenance tells you how a value is calculated by looking back at the history of its computation. Provenance can be used to precisely identify the cause of unexpected data in your application.

- -

Record

- -

Records are composed of facts. In Eve, you select records from the database by supplying a pattern of attributes, and any records matching that pattern are returned to you. For example, a record might be the ages, salaries, and departments of employees.

- -

Referential Transparency

- -

An expression is referentially transparency if it can be replaced with its result without changing the behavior of the program. Expression that are not referentially transparent tend to have side effects, or rely on state that is not supplied as part of the input arguments, but through a side channel.

- -

Set

- -

In mathematics, a set is a collection of elements where each element is unique. Sets have no order, so position in the set does not imply uniqueness. For example (1, 2, 3) is a set, whereas (1, 2, 1, 3) is not a set, because 1 appears twice. Furthermore, this means that (1, 2, 3) is equivalent to (3, 1, 2), (3, 2, 1), and (1, 3, 2) because they have the same elements regardless of order. Elements of a set can be anything, and therefore can be sets themselves. To make the previous collection a set we could do the following: ((1,A), (2,B), (1,C), (3,D)).

- - -
-
- -
- diff --git a/handbook/help/index.html b/handbook/help/index.html deleted file mode 100644 index 8caa8c2..0000000 --- a/handbook/help/index.html +++ /dev/null @@ -1,396 +0,0 @@ - - - - - - - - - - - - Getting Help - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Getting Help

- -

If you have any questions or get stuck while you are learning Eve, there are several ways to get help:

- -

Before reaching out, make sure you’ve looked at the following resources:

- -
    -
  • Read the quick start guide. It contains everything you’ll need to build your first Eve program.
  • -
  • Read the syntax reference. It summarizes the syntax of Eve on a single sheet of paper.
  • -
- -

If you’re still stuck, you can get in touch with Eve developers and the community through these channels:

- -
    -
  • Send a message to the mailing list. We generally respond to messages within a day.
  • -
  • Send a tweet to @with_eve.
  • -
  • Submit an issue to our GitHub repository.
  • -
  • Join the Eve Slack channel to talk with Eve developers and the community in real time (coming soon)
  • -
- -

Hare are some more resources to help you learn Eve:

- -
    -
  • Browse our growing catalog of example applications for something similar to what you’re doing.
  • -
  • Read our development blog to learn more about what goes on behind the scenes at Eve.
  • -
- -

See Also

- -

guides | tutorials | mailing list | @with_eve | GitHub

- - -
-
- -
- diff --git a/handbook/http/index.html b/handbook/http/index.html deleted file mode 100644 index d029a76..0000000 --- a/handbook/http/index.html +++ /dev/null @@ -1,367 +0,0 @@ - - - - - - - - - - - - @http - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

@http

- - -
-
- -
- diff --git a/handbook/if-then/index.html b/handbook/if-then/index.html deleted file mode 100644 index 9ff2ea2..0000000 --- a/handbook/if-then/index.html +++ /dev/null @@ -1,443 +0,0 @@ - - - - - - - - - - - - if-then - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

If-Then

- -

Conditional equivalence

- -

Syntax

-
result = if record then value
-  
-result = if record then value
-         else value
-
-result = if record then value
-         if record then value
-
-result = if record then value
-         else if record then value
-
-result = if record then value
-         else if record then value
-         else value
-
-(result1, ..., resultN) = if record then (value, ..., valueN)
-
-(result1, ..., resultN) = if record then (value, ..., valueN)
-                          else (value, ..., valueN)
-
-(result1, ..., resultN) = if record1 then (value, ..., valueN)
-                          if record2 then (value, ..., valueN)
-
-(result1, ..., resultN) = if record1 then (value, ..., valueN)
-                          else if record2 then (value, ..., valueN)
-
-(result1, ..., resultN) = if record1 then (value, ..., valueN)
-                          else if record2 then (value, ..., valueN)
-                          else (value, ..., valueN)                                          
-
- -

Description

- -

If allows conditional equivalence, and works a lot like if in other languages. Our if has two components: The keyword if followed by a conditional; and the keyword then followed by one or more return objects. An optional else keyword indicates the default value:

- -

This block is used to switch between the singular and plural for displaying the number of burgers each guest is eating. If statements can be composed, permitting the creation of complex conditional statements. For instance, instead of inviting friends and their spouses in two blocks (the first two blocks in the example program), I could have done it in a single block using an if statement:

- -

This is equivalent to a union/and operator, which combines elements from disparate sets into the same set. The second way to use if is in conjunction with the else keyword:

- -

This is equivalent to a choose/or operator, selecting only the first branch with a non-empty body. A bug in this program is that if some guest is tagged both #hungry and #vegetarian, that guest will actually receive two burgers. Therefore, while order of statements usually does not matter in Eve, if statements are one area where it does.

- -

A final feature of the if statement is multiple returns. For instance, we could have done this:

- -

Examples

- -

Basic usage

-
burger-switch = if guest.burgers = 1 then "burger"
-                else "burgers"
-
-
[@"my party" date]
-friend = [#friend busy-dates != date]
-guest = if friend then friend
-        if friend.spouse then friend.spouse
-
- -

Using else if

-
burgers = if guest = [@Arthur] then 3
-          else if guest = [#hungry] then 2
-          else if guest = [#vegetarian] then 0
-          else 1
-
- -

Multiple returns

-
(burgers, status) = if guest = [@Arthur] then (3, #fed)
-                    else if guest = [#hungry] then (2, #fed)
-                    else if guest = [#vegetarian] then (0, #needsfood)
-                    else (1, #fed)
-
- -

See Also

- -

expressions | records | functions

- - -
-
- -
- diff --git a/handbook/index.html b/handbook/index.html index 398bd69..5f38b4e 100644 --- a/handbook/index.html +++ b/handbook/index.html @@ -10,7 +10,7 @@ Handbooks - Eve Documentation - + @@ -74,15 +74,29 @@ +
+
+ + + +
+ +
+
@@ -362,420 +153,24 @@


- -

-
- -
- - +


- +


- -

Linux

-
- -
- - -

Mac

-
- -
- - -

Standard Library

-
- -
- - -

Windows

-
- -
- - -

abs

-
- -
- - -

ceiling

-
- -
- - -

click

-
- -
- - -

cos

-
- -
- - -

count

-
- -
- - -

fix

-
- -
- - -

floor

-
- -
- - -

join

-
- -
- - -

mod

-
- -
- - -

random

-
- -
- - -

range

-
- -
- - -

round

-
- -
- - -

sin

-
- -
- - -

sort

-
- -
- - -

split

-
- -
- - -

sum

-
- -
- - -

tan

-
- -
- - -

time

-
- -
- - -

@session

-
- -
- - -

Add: +=

-
- -
- - -

Equality

-
- -
- - -

Functions

-
- -
- - -

General

-
- -
- - +

Getting Eve


- -

Grammar

-
- -
- - -

Programming Model

-
- -
- - -

Records

-
- -
- - -

search

-
- -
- - -

@browser

-
- -
- - -

Aggregates

-
- -
- - -

CommonMark

-
- -
- - -

Equivalence

-
- -
- - -

Inequality

-
- -
- - -

Math

-
- -
- - -

Running Eve

-
- -
- - -

Set: :=

-
- -
- - -

Sets

-
- -
- - -

Tags

-
- -
- - -

bind

-
- -
- - -

@event

-
- -
- - -

Actions

-
- -
- - -

Getting Help

-
- -
- - -

Joins

-
- -
- - -

Literate Programming

-
- -
- - -

Remove: -=

-
- -
- - -

Strings

-
- -
- - -

commit

-
- -
- - -

if-then

-
- -
- - -

@http

-
- -
- - -

Blocks

-
- -
- - -

Docker

-
- -
- - -

Expressions

-
- -
- - -

Merge <-

-
- -
- - -

Statistics

-
- -
- - -

is

-
- -
- - -

not

-
- -
- - -

@view

-
- -
- - -

Date & Time

-
- -
- - -

String Interpolation

-
- -
- - -

Update Operators

-
- -
- - -

npm

-
- -
- - -

Glossary

-
- -
-
diff --git a/handbook/index.xml b/handbook/index.xml index 98aea9c..94f2470 100644 --- a/handbook/index.xml +++ b/handbook/index.xml @@ -2,7 +2,7 @@ Handbooks on Eve Documentation - http://docs.witheve.com/handbook/ + http://docs.witheve.com/handbook/index.xml Recent content in Handbooks on Eve Documentation Hugo -- gohugo.io en-us @@ -14,645 +14,500 @@ Mon, 01 Jan 0001 00:00:00 +0000 http://docs.witheve.com/handbook/core/ - - -<h1 id="core-language">Core Language</h1> - -<h2 id="see-also">See Also</h2> - -<p><a href="../records">records</a> | <a href="../equivalence">equivalence</a> | <a href="../actions">actions</a> | <a href="../expressions">expressions</a> | <a href="../update-operators">update operators</a> | <a href="../databases">databases</a></p> - + - http://docs.witheve.com/handbook/databases/ + http://docs.witheve.com/handbook/libraries/ Mon, 01 Jan 0001 00:00:00 +0000 - http://docs.witheve.com/handbook/databases/ - - -<h1 id="databases">Databases</h1> - -<p>Databases contain records</p> - -<h2 id="syntax">Syntax</h2> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="c1">// search action</span><span class="w"></span> -<span class="kr">search</span><span class="w"> </span><span class="nt">@database1</span><span class="p">,</span><span class="w"> </span><span class="x">...</span><span class="p">,</span><span class="w"> </span><span class="nt">@databaseN</span><span class="w"></span> - -<span class="c1">// Commit action</span><span class="w"></span> -<span class="kr">commit</span><span class="w"> </span><span class="nt">@database1</span><span class="p">,</span><span class="w"> </span><span class="x">...</span><span class="p">,</span><span class="w"> </span><span class="nt">@databaseN</span><span class="w"></span> - -<span class="c1">// Bind action</span><span class="w"></span> -<span class="kr">bind</span><span class="w"> </span><span class="nt">@database1</span><span class="p">,</span><span class="w"> </span><span class="x">...</span><span class="p">,</span><span class="w"> </span><span class="nt">@databaseN</span><span class="w"></span> -</code></pre></div> - -<h2 id="description">Description</h2> - -<p><code>&lt;action&gt; @database</code> performs the given action, one of <code>search</code>, <code>bind</code>, or <code>commit</code>, on the union of the provided databases.</p> - -<p>If no database is provided with an action, then that action is performed on the default <code>@session</code> database.</p> - -<h2 id="creating-and-searching-databases">Creating and Searching Databases</h2> - -<p>You can create databases on-demand by simply committing a record to one. e.g.</p> - -<pre><code>commit @my-database - [#my-record] -</code></pre> - -<p>This block will create a new database called &ldquo;my-database&rdquo;, which will contain the newly committed record. You can now search for this record in your new database:</p> - -<pre><code>search @my-database - [#my-record] - -bind @browser - [#div text: &quot;Found a record!&quot;] -</code></pre> - -<h2 id="special-databases">Special Databases</h2> - -<p>Eve has some built-in databases that have meaning to the runtime.</p> - -<ul> -<li><a href="../session">@session</a> - the default database when no database is specified with an action.</li> -<li><a href="../view">@view</a> - records committed to <code>@view</code> are used to visualize data.</li> -<li><a href="../event">@event</a> - contains events originating from the DOM</li> -<li><a href="../browser">@browser</a> - Eve clients running in the browser render applicable records in this <code>@browser</code> as HTML elements.</li> -<li><a href="../http">@http</a> - Stores records representing HTTP requests and responses</li> -</ul> - -<h2 id="examples">Examples</h2> - -<p>Display the element that was clicked in the DOM</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"> </span><span class="nt">@event</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#click</span><span class="w"> </span><span class="nt">#direct-target</span><span class="w"> </span><span class="x">element</span><span class="p">]</span><span class="w"></span> - -<span class="kr">commit</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;{{element}} was clicked.&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>Commit some data in <code>@session</code>, and then display it on a button click.</p> - -<pre><code>commit - [#for-display text: &quot;Hello&quot;] -</code></pre> - -<p>We are searching over three databases to complete this block.</p> - -<ul> -<li>the <code>#click</code> is in <code>@event</code></li> -<li>the <code>#button</code> is in <code>@browser</code></li> -<li>the text for display is in <code>@session</code>. This needs to be made explicit; since we are searching in other databases, <code>@session</code> is not searched implicitly.</li> -</ul> - -<pre><code>search @event @browser @session - [#click element: [#button]] - [#for-display text] - -commit @browser - [#div text] -</code></pre> - -<p>This block could have been written with two searches for the same effect:</p> - -<pre><code>search @event @browser - [#click element: [#button]] - -search - [#for-display text] - -commit @browser - [#div text] -</code></pre> - -<h2 id="see-also">See Also</h2> - -<p><a href="../search">search</a> | <a href="../bind">bind</a> | <a href="../commit">commit</a></p> - - - - - - http://docs.witheve.com/handbook/intro/ - Mon, 01 Jan 0001 00:00:00 +0000 - - http://docs.witheve.com/handbook/intro/ - - -<h1 id="introduction">Introduction</h1> - -<h2 id="notable-features">Notable Features</h2> - -<ul> -<li><p>Eve programs aren&rsquo;t talking to a database, they <em>are</em> the database. That means no plumbing, no impedance mismatch, and no extra infrastructure is needed.</p></li> - -<li><p>Everything is data. The file system, http requests, the DOM&hellip; That means everything can be queried and everything can be reacted to.</p></li> - -<li><p>Eve&rsquo;s semantics were built for concurrency, asynchrony, and distribution. There are no promises, or thread synchronizations, or borrows.</p></li> - -<li><p>Eve programs practice literate programming, since there&rsquo;s no incidental ordering imposed by the language.</p></li> - -<li><p>Another result of a lack of ordering is that programs grow very organically through composition.</p></li> - -<li><p>Eve programs are naturally tiny.</p></li> - -<li><p>Correctness can be defined globally through integrity constraints, allowing people to safely contribute to an application without worrying about checking every possible invariant locally.</p></li> -</ul> - -<h2 id="see-also">See Also</h2> - -<p><a href="../installation">getting eve</a> | <a href="../running">running eve</a> | <a href="../programs">eve programs</a> | <a href="../core">core language</a></p> - + http://docs.witheve.com/handbook/libraries/ + - http://docs.witheve.com/handbook/programs/ - Mon, 01 Jan 0001 00:00:00 +0000 - - http://docs.witheve.com/handbook/programs/ - - -<h1 id="eve-programs">Eve Programs</h1> - -<p>Coming soon&hellip;</p> - -<h2 id="see-also">See Also</h2> - -<p><a href="../model">programming model</a> | <a href="../literate-programming">literate programming</a> | <a href="../blocks">blocks</a></p> - - - - - Linux - http://docs.witheve.com/handbook/linux/ + http://docs.witheve.com/handbook/libraries/stdlib/ Mon, 01 Jan 0001 00:00:00 +0000 - http://docs.witheve.com/handbook/linux/ - - -<h1 id="installing-eve-on-linux">Installing Eve on Linux</h1> - -<p>First, <a href="https://github.com/witheve/Eve/archive/master.zip">download</a> the Eve source. You&rsquo;ll need a recent <a href="https://nodejs.org">node.js</a> and then in the extracted Eve directory:</p> - -<pre><code>npm install -npm start -</code></pre> - -<p>Then open <code>http://localhost:8080/</code> in your browser.</p> - -<h2 id="tips">Tips</h2> - -<p>Some distributions (most notably Ubuntu) have renamed <code>node</code> to <code>nodejs</code>. If this is the case, you&rsquo;ll need to create a symlink that remaps nodejs back to node. e.g.</p> - -<pre><code>ln -s /usr/bin/nodejs /usr/bin/node -</code></pre> - -<p>Then proceed with the installation as usual</p> - -<h2 id="see-also">See also</h2> - -<p><a href="../mac">mac</a> | <a href="../windows">windows</a> | <a href="../docker">docker</a> | <a href="../running">running</a></p> - + http://docs.witheve.com/handbook/libraries/stdlib/ + <head> + <link rel="stylesheet" type="text/css" href="style.css"> +</head> + +<body> + + <h2> + Aggregates + </h2> + + <table> + <tr> + <td> + <h3>gather/sort</h3> + Generates an ordering for a set + </td> + <td> + <ul> + <li><strong>for</strong> - the set to sort</li> + <li><strong>per</strong> - (optional) - one or more attributes by which to group `for`</li> + <li><strong>direction</strong> - (optional) - direction in which to sort `for`. Possible values are: + <ul> + <li>'up' - smallest to largest; default option</li> + <li>'down' - largest to smallest</li> + </ul> + </li> + </ul> + </td> + <td> + <code>// sorts the students by GPA + [#student GPA] + index = sort[value: GPA]</code> + </td> + </tr> + + <tr> + <td> + <h3>gather/count</h3> + Returns the number of elements in a set + </td> + <td> + <ul> + <li><strong>for</strong> - the set to count over</li> + <li><strong>per</strong> - (optional) - one or more attributes by which to group `for`</li> + </ul> + </td> + <td> + <code>// counts the number of citizens in each state + residents = [#citizen state] + population = count[given: residents, per: state]</code> + </td> + </tr> + + <tr> + <td> + <h3>gather/sum</h3> + Returns the sum of values in a set of attributes + </td> + <td> + <ul> + <li><strong>for</strong> - the set to gather</li> + <li><strong>value</strong> - the specific variable to be summed</li> + <li><strong>per</strong> - (optional) - one or more attributes by which to group `for`</li> + </ul> + </td> + <td> + <code>// returns the sum of salaries for each department + employees = [#employee salary department] + expenses = gather/sum[for: employees, value: employees.salary, per: department]</code> + </td> + </tr> + </table> + + <h2> + Math + </h2> + + <table> + <tr> + <td> + <h3>+</h3> + Adds two numbers + </td> + <td> + <ul> + <li>Infix notation</li> + </ul> + </td> + <td> + <code>total-debt = credit-card + debit-card</code> + </td> + </tr> + + <tr> + <td> + <h3>-</h3> + Subtracts two numbers + </td> + <td> + <ul> + <li>Infix notation</li> + </ul> + </td> + <td> + <code>remaining-debt = total-debt - amount_paid</code> + </td> + </tr> + + <tr> + <td> + <h3>*</h3> + Multiplies two numbers + </td> + <td> + <ul> + <li>Infix notation</li> + </ul> + </td> + <td> + <code>yearly-payments = monthly-payments * 12</code> + </td> + </tr> + + <tr> + <td> + <h3>/</h3> + Divides two numbers + </td> + <td> + <ul> + <li>Infix notation</li> + </ul> + </td> + <td> + <code>monthly-payments = yearly-payments / 12</code> + </td> + </tr> + + <tr> + <td> + <h3>math/floor</h3> + Rounds a number down + </td> + <td> + <ul> + <li><strong>a</strong> - the number to be rounded down</li> + </ul> + </td> + <td> + <code>// x rounded down to 34 + x = math/floor[a: 34.2]</code> + </td> + </tr> + + <tr> + <td> + <h3>math/ceil</h3> + Rounds a number up + </td> + <td> + <ul> + <li><strong>a</strong> - the number to be rounded up</li> + </ul> + </td> + <td> + <code>// x rounded up to 35 + x = math/floor[a: 34.2]</code> + </td> + </tr> + + <tr> + <td> + <h3>math/round</h3> + Rounds a number to the nearest integer + </td> + <td> + <ul> + <li><strong>a</strong> - the number to be rounded to the nearest integer</li> + </ul> + </td> + <td> + <code>// x rounded to 34 + x = math/floor[a: 34.2]</code> + </td> + </tr> + + <tr> + <td> + <h3>math/sin</h3> + Sine of an angle + </td> + <td> + <ul> + <li><strong>a</strong> - the angle in degrees</li> + </ul> + </td> + <td> + <code>// r calculated to 1 + r = math/sin[a: 90]</code> + </td> + </tr> + + <tr> + <td> + <h3>math/cos</h3> + Cosine of an angle + </td> + <td> + <ul> + <li><strong>a</strong> - the angle in degrees</li> + </ul> + </td> + <td> + <code>// r calculated to 0 + r = math/cos[a: 90]</code> + </td> + </tr> + + <tr> + <td> + <h3>math/tan</h3> + Tangent of an angle + </td> + <td> + <ul> + <li><strong>a</strong> - the angle in degrees</li> + </ul> + </td> + <td> + <code>// r calculated to 1 + r = math/tan[a: 45]</code> + </td> + </tr> + + <tr> + <td> + <h3>math/max</h3> + The greater of two values + </td> + <td> + <ul> + <li><strong>a</strong> - a value to compare</li> + <li><strong>b</strong> - another value to compare</li> + </ul> + </td> + <td> + <code>// takes the higher score + [#scores pac-man donkey-kong] + best-score = math/min[a: pac-man, b: donkey-kong]</code> + </td> + </tr> + + <tr> + <td> + <h3>math/min</h3> + The lesser of two values + </td> + <td> + <ul> + <li><strong>a</strong> - a value to compare</li> + <li><strong>b</strong> - another value to compare</li> + </ul> + </td> + <td> + <code>// takes the lower score + [#scores pac-man donkey-kong] + worst-score = math/min[a: pac-man, b: donkey-kong]</code> + </td> + </tr> + + <tr> + <td> + <h3>math/mod</h3> + Modulo division + </td> + <td> + <ul> + <li><strong>a</strong> - the number to be divided (dividend)</li> + <li><strong>b</strong> - the number by which to divide (divisor)</li> + </ul> + </td> + <td> + <code>// m is the remainder, 1 + m = math/mod[a: 5, b: 2]</code> + </td> + </tr> + + <tr> + <td> + <h3>math/abs</h3> + Absolute value of a number + </td> + <td> + <ul> + <li><strong>a</strong> - the number whose absolute value is found</li> + </ul> + </td> + <td> + <code>// number of hours from the prime meridian + [#city latitude longitude] + hours-from-gmt = math/abs[a: latitude] / 15</code> + </td> + </tr> + + <tr> + <td> + <h3>math/to-fixed</h3> + Formats a number as a string to a certain number of decimal places + </td> + <td> + <ul> + <li><strong>a</strong> - the number to be formatted</li> + <li><strong>b</strong> - the number of decimal places to which `a` will be formatted</li> + </ul> + </td> + <td> + <code>// pi represented as the string "3.14" + [#circle circumference diameter] + pi = math/to-fixed[a: (circumference / diameter), b: 2]</code> + </td> + </tr> + + <tr> + <td> + <h3>math/range</h3> + Generates a range of numbers + </td> + <td> + <ul> + <li><strong>start</strong> - the start of the range</li> + <li><strong>stop</strong> - the end of the range</li> + </ul> + </td> + <td> + <code>// generates integers 1 through 10 + y = math/range[start: 1, stop: 10]</code> + </td> + </tr> + + <tr> + <td> + <h3>random/number</h3> + Generates a random number between 1 and 0 + </td> + <td> + <ul> + <li><strong>seed</strong> - a number used to initialize the random number generator</li> + </ul> + </td> + <td> + <code>// generates a random number every second + [#time minutes seconds] + x = random/number[seed: seconds]</code> + </td> + </tr> + </table> + + <h2> + Strings + </h2> + + <table> + <tr> + <td> + <h3>string/replace</h3> + Replaces a string of text with another + </td> + <td> + <ul> + <li><strong>text</strong> - the text in which to search for strings and replace them</li> + <li><strong>replace</strong> - the string to be replaced</li> + <li><strong>with</strong> - the string that will replace `replace`</li> + </ul> + </td> + <td> + <code>// Americanized version of British spelling + [#website body] + american-version = string/replace[text: body, replace: "flavour", with: "flavor"]</code> + </td> + </tr> + + <tr> + <td> + <h3>string/get</h3> + Gets a character from a specific location in a string + </td> + <td> + <ul> + <li><strong>text</strong> - the text to be searched</li> + <li><strong>at</strong> - the location to be searched</li> + </ul> + </td> + <td> + <code>// finds the 17th letter of the alphabet + alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + letter = string/get[text: alphabet, at: 17]</code> + </td> + </tr> + + <tr> + <td> + <h3>string/uppercase</h3> + Converts a string to uppercase + </td> + <td> + <ul> + <li><strong>text</strong> - the text to be converted</li> + </ul> + </td> + <td> + <code>funny = "lol" +really-funny = string/uppercase[text: funny]</code> + </td> + </tr> + + <tr> + <td> + <h3>string/lowercase</h3> + Converts a string to lowercase + </td> + <td> + <ul> + <li><strong>text</strong> - the text to be converted</li> + </ul> + </td> + <td> + <code>really-funny = "LOL" +down-a-notch = string/uppercase[text: really-funny]</code> + </td> + </tr> + + <tr> + <td> + <h3>string/index-of</h3> + Returns the position of the first occurrence of a specified value in a string + </td> + <td> + <ul> + <li><strong>text</strong> - the text to be searched</li> + <li><strong>substring</strong> - the string to be found in `text`</li> + </ul> + </td> + <td> + <code>// Eve is in developers, starting at an index of 2 +index = string/index_of[text: "developers", substring: "eve"</code> + </td> + </tr> + + <tr> + <td> + <h3>string/codepoint-length</h3> + Returns the length of a string in Unicode code points. + </td> + <td> + <ul> + <li><strong>text</strong> - the string whose length is found</li> + </ul> + </td> + <td> + <code>// the code point length of the word "unicode" +string = "unicode" +length-in-js = string/codepoint_length[text: string]</code> + </td> + </tr> + </table> + +</body> - Mac - http://docs.witheve.com/handbook/mac/ + Getting Eve + http://docs.witheve.com/handbook/ Mon, 01 Jan 0001 00:00:00 +0000 - http://docs.witheve.com/handbook/mac/ - - -<h1 id="installing-eve-on-mac">Installing Eve on Mac</h1> - -<p>First, <a href="https://github.com/witheve/Eve/archive/master.zip">download</a> the Eve source. You&rsquo;ll need a recent <a href="https://nodejs.org">node.js</a> and then in the extracted Eve directory:</p> - -<pre><code>npm install -npm start -</code></pre> - -<p>Then open <code>http://localhost:8080/</code> in your browser.</p> - -<h2 id="see-also">See also</h2> - -<p><a href="../linux">linux</a> | <a href="../windows">windows</a> | <a href="../docker">docker</a> | <a href="../npm">npm</a> | <a href="../running">running</a></p> - - - - - Standard Library - http://docs.witheve.com/handbook/standard-library/ - Mon, 01 Jan 0001 00:00:00 +0000 - - http://docs.witheve.com/handbook/standard-library/ - - -<h1 id="standard-library">Standard Library</h1> - -<p>The Eve standard library of functions is globally available, meaning you don&rsquo;t have to reference a specific database to use these functions.</p> - -<h2 id="description">Description</h2> - -<ul> -<li><a href="../general">general</a> - General functions</li> -<li><a href="../math">math</a> - General mathematical and trigonometric functions</li> -<li><a href="../strings">strings</a> - Functions that manipulate strings</li> -<li><a href="../statistics">statistics</a> - Functions that calculate statistical measures on values</li> -<li><a href="../datetime">date &amp; time</a> - Functions that get and manipulate date and time</li> -</ul> - - - - - Windows - http://docs.witheve.com/handbook/windows/ - Mon, 01 Jan 0001 00:00:00 +0000 - - http://docs.witheve.com/handbook/windows/ - - -<h1 id="installing-eve-on-windows">Installing Eve on Windows</h1> - -<p>First, <a href="https://github.com/witheve/Eve/archive/master.zip">download</a> the Eve source. You&rsquo;ll need a recent <a href="https://nodejs.org">node.js</a> and then in the extracted Eve directory:</p> - -<pre><code>npm install -npm start -</code></pre> - -<p>Then open <code>http://localhost:8080/</code> in your browser.</p> - -<h2 id="see-also">See also</h2> - -<p><a href="../linux">linux</a> | <a href="../mac">mac</a> | <a href="../docker">docker</a> | <a href="../npm">npm</a> | <a href="../running">running</a></p> - - - - - abs - http://docs.witheve.com/handbook/math/abs/ - Mon, 01 Jan 0001 00:00:00 +0000 - - http://docs.witheve.com/handbook/math/abs/ - - -<h1 id="abs">abs</h1> - -<p>The absolute value of a number</p> - -<h2 id="syntax">Syntax</h2> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="x">y</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">abs</span><span class="p">[</span><span class="x">value</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<h2 id="attributes">Attributes</h2> - -<ul> -<li><code>value</code> - a set of numbers</li> -</ul> - -<h2 id="description">Description</h2> - -<p><code>y = abs[value]</code> returns the absolute value of the elements in <code>value</code>. Every positive number is kept positive, but every negative number is made positive.</p> - -<h2 id="examples">Examples</h2> - -<p>Get the absolute value of a number</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="w"> </span><span class="x">y</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">abs</span><span class="p">[</span><span class="x">value</span><span class="nf">:</span><span class="w"> </span><span class="nf">-</span><span class="m">3</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span> -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="x">y</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>Displays the number <code>3</code>.</p> - -<h2 id="see-also">See Also</h2> - -<p><a href="../sign">sign</a></p> - - - - - ceiling - http://docs.witheve.com/handbook/math/ceil/ - Mon, 01 Jan 0001 00:00:00 +0000 - - http://docs.witheve.com/handbook/math/ceil/ - - -<h1 id="ceiling">ceiling</h1> - -<p>Round a number up to the nearest integer.</p> - -<h2 id="syntax">Syntax</h2> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="x">y</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">ceiling</span><span class="p">[</span><span class="x">value</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<h2 id="attributes">Attributes</h2> - -<ul> -<li><code>value</code> - a set of numbers</li> -</ul> - -<h2 id="description">Description</h2> - -<p><code>y = ceiling[value]</code> rounds the elements of <code>value</code> up to the nearest integers.</p> - -<h2 id="examples">Examples</h2> - -<p>Calculate the ceiling of <code>34.2</code></p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="w"> </span><span class="x">y</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">ceiling</span><span class="p">[</span><span class="x">value</span><span class="nf">:</span><span class="w"> </span><span class="m">34</span><span class="x">.</span><span class="m">2</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span> -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="x">y</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>The result is <code>35</code>.</p> - -<h2 id="see-also">See Also</h2> - -<p><a href="../floor">floor</a> | <a href="../fix">fix</a> | <a href="../round">round</a></p> - - - - - click - http://docs.witheve.com/handbook/event/click/ - Mon, 01 Jan 0001 00:00:00 +0000 - - http://docs.witheve.com/handbook/event/click/ - - -<h1 id="click">click</h1> - -<p>click event</p> - -<h2 id="syntax">Syntax</h2> - -<pre><code>[#click] -[#click element] -[#click #direct-target element] -</code></pre> - -<h2 id="attributes">Attributes</h2> - -<ul> -<li><code>#direct-target</code> - selects only directly clicked elements, as opposed to elements to which the event bubbles.</li> -<li><code>element</code> - the element that was clicked.</li> -</ul> - -<h2 id="description">Description</h2> - -<p>When an element in the DOM is clicked, a <code>#click</code> record is created in the <code>@event</code> database.</p> - -<h2 id="examples">Examples</h2> - -<h2 id="see-also">See Also</h2> - - - - - cos - http://docs.witheve.com/handbook/math/cos/ - Mon, 01 Jan 0001 00:00:00 +0000 - - http://docs.witheve.com/handbook/math/cos/ - - -<h1 id="cos">cos</h1> - -<p>Calculate the cosine of an angle</p> - -<h2 id="syntax">Syntax</h2> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="x">y</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">cos</span><span class="p">[</span><span class="x">radians</span><span class="p">]</span><span class="w"></span> -<span class="x">y</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">cos</span><span class="p">[</span><span class="x">degrees</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<h2 id="attributes">Attributes</h2> - -<ul> -<li><code>radians</code> - the angle in radians</li> -<li><code>degrees</code> - the angle in degrees</li> -</ul> - -<h2 id="description">Description</h2> - -<p><code>y = cos[degrees]</code> calculates the cosine of an input in degrees.</p> - -<p><code>y = cos[radians]</code> calculates the cosine of an input in radians.</p> - -<p><code>cos</code> operates element-wise on its inputs.</p> - -<h2 id="examples">Examples</h2> - -<p>Calculate the cosine of 90 degrees</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="w"> </span><span class="x">y</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">cos</span><span class="p">[</span><span class="x">degrees</span><span class="nf">:</span><span class="w"> </span><span class="m">90</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span> -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="x">y</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<h2 id="see-also">See Also</h2> - -<p><a href="../sin">sin</a> | <a href="../tan">tan</a></p> - - - - - count - http://docs.witheve.com/handbook/statistics/count/ - Mon, 01 Jan 0001 00:00:00 +0000 - - http://docs.witheve.com/handbook/statistics/count/ - - -<h1 id="count">count</h1> - -<p>Returns the number of elements in a set</p> - -<h2 id="syntax">Syntax</h2> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="x">y</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">count</span><span class="p">[</span><span class="x">given</span><span class="p">]</span><span class="w"></span> -<span class="x">y</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">count</span><span class="p">[</span><span class="x">given</span><span class="p">,</span><span class="w"> </span><span class="x">per</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<h2 id="attributes">Attributes</h2> - -<ul> -<li><code>given</code> - the set to count over</li> -<li><code>per</code> - <em>optional</em> - one or more attributes by which to group <code>given</code>.</li> -</ul> - -<h2 id="description">Description</h2> - -<p><code>y = count[given]</code> counts the number of elements in <code>given</code>.</p> - -<p><code>y = count[given, per]</code> counts the number of elements in <code>given</code>, grouped by the attribute(s) provided in <code>per</code>. For instance, <code>class-size = count[given: students, per: grade]</code> would count the number of students in each grade. You can group along multiple axes; the previous example could be extended to work across multiple schools by doing <code>class-size = count[given: students, per: (grade, school)]</code>. See the examples section to see these in action.</p> - -<h2 id="examples">Examples</h2> - -<p>Before we get to the <code>count</code> examples, let&rsquo;s add some students. Each <code>#student</code> has a <code>grade</code> and a <code>school</code>. Grades are one of 10, 11, or 12. Schools are one of &ldquo;West&rdquo; and &ldquo;East&rdquo;.</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">commit</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;Diedra&quot;</span><span class="w"> </span><span class="x">grade</span><span class="nf">:</span><span class="w"> </span><span class="m">10</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;West&quot;</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;Celia&quot;</span><span class="w"> </span><span class="x">grade</span><span class="nf">:</span><span class="w"> </span><span class="m">10</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;West&quot;</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;Michaela&quot;</span><span class="w"> </span><span class="x">grade</span><span class="nf">:</span><span class="w"> </span><span class="m">11</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;West&quot;</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;Jermaine&quot;</span><span class="w"> </span><span class="x">grade</span><span class="nf">:</span><span class="w"> </span><span class="m">11</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;West&quot;</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;Issac&quot;</span><span class="w"> </span><span class="x">grade</span><span class="nf">:</span><span class="w"> </span><span class="m">12</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;West&quot;</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;Jamar&quot;</span><span class="w"> </span><span class="x">grade</span><span class="nf">:</span><span class="w"> </span><span class="m">12</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;West&quot;</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;Yee&quot;</span><span class="w"> </span><span class="x">grade</span><span class="nf">:</span><span class="w"> </span><span class="m">10</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;East&quot;</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;Johanne&quot;</span><span class="w"> </span><span class="x">grade</span><span class="nf">:</span><span class="w"> </span><span class="m">10</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;East&quot;</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;Mertie&quot;</span><span class="w"> </span><span class="x">grade</span><span class="nf">:</span><span class="w"> </span><span class="m">10</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;East&quot;</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;Elmira&quot;</span><span class="w"> </span><span class="x">grade</span><span class="nf">:</span><span class="w"> </span><span class="m">11</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;East&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>First let&rsquo;s count the total number of students in the school district.</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="w"> </span><span class="x">students</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="x">enrollment</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">count</span><span class="p">[</span><span class="x">given</span><span class="nf">:</span><span class="w"> </span><span class="x">students</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"> </span><span class="nt">@view</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#value</span><span class="w"> </span><span class="x">|</span><span class="w"> </span><span class="x">value</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;There are {{enrollment}} students in the district&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>Now let&rsquo;s count the number of students in each school.</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="w"> </span><span class="x">students</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">school</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="x">school</span><span class="nf">-</span><span class="x">enrollment</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">count</span><span class="p">[</span><span class="x">given</span><span class="nf">:</span><span class="w"> </span><span class="x">students</span><span class="p">,</span><span class="w"> </span><span class="x">per</span><span class="nf">:</span><span class="w"> </span><span class="x">school</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"> </span><span class="nt">@view</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#value</span><span class="w"> </span><span class="x">|</span><span class="w"> </span><span class="x">value</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;{{school-enrollment}} attend {{school}}&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>We could have similarly counted the number of students in each grade across the district.</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="w"> </span><span class="x">students</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">grade</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="x">grade</span><span class="nf">-</span><span class="x">enrollment</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">count</span><span class="p">[</span><span class="x">given</span><span class="nf">:</span><span class="w"> </span><span class="x">students</span><span class="p">,</span><span class="w"> </span><span class="x">per</span><span class="nf">:</span><span class="w"> </span><span class="x">grade</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"> </span><span class="nt">@view</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#value</span><span class="w"> </span><span class="x">|</span><span class="w"> </span><span class="x">value</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;{{grade-enrollment}} students are in {{grade}}th grade&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>Finally, we can count the number of students per grade, per school.</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="w"> </span><span class="x">students</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">grade</span><span class="w"> </span><span class="x">school</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="x">grade</span><span class="nf">-</span><span class="x">school</span><span class="nf">-</span><span class="x">enrollment</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">count</span><span class="p">[</span><span class="x">given</span><span class="nf">:</span><span class="w"> </span><span class="x">students</span><span class="p">,</span><span class="w"> </span><span class="x">per</span><span class="nf">:</span><span class="w"> </span><span class="p">(</span><span class="x">grade</span><span class="p">,</span><span class="w"> </span><span class="x">school</span><span class="p">)]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"> </span><span class="nt">@view</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#value</span><span class="w"> </span><span class="x">|</span><span class="w"> </span><span class="x">value</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;{{grade-school-enrollment}} students are in {{grade}}th grade at {{school}}&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<h3 id="example-usage">Example Usage</h3> - -<ul> -<li><a href="http://play.witheve.com/#/examples/todomvc.eve">TodoMVC</a></li> -<li><a href="http://play.witheve.com/#/examples/tic-tac-toe.eve">Tic-Tac-Toe</a></li> -</ul> - -<h2 id="see-also">See Also</h2> - -<p><a href="../../math/sum">sum</a> | <a href="../../aggregates">aggregates</a></p> - - - - - fix - http://docs.witheve.com/handbook/math/fix/ - Mon, 01 Jan 0001 00:00:00 +0000 - - http://docs.witheve.com/handbook/math/fix/ - - -<h1 id="fix">fix</h1> - -<p>Round a number toward zero.</p> - -<h2 id="syntax">Syntax</h2> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="x">y</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">fix</span><span class="p">[</span><span class="x">value</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<h2 id="attributes">Attributes</h2> - -<ul> -<li><code>value</code> - a set of numbers</li> -</ul> - -<h2 id="description">Description</h2> - -<p><code>y = fix[value]</code> rounds the elements of <code>value</code> toward zero. This means that negative numbers will be rounded up to the nearest integer, while positive numbers will be rounded down.</p> - -<h2 id="examples">Examples</h2> - -<p>Calculate the fix of <code>34.7</code> and <code>-34.7</code></p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="w"> </span><span class="x">y</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">fix</span><span class="p">[</span><span class="x">value</span><span class="nf">:</span><span class="w"> </span><span class="m">34</span><span class="x">.</span><span class="m">7</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="x">z</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">fix</span><span class="p">[</span><span class="x">value</span><span class="nf">:</span><span class="w"> </span><span class="nf">-</span><span class="m">34</span><span class="x">.</span><span class="m">7</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;The fix of 34.7 is {{y}}&quot;</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;The fix of -34.7 is {{z}}&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>We see that the fix of <code>34.7</code> is <code>34</code>, while the fix of <code>-34.7</code> is <code>-34</code>. Compare this to rounding the numbers:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="w"> </span><span class="x">y</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">round</span><span class="p">[</span><span class="x">value</span><span class="nf">:</span><span class="w"> </span><span class="m">34</span><span class="x">.</span><span class="m">7</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="x">z</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">round</span><span class="p">[</span><span class="x">value</span><span class="nf">:</span><span class="w"> </span><span class="nf">-</span><span class="m">34</span><span class="x">.</span><span class="m">7</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;The round of 34.7 is {{y}}&quot;</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;The round of -34.7 is {{z}}&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>We see that the round of <code>34.7</code> is <code>35</code>, while the round of <code>-34.7</code> is <code>-35</code>.</p> - -<h2 id="see-also">See Also</h2> - -<p><a href="../floor">floor</a> | <a href="../ceil">ceil</a> | <a href="../round">round</a></p> - - - - - floor - http://docs.witheve.com/handbook/math/floor/ - Mon, 01 Jan 0001 00:00:00 +0000 - - http://docs.witheve.com/handbook/math/floor/ - - -<h1 id="floor">floor</h1> - -<p>Round a number down to the nearest integer.</p> - -<h2 id="syntax">Syntax</h2> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="x">y</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">floor</span><span class="p">[</span><span class="x">value</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<h2 id="attributes">Attributes</h2> - -<ul> -<li><code>value</code> - a set of numbers</li> -</ul> - -<h2 id="description">Description</h2> - -<p><code>y = floor[value]</code> rounds the elements of <code>value</code> down to the nearest integers.</p> - -<h2 id="examples">Examples</h2> - -<p>Calculate the floor of <code>34.2</code></p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="w"> </span><span class="x">y</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">floor</span><span class="p">[</span><span class="x">value</span><span class="nf">:</span><span class="w"> </span><span class="m">34</span><span class="x">.</span><span class="m">2</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="x">y</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>The result is <code>34</code>.</p> - -<h2 id="see-also">See Also</h2> - -<p><a href="ceil.md">ceil</a> | <a href="fix.md">fix</a> | <a href="round.md">round</a></p> + http://docs.witheve.com/handbook/ + <p>Test</p> diff --git a/handbook/inequality/index.html b/handbook/inequality/index.html deleted file mode 100644 index c4d535d..0000000 --- a/handbook/inequality/index.html +++ /dev/null @@ -1,428 +0,0 @@ - - - - - - - - - - - - Inequality - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Inequality

- -

inequality operators filter records

- -

Syntax

-
// Inequality Operators
->, >=, <, <=, !=
-
-// Inside of records
-[attribute >= value]
-[attribute >= variable]
-
-// Outside of records
-variable >= value
-variable >= variable
-
-// Satisfy multiple constraints in a single line
-value <= variable <= value   
-variable <= variable <= variable
-
- -

Description

- -

Attributes can be filtered using inequality operators, including >, >=, <, <= and !=.

- -

>, >=, <, <= can only filter using values that can be sorted. For instance, you can use these operators to filter numbers, but you cannot filter records this way.

- -

!= tests only for inequality, and doesn’t compare whether an attribute is greater or less than a particular value. Therefore, != can be used to filter any value.

- -

You can use inequality operators inside records or outside of them. Inside of records, you can filter an attribute on a single value. Outside of records, you have more freedom to filter on multiple values. For instance, if you want only records with an attribute between a maximum and minimum value, you can write something like min-value < variable < max-value.

- -

Examples

- -

Select students with a low GPA

-
search @test-data
-  [#student name GPA < 2.0]
-
-bind @browser
-  [#div text: "{{name}} needs a tutor."]
-
- -

Select students with a GPA over 2.0 but less than 3.0

-
search @test-data
-  [#student name GPA]
-  2.0 <= GPA < 3.0
-
-bind @browser
-  [#div text: "{{name}} is doing fine"]
-
- -

You can be very specific with filters. Select students named “John” in 11th or 12th grade with a GPA between 2.0 and 3.0, and who don’t attend “West” high school.

-
search @test-data
-  students = [#student name: "John", grade >= 11, school != "West" ]
-  2.0 <= students.GPA < 3.0
-
-bind @browser
-  [#div text: "{{name}} is doing fine"]  
-
- -

See Also

- -

equality | joins | equivalence

- - -
-
- -
- diff --git a/handbook/installation/index.html b/handbook/installation/index.html deleted file mode 100644 index d336174..0000000 --- a/handbook/installation/index.html +++ /dev/null @@ -1,380 +0,0 @@ - - - - - - - - - - - - Getting Eve - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - -
- diff --git a/handbook/intro/index.html b/handbook/intro/index.html deleted file mode 100644 index eeb59ff..0000000 --- a/handbook/intro/index.html +++ /dev/null @@ -1,389 +0,0 @@ - - - - - - - - - - - - - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Introduction

- -

Notable Features

- -
    -
  • Eve programs aren’t talking to a database, they are the database. That means no plumbing, no impedance mismatch, and no extra infrastructure is needed.

  • - -
  • Everything is data. The file system, http requests, the DOM… That means everything can be queried and everything can be reacted to.

  • - -
  • Eve’s semantics were built for concurrency, asynchrony, and distribution. There are no promises, or thread synchronizations, or borrows.

  • - -
  • Eve programs practice literate programming, since there’s no incidental ordering imposed by the language.

  • - -
  • Another result of a lack of ordering is that programs grow very organically through composition.

  • - -
  • Eve programs are naturally tiny.

  • - -
  • Correctness can be defined globally through integrity constraints, allowing people to safely contribute to an application without worrying about checking every possible invariant locally.

  • -
- -

See Also

- -

getting eve | running eve | eve programs | core language

- - -
-
- -
- diff --git a/handbook/is/index.html b/handbook/is/index.html deleted file mode 100644 index 2769806..0000000 --- a/handbook/is/index.html +++ /dev/null @@ -1,400 +0,0 @@ - - - - - - - - - - - - is - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

is

- -

Tests the truth of a statement

- -

Syntax

-
y = is( ... )
-
- -

Description

- -

y = is( ... ) tests the truth of the statement contained in the parentheses. If the statement is true, then is returns the value true, otherwise it returns false.

- -

Examples

-
search
-  x = 10
-  y = is(20 = x)
-  z = is(20 = x * 2)
-
-bind @browser
-  [#div text: "y is {{y}}"]
-  [#div text: "z is {{z}}"]
-
- -

The output shows that y is false while z is true.

- -

Example Usage

- - - -

See Also

- -

not | records | expressions

- - -
-
- -
- diff --git a/handbook/joins/index.html b/handbook/joins/index.html deleted file mode 100644 index fcea673..0000000 --- a/handbook/joins/index.html +++ /dev/null @@ -1,387 +0,0 @@ - - - - - - - - - - - - Joins - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Joins

- -

joins allow you to relate two records

- -

Syntax

-
// Join two records using a bind
-[#record1 attribute1]
-[#record2 attribute2: attribute1]
-
-// Join two records using a name
-[#record1 attribute]
-[#record2 attribute]
-
- -

Description

- -

Examples

- -

See Also

- -

equality | inequality | records

- - -
-
- -
- diff --git a/handbook/libraries/stdlib/index.html b/handbook/libraries/stdlib/index.html new file mode 100644 index 0000000..4e690da --- /dev/null +++ b/handbook/libraries/stdlib/index.html @@ -0,0 +1,467 @@ + + + + + + +

+ Aggregates +

+ + + + + + + + + + + + + + + + + + + +
+

gather/sort

+ Generates an ordering for a set +
+
    +
  • for - the set to sort
  • +
  • per - (optional) - one or more attributes by which to group `for`
  • +
  • direction - (optional) - direction in which to sort `for`. Possible values are: +
      +
    • 'up' - smallest to largest; default option
    • +
    • 'down' - largest to smallest
    • +
    +
  • +
+
+ // sorts the students by GPA + [#student GPA] + index = sort[value: GPA] +
+

gather/count

+ Returns the number of elements in a set +
+
    +
  • for - the set to count over
  • +
  • per - (optional) - one or more attributes by which to group `for`
  • +
+
+ // counts the number of citizens in each state + residents = [#citizen state] + population = count[given: residents, per: state] +
+

gather/sum

+ Returns the sum of values in a set of attributes +
+
    +
  • for - the set to gather
  • +
  • value - the specific variable to be summed
  • +
  • per - (optional) - one or more attributes by which to group `for`
  • +
+
+ // returns the sum of salaries for each department + employees = [#employee salary department] + expenses = gather/sum[for: employees, value: employees.salary, per: department] +
+ +

+ Math +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+

+ Adds two numbers +
+
    +
  • Infix notation
  • +
+
+ total-debt = credit-card + debit-card +
+

-

+ Subtracts two numbers +
+
    +
  • Infix notation
  • +
+
+ remaining-debt = total-debt - amount_paid +
+

*

+ Multiplies two numbers +
+
    +
  • Infix notation
  • +
+
+ yearly-payments = monthly-payments * 12 +
+

/

+ Divides two numbers +
+
    +
  • Infix notation
  • +
+
+ monthly-payments = yearly-payments / 12 +
+

math/floor

+ Rounds a number down +
+
    +
  • a - the number to be rounded down
  • +
+
+ // x rounded down to 34 + x = math/floor[a: 34.2] +
+

math/ceil

+ Rounds a number up +
+
    +
  • a - the number to be rounded up
  • +
+
+ // x rounded up to 35 + x = math/floor[a: 34.2] +
+

math/round

+ Rounds a number to the nearest integer +
+
    +
  • a - the number to be rounded to the nearest integer
  • +
+
+ // x rounded to 34 + x = math/floor[a: 34.2] +
+

math/sin

+ Sine of an angle +
+
    +
  • a - the angle in degrees
  • +
+
+ // r calculated to 1 + r = math/sin[a: 90] +
+

math/cos

+ Cosine of an angle +
+
    +
  • a - the angle in degrees
  • +
+
+ // r calculated to 0 + r = math/cos[a: 90] +
+

math/tan

+ Tangent of an angle +
+
    +
  • a - the angle in degrees
  • +
+
+ // r calculated to 1 + r = math/tan[a: 45] +
+

math/max

+ The greater of two values +
+
    +
  • a - a value to compare
  • +
  • b - another value to compare
  • +
+
+ // takes the higher score + [#scores pac-man donkey-kong] + best-score = math/min[a: pac-man, b: donkey-kong] +
+

math/min

+ The lesser of two values +
+
    +
  • a - a value to compare
  • +
  • b - another value to compare
  • +
+
+ // takes the lower score + [#scores pac-man donkey-kong] + worst-score = math/min[a: pac-man, b: donkey-kong] +
+

math/mod

+ Modulo division +
+
    +
  • a - the number to be divided (dividend)
  • +
  • b - the number by which to divide (divisor)
  • +
+
+ // m is the remainder, 1 + m = math/mod[a: 5, b: 2] +
+

math/abs

+ Absolute value of a number +
+
    +
  • a - the number whose absolute value is found
  • +
+
+ // number of hours from the prime meridian + [#city latitude longitude] + hours-from-gmt = math/abs[a: latitude] / 15 +
+

math/to-fixed

+ Formats a number as a string to a certain number of decimal places +
+
    +
  • a - the number to be formatted
  • +
  • b - the number of decimal places to which `a` will be formatted
  • +
+
+ // pi represented as the string "3.14" + [#circle circumference diameter] + pi = math/to-fixed[a: (circumference / diameter), b: 2] +
+

math/range

+ Generates a range of numbers +
+
    +
  • start - the start of the range
  • +
  • stop - the end of the range
  • +
+
+ // generates integers 1 through 10 + y = math/range[start: 1, stop: 10] +
+

random/number

+ Generates a random number between 1 and 0 +
+
    +
  • seed - a number used to initialize the random number generator
  • +
+
+ // generates a random number every second + [#time minutes seconds] + x = random/number[seed: seconds] +
+ +

+ Strings +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

string/replace

+ Replaces a string of text with another +
+
    +
  • text - the text in which to search for strings and replace them
  • +
  • replace - the string to be replaced
  • +
  • with - the string that will replace `replace`
  • +
+
+ // Americanized version of British spelling + [#website body] + american-version = string/replace[text: body, replace: "flavour", with: "flavor"] +
+

string/get

+ Gets a character from a specific location in a string +
+
    +
  • text - the text to be searched
  • +
  • at - the location to be searched
  • +
+
+ // finds the 17th letter of the alphabet + alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + letter = string/get[text: alphabet, at: 17] +
+

string/uppercase

+ Converts a string to uppercase +
+
    +
  • text - the text to be converted
  • +
+
+ funny = "lol" +really-funny = string/uppercase[text: funny] +
+

string/lowercase

+ Converts a string to lowercase +
+
    +
  • text - the text to be converted
  • +
+
+ really-funny = "LOL" +down-a-notch = string/uppercase[text: really-funny] +
+

string/index-of

+ Returns the position of the first occurrence of a specified value in a string +
+
    +
  • text - the text to be searched
  • +
  • substring - the string to be found in `text`
  • +
+
+ // Eve is in developers, starting at an index of 2 +index = string/index_of[text: "developers", substring: "eve" +
+

string/codepoint-length

+ Returns the length of a string in Unicode code points. +
+
    +
  • text - the string whose length is found
  • +
+
+ // the code point length of the word "unicode" +string = "unicode" +length-in-js = string/codepoint_length[text: string] +
+ + \ No newline at end of file diff --git a/handbook/libraries/style.css b/handbook/libraries/style.css new file mode 100644 index 0000000..19254f9 --- /dev/null +++ b/handbook/libraries/style.css @@ -0,0 +1 @@ +html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}table{border-collapse:collapse;border-spacing:0}*{box-sizing:border-box}body{display:flex;flex-direction:column;margin:0;background:white;color:#555;line-height:1.7;font-family:"Open Sans",Avenir,"Helvetica neue",sans-serif}h1{padding:0;margin:0;margin-bottom:15px;font-size:2em;font-weight:600}h2{padding:0;margin:0;margin-bottom:15px;font-size:1.5em}h3{padding:0;margin:0;margin-bottom:15px;font-size:1em;color}p{display:block;-webkit-margin-before:.5em;-webkit-margin-after:1em;-webkit-margin-start:0;-webkit-margin-end:0}a{color:#009ee0}a:hover{color:#00b8f1}a:active{color:#0079b1}ul{display:block;margin-left:2em}code{padding:.2em;background:#f0f2f7;white-space:pre-wrap;font-family:"Inconsolata","Monaco","Consolas","Ubuntu Mono",monospace;font-size:.9rem}strong{font-weight:600}table{border:1px black solid;margin-bottom:1em}td{border:1px black solid;width:20em} \ No newline at end of file diff --git a/handbook/linux/index.html b/handbook/linux/index.html deleted file mode 100644 index 2bc3432..0000000 --- a/handbook/linux/index.html +++ /dev/null @@ -1,388 +0,0 @@ - - - - - - - - - - - - Linux - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Installing Eve on Linux

- -

First, download the Eve source. You’ll need a recent node.js and then in the extracted Eve directory:

- -
npm install
-npm start
-
- -

Then open http://localhost:8080/ in your browser.

- -

Tips

- -

Some distributions (most notably Ubuntu) have renamed node to nodejs. If this is the case, you’ll need to create a symlink that remaps nodejs back to node. e.g.

- -
ln -s /usr/bin/nodejs /usr/bin/node
-
- -

Then proceed with the installation as usual

- -

See also

- -

mac | windows | docker | running

- - -
-
- -
- diff --git a/handbook/literate-programming/index.html b/handbook/literate-programming/index.html deleted file mode 100644 index 95683c8..0000000 --- a/handbook/literate-programming/index.html +++ /dev/null @@ -1,404 +0,0 @@ - - - - - - - - - - - - Literate Programming - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Literate Programming

- -

In the spirit of literate programming, Eve programs are primarily prose, interleaved with Eve code. Donald Knuth explains literate programming in his influential paper:

- -
-

The practitioner of literate programming can be regarded as an essayist, whose main concern is with exposition and excellence of style. Such an author … strives for a program that is comprehensible because its concepts have been introduced in an order that is best for human understanding, using a mixture of formal and informal methods that reinforce each other.

-
- -

This description fits with the ethos of Eve - that programming is primarily meant to communicate with other humans, not the computer. You’ll notice the above Eve program is actually written in two languages: Markdown, used to format the prose; and Eve, which is delineated by standard Markdown code blocks. Only the content within a block is compiled, while everything else is disregarded as a comment.

- -

Writing code this way has several properties that result in higher quality programs:

- -
    -
  • Literate programming forces you to consider a human audience. While this is usually the first step in writing any document, in programming the audience is typically a machine. For an Eve program, the audience might be your collaborators, your boss, or even your future self when revisiting the program in a year. By considering the audience of your program source, you create an anchor from which the narrative of your program flows, leading to a more coherent document.

  • - -
  • The human brain is wired to engage with and remember stories. Think back to a book you read (or maybe a show you watched) last year. You probably remember in great detail all of the characters and their personalities, the pivotal moments of the plot, the descriptions of the various settings, etc. But how much can you remember of a piece of code you haven’t looked at for a year? Literate programming adds another dimension to your code that will help you keep more of your program in working memory.

  • - -
  • Since Eve code blocks can be arranged in any order, literate programming encourages the programmer to arrange them in an way that makes narrative sense. Code can have a beginning, middle, and end just like a short story. Or like an epic novel, code can have many interwoven storylines. Either way, the structure of the code should follow an order imposed by a narrative, not one imposed by the compiler.

  • - -
  • Literate programming can help you think about your program more thoroughly. Through practicing literate programming, you can reveal edge cases, incorrect assumptions, gaps in understanding the problem domain, and shaky implementation details before any code is even written.

  • -
- -

Literate programming is a first-class design concept in Eve. We will be writing all of our programs in this manner, and will encourage others to do the same for the reasons above. That said, there is nothing in the syntax that specifically requires literate programming; you can write your program as a series of code blocks without any prose, and it will be perfectly valid.

- -

CommonMark

- -

Eve is CommonMark compatible.

- -

Examples

- - - -

See Also

- -

blocks | programming model | CommonMark

- - -
-
- -
- diff --git a/handbook/mac/index.html b/handbook/mac/index.html deleted file mode 100644 index ff1dbb9..0000000 --- a/handbook/mac/index.html +++ /dev/null @@ -1,379 +0,0 @@ - - - - - - - - - - - - Mac - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Installing Eve on Mac

- -

First, download the Eve source. You’ll need a recent node.js and then in the extracted Eve directory:

- -
npm install
-npm start
-
- -

Then open http://localhost:8080/ in your browser.

- -

See also

- -

linux | windows | docker | npm | running

- - -
-
- -
- diff --git a/handbook/math/abs/index.html b/handbook/math/abs/index.html deleted file mode 100644 index 64c736a..0000000 --- a/handbook/math/abs/index.html +++ /dev/null @@ -1,399 +0,0 @@ - - - - - - - - - - - - abs - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

abs

- -

The absolute value of a number

- -

Syntax

-
y = abs[value]
-
- -

Attributes

- -
    -
  • value - a set of numbers
  • -
- -

Description

- -

y = abs[value] returns the absolute value of the elements in value. Every positive number is kept positive, but every negative number is made positive.

- -

Examples

- -

Get the absolute value of a number

-
search
-  y = abs[value: -3]
-  
-bind @browser
-  [#div text: y]
-
- -

Displays the number 3.

- -

See Also

- -

sign

- - -
-
- -
- diff --git a/handbook/math/ceil/index.html b/handbook/math/ceil/index.html deleted file mode 100644 index f7137c9..0000000 --- a/handbook/math/ceil/index.html +++ /dev/null @@ -1,399 +0,0 @@ - - - - - - - - - - - - ceiling - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

ceiling

- -

Round a number up to the nearest integer.

- -

Syntax

-
y = ceiling[value]
-
- -

Attributes

- -
    -
  • value - a set of numbers
  • -
- -

Description

- -

y = ceiling[value] rounds the elements of value up to the nearest integers.

- -

Examples

- -

Calculate the ceiling of 34.2

-
search
-  y = ceiling[value: 34.2]
-  
-bind @browser
-  [#div text: y]
-
- -

The result is 35.

- -

See Also

- -

floor | fix | round

- - -
-
- -
- diff --git a/handbook/math/cos/index.html b/handbook/math/cos/index.html deleted file mode 100644 index 256bc6a..0000000 --- a/handbook/math/cos/index.html +++ /dev/null @@ -1,403 +0,0 @@ - - - - - - - - - - - - cos - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

cos

- -

Calculate the cosine of an angle

- -

Syntax

-
y = cos[radians]
-y = cos[degrees]
-
- -

Attributes

- -
    -
  • radians - the angle in radians
  • -
  • degrees - the angle in degrees
  • -
- -

Description

- -

y = cos[degrees] calculates the cosine of an input in degrees.

- -

y = cos[radians] calculates the cosine of an input in radians.

- -

cos operates element-wise on its inputs.

- -

Examples

- -

Calculate the cosine of 90 degrees

-
search
-  y = cos[degrees: 90]
-  
-bind @browser
-  [#div text: y]
-
- -

See Also

- -

sin | tan

- - -
-
- -
- diff --git a/handbook/math/fix/index.html b/handbook/math/fix/index.html deleted file mode 100644 index 23bcab8..0000000 --- a/handbook/math/fix/index.html +++ /dev/null @@ -1,411 +0,0 @@ - - - - - - - - - - - - fix - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

fix

- -

Round a number toward zero.

- -

Syntax

-
y = fix[value]
-
- -

Attributes

- -
    -
  • value - a set of numbers
  • -
- -

Description

- -

y = fix[value] rounds the elements of value toward zero. This means that negative numbers will be rounded up to the nearest integer, while positive numbers will be rounded down.

- -

Examples

- -

Calculate the fix of 34.7 and -34.7

-
search
-  y = fix[value: 34.7]
-  z = fix[value: -34.7]
-
-bind @browser
-  [#div text: "The fix of 34.7 is {{y}}"]
-  [#div text: "The fix of -34.7 is {{z}}"]
-
- -

We see that the fix of 34.7 is 34, while the fix of -34.7 is -34. Compare this to rounding the numbers:

-
search
-  y = round[value: 34.7]
-  z = round[value: -34.7]
-
-bind @browser
-  [#div text: "The round of 34.7 is {{y}}"]
-  [#div text: "The round of -34.7 is {{z}}"]
-
- -

We see that the round of 34.7 is 35, while the round of -34.7 is -35.

- -

See Also

- -

floor | ceil | round

- - -
-
- -
- diff --git a/handbook/math/floor/index.html b/handbook/math/floor/index.html deleted file mode 100644 index 0036b95..0000000 --- a/handbook/math/floor/index.html +++ /dev/null @@ -1,399 +0,0 @@ - - - - - - - - - - - - floor - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

floor

- -

Round a number down to the nearest integer.

- -

Syntax

-
y = floor[value]
-
- -

Attributes

- -
    -
  • value - a set of numbers
  • -
- -

Description

- -

y = floor[value] rounds the elements of value down to the nearest integers.

- -

Examples

- -

Calculate the floor of 34.2

-
search
-  y = floor[value: 34.2]
-
-bind @browser
-  [#div text: y]
-
- -

The result is 34.

- -

See Also

- -

ceil | fix | round

- - -
-
- -
- diff --git a/handbook/math/index.html b/handbook/math/index.html deleted file mode 100644 index f5a7037..0000000 --- a/handbook/math/index.html +++ /dev/null @@ -1,418 +0,0 @@ - - - - - - - - - - - - Math - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Math

- -

Arithmetic

- -
    -
  • plus ( + ) - Add two numbers
  • -
  • minus ( - ) - Subtract two numbers
  • -
  • times ( * ) - Multiply two numbers
  • -
  • divide ( / ) - Divide two numbers
  • -
- -

General Math

- -
    -
  • abs - Absolute value
  • -
  • ceiling - Round a number up
  • -
  • floor - Round a number down
  • -
  • round - Round a number
  • -
  • fix - Calculate the fix of a number
  • -
  • mod - Modulo division
  • -
  • exp - The number e raised to a power
  • -
  • log - Calculate the logarithm of a number
  • -
- -

Trigonometric Functions

- -
    -
  • sin - Sine of an angle
  • -
  • cos - Cosine of an angle
  • -
  • tan - Tangent of an angle
  • -
  • asin - Arc sine of an angle
  • -
  • acos - Arc cosine of an angle
  • -
  • atan - Arc tangent of an angle
  • -
  • atan2 - Arc tangent using sign to determine quadrant
  • -
- -

Hyperbolic Functions

- -
    -
  • sinh - Hyperbolic sine of an angle
  • -
  • cosh - Hyperbolic cosine of an angle
  • -
  • tanh - Hyperbolic tangent of an angle
  • -
  • asinh - Hyperbolic arc sine of an angle
  • -
  • acosh - Hyperbolic arc cosine of an angle
  • -
  • atanh - Hyperbolic arc tangent of an angle
  • -
- -

Other Functions

- -
    -
  • range - Generates a range of numbers
  • -
- - -
-
- -
- diff --git a/handbook/math/mod/index.html b/handbook/math/mod/index.html deleted file mode 100644 index 1aaacd5..0000000 --- a/handbook/math/mod/index.html +++ /dev/null @@ -1,402 +0,0 @@ - - - - - - - - - - - - mod - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

mod

- -

Return the modulus after division

- -

Syntax

-
y = mod[value, by]
-
- -

Attributes

- -
    -
  • value - the number to be divided
  • -
  • by - the number by which to divide value
  • -
- -

Description

- -

Modulo division calculates the modulus (the remainder) after dividing value by by. If value is a set of size N, then by can either be a scalar or another set of size N.

- -

Examples

- -

Keeps the value of an angle between the range [π, -π]:

-
search
-  value = 30
-  angle = mod[value, by: 2 * pi[]]
-  pi2pi = if angle > pi[] then angle - 2 * pi[]
-          if angle < pi[] * -1 then angle + 2 * pi[]
-          else angle
-        
-bind @view
-  [#value | value: "{{value}} -> {{pi2pi}}"]
-
- -

See Also

- -

ceil | floor | round

- - -
-
- -
- diff --git a/handbook/math/range/index.html b/handbook/math/range/index.html deleted file mode 100644 index 8264584..0000000 --- a/handbook/math/range/index.html +++ /dev/null @@ -1,434 +0,0 @@ - - - - - - - - - - - - range - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

range

- -

Generates a set of numbers between two values

- -

Syntax

-
y = range[from, to]
-y = range[from, to, increment]
-
- -

Attributes

- -
    -
  • from - the start of the range. Does not need to be an integer.
  • -
  • to - the end of the range. Does not need to be an integer.
  • -
  • increment - specifies the increment by which the elements are separated. By default, this value is 1.
  • -
- -

Description

- -

y = range[from, to] generates a set of numbers starting at from and ending at to, in increments of 1. The range generated includes from and to.

- -

y = range[from, to, increment] generates a set of numbers starting at from and ending at to inclusive, at a specified increment. The range generated will start at from and include as many elements as possible until the next element exceeds to. Depending on the chosen increment, this could potentially exclude to from the generated range.

- -

Examples

- -

Generate and display the integers between 1 and 10. In this example, y = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10):

-
search
-  y = range[from: 1, to: 10]
-
-bind @browser
-  [#div sort: y, text: y]
-
- -

Generate and display the odd integers between 1 and 10. In this example, y = (1, 3, 5, 7, 9). Notice the set does not include 10 in this case.

-
search
-  y = range[from: 1, to: 10, increment: 2]
-
-bind @browser
-  [#div sort: y, text: y]
-
- -

We can use range and Eve’s join semantics to generate indicies for a grid of cells.

-
search
-  i = range[from: 1 to: 5]
-  j = range[from: 1 to: 5]
-  coordinate = "({{i}}, {{j}})"
-
-bind @browser
-  [#div sort: coordinate, text: coordinate]
-
- -

Will display:

- -
(1, 1)
-(1, 2)
-(1, 3)
-...
-(5, 4)
-(5, 5)
-
- -

Example Usage

- - - -

See Also

- - -
-
- -
- diff --git a/handbook/math/round/index.html b/handbook/math/round/index.html deleted file mode 100644 index 57eae8e..0000000 --- a/handbook/math/round/index.html +++ /dev/null @@ -1,402 +0,0 @@ - - - - - - - - - - - - round - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

round

- -

Round a number to the nearest integer

- -

Syntax

-
y = round[value]
-
- -

Attributes

- -
    -
  • value - a set of numbers
  • -
- -

Description

- -

y = round[value] rounds the elements of value toward the nearest integers.

- -
    -
  • For positive numbers - if the fractional part of the number is greater than or equal to 0.5, then the number is rounded up. Otherwise, it is rounded down.
  • -
  • For negative numbers - if the fractional part of the number is greater than or equal to -0.5, then the number is rounded down to the nearest negative integer. Otherwise, it is rounded up.
  • -
- -

Examples

-
search
-  y = round[value: 34.5]
-  z = round[value: 34.4]
-  
-bind @browser
-  [#div text: "The round of 34.5 is {{y}}"]
-  [#div text: "The round of 34.4 is {{z}}"]
-
- -

See Also

- -

floor | ceil | fix

- - -
-
- -
- diff --git a/handbook/math/sin/index.html b/handbook/math/sin/index.html deleted file mode 100644 index 76182aa..0000000 --- a/handbook/math/sin/index.html +++ /dev/null @@ -1,403 +0,0 @@ - - - - - - - - - - - - sin - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

sin

- -

Calculate the sine of an angle

- -

Syntax

-
y = sin[radians]
-y = sin[degrees]
-
- -

Attributes

- -
    -
  • radians - the angle in radians
  • -
  • degrees - the angle in degrees
  • -
- -

Description

- -

y = sin[degrees] calculates the sine of an input in degrees.

- -

y = sin[radians] calculates the sine of an input in radians.

- -

sin operates element-wise on its inputs.

- -

Examples

-
search
-  y = sin[degrees: 90]
-  x = sin[radians: 3.14 / 2]
-  
-bind @browser
-  [#div text: y]
-  [#div text: x]
-
- -

See Also

- -

cos | tan

- - -
-
- -
- diff --git a/handbook/math/sum/index.html b/handbook/math/sum/index.html deleted file mode 100644 index 1899083..0000000 --- a/handbook/math/sum/index.html +++ /dev/null @@ -1,417 +0,0 @@ - - - - - - - - - - - - sum - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

sum

- -

Sum the elements in a set

- -

Syntax

-
y = sum[value, given]
-y = sum[value, given, per]
-
- -

Arguments

- -
    -
  • value - the variable or attribute to be summed
  • -
  • given - the record from which the value can be accessed
  • -
  • per - optional - specifies the set over which you are summing
  • -
- -

Description

- -

y = sum[value, given] returns the sum of elements in a set. The set must be entirely numeric or a runtime-error occurs.

- -

Examples

- -

Context data:

-
commit
-  [#employee salary: 100, department: "hunting"]
-  [#employee salary: 200, department: "hunting"]
-  [#employee salary: 300, department: "gathering"]
-
- -

Get sum of all matching records:

-
search
-  employee = [#employee salary department]
-  total-salary = sum[value:salary, given: employee]
-
-bind @browser
-  [#div text: "Total: {{ total-salary }}" ]
-
- -

Get sum of matching records grouped by department:

-
search
-  employee = [#employee salary department]
-  total-salary = sum[value:salary, given: employee, per: department]
-
-bind @browser
-  [#div text: "{{department}} : {{ total-salary }}" ]
-
- -

See Also

- -

count | aggregates

- - -
-
- -
- diff --git a/handbook/math/tan/index.html b/handbook/math/tan/index.html deleted file mode 100644 index 91b8108..0000000 --- a/handbook/math/tan/index.html +++ /dev/null @@ -1,400 +0,0 @@ - - - - - - - - - - - - tan - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

tan

- -

Calculate the tangent of an angle

- -

Syntax

-
y = tan[radians]
-y = tan[degrees]
-
- -

Attributes

- -
    -
  • radians - the angle in radians
  • -
  • degrees - the angle in degrees
  • -
- -

Description

- -

y = tan[degrees] calculates the tangent of an input in degrees.

- -

y = tan[radians] calculates the tangent of an input in radians.

- -

tan operates element-wise on its inputs.

- -

Examples

-
match
-  y = tan[degrees: 90]
-bind @browser
-  [#div text: y]
-
- -

See Also

- -

cos | sin

- - -
-
- -
- diff --git a/handbook/merge/index.html b/handbook/merge/index.html deleted file mode 100644 index e8288b0..0000000 --- a/handbook/merge/index.html +++ /dev/null @@ -1,391 +0,0 @@ - - - - - - - - - - - - Merge <- - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Merge Operator

- -

Merges one record into another

- -

Syntax

-
record <- [attribute: value, ... ]
-
- -

Description

- -

record <- [attribute: value, ... ] merges the anonymous record [attribute: value, ... ] into the record bound to record. Merge is useful for setting multiple attributes on a record at once.

- -

Examples

- -

Search for a record and merge another record into it.

-
search
-  celia = [#Celia]
-
-bind
-  celia <- [#student grade: 10, school: "East"]
-
- -

See Also

- -

set operator | add operator | remove operator | action phase

- - -
-
- -
- diff --git a/handbook/model/index.html b/handbook/model/index.html deleted file mode 100644 index 37ab16c..0000000 --- a/handbook/model/index.html +++ /dev/null @@ -1,386 +0,0 @@ - - - - - - - - - - - - Programming Model - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Programming Model

- -

At its core, Eve only responds to two commands:

- -
    -
  1. What facts do you know about this “record”?
  2. -
  3. Remember a new fact about this “record”.
  4. -
- -

Communication with Eve happens through “records”, which are key-value pairs attached to a unique ID.

- -

Computation occurs as a result of relationships between records. For example, I might model myself as a record with an age and a birth-year. There might also be a record representing the current-year. Then I could compute my age as my birth-year subtracted from the current-year.

- -

A key concept here is that age is a derived fact, supported by two other facts: birth-year and current-year. If either of those supporting facts are removed from Eve, then age can no longer be computed. For intuition, think about modeling this calculation in a spreadsheet using three cells.

- -

One last thing to note about control flow is that we have no concept of a loop in Eve. Recursion is one way to recover looping, but set semantics and aggregates often removes the need for recursion. In Eve, every value is actually a set. With operators defined over sets (think map()) and aggregation (think reduce()) we can actually do away with most cases where we would be tempted to use a loop.

- -

See also

- -

blocks | literate programming | sets | records

- - -
-
- -
- diff --git a/handbook/not/index.html b/handbook/not/index.html deleted file mode 100644 index 24ab2d6..0000000 --- a/handbook/not/index.html +++ /dev/null @@ -1,391 +0,0 @@ - - - - - - - - - - - - not - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

not

- -

excludes records from the results

- -

Syntax

-
not([ ... ])
-
- -

Description

- -

Not is an anti-join operator, which takes a body of records. For example, we can get a list of people who are not invited to the party:

-
// friends not invited to the party
-search
-  friends = [#friend]
-  not(friends = [#invited])
-
-bind @view
-  [#value | value: "{{friends.name}} wasn't invited to the party"]
-
- -

Examples

- -

See Also

- -

is | records | match

- - -
-
- -
- diff --git a/handbook/npm/index.html b/handbook/npm/index.html deleted file mode 100644 index a00951a..0000000 --- a/handbook/npm/index.html +++ /dev/null @@ -1,378 +0,0 @@ - - - - - - - - - - - - npm - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Eve on npm

- -

A package for Eve is available on npm. After installing npm for your platform, you can download our package with the following command:

- -
npm install -g witheve
-
- -

This will give you a global Eve installation that you can invoke with the command eve from any folder. Doing so will launch an Eve server at http://localhost:8080.

- -

See also

- -

linux | mac | windows | docker | running

- - -
-
- -
- diff --git a/handbook/programs/index.html b/handbook/programs/index.html deleted file mode 100644 index f5cb9e2..0000000 --- a/handbook/programs/index.html +++ /dev/null @@ -1,373 +0,0 @@ - - - - - - - - - - - - - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - -
- diff --git a/handbook/records/index.html b/handbook/records/index.html deleted file mode 100644 index 0d46612..0000000 --- a/handbook/records/index.html +++ /dev/null @@ -1,460 +0,0 @@ - - - - - - - - - - - - Records - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Records

- -

Records are attribute: value pairs associated to a unique ID

- -

Syntax

-
// A record with an attribute
-[attribute]
-
-// A record with an attribute of given value
-[attribute: value]
-
-// A record with N attributes of given values
-[attribute1: value1, ... , attributeN: valueN]
-
-// A record nested within another record
-[attribute1: [attribute2: value]]
-
-// Equates a record and a variable
-r = [attribute ...]
-
-// Accessing an attribute on a record
-r.attribute
-
-// Join two records
-[attribute1: attribute2]
-[attribute2]
-
- -

Description

- -

Records are the predominant datatype in Eve. Records are used in two ways:

- -
    -
  1. In a search you supply a pattern of attributes to match records in a supplied database.
  2. -
  3. In a bind or commit, you supply a pattern of attributes to insert into a database.
  4. -
- -

[attribute] matches all records with the given attribute.

- -

[attribute: value] matches all records with the given attribute bound to specified value.

- -

[attribute > value] matches all records with the given attribute bound filtered on a value. The inequality > can be one of the inequality operators.

- -

[attribute1: value1, ... , attributeN: valueN] is the general case for records. This matches all records with all of the given attributes filtered on the given values.

- -

[attribute1: [attribute2: value]] nests a record within another record.

- -

r = [attribute ...] equates a record to a variable r.

- -

r.attribute accesses the value of attribute on variable r.

- -

Examples

- -

Match all records with a name, and bind a #div for each one.

-
search
-  [name]
-
-bind @browser
-  [#div text: name]
-
- -

Records can have multiple attributes

-
search
-  [#student name grade school]
-  
-bind @browser
-  [#div text: "{{name}} is in {{grade}}th grade at {{school}}"]
-
- -

Join records by binding attributes from one record into another record. Equate records with variables. Access record attributes using dot notation.

-
search
-  school = [#school name address]
-  student = [#student school: name]
-
-bind @browser
-  [#div text: "{{student.name}} attends {{school.name}} at {{address}}"]
-
- -

Records can be nested.

-
commit
-  [name: "Jeremy" spouse: [name: "Wendy"]]
-
- -

Dot notation can be composed for deep access to records

-
search
-  Jeremy = [name: "Jeremy"]
-
-bind @browser
-  [#div text: "{{Jeremy.name}} is married to {{Jeremy.spouse.name}}"]
-
- -

See Also

- -

search | bind | commit | tags | databases | equality | inequality | joins

- - -
-
- -
- diff --git a/handbook/remove/index.html b/handbook/remove/index.html deleted file mode 100644 index f414dbe..0000000 --- a/handbook/remove/index.html +++ /dev/null @@ -1,384 +0,0 @@ - - - - - - - - - - - - Remove: -= - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - -
- diff --git a/handbook/running/index.html b/handbook/running/index.html deleted file mode 100644 index 0ef1efa..0000000 --- a/handbook/running/index.html +++ /dev/null @@ -1,425 +0,0 @@ - - - - - - - - - - - - Running Eve - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Running Eve

- -

If you’ve downloaded and installed Eve via npm, you can launch Eve with the eve command.

- -
eve
-
- -

This launches an Eve server running in the Eve root directory at http://localhost:8080. From here, you’ll be directed to quickstart.eve, and have access to the Eve examples directory from within the editor.

- -

Running an Eve File

- -

If you want to run a specific Eve program, you can provide its path after the eve command:

- -
eve ~/myDir/myEveFile.eve
-
- -

Then you navigate to Eve in your browser to access the specified program. If you like, you can also recover the editor with a flag:

- -
eve ~/myEveDir/myEveFile.eve --editor
-
- -

This will run the supplied Eve program with the editor visible

- -

Running Eve in Server mode

- -

Eve can be started in server mode using the --server flag:

- -
eve --server
-
- -

Without this flag, execution of Eve programs happens within the browser, with the Eve server acting only as a file server between the browser and your local system. In server mode, Eve will instead execute your program on the server. Currently written programs will operate exactly as before, but this is a preliminary step in order to get networked Eve applications going (like a chat server or a multiplayer game). There is still work needed to be done there

- -

Eve Workspaces

- -

You can run Eve in a custom workspace. To create a new Eve workspace, create a folder with an empty file named package.json, then start Eve from within this folder. Eve recognizes that it is starting an Eve workspace, and will serve *.eve files from within this directory instead of the Eve examples folder. Furthermore, you can serve various assets, like images or CSS, by placing them in an “assets” sub-folder.

- -

Flags

- -
    -
  • server - run Eve in server execution mode.
  • -
  • editor - run Eve with the editor visible. This defaults to false, except when Eve is started in an Eve project folder.
  • -
  • port - specify the port on which to run the Eve server. Alternatively, the running port can be specified with the PORT environment variable, which takes precedence over the port flag.
  • -
- -

Running Eve from Source

- -

To run Eve from source, you invoke the following command in the extracted Eve folder:

- -
npm start
-
- -

You can apply the above flags to this command, but you’ll need an extra -- to do so. e.g.

- -
npm start -- --port 1234
-
- -

See Also

- -

linux | mac | windows | docker | npm

- - -
-
- -
- diff --git a/handbook/search/index.html b/handbook/search/index.html deleted file mode 100644 index 3d02e23..0000000 --- a/handbook/search/index.html +++ /dev/null @@ -1,400 +0,0 @@ - - - - - - - - - - - - search - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

search

- -

signifies the beginning of the search phase

- -

Syntax

-
search
-
-search @database1, ..., @databaseN
-
- -

Description

- -

search signifies the beginning of the search phase of a block. By default, searched records are drawn from a default local database.

- -

search @database1, ... @databaseN draws searched records from one or more databases.

- -

Examples

- -

search a record

-
search
-  [name]
-  
-bind
-  [#div text: name]  
-
- -

Omit the search phase

-
bind
-  [#div text: "Hello, world"]
-
- -

See Also

- -

bind | commit | databases | records

- - -
-
- -
- diff --git a/handbook/session/index.html b/handbook/session/index.html deleted file mode 100644 index 6c263f5..0000000 --- a/handbook/session/index.html +++ /dev/null @@ -1,367 +0,0 @@ - - - - - - - - - - - - @session - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

@session

- - -
-
- -
- diff --git a/handbook/set/index.html b/handbook/set/index.html deleted file mode 100644 index c19e024..0000000 --- a/handbook/set/index.html +++ /dev/null @@ -1,403 +0,0 @@ - - - - - - - - - - - - Set: := - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Set Operator

- -

Sets the value of an attribute on a record

- -

Syntax

-
// Set attribute to value
-record.attribute := value
-
-// Remove attribute
-record.attribute := none
-
- -

Description

- -

record.attribute := value sets attribute to value. If record already has an attribute with a value, then this will overwrite it. Otherwise, if record doesn’t have an attribute with this name already, then := will create the attribute and set it to value.

- -

attribute can be an attribute already on the record, or it can be a new attribute.

- -

value can be a string or number literal, a record, or a variable bound to one of these.

- -

record.attribute := none sets the value of attribute to the special value none, which is the empty set (a set with no elements).

- -

Examples

- -

Set the age of #students that don’t already have an age.

-
search
-  student = [#student]
-  age = if student.age then student.age
-        else if student.grade then student.grade + 6
-        
-bind
-  student.age := age
-
- -

See Also

- -

add operator | remove operator | merge operator

- - -
-
- -
- diff --git a/handbook/sets/index.html b/handbook/sets/index.html deleted file mode 100644 index e826aba..0000000 --- a/handbook/sets/index.html +++ /dev/null @@ -1,406 +0,0 @@ - - - - - - - - - - - - Sets - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Set Semantics

- -

Expressions and actions in Eve work over sets.

- -

Description

- -

Sets are unordered collections where every element of the collection is unique. For example, ("a", "b", "c") is a set, while ("a", "a", "b", "c") is not. Furthermoer, ("a", "b", "c") and ("c", "b", "a") are equivalent sets, even though the order of elements is different.

- -

Examples

- -
(1, 2, 3, 4) // Every element is unique           
-(1, 2, 3, 1) // One is repeated twice, so this is not a set
-(4, 3, 2, 1) // This set is the same as the first, despite the order of elements
-("Steve", 1, (1, 2)) // Elements can be nonhomogeneous, as long as each one is unique
-(("a", 1), ("a", 2), ("a", 3)) // Sets within sets can be used to repeat values
-
- -

Set Example in Eve

-
commit
-  [#point x: 5, y: 4]
-  [#point x: 3, y: 7]
-  [#point x: 1, y: 2]
-
- -

We can calculate the distance from each of these points to every other point:

-
search
-  p1 = [#point x: x1, y: y1]
-  p2 = [#point x: x2, y: y2]
-  dx = x1 - x2 
-  dy = y1 - y2
-  
-bind @browser
- [#div sort: x1, text: "({{x1}}, {{y1}}) - ({{x2}}, {{y2}}) = ({{dx}}, {{dy}})"]
-
- -

In imperative languages, you would need a nested loop to cover all of the combinations. In Eve, functions (and infix operators like +, which are just sugar for a function) operate over sets, so this loop is implicitly handled by Eve.

- -

See Also

- -

programming model | functions | aggregates | cartesian product

- - -
-
- -
- diff --git a/handbook/standard-library/index.html b/handbook/standard-library/index.html deleted file mode 100644 index b09e933..0000000 --- a/handbook/standard-library/index.html +++ /dev/null @@ -1,379 +0,0 @@ - - - - - - - - - - - - Standard Library - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Standard Library

- -

The Eve standard library of functions is globally available, meaning you don’t have to reference a specific database to use these functions.

- -

Description

- -
    -
  • general - General functions
  • -
  • math - General mathematical and trigonometric functions
  • -
  • strings - Functions that manipulate strings
  • -
  • statistics - Functions that calculate statistical measures on values
  • -
  • date & time - Functions that get and manipulate date and time
  • -
- - -
-
- -
- diff --git a/handbook/statistics/count/index.html b/handbook/statistics/count/index.html deleted file mode 100644 index f274079..0000000 --- a/handbook/statistics/count/index.html +++ /dev/null @@ -1,450 +0,0 @@ - - - - - - - - - - - - count - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

count

- -

Returns the number of elements in a set

- -

Syntax

-
y = count[given]
-y = count[given, per]
-
- -

Attributes

- -
    -
  • given - the set to count over
  • -
  • per - optional - one or more attributes by which to group given.
  • -
- -

Description

- -

y = count[given] counts the number of elements in given.

- -

y = count[given, per] counts the number of elements in given, grouped by the attribute(s) provided in per. For instance, class-size = count[given: students, per: grade] would count the number of students in each grade. You can group along multiple axes; the previous example could be extended to work across multiple schools by doing class-size = count[given: students, per: (grade, school)]. See the examples section to see these in action.

- -

Examples

- -

Before we get to the count examples, let’s add some students. Each #student has a grade and a school. Grades are one of 10, 11, or 12. Schools are one of “West” and “East”.

-
commit
-  [#student name: "Diedra" grade: 10 school: "West"]
-  [#student name: "Celia" grade: 10 school: "West"]
-  [#student name: "Michaela" grade: 11 school: "West"]
-  [#student name: "Jermaine" grade: 11 school: "West"]
-  [#student name: "Issac" grade: 12 school: "West"]
-  [#student name: "Jamar" grade: 12 school: "West"]
-  [#student name: "Yee" grade: 10 school: "East"]
-  [#student name: "Johanne" grade: 10 school: "East"]
-  [#student name: "Mertie" grade: 10 school: "East"]
-  [#student name: "Elmira" grade: 11 school: "East"]
-
- -

First let’s count the total number of students in the school district.

-
search
-  students = [#student]
-  enrollment = count[given: students]
-
-bind @view
-  [#value | value: "There are {{enrollment}} students in the district"]
-
- -

Now let’s count the number of students in each school.

-
search
-  students = [#student school]
-  school-enrollment = count[given: students, per: school]
-
-bind @view
-  [#value | value: "{{school-enrollment}} attend {{school}}"]
-
- -

We could have similarly counted the number of students in each grade across the district.

-
search
-  students = [#student grade]
-  grade-enrollment = count[given: students, per: grade]
-
-bind @view
-  [#value | value: "{{grade-enrollment}} students are in {{grade}}th grade"]
-
- -

Finally, we can count the number of students per grade, per school.

-
search
-  students = [#student grade school]
-  grade-school-enrollment = count[given: students, per: (grade, school)]
-
-bind @view
-  [#value | value: "{{grade-school-enrollment}} students are in {{grade}}th grade at {{school}}"]
-
- -

Example Usage

- - - -

See Also

- -

sum | aggregates

- - -
-
- -
- diff --git a/handbook/statistics/index.html b/handbook/statistics/index.html deleted file mode 100644 index c86d361..0000000 --- a/handbook/statistics/index.html +++ /dev/null @@ -1,377 +0,0 @@ - - - - - - - - - - - - Statistics - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Statistics

- -
    -
  • count - counts the number of elements in a set
  • -
- -

Random Functions

- -
    -
  • random - Generates a random number between 0 and 1
  • -
- - -
-
- -
- diff --git a/handbook/statistics/random/index.html b/handbook/statistics/random/index.html deleted file mode 100644 index b804bfc..0000000 --- a/handbook/statistics/random/index.html +++ /dev/null @@ -1,423 +0,0 @@ - - - - - - - - - - - - random - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

random

- -

Generates a random number between 0 and 1

- -

Syntax

-
y = random[seed]
-
- -

Attributes

- -
    -
  • seed - initializes the random number generator. The seed itself does not need to be random.
  • -
- -

Description

- -

y = random[seed] generates a pseudorandom number drawn from the standard uniform distribution, meaning the generated number is restricted to be between 0 and 1. To generate a number between a custom range, see the examples.

- -

Examples

- -

Prints a random number every second. The time attribute in #div is used to make each generated number unique for display purposes.

-
search 
-  [#time minutes seconds]
-  x = random[seed: seconds]
-
-commit @browser
-  [#div time: "{{minutes}}{{seconds}}"  text: x]
-
- -

Generate a random number between min and max

-
search
-  min = 5
-  max = 10
-  x = random[seed: 1] * (max - min) + min
-
-bind @browser
-  [#div text: x]
-
- -

Generate 10 random numbers

-
search
-  i = range[from: 1, to: 10]
-  x = random[seed: i]
-
-bind @browser
-  [#div text: x]
-
- -

Example Usage

- - - -

See Also

- -

[gaussian][../gaussian]

- - -
-
- -
- diff --git a/handbook/string-interpolation/index.html b/handbook/string-interpolation/index.html deleted file mode 100644 index 12a5251..0000000 --- a/handbook/string-interpolation/index.html +++ /dev/null @@ -1,404 +0,0 @@ - - - - - - - - - - - - String Interpolation - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

String Interpolation

- -

injects the value of an attribute or variable into a string

- -

Syntax

-
"{{ variable }}"
-
- -

Description

- -

"{{ variable }}" embeds the value of variable within a string. Variable should be an attribute on a record or the result of an expression.

- -

String interpolation works element-wise on its input. This means the string will be repeated for every unique value in variable.

- -

Multiple variables can be interpolated into strings. If the variables have no relation to each other (i.e. they are not joined or part of the same record), then string interpolation is applied to the cartesian product of the sets.

- -

Examples

- -

Display student name, grade and school:

-
search
-  [#student name grade school]
-
-bind @browser
-  [#div text: "{{name}} is a {{grade}}th grade student at {{school}}."]
-
- -

Use string interpolation to display pairs of numbers:

-
search 
-  i = range[from: 1, to: 10]
-  j = range[from: 1, to: 10]
-
-bind @browser
-  [#div text: "({{ i }}, {{ j }})"]
-
- -

See Also

- -

strings | expressions

- - -
-
- -
- diff --git a/handbook/strings/index.html b/handbook/strings/index.html deleted file mode 100644 index a2ed920..0000000 --- a/handbook/strings/index.html +++ /dev/null @@ -1,372 +0,0 @@ - - - - - - - - - - - - Strings - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Strings

- -
    -
  • split - split a string into tokens
  • -
  • join - join tokens into a string
  • -
- - -
-
- -
- diff --git a/handbook/strings/join/index.html b/handbook/strings/join/index.html deleted file mode 100644 index c1590cd..0000000 --- a/handbook/strings/join/index.html +++ /dev/null @@ -1,433 +0,0 @@ - - - - - - - - - - - - join - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

join

- -

Joins a set of strings into a single string

- -

Syntax

-
text = join[token, given, index, with]
-
- -

Attributes

- -
    -
  • token - set of strings to be joined
  • -
  • given - establishes the set being joined. If tokens are not unique, you can add attributes here that will make them unique. Must at least provide token as part of the given set, or only the first one will be returned.
  • -
  • index - indicates where each token is ordered in text.
  • -
  • with - inserted between every element in token.
  • -
- -

Description

- -

text = join[token, index, given, with] takes tokens together using with in an order specified by index. Returns the joined string.

- -

Examples

- -

Split a sentence into tokens, and join the tokens into a sentence again

-
search
-  // Split the sentence into words
-  (token, index) = split[text: "the quick brown fox", by: " "]
-
-  // Join the words back into a sentence, but with hyphens instead of spaces
-  text = join[token given: token, index with: "-"]
-
-bind @view
-  [#value | value: text] // Expected "the-quick-brown-fox"
-
- -
- -

Since join is an aggregate, set semantics play an important part here; if we don’t specify what makes each token unique, then the results can be surprising. The following example will demonstrate this.

- -

Let’s split the phrase “hello world” into letters:

-
search
-  //token = (h, e, l, l, o, w, o, r, l, d)
-  (token, index) = split[text: "hello world", by: ""]
-
-bind
-  [#phrase token index]
-
-bind @view
-  [#value | value: token]
-
- -

Let’s join this phrase back together. Like last time, we’ll join with a -. Notice that some tokens (“l” and “o”) should appear multiple times in the phrase. To correctly join them, we add index as part of the given set:

-
search
-  [#phrase token index]
-  // given = (("h", 1), ("e", 2), ("l", 3), ("l", 4) ... ("l", 10), ("d", 11)) 
-  // without including index, the result is "h-e-l-o- -w-r-d". Try it and see!
-  text = join[token given: (token, index) index with: "-"]
-
-bind @view
-  [#value | value: text]
-
- -

The result expected result is “h-e-l-l-o- -w-o-r-l-d”.

- -

See Also

- -

split

- - -
-
- -
- diff --git a/handbook/strings/split/index.html b/handbook/strings/split/index.html deleted file mode 100644 index 7961ca7..0000000 --- a/handbook/strings/split/index.html +++ /dev/null @@ -1,408 +0,0 @@ - - - - - - - - - - - - split - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

split

- -

splits a string at the given delimiter

- -

Syntax

-
(token, index) = split[text, by]
-
- -

Attributes

- -
    -
  • text - the text to be split
  • -
  • by - the delimiter at which to split the text. An empty string will split the text at every character.
  • -
  • token - the recovered tokens after the split
  • -
  • index - the indices of the tokens in the original text
  • -
- -

Description

- -

(token, index) = split[text, by] splits a text into tokens according to the given delimiter, by. Returns token and index of those tokens in the original string.

- -

Examples

- -

Splits a string at every character

-
search
-  (token, index) = split[text: "hello, world", by: ""]
-  
-bind @browser
-  [#div text: "{{token}} {{index}}"]
-
- -

Split a sentence into words and display them in order

-
search
-  (token, index) = split[text: "the quick brown fox", by: " "]
-  
-bind @browser
-  [#div sort: index, text: token]
-
- -

See Also

- -

concat | join | char-at | find | length | replace

- - -
-
- -
- diff --git a/handbook/tags/index.html b/handbook/tags/index.html deleted file mode 100644 index 4b5c340..0000000 --- a/handbook/tags/index.html +++ /dev/null @@ -1,424 +0,0 @@ - - - - - - - - - - - - Tags - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Tag Selector

- -

The tag selector is a shortcut for the tag attribute on records

- -

Syntax

-
#tag
-
-#"tag with spaces"
-
- -

Description

- -

The tag selector # is a shortcut for the tag attribute, e.g. [#person] is a shortcut for [tag: "person"].

- -

The tag selector is useful for selecting a group of similar records.

- -

Tags are useful for making a record unique. For instance, in a single database, many disparate records might have an age attribute. e.g. [age] might select unrelated records if you’re only interested in ages of employees. A more specific record would be [#employee age], which would match only records that are both tagged “employee” and have an age attribute.

- -

Multiple tags can be used to further specify a record. For instance:

-
[#employee wage]
-[#employee #part-time wage]
-
- -

The first record matches all #employees, while the second matches only those who are also #part-time. Any number of tags can be used in this way.

- -

Tips

- -

Tags are useful for creating switches. Add a tag to a record to include it in a set. Then, when you don’t want that record in the set anymore, just remove the tag. The record will no longer match the set.

- -

Examples

- -

Search for students and display their names and the grade they’re in.

-
search
-  [#student name grade]
-
-bind @browser
-  [#div text: "{{name}} is in {{grade}}th grade."]
-
- -

Add students with good marks to the honor roll. When a student’s GPA falls below 3.5, he or she will not make the honor roll because this block will not add the #honor-roll tag.

-
search
-  students = [#student gpa >= 3.5]
-
-bind
-  students += #honor-roll
-
- -

Display the honor roll

-
search
-  [#student #honor-roll name]
-
-bind @browser
-  [#div text: "{{name}} is a smarty pants"]
-
- -

See Also

- -

records | search | sets

- - -
-
- -
- diff --git a/handbook/update-operators/index.html b/handbook/update-operators/index.html deleted file mode 100644 index f54a384..0000000 --- a/handbook/update-operators/index.html +++ /dev/null @@ -1,391 +0,0 @@ - - - - - - - - - - - - Update Operators - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Update Operators

- -

Update operates are used to modify records

- -

Syntax

-
// Add operator
-record.attribute += value
-
-// Remove operator
-record.attribute -= value
-
-// Set operator
-record.attribute := value
-
-// Merge operator
-record <- [ ... ]
-
- -

Description

- -

Examples

- -

See Also

- -

add | remove | set | merge | bind | commit

- - -
-
- -
- diff --git a/handbook/view/index.html b/handbook/view/index.html deleted file mode 100644 index 069b6f9..0000000 --- a/handbook/view/index.html +++ /dev/null @@ -1,367 +0,0 @@ - - - - - - - - - - - - @view - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

@view

- - -
-
- -
- diff --git a/handbook/windows/index.html b/handbook/windows/index.html deleted file mode 100644 index bc0b04b..0000000 --- a/handbook/windows/index.html +++ /dev/null @@ -1,379 +0,0 @@ - - - - - - - - - - - - Windows - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Installing Eve on Windows

- -

First, download the Eve source. You’ll need a recent node.js and then in the extracted Eve directory:

- -
npm install
-npm start
-
- -

Then open http://localhost:8080/ in your browser.

- -

See also

- -

linux | mac | docker | npm | running

- - -
-
- -
- diff --git a/images/eve.svg b/images/eve.svg new file mode 100644 index 0000000..7bf5127 --- /dev/null +++ b/images/eve.svg @@ -0,0 +1 @@ +Asset 1 \ No newline at end of file diff --git a/index.html b/index.html index f506c17..bed75d0 100644 --- a/index.html +++ b/index.html @@ -10,7 +10,7 @@ Eve Documentation - + @@ -74,24 +74,35 @@ +
+
+ + + +
+ +
+
-
-
-
- -
-
- -
+ + +
\ No newline at end of file + +
+ +
+ +
+
+ +

Blog

+

Read up on new releases, technical musings and more.

+
+ +

Mailing List

+

Chat with the community and team about the future of Eve.

+
+ +

GitHub Issues

+

Let us know about any problems you run into using Eve.

+
+
+
\ No newline at end of file diff --git a/index.xml b/index.xml index e12f38c..d6b123b 100644 --- a/index.xml +++ b/index.xml @@ -2,849 +2,703 @@ Eve Documentation - http://docs.witheve.com/ + http://docs.witheve.com/index.xml Recent content on Eve Documentation Hugo -- gohugo.io en-us - - http://docs.witheve.com/README/ + Getting Eve + http://docs.witheve.com/handbook/ Mon, 01 Jan 0001 00:00:00 +0000 - http://docs.witheve.com/README/ - - -<p align="center"> - <img src="http://www.witheve.com/logo.png" alt="Eve logo" width="10%" /> -</p> - -<hr /> - -<h1 id="documentation-for-the-eve-programming-language">Documentation for the Eve programming language.</h1> - -<p>You can learn more about Eve here: <a href="http://witheve.com/">http://witheve.com/</a></p> - -<p>You can play with Eve here: <a href="http://play.witheve.com">http://play.witheve.com</a></p> - -<p>Eve is under active development here: <a href="https://github.com/witheve/Eve">https://github.com/witheve/Eve</a></p> - -<h2 id="contributing">Contributing</h2> - -<p>There&rsquo;s a lot of work to be done on the documentation, so this is a great place for beginners to get started with Eve. From fixing typos to adding examples, work needs to be done across the board here. Check out the <a href="https://github.com/witheve/docs/issues">issues</a> for a place to start, as they have been raised already as points of improvement by the community. If someone is already assigned and the issue has been aroud a while, check to see if it&rsquo;s being worked on before starting it yourself. Or, if you find an issue yourself, please report it so others know it exists. Thank you!</p> + http://docs.witheve.com/handbook/ + <p>Test</p> - - http://docs.witheve.com/handbook/core/ + Quickstart + http://docs.witheve.com/tutorials/quickstart.eve/ Mon, 01 Jan 0001 00:00:00 +0000 - http://docs.witheve.com/handbook/core/ + http://docs.witheve.com/tutorials/quickstart.eve/ -<h1 id="core-language">Core Language</h1> +<h1 id="quickstart">Quickstart</h1> -<h2 id="see-also">See Also</h2> +<p>In this guide we&rsquo;re going to give you a 5 minute introduction to the essential concepts in Eve. If you&rsquo;ve never used Eve before, you&rsquo;re in the right place.</p> -<p><a href="../records">records</a> | <a href="../equivalence">equivalence</a> | <a href="../actions">actions</a> | <a href="../expressions">expressions</a> | <a href="../update-operators">update operators</a> | <a href="../databases">databases</a></p> - - - - - - http://docs.witheve.com/handbook/databases/ - Mon, 01 Jan 0001 00:00:00 +0000 - - http://docs.witheve.com/handbook/databases/ - +<h2 id="adding-records-to-eve">Adding records to Eve</h2> -<h1 id="databases">Databases</h1> +<p>Eve represents data as records, which are key value pairs attached to a unique ID. Eve programs are made up of small composable blocks that search for and create records. Let&rsquo;s start with a block that adds a record to Eve:</p> +<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">commit</span> + <span class="p">[</span><span class="err">#</span><span class="nv">greeting</span> <span class="nv">text</span><span class="nf">:</span> <span class="s">&quot;hello world&quot;</span><span class="p">]</span> +</code></pre></div> -<p>Databases contain records</p> +<p>This record is tagged <code>#greeting</code>, and has an attribute &ldquo;text&rdquo; with the value &ldquo;hello world&rdquo;. Although tags have a special syntax, they are attributes like any other. We encourage you to classify groups of related records with tags.</p> -<h2 id="syntax">Syntax</h2> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="c1">// search action</span><span class="w"></span> -<span class="kr">search</span><span class="w"> </span><span class="nt">@database1</span><span class="p">,</span><span class="w"> </span><span class="x">...</span><span class="p">,</span><span class="w"> </span><span class="nt">@databaseN</span><span class="w"></span> +<h2 id="finding-records-in-eve">Finding records in Eve</h2> -<span class="c1">// Commit action</span><span class="w"></span> -<span class="kr">commit</span><span class="w"> </span><span class="nt">@database1</span><span class="p">,</span><span class="w"> </span><span class="x">...</span><span class="p">,</span><span class="w"> </span><span class="nt">@databaseN</span><span class="w"></span> +<p>Eve finds every record that matches the supplied patterns, then binds new records to them. If no records match the search, then the block does not run at all. A block will only run if every pattern in a search matches at least one record. Let&rsquo;s search for the <code>#greeting</code> we just committed, and then display it in a text container:</p> +<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span> + <span class="p">[</span><span class="err">#</span><span class="nv">greeting</span> <span class="nv">text</span><span class="p">]</span> -<span class="c1">// Bind action</span><span class="w"></span> -<span class="kr">bind</span><span class="w"> </span><span class="nt">@database1</span><span class="p">,</span><span class="w"> </span><span class="x">...</span><span class="p">,</span><span class="w"> </span><span class="nt">@databaseN</span><span class="w"></span> +<span class="kr">bind</span> + <span class="p">[</span><span class="err">#</span><span class="nv">ui</span><span class="nf">/</span><span class="nv">text</span> <span class="nv">text</span><span class="p">]</span> </code></pre></div> -<h2 id="description">Description</h2> +<p>Variables with the same name are equivalent within a block; because they have the same name, the <code>text</code> in <code>[#greeting text]</code> and <code>[#ui/text text]</code> are equivalent. Go ahead and add another <code>#greeting</code> record to the first block to see what happens when more than one record matches the search.</p> -<p><code>&lt;action&gt; @database</code> performs the given action, one of <code>search</code>, <code>bind</code>, or <code>commit</code>, on the union of the provided databases.</p> +<h2 id="records-update-as-data-changes">Records update as data changes</h2> -<p>If no database is provided with an action, then that action is performed on the default <code>@session</code> database.</p> +<p>Blocks in Eve react automatically to changes in data. When a record changes, any bound records are automatically updated. Let&rsquo;s search for the current time, and display it in a div:</p> +<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span> + <span class="p">[</span><span class="err">#</span><span class="nv">time</span> <span class="nv">seconds</span><span class="p">]</span> -<h2 id="creating-and-searching-databases">Creating and Searching Databases</h2> - -<p>You can create databases on-demand by simply committing a record to one. e.g.</p> +<span class="kr">bind</span> + <span class="p">[</span><span class="err">#</span><span class="nv">ui</span><span class="nf">/</span><span class="nv">text</span> <span class="nv">text</span><span class="nf">:</span> <span class="nv">seconds</span><span class="p">]</span> +</code></pre></div> -<pre><code>commit @my-database - [#my-record] -</code></pre> +<p>As the time changes, the output updates to reflect the current state of the <code>#time</code> record. Records can be committed instead of bound, but the behavior is a little different &ndash; committed records persist until they are removed explicitly. Try changing <code>bind</code> to <code>commit</code> in the above block and see what happens.</p> -<p>This block will create a new database called &ldquo;my-database&rdquo;, which will contain the newly committed record. You can now search for this record in your new database:</p> +<h2 id="reacting-to-events">Reacting to events</h2> -<pre><code>search @my-database - [#my-record] +<p>Let&rsquo;s draw a button on the screen:</p> +<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">commit</span> + <span class="p">[</span><span class="err">#</span><span class="nv">ui</span><span class="nf">/</span><span class="nv">button</span> <span class="err">#</span><span class="nv">increment</span> <span class="nv">text</span><span class="nf">:</span> <span class="s">&quot;+1&quot;</span><span class="p">]</span> +</code></pre></div> -bind @browser - [#div text: &quot;Found a record!&quot;] -</code></pre> +<p>When you click anywhere on the screen, Eve creates an <code>#html/event/click</code> record representing the click. You can react to clicks on the <code>#increment</code> button by searching for the <code>#html/event/click</code> record, where the element attribute is the button:</p> +<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span> + <span class="nv">event</span> <span class="nf">=</span> <span class="p">[</span><span class="err">#</span><span class="nv">html</span><span class="nf">/</span><span class="nv">event</span><span class="nf">/</span><span class="nv">click</span> <span class="nv">element</span><span class="nf">:</span> <span class="p">[</span><span class="err">#</span><span class="nv">increment</span><span class="p">]]</span> -<h2 id="special-databases">Special Databases</h2> +<span class="kr">commit</span> + <span class="p">[</span><span class="err">#</span><span class="nv">clicked</span> <span class="nv">event</span><span class="p">]</span> +</code></pre></div> -<p>Eve has some built-in databases that have meaning to the runtime.</p> +<p>Clicks only last for an instant, but we want to create a permanent record of each click so we can search for them later. This block commits a <code>#clicked</code> record that will persist until it&rsquo;s explicitly removed. Much like the <code>#greeting</code> text we bound to the <code>#ui</code>, variables with the same name are equivalent, so the variable <code>event</code> in the <code>#clicked</code> record is a reference to the <code>#html/event/click</code> on the <code>#increment</code> button.</p> -<ul> -<li><a href="../session">@session</a> - the default database when no database is specified with an action.</li> -<li><a href="../view">@view</a> - records committed to <code>@view</code> are used to visualize data.</li> -<li><a href="../event">@event</a> - contains events originating from the DOM</li> -<li><a href="../browser">@browser</a> - Eve clients running in the browser render applicable records in this <code>@browser</code> as HTML elements.</li> -<li><a href="../http">@http</a> - Stores records representing HTTP requests and responses</li> -</ul> +<p>The identity of a record is determined by its attribute/value pairs. Two records with the same attributes and values are identical in Eve. We included the <code>event</code> attribute in the <code>#clicked</code> record to differentiate each record. Without this differentiation, we could only ever create a single <code>#clicked</code> record. Try removing <code>event</code> from the record and click the button to test this out.</p> -<h2 id="examples">Examples</h2> +<h2 id="count-the-number-of-clicks">Count the number of clicks</h2> -<p>Display the element that was clicked in the DOM</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"> </span><span class="nt">@event</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#click</span><span class="w"> </span><span class="nt">#direct-target</span><span class="w"> </span><span class="x">element</span><span class="p">]</span><span class="w"></span> +<p>Now let&rsquo;s count the number of times the button has been clicked. Make sure <code>event</code> is back in <code>#clicked</code>, and then we can count those records directly:</p> +<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span> + <span class="nv">how</span><span class="nf">-</span><span class="nv">many</span> <span class="nf">=</span> <span class="nv">gather</span><span class="nf">/</span><span class="nv">count</span><span class="p">[</span><span class="nv">for</span><span class="nf">:</span> <span class="p">[</span><span class="err">#</span><span class="nv">clicked</span><span class="p">]]</span> -<span class="kr">commit</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;{{element}} was clicked.&quot;</span><span class="p">]</span><span class="w"></span> +<span class="kr">bind</span> + <span class="p">[</span><span class="err">#</span><span class="nv">ui</span><span class="nf">/</span><span class="nv">text</span> <span class="nv">text</span><span class="nf">:</span> <span class="s">&quot;The button has been clicked {{how-many}} times&quot;</span><span class="p">]</span> </code></pre></div> -<p>Commit some data in <code>@session</code>, and then display it on a button click.</p> +<p>This block searches for every unique <code>#clicked</code>, counts them, and returns that value in <code>how-many</code>. Then we display this value in a text container using the operator <code>{{ ... }}</code>, which inserts the value of the contained variable into the string. An important thing to remember here is that this block will only run when the button has been clicked at least once. Before then, this block will not run because there are no <code>#clicked</code> records to count.</p> -<pre><code>commit - [#for-display text: &quot;Hello&quot;] -</code></pre> +<h2 id="summary">Summary</h2> -<p>We are searching over three databases to complete this block.</p> +<p>That&rsquo;s it for the 5 minute introduction to Eve. To summarize:</p> <ul> -<li>the <code>#click</code> is in <code>@event</code></li> -<li>the <code>#button</code> is in <code>@browser</code></li> -<li>the text for display is in <code>@session</code>. This needs to be made explicit; since we are searching in other databases, <code>@session</code> is not searched implicitly.</li> +<li>Eve programs are made up of blocks.</li> +<li>Data are represented by records, key value pairs associated to a unique ID.</li> +<li>There are two sections of a block: one where you search for records, and one where you bind or commit records.</li> +<li>Blocks update records automatically to reflect changes in data.</li> +<li>Bound records are replaced when data changes, while committed records must be removed manually.</li> +<li>Records are unique, uniqueness is determined by a record&rsquo;s attributes and their values.</li> </ul> -<pre><code>search @event @browser @session - [#click element: [#button]] - [#for-display text] - -commit @browser - [#div text] -</code></pre> - -<p>This block could have been written with two searches for the same effect:</p> - -<pre><code>search @event @browser - [#click element: [#button]] - -search - [#for-display text] - -commit @browser - [#div text] -</code></pre> - -<h2 id="see-also">See Also</h2> - -<p><a href="../search">search</a> | <a href="../bind">bind</a> | <a href="../commit">commit</a></p> - - - - - - http://docs.witheve.com/handbook/intro/ - Mon, 01 Jan 0001 00:00:00 +0000 - - http://docs.witheve.com/handbook/intro/ - - -<h1 id="introduction">Introduction</h1> - -<h2 id="notable-features">Notable Features</h2> +<p>This will get you started with Eve, but there&rsquo;s still more to learn. From here, you can:</p> <ul> -<li><p>Eve programs aren&rsquo;t talking to a database, they <em>are</em> the database. That means no plumbing, no impedance mismatch, and no extra infrastructure is needed.</p></li> - -<li><p>Everything is data. The file system, http requests, the DOM&hellip; That means everything can be queried and everything can be reacted to.</p></li> - -<li><p>Eve&rsquo;s semantics were built for concurrency, asynchrony, and distribution. There are no promises, or thread synchronizations, or borrows.</p></li> - -<li><p>Eve programs practice literate programming, since there&rsquo;s no incidental ordering imposed by the language.</p></li> - -<li><p>Another result of a lack of ordering is that programs grow very organically through composition.</p></li> - -<li><p>Eve programs are naturally tiny.</p></li> - -<li><p>Correctness can be defined globally through integrity constraints, allowing people to safely contribute to an application without worrying about checking every possible invariant locally.</p></li> +<li>Advance to Level 2 of the introductory tutorial.</li> +<li>View the syntax reference or the Eve handbook.</li> +<li>Explore already made examples.</li> +<li>Or dive right in to the editor and try out the concepts you&rsquo;ve just learned.</li> </ul> - -<h2 id="see-also">See Also</h2> - -<p><a href="../installation">getting eve</a> | <a href="../running">running eve</a> | <a href="../programs">eve programs</a> | <a href="../core">core language</a></p> - - - - - - http://docs.witheve.com/handbook/programs/ - Mon, 01 Jan 0001 00:00:00 +0000 - - http://docs.witheve.com/handbook/programs/ - - -<h1 id="eve-programs">Eve Programs</h1> - -<p>Coming soon&hellip;</p> - -<h2 id="see-also">See Also</h2> - -<p><a href="../model">programming model</a> | <a href="../literate-programming">literate programming</a> | <a href="../blocks">blocks</a></p> - Eve Documentation + Index http://docs.witheve.com/ Mon, 01 Jan 0001 00:00:00 +0000 http://docs.witheve.com/ -<h1 id="eve-programming-language-documentation">Eve Programming Language Documentation</h1> +<h2 id="install-guide">Install guide</h2> -<h2 id="guides">Guides</h2> +<p>Need to install Eve on your machine? <a href="../install">Head here</a> for step-by-step directions.</p> -<ul> -<li><a href="http://play.witheve.com">Eve Quickstart Guide</a></li> -</ul> - - - - - Eve for Programmers - http://docs.witheve.com/guides/for-programmers/ - Mon, 01 Jan 0001 00:00:00 +0000 - - http://docs.witheve.com/guides/for-programmers/ - - -<h1 id="eve-for-programmers">Eve for Programmers</h1> - -<p>As a programmer, you probably find it easy to switch between different programming langauges. If you know Javascript, you probably wouldn&rsquo;t have a hard time learning similar langauges like C++, Java, or Python. That&rsquo;s because despite syntactic differences, these languages largely conform to the same programming model. When we program in languages like these, we use similar abstractions between them &ndash; loops, functions, and input/output patterns have become a staple of every programmer&rsquo;s toolbox. When we solve problems, we usually reach a solution in terms of these primitive operations.</p> - -<p>Eve is a different kind of programming langauge from Javascript or Python, so programmers new to Eve may feel a little lost at first. How do you get anything done in a language without loops? How do you compose code without functions? The purpose of this guide is to provide a mapping from the common tools you know, to the Eve way of solving problems. We&rsquo;ll look at some programs written in Javascript, and see how they Eve can solve them.</p> - -<h2 id="functions">Functions</h2> - -<p>Functions are the fundamental unit of code reuse in most conventional programming languages. These langauges typically start from a &ldquo;main&rdquo; function, and branch</p> - -<h2 id="looping">Looping</h2> - -<h3 id="map">Map</h3> - -<h3 id="reduce">Reduce</h3> - -<h3 id="recursion">Recursion</h3> - -<h2 id="i-o">I/O</h2> - - - - - Linux - http://docs.witheve.com/handbook/linux/ - Mon, 01 Jan 0001 00:00:00 +0000 - - http://docs.witheve.com/handbook/linux/ - - -<h1 id="installing-eve-on-linux">Installing Eve on Linux</h1> - -<p>First, <a href="https://github.com/witheve/Eve/archive/master.zip">download</a> the Eve source. You&rsquo;ll need a recent <a href="https://nodejs.org">node.js</a> and then in the extracted Eve directory:</p> - -<pre><code>npm install -npm start -</code></pre> - -<p>Then open <code>http://localhost:8080/</code> in your browser.</p> - -<h2 id="tips">Tips</h2> - -<p>Some distributions (most notably Ubuntu) have renamed <code>node</code> to <code>nodejs</code>. If this is the case, you&rsquo;ll need to create a symlink that remaps nodejs back to node. e.g.</p> +<h2 id="quickstart">Quickstart</h2> -<pre><code>ln -s /usr/bin/nodejs /usr/bin/node -</code></pre> +<p>If you’re new to Eve and want a hands-on demo to learn the language, you can jump right in with a 5 minute <a href="../quickstart">quickstart guide</a> that shows you how to build a simple incrementing counter.</p> -<p>Then proceed with the installation as usual</p> +<h2 id="syntax-reference">Syntax reference</h2> -<h2 id="see-also">See also</h2> +<p>Want a reminder how the syntax works or to get an overview of Eve without going through the quickstart? The <a href="../syntax">syntax reference</a> is a good place to start.</p> -<p><a href="../mac">mac</a> | <a href="../windows">windows</a> | <a href="../docker">docker</a> | <a href="../running">running</a></p> - - - - - Mac - http://docs.witheve.com/handbook/mac/ - Mon, 01 Jan 0001 00:00:00 +0000 - - http://docs.witheve.com/handbook/mac/ - +<h2 id="libraries">Libraries</h2> -<h1 id="installing-eve-on-mac">Installing Eve on Mac</h1> +<p>Want to know everything Eve can do? <a href="../library">Here’s a list</a> of all the functions, operators, and watchers available in the language.</p> -<p>First, <a href="https://github.com/witheve/Eve/archive/master.zip">download</a> the Eve source. You&rsquo;ll need a recent <a href="https://nodejs.org">node.js</a> and then in the extracted Eve directory:</p> +<h2 id="stuck">Stuck?</h2> -<pre><code>npm install -npm start -</code></pre> +<p>If you didn’t find what you were looking for, you can get in touch with the Eve team and the community through these channels:</p> -<p>Then open <code>http://localhost:8080/</code> in your browser.</p> +<ul> +<li>Send a message to the <a href="https://groups.google.com/forum/#!forum/eve-talk">mailing list</a>. We generally respond to messages within a day.</li> +<li>Send a tweet to <a href="https://twitter.com/with_eve/">@with_eve</a>.</li> +<li>Submit an issue to our <a href="https://github.com/witheve">GitHub repository</a>.</li> +<li>Join the Eve Slack channel to talk with Eve developers and the community in real time <em>(coming soon)</em></li> +</ul> -<h2 id="see-also">See also</h2> +<h2 id="want-to-learn-more">Want to learn more?</h2> -<p><a href="../linux">linux</a> | <a href="../windows">windows</a> | <a href="../docker">docker</a> | <a href="../npm">npm</a> | <a href="../running">running</a></p> +<ul> +<li>Browse our <a href="../gallery">gallery</a> of examples from the Eve crew and the community to learn, to be inspired, or just for fun!</li> +<li>Read our <a href="http://incidentalcomplexity.com">blog</a> to see what we’re up to, from our developer diary to essays, announcements, and more.</li> +</ul> - Quickstart - http://docs.witheve.com/tutorials/quickstart/ + + http://docs.witheve.com/README/ Mon, 01 Jan 0001 00:00:00 +0000 - http://docs.witheve.com/tutorials/quickstart/ + http://docs.witheve.com/README/ -<h1 id="eve-quick-start-tutorial">Eve Quick Start Tutorial</h1> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="x">```</span><span class="w"></span> -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="x">tag</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;div&quot;</span><span class="p">,</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;Hello, world&quot;</span><span class="p">]</span><span class="w"></span> -<span class="x">```</span><span class="w"></span> -</code></pre></div> - -<p>Hello world! At its core, Eve is a pattern matching language. You match patterns of data by searching a database, then update or create new data according to what you&rsquo;ve found. In this example, we created a <a href="https://witheve.github.io/docs/handbook/records/"><code>record</code></a> that has two attributes: a tag attribute with the value <code>&quot;div&quot;</code>, and a text attribute with the value <code>&quot;Hello, world&quot;</code>. We <a href="https://witheve.github.io/docs/handbook/bind/">bound</a> this record to the browser, which is how we displayed our venerable message.</p> - -<p>The three backticks <code>```</code> are called a code fence, and they allow us to denote blocks of code. This gives us the ability to embed Eve code in normal documents written in Markdown. This is how Eve programs are written: everything in a code fence is a <a href="https://witheve.github.io/docs/handbook/blocks/">block</a> of Eve code, while everything outside is prose describing the program. In fact, this quick start tutorial is an example of an executable Eve program! In the subsequent blocks, you won&rsquo;t see any code fences, but they still exist in the <a href="https://raw.githubusercontent.com/witheve/docs/src/guides/quickstart.md">document&rsquo;s source</a>.</p> - -<p>So far we&rsquo;ve created a record that displays “Hello, world!” but as I said, Eve is a pattern matching language. Let&rsquo;s explore that by searching for something:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="x">name</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="x">tag</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;div&quot;</span><span class="p">,</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;Hello, world&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>Our message disappeared! Before, we bound without searching, so the message displayed by default. Now we&rsquo;re binding in the presence of a <a href="https://witheve.github.io/docs/handbook/search/"><code>search</code></a> action, so the bound record only exists if all the searched records are matched. Here, we&rsquo;re searching for all records with a <code>name</code> attribute, but we haven&rsquo;t added any records like that to Eve so none are matched. With no matching records, the <code>bind</code> cannot execute, and the message disappears from the screen.</p> - -<p>This is the flow of an Eve block: you search for records in a database, and if all the records you searched for are matched, you can modify the matched records or create new ones. If any part of your search is not matched, then no records will be created or updated.</p> - -<p>To get our message back, all we need is a record with a name attribute. We can create one permanently with the <a href="https://witheve.github.io/docs/handbook/commit/"><code>commit</code></a> action:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">commit</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;Celia&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>Hello, world… again! Commit permanently updates or creates a record that will persist even if its matched records (the records matched in a search action) change. Since we aren&rsquo;t searching for anything in this block, the commit executes by default and adds a record with a name attribute of <code>&quot;Celia&quot;</code>. The addition of this new record satisfies the search in the previous block, so “Hello, world!” appears on the screen again.</p> - -<p>But what else can you do with matched records? For starters, we can use them to create new records:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="x">name</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="p">,</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;Hello, {{name}}&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>Since we matched on a record with a name attribute, we now have a reference to that name, and we can inject it into a string using <a href="https://witheve.github.io/docs/handbook/string-interpolation/"><code>{{ ... }}</code></a> embedding. We can also swap out <code>tag: &quot;div&quot;</code> for the sugared <code>#div</code>. <a href="https://witheve.github.io/docs/handbook/tags/">Tags</a> are used a lot in Eve to talk about collections of related records. For example, we could search for all records with a <code>#student</code> tag, with name, grade, and school attributes.</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="w"> </span><span class="x">grade</span><span class="w"> </span><span class="x">school</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;{{name}} is a {{grade}}th grade student at {{school}}.&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>Since we&rsquo;re matching on more attributes, this block is no longer satisfied by the record we added earlier; we&rsquo;re missing a <code>#student</code> tag, as well as grade and school attributes. Even though these are currently missing, we can still write the code that would display them.</p> - -<p>Let&rsquo;s display this new message by adding the missing attributes to Celia. We could add them to the block where we comitted Celia originally, but we can also do it programatically:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">celia</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="x">“Celia”</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">celia</span><span class="w"> </span><span class="nf">&lt;-</span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">grade</span><span class="nf">:</span><span class="w"> </span><span class="m">10</span><span class="p">,</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;East&quot;</span><span class="p">,</span><span class="w"> </span><span class="x">age</span><span class="nf">:</span><span class="w"> </span><span class="m">16</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>You can define variables within blocks, which act as handles on records that allow you to change them. In this case, we&rsquo;re using the <a href="https://witheve.github.io/docs/handbook/merge/">merge operator</a> <code>&lt;-</code> to combine two records. With the addition of this block, the sentence &ldquo;Celia is a 10th grade student at East.&rdquo; appears in the browser.</p> - -<p>Celia is cool and all, but let&rsquo;s add some more students to our database:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">commit</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="x">“Diedra”</span><span class="p">,</span><span class="w"> </span><span class="x">grade</span><span class="nf">:</span><span class="w"> </span><span class="m">12</span><span class="p">,</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;West&quot;</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="x">“Michelle”</span><span class="p">,</span><span class="w"> </span><span class="x">grade</span><span class="nf">:</span><span class="w"> </span><span class="m">11</span><span class="p">,</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;West&quot;</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="x">“Jermaine”</span><span class="p">,</span><span class="w"> </span><span class="x">grade</span><span class="nf">:</span><span class="w"> </span><span class="m">9</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>Three sentences are now printed, one for each student that matches the search. Eve works on <a href="https://witheve.github.io/docs/handbook/sets/">sets</a>, so when we search for <code>[#student name grade school]</code>, we find <em>all</em> records that match the given pattern. This includes Celia, Diedra and Michelle (but not Jermaine, as he has no school in his record). Therefore, when we bind the record <code>[#div text: &quot;{{name}} is a ... &quot;]</code>, we are actually binding three records, one for each matching <code>#student</code>.</p> - -<p>If you re-compile the program a couple times, you&rsquo;ll see the order of sentences may change. This is because <strong>there is no ordering in Eve - blocks are not ordered, statements are not ordered, and results are not ordered</strong>. If you want to order elements, you must impose an ordering yourself. We can ask the browser to draw elements in an order with the &ldquo;sort&rdquo; attribute:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="w"> </span><span class="x">grade</span><span class="w"> </span><span class="x">school</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">sort</span><span class="nf">:</span><span class="w"> </span><span class="x">name</span><span class="p">,</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;{{name}} is a {{grade}}th grade student at {{school}}.&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>This time when you recompile your program, the order will stay fixed, sorted alphabetically by name.</p> - -<p>Let&rsquo;s make things a little more interesting by adding some records about the schools the students attend:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">commit</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#school</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="x">“West”</span><span class="p">,</span><span class="w"> </span><span class="x">address</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;1234 Main Street&quot;</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#school</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="x">“East”</span><span class="p">,</span><span class="w"> </span><span class="x">address</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;5678 Broad Street&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>What if we want to display the address of the school each student attends? Although <code>#student</code>s and <code>#school</code>s are in different records, <strong>we can relate two records by associating attributes from one record with attributes from the other.</strong> This is an operation known as <a href="https://witheve.github.io/docs/handbook/joins/">joining</a>. In this case, we want to relate the <code>name</code> attribute on <code>#schools</code> with the <code>school</code> attribute on <code>#students</code>. This compares the values of the attributes between records, and matches up those with the same value. For instance, since Celia&rsquo;s school is &ldquo;East&rdquo;, she can join with the <code>#school</code> named &ldquo;East&rdquo;.</p> - -<p>Our first attempt may come out looking a little something like this:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">school</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#school</span><span class="w"> </span><span class="x">name</span><span class="w"> </span><span class="x">address</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">student</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="x">name</span><span class="p">]</span><span class="w"> </span> - -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;{{student.name}} attends {{school.name}} at {{address}}&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>But that didn&rsquo;t work. How come? In Eve, <strong>things with the same name are <a href="https://witheve.github.io/docs/handbook/equivalence/">equivalent</a></strong>. In this block, we&rsquo;ve used &ldquo;name&rdquo; three times, which says that the school&rsquo;s name, the student&rsquo;s name, and the student&rsquo;s school are all the same. Of course, there is no combination of students and schools that match this search, so nothing is displayed.</p> - -<p>Instead, we can use the dot operator to specifically ask for the name attribute in the <code>#school</code> records, and rename our variables to get a correct block:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">schools</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#school</span><span class="w"> </span><span class="x">address</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">students</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="x">school.name</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;{{students.name}} attends {{schools.name}} at {{address}}&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>This creates an implicit join over the school name without mixing up the names of the students and the names of the schools, giving us our desired output. You can actually bind attributes to any name you want to avoid collisions in a block:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#school</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="x">school</span><span class="nf">-</span><span class="x">name</span><span class="w"> </span><span class="x">address</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="x">student</span><span class="nf">-</span><span class="x">name</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="x">school</span><span class="nf">-</span><span class="x">name</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;{{student-name}} attends {{school-name}} at {{address}}&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<h2 id="advanced-eve">Advanced Eve</h2> - -<p>Recall when we added our students, Celia was the only one we added an <code>age</code> to. Therefore, the following block only displays Celia&rsquo;s age, even though we ask for all the <code>#student</code>s:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="w"> </span><span class="x">age</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;{{name}} is {{age}} years old&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>Let&rsquo;s pretend that all students enter first grade at six years old. Therefore, if we know a student&rsquo;s grade, we can calculate their age and add it to the student&rsquo;s record:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">student</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">calculated</span><span class="nf">-</span><span class="x">age</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="kr">if</span><span class="w"> </span><span class="x">student.age</span><span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="x">student.age</span><span class="w"></span> -<span class="x">                  </span><span class="w"> </span><span class="kr">else</span><span class="w"> </span><span class="kr">if</span><span class="w"> </span><span class="x">student.grade</span><span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="x">student.grade</span><span class="w"> </span><span class="nf">+</span><span class="w"> </span><span class="m">5</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">student.age</span><span class="w"> </span><span class="nf">:=</span><span class="w"> </span><span class="x">calculated</span><span class="nf">-</span><span class="x">age</span><span class="w"></span> -</code></pre></div> - -<p>This block selects all students, and uses and <a href="https://witheve.github.io/docs/handbook/if-then/"><code>if-then</code></a> expression to set the student&rsquo;s calculated age. If the student already has an age, we set it to that. Otherwise, if the student has no age, we can calculate it with some arithmetic. The <a href="https://witheve.github.io/docs/handbook/set/">set operator</a> <code>:=</code> sets an attribute to a specified value regardless of what it was before the block executed. That value can be anything, from a number to a string to another record.</p> - -<h3 id="aggregates">Aggregates</h3> - -<p>So far everything we&rsquo;ve done has used one record at a time, but what happens when we want to work over a group of records, such as counting how many students there are? To solve such a problem, we&rsquo;ll need to use an <a href="https://witheve.github.io/docs/handbook/aggregates/">aggregate</a>. Aggregates take a set of values and turn them into a single value, akin to &ldquo;fold&rdquo; or &ldquo;reduce&rdquo; functions in other languages. In this case, we&rsquo;ll use the aggregate <a href="https://witheve.github.io/docs/handbook/statistics/count/"><code>count</code></a> to figure out how many <code>#students</code> are in the school district:  </p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">students</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">total</span><span class="nf">-</span><span class="x">students</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">count</span><span class="p">[</span><span class="x">given</span><span class="nf">:</span><span class="w"> </span><span class="x">students</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"> </span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;{{total-students}} are in the school district&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>A quick note on the syntax for <code>count</code> - it feels a lot like a function in other languages, since it has a return value and can be used inline in expressions. Under the hood, <a href="https://witheve.github.io/docs/handbook/functions/">functions</a> and aggregates are actually records; <code>total = count[given: students]</code> is shorthand for <code>[#count #function given: students, value: total]</code>. This distinction won&rsquo;t materially change the way you use <code>count</code>, but it goes to show that everything in Eve reduces to working with records.</p> - -<p>While <code>given</code> is a required argument in <code>count</code>, aggregates (and functions in general) can also have optional arguments. Let&rsquo;s say we want to know how many students attend each school. We can use the optional argument <code>per</code> to count students grouped by the school they attend:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">students</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">school</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">students</span><span class="nf">-</span><span class="x">per</span><span class="nf">-</span><span class="x">school</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">count</span><span class="p">[</span><span class="x">given</span><span class="nf">:</span><span class="w"> </span><span class="x">students</span><span class="p">,</span><span class="w"> </span><span class="x">per</span><span class="nf">:</span><span class="w"> </span><span class="x">school</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;{{students-per-school}} attend {{school}}&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>All function-like records in Eve specify their arguments as attributes. This means you specify the argument and its value, unlike in other languages, where the order of the values determines the attribute to which they belong. As with everything else in Eve, order doesn&rsquo;t matter.</p> - -<h2 id="extra-credit">Extra Credit</h2> - -<p>At this point, you know everything necessary about Eve to complete this extra credit portion (the only additional knowledge you need is domain knowledge of HTML and forms). Let&rsquo;s review some of the key concepts:</p> - -<ul> -<li>Eve programs are composed of blocks of code that search for and update records.</li> -<li>Records are sets of <code>attribute: value</code> pairs attached to a unique ID.</li> -<li>Eve works with sets, which have no ordering and contain unique elements.</li> -<li>Things with the same name are equivalent.</li> -</ul> - -<p>Your extra credit task is to build a web-based form that allows you to add students to the database. Take a moment to think about how this might be done in Eve, given everything we&rsquo;ve learned so far.</p> - -<p>First, let&rsquo;s make the form. We&rsquo;ve already displayed a <code>#div</code>, and in the same way we can draw <code>#input</code>s and a <code>#button</code>:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">children</span><span class="nf">:</span><span class="w"> </span> -<span class="x">   </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">sort</span><span class="nf">:</span><span class="w"> </span><span class="m">1</span><span class="p">,</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;Name:&quot;</span><span class="p">]</span><span class="w"></span> -<span class="x">   </span><span class="w"> </span><span class="p">[</span><span class="nt">#input</span><span class="w"> </span><span class="nt">#name-input</span><span class="w"> </span><span class="x">sort</span><span class="nf">:</span><span class="w"> </span><span class="m">2</span><span class="p">]</span><span class="w"></span> -<span class="x">   </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">sort</span><span class="nf">:</span><span class="w"> </span><span class="m">3</span><span class="p">,</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;Grade:&quot;</span><span class="p">]</span><span class="w"></span> -<span class="x">   </span><span class="w"> </span><span class="p">[</span><span class="nt">#input</span><span class="w"> </span><span class="nt">#grade-input</span><span class="w"> </span><span class="x">sort</span><span class="nf">:</span><span class="w"> </span><span class="m">4</span><span class="p">]</span><span class="w"></span> -<span class="x">   </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">sort</span><span class="nf">:</span><span class="w"> </span><span class="m">5</span><span class="p">,</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;School:&quot;</span><span class="p">]</span><span class="w"></span> -<span class="x">   </span><span class="w"> </span><span class="p">[</span><span class="nt">#input</span><span class="w"> </span><span class="nt">#school-input</span><span class="w"> </span><span class="x">sort</span><span class="nf">:</span><span class="w"> </span><span class="m">6</span><span class="p">]</span><span class="w"></span> -<span class="x">   </span><span class="w"> </span><span class="p">[</span><span class="nt">#button</span><span class="w"> </span><span class="nt">#submit</span><span class="w"> </span><span class="x">sort</span><span class="nf">:</span><span class="w"> </span><span class="m">7</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;submit&quot;</span><span class="p">]]</span><span class="w"></span> -</code></pre></div> - -<p>We&rsquo;ve added some tags to the inputs and the button to distinguish them, so we can easily search for them from other blocks. Now that we have a form, we need to define what happens when the submit button is clicked.</p> - -<p>Remember, everything in Eve is a record, so the <code>#click</code> event is no different. When a user clicks the mouse in the browser, Eve records that click in the database.</p> +<p align="center"> + <img src="http://www.witheve.com/logo.png" alt="Eve logo" width="10%" /> +</p> -<p>This record exists only for an instant, but we can react to it by searching for <code>[#click element: [#submit]]</code>. This record represents a <code>#click</code> on our <code>#submit</code> button. Then, all we need to do is capture the values of the input boxes and save them as a <code>#student</code> record:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#click</span><span class="w"> </span><span class="x">element</span><span class="nf">:</span><span class="w"> </span><span class="p">[</span><span class="nt">#submit</span><span class="p">]]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">name</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#name-input</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">grade</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#grade-input</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">school</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#school-input</span><span class="p">]</span><span class="w"></span> +<hr /> -<span class="kr">commit</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="c1">// save the new student</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="x">name.value</span><span class="p">,</span><span class="w"> </span><span class="x">grade</span><span class="nf">:</span><span class="w"> </span><span class="x">grade.value</span><span class="p">,</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="x">school.value</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="c1">// reset the form</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">name.value</span><span class="w"> </span><span class="nf">:=</span><span class="w"> </span><span class="s">&quot;&quot;</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">grade.value</span><span class="w"> </span><span class="nf">:=</span><span class="w"> </span><span class="s">&quot;&quot;</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">school.value</span><span class="w"> </span><span class="nf">:=</span><span class="w"> </span><span class="s">&quot;&quot;</span><span class="w"></span> -</code></pre></div> +<h1 id="documentation-for-the-eve-programming-language">Documentation for the Eve programming language.</h1> -<h2 id="learning-more">Learning more</h2> +<p>You can learn more about Eve here: <a href="http://witheve.com/">http://witheve.com/</a></p> -<p>If you want to learn more about Eve, we have some resources to help with that:</p> +<p>You can play with Eve here: <a href="http://play.witheve.com">http://play.witheve.com</a></p> -<ul> -<li>Example applications - See some working programs and explore how they work.</li> -<li>Tutorials - Step by step instructions on building Eve applications.</li> -<li><a href="https://witheve.github.io/docs">The Eve Handbook</a> - Everything you need to know about Eve.</li> -<li><a href="https://witheve.github.io/assets/docs/SyntaxReference.pdf">Eve syntax reference</a> - Eve&rsquo;s syntax in one page.</li> -<li>Guides - In-depth documents on topics relating to Eve.</li> -</ul> +<p>Eve is under active development here: <a href="https://github.com/witheve/Eve">https://github.com/witheve/Eve</a></p> -<p>We also invite you to join the Eve community! There are several ways to get involved:</p> +<h2 id="contributing">Contributing</h2> -<ul> -<li>Join our <a href="https://groups.google.com/forum/#!forum/eve-talk">mailing list</a> and get involved with the latest discussions on Eve.</li> -<li>Impact the future of Eve by getting involved with our <a href="https://github.com/witheve/rfcs">Request for Comments</a> process.</li> -<li>Read our <a href="http://incidentalcomplexity.com/">development diary</a> for the latest news and articles on Eve.</li> -<li>Follow us on <a href="https://twitter.com/with_eve">twitter</a>.</li> -</ul> +<p>There&rsquo;s a lot of work to be done on the documentation, so this is a great place for beginners to get started with Eve. From fixing typos to adding examples, work needs to be done across the board here. Check out the <a href="https://github.com/witheve/docs/issues">issues</a> for a place to start, as they have been raised already as points of improvement by the community. If someone is already assigned and the issue has been aroud a while, check to see if it&rsquo;s being worked on before starting it yourself. Or, if you find an issue yourself, please report it so others know it exists. Thank you!</p> - Standard Library - http://docs.witheve.com/handbook/standard-library/ + + http://docs.witheve.com/guides/ Mon, 01 Jan 0001 00:00:00 +0000 - http://docs.witheve.com/handbook/standard-library/ - - -<h1 id="standard-library">Standard Library</h1> - -<p>The Eve standard library of functions is globally available, meaning you don&rsquo;t have to reference a specific database to use these functions.</p> - -<h2 id="description">Description</h2> - -<ul> -<li><a href="../general">general</a> - General functions</li> -<li><a href="../math">math</a> - General mathematical and trigonometric functions</li> -<li><a href="../strings">strings</a> - Functions that manipulate strings</li> -<li><a href="../statistics">statistics</a> - Functions that calculate statistical measures on values</li> -<li><a href="../datetime">date &amp; time</a> - Functions that get and manipulate date and time</li> -</ul> - + http://docs.witheve.com/guides/ + - Style Guide - http://docs.witheve.com/guides/style/ + + http://docs.witheve.com/handbook/core/ Mon, 01 Jan 0001 00:00:00 +0000 - http://docs.witheve.com/guides/style/ - - -<h1 id="eve-style-guide">Eve Style Guide</h1> - -<h2 id="comments">Comments</h2> - -<p>Add a space after the comment marker to make comments more readable</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="c1">// This is correct</span><span class="w"></span> -<span class="c1">//This is incorrect</span><span class="w"></span> -</code></pre></div> - -<h2 id="naming">Naming</h2> - -<p>As much as possible, don&rsquo;t abbreviate names. The goal in writing an Eve program is to be as readable as possible. An abbreviation that makes sense to you might not make sense to someone else, or even yourself when you revisit the program in a year.</p> - -<p>Multi-word names should be joined by dashes <code>-</code>, not underscores <code>_</code>.</p> - -<h2 id="program-layout">Program layout</h2> - -<p>Blocks should be preceded by at least a one line comment, indicating the purpose of the block.</p> - -<h2 id="commas">Commas</h2> - -<p>Although Eve treats commas as white-space, they should be used to enhance readability as needed:</p> - -<p>In records, separate attributes with commas after a bind</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="c1">// More readable</span><span class="w"></span> -<span class="p">[</span><span class="nt">#person</span><span class="w"> </span><span class="x">name</span><span class="w"> </span><span class="x">age</span><span class="nf">:</span><span class="w"> </span><span class="m">30</span><span class="p">,</span><span class="w"> </span><span class="x">height</span><span class="nf">:</span><span class="w"> </span><span class="m">5</span><span class="p">,</span><span class="w"> </span><span class="x">hair</span><span class="nf">-</span><span class="x">color</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;brown&quot;</span><span class="p">]</span><span class="w"></span> - -<span class="c1">// Less readable</span><span class="w"></span> -<span class="p">[</span><span class="nt">#person</span><span class="w"> </span><span class="x">name</span><span class="w"> </span><span class="x">age</span><span class="nf">:</span><span class="w"> </span><span class="m">30</span><span class="w"> </span><span class="x">height</span><span class="nf">:</span><span class="w"> </span><span class="m">5</span><span class="w"> </span><span class="x">hair</span><span class="nf">-</span><span class="x">color</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;brown&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>Commas should also be used to separate items contained in parenthesis, such as in a multiple return.</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="c1">// More readable</span><span class="w"></span> -<span class="p">(</span><span class="x">val</span><span class="m">1</span><span class="p">,</span><span class="w"> </span><span class="x">val</span><span class="m">2</span><span class="p">)</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="kr">if</span><span class="w"> </span><span class="p">[</span><span class="nt">#tag1</span><span class="p">]</span><span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="p">(</span><span class="m">1</span><span class="p">,</span><span class="w"> </span><span class="l">false</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="kr">else</span><span class="w"> </span><span class="p">(</span><span class="m">0</span><span class="p">,</span><span class="w"> </span><span class="l">true</span><span class="p">)</span><span class="w"></span> -<span class="x">total</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">count</span><span class="p">[</span><span class="x">given</span><span class="nf">:</span><span class="w"> </span><span class="x">attr</span><span class="m">1</span><span class="p">,</span><span class="w"> </span><span class="x">per</span><span class="nf">:</span><span class="w"> </span><span class="p">(</span><span class="x">attr</span><span class="m">2</span><span class="p">,</span><span class="w"> </span><span class="x">attr</span><span class="m">3</span><span class="p">)]</span><span class="w"></span> - -<span class="c1">// Less readable</span><span class="w"></span> -<span class="p">(</span><span class="x">val</span><span class="m">1</span><span class="w"> </span><span class="x">val</span><span class="m">2</span><span class="p">)</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="kr">if</span><span class="w"> </span><span class="p">[</span><span class="nt">#tag1</span><span class="p">]</span><span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="p">(</span><span class="m">1</span><span class="w"> </span><span class="l">false</span><span class="p">)</span><span class="w"></span> -<span class="w"> </span><span class="kr">else</span><span class="w"> </span><span class="p">(</span><span class="m">0</span><span class="w"> </span><span class="l">true</span><span class="p">)</span><span class="w"></span> -<span class="x">total</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">count</span><span class="p">[</span><span class="x">given</span><span class="nf">:</span><span class="w"> </span><span class="x">attr</span><span class="m">1</span><span class="w"> </span><span class="x">per</span><span class="nf">:</span><span class="w"> </span><span class="p">(</span><span class="x">attr</span><span class="m">2</span><span class="w"> </span><span class="x">attr</span><span class="m">3</span><span class="p">)]</span><span class="w"></span> -</code></pre></div> - -<h2 id="indention">Indention</h2> - -<p>Eve does not enforce indention, but it is important for readability</p> - -<h3 id="blocks">Blocks</h3> - -<p><code>search</code>. <code>commit</code>, and <code>bind</code> should be the only lines at zero indention. Everything else should be indented.</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="c1">// Good</span><span class="w"></span> -<span class="kr">search</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="x">...</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="x">...</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>But not this:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="c1">// Not good</span><span class="w"></span> -<span class="kr">search</span><span class="w"></span> -<span class="p">[</span><span class="x">...</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"></span> -<span class="p">[</span><span class="x">...</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<h3 id="if-then">If-Then</h3> - -<p>Each arm of an <code>if-then</code> statement should be at the same indention level. The <code>then</code> portion of the statement can be on a new line if the <code>if</code> portion is exceptionally long, but it should be indented once.</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="c1">// Good if layout</span><span class="w"></span> -<span class="x">value</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="kr">if</span><span class="w"> </span><span class="x">bar</span><span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="x">baz</span><span class="w"></span> -<span class="w"> </span><span class="kr">if</span><span class="w"> </span><span class="x">bar</span><span class="m">2</span><span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="x">baz</span><span class="m">2</span><span class="w"></span> -<span class="w"> </span><span class="kr">else</span><span class="w"> </span><span class="x">baz</span><span class="m">3</span><span class="w"></span> - -<span class="c1">// Okay, especially if the branch is long</span><span class="w"></span> -<span class="x">value</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="kr">if</span><span class="w"> </span><span class="p">[</span><span class="nt">#long-record</span><span class="w"> </span><span class="x">attr</span><span class="m">1</span><span class="w"> </span><span class="x">attr</span><span class="m">2</span><span class="w"> </span><span class="x">attr</span><span class="m">3</span><span class="p">]</span><span class="w"> </span> -<span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="x">baz</span><span class="w"></span> -<span class="w"> </span><span class="kr">if</span><span class="w"> </span><span class="p">[</span><span class="nt">#long-record2</span><span class="w"> </span><span class="x">attr</span><span class="m">1</span><span class="w"> </span><span class="x">attr</span><span class="m">2</span><span class="w"> </span><span class="x">attr</span><span class="m">3</span><span class="p">]</span><span class="w"> </span> -<span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="x">baz</span><span class="m">2</span><span class="w"></span> -<span class="w"> </span><span class="kr">else</span><span class="w"> </span><span class="x">baz</span><span class="m">3</span><span class="w"></span> - -<span class="c1">// Less readable &quot;if&quot; formatting</span><span class="w"></span> -<span class="x">value</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="kr">if</span><span class="w"> </span><span class="x">bar</span><span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="x">baz</span><span class="w"></span> -<span class="kr">if</span><span class="w"> </span><span class="x">bar</span><span class="m">2</span><span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="x">baz</span><span class="m">2</span><span class="w"></span> -<span class="kr">else</span><span class="w"> </span><span class="x">baz</span><span class="m">3</span><span class="w"></span> - -<span class="c1">// Less readable &quot;if&quot; formatting</span><span class="w"></span> -<span class="x">value</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="kr">if</span><span class="w"> </span><span class="x">bar</span><span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="x">baz</span><span class="w"> </span><span class="kr">if</span><span class="w"> </span><span class="x">bar</span><span class="m">2</span><span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="x">baz</span><span class="m">2</span><span class="w"> </span><span class="kr">else</span><span class="w"> </span><span class="x">baz</span><span class="m">3</span><span class="w"></span> -</code></pre></div> - -<h3 id="nested-records">Nested records</h3> - -<p>When nested records are placed on a new line, they should be indented once past the parent record. Where possible, nested records should be the final attribute in the parent record.</p> - -<p>Nested records should appear on their own line if you are nesting more than one.</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="c1">// Okay, but only do this for one level of nesting</span><span class="w"></span> -<span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;hello&quot;</span><span class="p">,</span><span class="w"> </span><span class="x">children</span><span class="nf">:</span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;world&quot;</span><span class="p">]]</span><span class="w"></span> - -<span class="c1">// More readable</span><span class="w"></span> -<span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;hello&quot;</span><span class="p">,</span><span class="w"> </span><span class="x">children</span><span class="nf">:</span><span class="w"> </span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;world&quot;</span><span class="p">]]</span><span class="w"></span> - -<span class="c1">// Also good</span><span class="w"></span> -<span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">children</span><span class="nf">:</span><span class="w"> </span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;div1&quot;</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;div2&quot;</span><span class="w"> </span><span class="x">children</span><span class="nf">:</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;div3&quot;</span><span class="p">]]]</span><span class="w"> </span> - -<span class="c1">// Not good</span><span class="w"></span> -<span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">children</span><span class="nf">:</span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;div2&quot;</span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;div2&quot;</span><span class="p">]]</span><span class="w"></span> - -<span class="c1">// Also not good</span><span class="w"></span> -<span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">children</span><span class="nf">:</span><span class="w"> </span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;world&quot;</span><span class="p">],</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;hello&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<h2 id="newlines">Newlines</h2> - -<p>Newlines should precede and follow every code block.</p> - -<p>Within code blocks, a newline should be added between every action. This enhances readability, especially in the case where multiple actions are needed. For instance, the following code block:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"> </span><span class="nt">@studentDB</span><span class="w"></span> -<span class="w"> </span><span class="x">students</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#students</span><span class="p">]</span><span class="w"></span> - -<span class="kr">search</span><span class="w"> </span><span class="nt">@schoolDB</span><span class="w"></span> -<span class="w"> </span><span class="x">schools</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#school</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="x">schools.name</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">student.school</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="x">students.name</span><span class="p">]</span><span class="w"> </span> - -<span class="kr">commit</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#new-record</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>is more readable than this code block:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"> </span><span class="nt">@studentDB</span><span class="w"></span> -<span class="w"> </span><span class="x">students</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#students</span><span class="p">]</span><span class="w"></span> -<span class="kr">search</span><span class="w"> </span><span class="nt">@schoolDB</span><span class="w"></span> -<span class="w"> </span><span class="x">schools</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#school</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span><span class="x">schools.name</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">student.school</span><span class="w"></span> -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="x">students.name</span><span class="p">]</span><span class="w"> </span> -<span class="kr">commit</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#new-record</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - + http://docs.witheve.com/handbook/core/ + - Windows - http://docs.witheve.com/handbook/windows/ + + http://docs.witheve.com/handbook/libraries/ Mon, 01 Jan 0001 00:00:00 +0000 - http://docs.witheve.com/handbook/windows/ - - -<h1 id="installing-eve-on-windows">Installing Eve on Windows</h1> - -<p>First, <a href="https://github.com/witheve/Eve/archive/master.zip">download</a> the Eve source. You&rsquo;ll need a recent <a href="https://nodejs.org">node.js</a> and then in the extracted Eve directory:</p> - -<pre><code>npm install -npm start -</code></pre> - -<p>Then open <code>http://localhost:8080/</code> in your browser.</p> - -<h2 id="see-also">See also</h2> - -<p><a href="../linux">linux</a> | <a href="../mac">mac</a> | <a href="../docker">docker</a> | <a href="../npm">npm</a> | <a href="../running">running</a></p> - + http://docs.witheve.com/handbook/libraries/ + - abs - http://docs.witheve.com/handbook/math/abs/ + + http://docs.witheve.com/handbook/libraries/stdlib/ Mon, 01 Jan 0001 00:00:00 +0000 - http://docs.witheve.com/handbook/math/abs/ - - -<h1 id="abs">abs</h1> - -<p>The absolute value of a number</p> - -<h2 id="syntax">Syntax</h2> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="x">y</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">abs</span><span class="p">[</span><span class="x">value</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<h2 id="attributes">Attributes</h2> - -<ul> -<li><code>value</code> - a set of numbers</li> -</ul> - -<h2 id="description">Description</h2> - -<p><code>y = abs[value]</code> returns the absolute value of the elements in <code>value</code>. Every positive number is kept positive, but every negative number is made positive.</p> - -<h2 id="examples">Examples</h2> - -<p>Get the absolute value of a number</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="w"> </span><span class="x">y</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">abs</span><span class="p">[</span><span class="x">value</span><span class="nf">:</span><span class="w"> </span><span class="nf">-</span><span class="m">3</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span> -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="x">y</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>Displays the number <code>3</code>.</p> - -<h2 id="see-also">See Also</h2> - -<p><a href="../sign">sign</a></p> - + http://docs.witheve.com/handbook/libraries/stdlib/ + <head> + <link rel="stylesheet" type="text/css" href="style.css"> +</head> + +<body> + + <h2> + Aggregates + </h2> + + <table> + <tr> + <td> + <h3>gather/sort</h3> + Generates an ordering for a set + </td> + <td> + <ul> + <li><strong>for</strong> - the set to sort</li> + <li><strong>per</strong> - (optional) - one or more attributes by which to group `for`</li> + <li><strong>direction</strong> - (optional) - direction in which to sort `for`. Possible values are: + <ul> + <li>'up' - smallest to largest; default option</li> + <li>'down' - largest to smallest</li> + </ul> + </li> + </ul> + </td> + <td> + <code>// sorts the students by GPA + [#student GPA] + index = sort[value: GPA]</code> + </td> + </tr> + + <tr> + <td> + <h3>gather/count</h3> + Returns the number of elements in a set + </td> + <td> + <ul> + <li><strong>for</strong> - the set to count over</li> + <li><strong>per</strong> - (optional) - one or more attributes by which to group `for`</li> + </ul> + </td> + <td> + <code>// counts the number of citizens in each state + residents = [#citizen state] + population = count[given: residents, per: state]</code> + </td> + </tr> + + <tr> + <td> + <h3>gather/sum</h3> + Returns the sum of values in a set of attributes + </td> + <td> + <ul> + <li><strong>for</strong> - the set to gather</li> + <li><strong>value</strong> - the specific variable to be summed</li> + <li><strong>per</strong> - (optional) - one or more attributes by which to group `for`</li> + </ul> + </td> + <td> + <code>// returns the sum of salaries for each department + employees = [#employee salary department] + expenses = gather/sum[for: employees, value: employees.salary, per: department]</code> + </td> + </tr> + </table> + + <h2> + Math + </h2> + + <table> + <tr> + <td> + <h3>+</h3> + Adds two numbers + </td> + <td> + <ul> + <li>Infix notation</li> + </ul> + </td> + <td> + <code>total-debt = credit-card + debit-card</code> + </td> + </tr> + + <tr> + <td> + <h3>-</h3> + Subtracts two numbers + </td> + <td> + <ul> + <li>Infix notation</li> + </ul> + </td> + <td> + <code>remaining-debt = total-debt - amount_paid</code> + </td> + </tr> + + <tr> + <td> + <h3>*</h3> + Multiplies two numbers + </td> + <td> + <ul> + <li>Infix notation</li> + </ul> + </td> + <td> + <code>yearly-payments = monthly-payments * 12</code> + </td> + </tr> + + <tr> + <td> + <h3>/</h3> + Divides two numbers + </td> + <td> + <ul> + <li>Infix notation</li> + </ul> + </td> + <td> + <code>monthly-payments = yearly-payments / 12</code> + </td> + </tr> + + <tr> + <td> + <h3>math/floor</h3> + Rounds a number down + </td> + <td> + <ul> + <li><strong>a</strong> - the number to be rounded down</li> + </ul> + </td> + <td> + <code>// x rounded down to 34 + x = math/floor[a: 34.2]</code> + </td> + </tr> + + <tr> + <td> + <h3>math/ceil</h3> + Rounds a number up + </td> + <td> + <ul> + <li><strong>a</strong> - the number to be rounded up</li> + </ul> + </td> + <td> + <code>// x rounded up to 35 + x = math/floor[a: 34.2]</code> + </td> + </tr> + + <tr> + <td> + <h3>math/round</h3> + Rounds a number to the nearest integer + </td> + <td> + <ul> + <li><strong>a</strong> - the number to be rounded to the nearest integer</li> + </ul> + </td> + <td> + <code>// x rounded to 34 + x = math/floor[a: 34.2]</code> + </td> + </tr> + + <tr> + <td> + <h3>math/sin</h3> + Sine of an angle + </td> + <td> + <ul> + <li><strong>a</strong> - the angle in degrees</li> + </ul> + </td> + <td> + <code>// r calculated to 1 + r = math/sin[a: 90]</code> + </td> + </tr> + + <tr> + <td> + <h3>math/cos</h3> + Cosine of an angle + </td> + <td> + <ul> + <li><strong>a</strong> - the angle in degrees</li> + </ul> + </td> + <td> + <code>// r calculated to 0 + r = math/cos[a: 90]</code> + </td> + </tr> + + <tr> + <td> + <h3>math/tan</h3> + Tangent of an angle + </td> + <td> + <ul> + <li><strong>a</strong> - the angle in degrees</li> + </ul> + </td> + <td> + <code>// r calculated to 1 + r = math/tan[a: 45]</code> + </td> + </tr> + + <tr> + <td> + <h3>math/max</h3> + The greater of two values + </td> + <td> + <ul> + <li><strong>a</strong> - a value to compare</li> + <li><strong>b</strong> - another value to compare</li> + </ul> + </td> + <td> + <code>// takes the higher score + [#scores pac-man donkey-kong] + best-score = math/min[a: pac-man, b: donkey-kong]</code> + </td> + </tr> + + <tr> + <td> + <h3>math/min</h3> + The lesser of two values + </td> + <td> + <ul> + <li><strong>a</strong> - a value to compare</li> + <li><strong>b</strong> - another value to compare</li> + </ul> + </td> + <td> + <code>// takes the lower score + [#scores pac-man donkey-kong] + worst-score = math/min[a: pac-man, b: donkey-kong]</code> + </td> + </tr> + + <tr> + <td> + <h3>math/mod</h3> + Modulo division + </td> + <td> + <ul> + <li><strong>a</strong> - the number to be divided (dividend)</li> + <li><strong>b</strong> - the number by which to divide (divisor)</li> + </ul> + </td> + <td> + <code>// m is the remainder, 1 + m = math/mod[a: 5, b: 2]</code> + </td> + </tr> + + <tr> + <td> + <h3>math/abs</h3> + Absolute value of a number + </td> + <td> + <ul> + <li><strong>a</strong> - the number whose absolute value is found</li> + </ul> + </td> + <td> + <code>// number of hours from the prime meridian + [#city latitude longitude] + hours-from-gmt = math/abs[a: latitude] / 15</code> + </td> + </tr> + + <tr> + <td> + <h3>math/to-fixed</h3> + Formats a number as a string to a certain number of decimal places + </td> + <td> + <ul> + <li><strong>a</strong> - the number to be formatted</li> + <li><strong>b</strong> - the number of decimal places to which `a` will be formatted</li> + </ul> + </td> + <td> + <code>// pi represented as the string "3.14" + [#circle circumference diameter] + pi = math/to-fixed[a: (circumference / diameter), b: 2]</code> + </td> + </tr> + + <tr> + <td> + <h3>math/range</h3> + Generates a range of numbers + </td> + <td> + <ul> + <li><strong>start</strong> - the start of the range</li> + <li><strong>stop</strong> - the end of the range</li> + </ul> + </td> + <td> + <code>// generates integers 1 through 10 + y = math/range[start: 1, stop: 10]</code> + </td> + </tr> + + <tr> + <td> + <h3>random/number</h3> + Generates a random number between 1 and 0 + </td> + <td> + <ul> + <li><strong>seed</strong> - a number used to initialize the random number generator</li> + </ul> + </td> + <td> + <code>// generates a random number every second + [#time minutes seconds] + x = random/number[seed: seconds]</code> + </td> + </tr> + </table> + + <h2> + Strings + </h2> + + <table> + <tr> + <td> + <h3>string/replace</h3> + Replaces a string of text with another + </td> + <td> + <ul> + <li><strong>text</strong> - the text in which to search for strings and replace them</li> + <li><strong>replace</strong> - the string to be replaced</li> + <li><strong>with</strong> - the string that will replace `replace`</li> + </ul> + </td> + <td> + <code>// Americanized version of British spelling + [#website body] + american-version = string/replace[text: body, replace: "flavour", with: "flavor"]</code> + </td> + </tr> + + <tr> + <td> + <h3>string/get</h3> + Gets a character from a specific location in a string + </td> + <td> + <ul> + <li><strong>text</strong> - the text to be searched</li> + <li><strong>at</strong> - the location to be searched</li> + </ul> + </td> + <td> + <code>// finds the 17th letter of the alphabet + alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + letter = string/get[text: alphabet, at: 17]</code> + </td> + </tr> + + <tr> + <td> + <h3>string/uppercase</h3> + Converts a string to uppercase + </td> + <td> + <ul> + <li><strong>text</strong> - the text to be converted</li> + </ul> + </td> + <td> + <code>funny = "lol" +really-funny = string/uppercase[text: funny]</code> + </td> + </tr> + + <tr> + <td> + <h3>string/lowercase</h3> + Converts a string to lowercase + </td> + <td> + <ul> + <li><strong>text</strong> - the text to be converted</li> + </ul> + </td> + <td> + <code>really-funny = "LOL" +down-a-notch = string/uppercase[text: really-funny]</code> + </td> + </tr> + + <tr> + <td> + <h3>string/index-of</h3> + Returns the position of the first occurrence of a specified value in a string + </td> + <td> + <ul> + <li><strong>text</strong> - the text to be searched</li> + <li><strong>substring</strong> - the string to be found in `text`</li> + </ul> + </td> + <td> + <code>// Eve is in developers, starting at an index of 2 +index = string/index_of[text: "developers", substring: "eve"</code> + </td> + </tr> + + <tr> + <td> + <h3>string/codepoint-length</h3> + Returns the length of a string in Unicode code points. + </td> + <td> + <ul> + <li><strong>text</strong> - the string whose length is found</li> + </ul> + </td> + <td> + <code>// the code point length of the word "unicode" +string = "unicode" +length-in-js = string/codepoint_length[text: string]</code> + </td> + </tr> + </table> + +</body> - ceiling - http://docs.witheve.com/handbook/math/ceil/ + + http://docs.witheve.com/tutorials/ Mon, 01 Jan 0001 00:00:00 +0000 - http://docs.witheve.com/handbook/math/ceil/ - - -<h1 id="ceiling">ceiling</h1> - -<p>Round a number up to the nearest integer.</p> - -<h2 id="syntax">Syntax</h2> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="x">y</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">ceiling</span><span class="p">[</span><span class="x">value</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<h2 id="attributes">Attributes</h2> - -<ul> -<li><code>value</code> - a set of numbers</li> -</ul> - -<h2 id="description">Description</h2> - -<p><code>y = ceiling[value]</code> rounds the elements of <code>value</code> up to the nearest integers.</p> - -<h2 id="examples">Examples</h2> - -<p>Calculate the ceiling of <code>34.2</code></p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="w"> </span><span class="x">y</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">ceiling</span><span class="p">[</span><span class="x">value</span><span class="nf">:</span><span class="w"> </span><span class="m">34</span><span class="x">.</span><span class="m">2</span><span class="p">]</span><span class="w"></span> -<span class="w"> </span> -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="x">y</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>The result is <code>35</code>.</p> - -<h2 id="see-also">See Also</h2> - -<p><a href="../floor">floor</a> | <a href="../fix">fix</a> | <a href="../round">round</a></p> - + http://docs.witheve.com/tutorials/ + diff --git a/sitemap.xml b/sitemap.xml index 1f66684..1d127b8 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -2,27 +2,11 @@ - http://docs.witheve.com/ + http://docs.witheve.com/handbook/ - http://docs.witheve.com/README/ - - - - http://docs.witheve.com/handbook/core/ - - - - http://docs.witheve.com/handbook/databases/ - - - - http://docs.witheve.com/handbook/intro/ - - - - http://docs.witheve.com/handbook/programs/ + http://docs.witheve.com/tutorials/quickstart.eve/ @@ -30,279 +14,47 @@ - http://docs.witheve.com/guides/for-programmers/ - - - - http://docs.witheve.com/handbook/linux/ - - - - http://docs.witheve.com/handbook/mac/ - - - - http://docs.witheve.com/tutorials/quickstart/ - - - - http://docs.witheve.com/handbook/standard-library/ - - - - http://docs.witheve.com/guides/style/ - - - - http://docs.witheve.com/handbook/windows/ - - - - http://docs.witheve.com/handbook/math/abs/ - - - - http://docs.witheve.com/handbook/math/ceil/ - - - - http://docs.witheve.com/handbook/event/click/ - - - - http://docs.witheve.com/handbook/math/cos/ - - - - http://docs.witheve.com/handbook/statistics/count/ - - - - http://docs.witheve.com/handbook/math/fix/ - - - - http://docs.witheve.com/handbook/math/floor/ - - - - http://docs.witheve.com/handbook/strings/join/ - - - - http://docs.witheve.com/handbook/math/mod/ - - - - http://docs.witheve.com/handbook/statistics/random/ - - - - http://docs.witheve.com/handbook/math/range/ - - - - http://docs.witheve.com/handbook/math/round/ - - - - http://docs.witheve.com/handbook/math/sin/ - - - - http://docs.witheve.com/handbook/general/sort/ - - - - http://docs.witheve.com/handbook/strings/split/ - - - - http://docs.witheve.com/handbook/math/sum/ - - - - http://docs.witheve.com/handbook/math/tan/ - - - - http://docs.witheve.com/handbook/datetime/time/ - - - - http://docs.witheve.com/handbook/session/ - - - - http://docs.witheve.com/handbook/add/ - - - - http://docs.witheve.com/handbook/equality/ - - - - http://docs.witheve.com/handbook/functions/ - - - - http://docs.witheve.com/handbook/general/ - - - - http://docs.witheve.com/handbook/installation/ - - - - http://docs.witheve.com/handbook/ebnf/ - - - - http://docs.witheve.com/handbook/model/ - - - - http://docs.witheve.com/handbook/records/ - - - - http://docs.witheve.com/handbook/search/ - - - - http://docs.witheve.com/handbook/browser/ - - - - http://docs.witheve.com/handbook/aggregates/ - - - - http://docs.witheve.com/handbook/commonmark/ - - - - http://docs.witheve.com/handbook/equivalence/ - - - - http://docs.witheve.com/handbook/inequality/ - - - - http://docs.witheve.com/handbook/math/ - - - - http://docs.witheve.com/handbook/running/ - - - - http://docs.witheve.com/handbook/set/ - - - - http://docs.witheve.com/handbook/sets/ - - - - http://docs.witheve.com/handbook/tags/ - - - - http://docs.witheve.com/handbook/bind/ - - - - http://docs.witheve.com/handbook/event/ - - - - http://docs.witheve.com/handbook/actions/ - - - - http://docs.witheve.com/handbook/help/ - - - - http://docs.witheve.com/handbook/joins/ - - - - http://docs.witheve.com/handbook/literate-programming/ - - - - http://docs.witheve.com/handbook/remove/ - - - - http://docs.witheve.com/handbook/strings/ - - - - http://docs.witheve.com/handbook/commit/ - - - - http://docs.witheve.com/handbook/if-then/ - - - - http://docs.witheve.com/handbook/http/ - - - - http://docs.witheve.com/handbook/blocks/ - - - - http://docs.witheve.com/handbook/docker/ - - - - http://docs.witheve.com/handbook/expressions/ - - - - http://docs.witheve.com/handbook/merge/ + http://docs.witheve.com/README/ - http://docs.witheve.com/handbook/statistics/ + http://docs.witheve.com/guides/ - http://docs.witheve.com/handbook/is/ + http://docs.witheve.com/handbook/core/ - http://docs.witheve.com/handbook/not/ + http://docs.witheve.com/handbook/libraries/ - http://docs.witheve.com/handbook/view/ + http://docs.witheve.com/handbook/libraries/stdlib/ - http://docs.witheve.com/handbook/datetime/ + http://docs.witheve.com/tutorials/ - http://docs.witheve.com/handbook/string-interpolation/ + http://docs.witheve.com/ + 0 - http://docs.witheve.com/handbook/update-operators/ + http://docs.witheve.com/guides/ + 0 - http://docs.witheve.com/handbook/npm/ + http://docs.witheve.com/handbook/ + 0 - http://docs.witheve.com/handbook/glossary/ + http://docs.witheve.com/tutorials/ + 0 \ No newline at end of file diff --git a/style.css b/style.css new file mode 100644 index 0000000..19254f9 --- /dev/null +++ b/style.css @@ -0,0 +1 @@ +html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}table{border-collapse:collapse;border-spacing:0}*{box-sizing:border-box}body{display:flex;flex-direction:column;margin:0;background:white;color:#555;line-height:1.7;font-family:"Open Sans",Avenir,"Helvetica neue",sans-serif}h1{padding:0;margin:0;margin-bottom:15px;font-size:2em;font-weight:600}h2{padding:0;margin:0;margin-bottom:15px;font-size:1.5em}h3{padding:0;margin:0;margin-bottom:15px;font-size:1em;color}p{display:block;-webkit-margin-before:.5em;-webkit-margin-after:1em;-webkit-margin-start:0;-webkit-margin-end:0}a{color:#009ee0}a:hover{color:#00b8f1}a:active{color:#0079b1}ul{display:block;margin-left:2em}code{padding:.2em;background:#f0f2f7;white-space:pre-wrap;font-family:"Inconsolata","Monaco","Consolas","Ubuntu Mono",monospace;font-size:.9rem}strong{font-weight:600}table{border:1px black solid;margin-bottom:1em}td{border:1px black solid;width:20em} \ No newline at end of file diff --git a/stylesheets/application.css b/stylesheets/application.css index 119f9e1..3509bcd 100644 --- a/stylesheets/application.css +++ b/stylesheets/application.css @@ -64,16 +64,30 @@ color: rgb(145, 192, 214); } -html, body { - font-family: Avenir, "Nelvetica Neue", sans-serif; - height: 100%; - padding: 0px; - margin: 0px; - color: rgb(85,85,85); - font-size: 15px; - background-color: #f5f5f5; +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; } +body { display: flex; flex-direction: column; margin: 0; background: white; color: #555; line-height: 1.7; font-family: "Open Sans", Avenir, "Helvetica neue", sans-serif;} + + pre { background-color: rgb(38,38,38); padding: 20px; @@ -100,19 +114,15 @@ ul, ol { } h1 { - font-size: 30px; - color: rgb(85, 85, 85); + font-size: 35px; + padding-top: 0px; + margin-top:0px; + margin-bottom: 20px; } h2 { font-size: 25px; - color: rgb(85, 85, 85); - font-weight: bold; - line-height: 25px; -} - -.logo { - width: 30%; + padding-top: 0px; margin-top: 20px; margin-bottom: 20px; } @@ -124,24 +134,29 @@ h2 { } .drawer { - background-color: #555; - color: rgb(187,187,187); - width: 280px; + color: rgb(85, 85, 85); + border-right: 1px solid #f0f0f0; padding-left: 10px; - padding-right: 10px; + padding-right: 50px; padding-bottom: 20px; + +} + +.highlight { + margin-bottom: 20px; + margin-top: 20px; +} + +.colored { + font-weight: bold; } .drawer a { - color: rgb(187,187,187); + color: rgb(85, 85, 85); } .article { - max-width: 750px; - padding-left: 60px; - padding-right: 60px; - padding-top: 30px; - background-color: white; + padding-left: 50px; } .article a { @@ -176,10 +191,6 @@ h2 { margin-top: 20px; } -.colored { - color: #eee; -} - .selected a { color: rgb(145, 192, 214); } @@ -208,4 +219,62 @@ h2 { white-space: pre; font-family: monospace; padding: 5px; -} \ No newline at end of file +} + +.flex-spacer { flex: 1; } +.flex-row { display: flex; } +.flex-row.spaced > * + * { margin-left: 30px; } +.flex-row.double-spaced > * + * { margin-left: 60px; } +.flex-row.stretched { align-self: stretch; } + +.layer-wrapper { display: flex; flex-direction: column; align-items: center; margin-top: 60px; padding: 0 40px; } +.layer { max-width: 100%; width: 960px; display: flex; align-items: center; } +.toplayer { max-width: 100%; width: 960px; display: flex; align-items: top; } +.sub-layer { margin-top: 30px; } + +.header-wrapper { } +.logo { display: flex; flex: 0 0 auto; align-items: center; padding: 0; } +.logo > img { max-width: 60px; } +.logo > h1 { margin: 0; margin-left: 18px; padding: 0; height: 26px; margin-top: -32px; } +.logo > h1 > img { height: 100%; } + +nav { flex: none; display: flex; flex-direction: row-reverse; } +nav > * { flex: 0 0 auto; padding: 10px 20px; margin: 0; text-decoration: none; color: rgb(74, 64, 136); transition: background 0.1s ease-out; } +nav > *:hover { background: #f2f2f2; } +nav > *:active { background: #e9e9e9; } +nav > .play-cta { margin: 0; padding: 10px 20px; color: white; } + +.btn { cursor: pointer; text-align: center; user-select: none; -moz-user-select: none; -ms-user-select: none; } +.btn.big { flex: 1 0 auto; padding: 18px 30px; } +.btn.rounded { border-radius: 3px; } + +.cta { cursor: pointer; text-decoration: none; -ms-user-select: none; -moz-user-select: none; -webkit-user-select: none; user-select: none; transition: background 0.1s ease-out; } + +.cta.primary { background: rgb(0, 184, 241); color: white; } +.cta.primary:hover { background: rgb(0, 158, 224); } +.cta.primary:active { background: rgb(0, 121, 177); } + +.cta.secondary { background: rgb(107, 103, 173); color: white; } +.cta.secondary:hover { background: rgb(91, 89, 164); } +.cta.secondary:active { background: rgb(74, 64, 136); } + +.cta.tertiary { background: #888a8f; color: white; } +.cta.tertiary:hover { background: #808284; } +.cta.tertiary:active { background: #787a7f; } + +.contact-wrapper { display: flex; flex-direction: column; padding: 0; position: relative; margin-bottom: 60px; color: white; } +.contact { display: flex; flex-direction: row; max-width: 960px; align-self: center; margin: auto; overflow: hidden; border-radius: 3px; cursor: pointer; -ms-user-select: none; -moz-user-select: none; -webkit-user-select: none; user-select: none; } +.contact > * { flex: 1 1 auto; align-self: stretch; max-width: 320px; padding: 30px; color: white !important; text-decoration: none; transition: background 0.1s ease-out; } +.contact h3 { margin-bottom: 20px; font-size: 1.25rem; } + +.contact > *:first-child { background: rgb(107, 103, 173); } +.contact > *:first-child:hover { background: rgb(117, 115, 190); } +.contact > *:first-child:active { background: rgb(142, 140, 215); } + +.contact > *:nth-child(2) { background: rgb(91, 89, 164); } +.contact > *:nth-child(2):hover { background: rgb(117, 115, 190); } +.contact > *:nth-child(2):active { background: rgb(142, 140, 215); } + +.contact > *:last-child { background: rgb(74, 64, 136); } +.contact > *:last-child:hover { background: rgb(117, 115, 190); } +.contact > *:last-child:active { background: rgb(142, 140, 215); } \ No newline at end of file diff --git a/tutorials/index.html b/tutorials/index.html index 0fd06a1..038e271 100644 --- a/tutorials/index.html +++ b/tutorials/index.html @@ -10,7 +10,7 @@ Tutorials - Eve Documentation - + @@ -74,15 +74,29 @@ +
+
+ + + +
+ +
+
@@ -356,7 +147,13 @@

Pages in Tutorial

- + +

+
+ +
+ +

Quickstart

diff --git a/tutorials/index.xml b/tutorials/index.xml index 93c43b1..3183735 100644 --- a/tutorials/index.xml +++ b/tutorials/index.xml @@ -2,244 +2,117 @@ Tutorials on Eve Documentation - http://docs.witheve.com/tutorials/ + http://docs.witheve.com/tutorials/index.xml Recent content in Tutorials on Eve Documentation Hugo -- gohugo.io en-us + + + http://docs.witheve.com/tutorials/ + Mon, 01 Jan 0001 00:00:00 +0000 + + http://docs.witheve.com/tutorials/ + + + Quickstart - http://docs.witheve.com/tutorials/quickstart/ + http://docs.witheve.com/tutorials/quickstart.eve/ Mon, 01 Jan 0001 00:00:00 +0000 - http://docs.witheve.com/tutorials/quickstart/ + http://docs.witheve.com/tutorials/quickstart.eve/ -<h1 id="eve-quick-start-tutorial">Eve Quick Start Tutorial</h1> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="x">```</span><span class="w"></span> -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="x">tag</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;div&quot;</span><span class="p">,</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;Hello, world&quot;</span><span class="p">]</span><span class="w"></span> -<span class="x">```</span><span class="w"></span> -</code></pre></div> - -<p>Hello world! At its core, Eve is a pattern matching language. You match patterns of data by searching a database, then update or create new data according to what you&rsquo;ve found. In this example, we created a <a href="https://witheve.github.io/docs/handbook/records/"><code>record</code></a> that has two attributes: a tag attribute with the value <code>&quot;div&quot;</code>, and a text attribute with the value <code>&quot;Hello, world&quot;</code>. We <a href="https://witheve.github.io/docs/handbook/bind/">bound</a> this record to the browser, which is how we displayed our venerable message.</p> - -<p>The three backticks <code>```</code> are called a code fence, and they allow us to denote blocks of code. This gives us the ability to embed Eve code in normal documents written in Markdown. This is how Eve programs are written: everything in a code fence is a <a href="https://witheve.github.io/docs/handbook/blocks/">block</a> of Eve code, while everything outside is prose describing the program. In fact, this quick start tutorial is an example of an executable Eve program! In the subsequent blocks, you won&rsquo;t see any code fences, but they still exist in the <a href="https://raw.githubusercontent.com/witheve/docs/src/guides/quickstart.md">document&rsquo;s source</a>.</p> - -<p>So far we&rsquo;ve created a record that displays “Hello, world!” but as I said, Eve is a pattern matching language. Let&rsquo;s explore that by searching for something:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="x">name</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="x">tag</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;div&quot;</span><span class="p">,</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;Hello, world&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>Our message disappeared! Before, we bound without searching, so the message displayed by default. Now we&rsquo;re binding in the presence of a <a href="https://witheve.github.io/docs/handbook/search/"><code>search</code></a> action, so the bound record only exists if all the searched records are matched. Here, we&rsquo;re searching for all records with a <code>name</code> attribute, but we haven&rsquo;t added any records like that to Eve so none are matched. With no matching records, the <code>bind</code> cannot execute, and the message disappears from the screen.</p> - -<p>This is the flow of an Eve block: you search for records in a database, and if all the records you searched for are matched, you can modify the matched records or create new ones. If any part of your search is not matched, then no records will be created or updated.</p> - -<p>To get our message back, all we need is a record with a name attribute. We can create one permanently with the <a href="https://witheve.github.io/docs/handbook/commit/"><code>commit</code></a> action:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">commit</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;Celia&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>Hello, world… again! Commit permanently updates or creates a record that will persist even if its matched records (the records matched in a search action) change. Since we aren&rsquo;t searching for anything in this block, the commit executes by default and adds a record with a name attribute of <code>&quot;Celia&quot;</code>. The addition of this new record satisfies the search in the previous block, so “Hello, world!” appears on the screen again.</p> - -<p>But what else can you do with matched records? For starters, we can use them to create new records:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="x">name</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="p">,</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;Hello, {{name}}&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>Since we matched on a record with a name attribute, we now have a reference to that name, and we can inject it into a string using <a href="https://witheve.github.io/docs/handbook/string-interpolation/"><code>{{ ... }}</code></a> embedding. We can also swap out <code>tag: &quot;div&quot;</code> for the sugared <code>#div</code>. <a href="https://witheve.github.io/docs/handbook/tags/">Tags</a> are used a lot in Eve to talk about collections of related records. For example, we could search for all records with a <code>#student</code> tag, with name, grade, and school attributes.</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="w"> </span><span class="x">grade</span><span class="w"> </span><span class="x">school</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;{{name}} is a {{grade}}th grade student at {{school}}.&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>Since we&rsquo;re matching on more attributes, this block is no longer satisfied by the record we added earlier; we&rsquo;re missing a <code>#student</code> tag, as well as grade and school attributes. Even though these are currently missing, we can still write the code that would display them.</p> - -<p>Let&rsquo;s display this new message by adding the missing attributes to Celia. We could add them to the block where we comitted Celia originally, but we can also do it programatically:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">celia</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="x">“Celia”</span><span class="p">]</span><span class="w"></span> +<h1 id="quickstart">Quickstart</h1> -<span class="kr">bind</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">celia</span><span class="w"> </span><span class="nf">&lt;-</span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">grade</span><span class="nf">:</span><span class="w"> </span><span class="m">10</span><span class="p">,</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;East&quot;</span><span class="p">,</span><span class="w"> </span><span class="x">age</span><span class="nf">:</span><span class="w"> </span><span class="m">16</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>You can define variables within blocks, which act as handles on records that allow you to change them. In this case, we&rsquo;re using the <a href="https://witheve.github.io/docs/handbook/merge/">merge operator</a> <code>&lt;-</code> to combine two records. With the addition of this block, the sentence &ldquo;Celia is a 10th grade student at East.&rdquo; appears in the browser.</p> - -<p>Celia is cool and all, but let&rsquo;s add some more students to our database:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">commit</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="x">“Diedra”</span><span class="p">,</span><span class="w"> </span><span class="x">grade</span><span class="nf">:</span><span class="w"> </span><span class="m">12</span><span class="p">,</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;West&quot;</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="x">“Michelle”</span><span class="p">,</span><span class="w"> </span><span class="x">grade</span><span class="nf">:</span><span class="w"> </span><span class="m">11</span><span class="p">,</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;West&quot;</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="x">“Jermaine”</span><span class="p">,</span><span class="w"> </span><span class="x">grade</span><span class="nf">:</span><span class="w"> </span><span class="m">9</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>Three sentences are now printed, one for each student that matches the search. Eve works on <a href="https://witheve.github.io/docs/handbook/sets/">sets</a>, so when we search for <code>[#student name grade school]</code>, we find <em>all</em> records that match the given pattern. This includes Celia, Diedra and Michelle (but not Jermaine, as he has no school in his record). Therefore, when we bind the record <code>[#div text: &quot;{{name}} is a ... &quot;]</code>, we are actually binding three records, one for each matching <code>#student</code>.</p> - -<p>If you re-compile the program a couple times, you&rsquo;ll see the order of sentences may change. This is because <strong>there is no ordering in Eve - blocks are not ordered, statements are not ordered, and results are not ordered</strong>. If you want to order elements, you must impose an ordering yourself. We can ask the browser to draw elements in an order with the &ldquo;sort&rdquo; attribute:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="w"> </span><span class="x">grade</span><span class="w"> </span><span class="x">school</span><span class="p">]</span><span class="w"></span> - -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">sort</span><span class="nf">:</span><span class="w"> </span><span class="x">name</span><span class="p">,</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;{{name}} is a {{grade}}th grade student at {{school}}.&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>This time when you recompile your program, the order will stay fixed, sorted alphabetically by name.</p> - -<p>Let&rsquo;s make things a little more interesting by adding some records about the schools the students attend:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">commit</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#school</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="x">“West”</span><span class="p">,</span><span class="w"> </span><span class="x">address</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;1234 Main Street&quot;</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#school</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="x">“East”</span><span class="p">,</span><span class="w"> </span><span class="x">address</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;5678 Broad Street&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>What if we want to display the address of the school each student attends? Although <code>#student</code>s and <code>#school</code>s are in different records, <strong>we can relate two records by associating attributes from one record with attributes from the other.</strong> This is an operation known as <a href="https://witheve.github.io/docs/handbook/joins/">joining</a>. In this case, we want to relate the <code>name</code> attribute on <code>#schools</code> with the <code>school</code> attribute on <code>#students</code>. This compares the values of the attributes between records, and matches up those with the same value. For instance, since Celia&rsquo;s school is &ldquo;East&rdquo;, she can join with the <code>#school</code> named &ldquo;East&rdquo;.</p> +<p>In this guide we&rsquo;re going to give you a 5 minute introduction to the essential concepts in Eve. If you&rsquo;ve never used Eve before, you&rsquo;re in the right place.</p> -<p>Our first attempt may come out looking a little something like this:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">school</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#school</span><span class="w"> </span><span class="x">name</span><span class="w"> </span><span class="x">address</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">student</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="x">name</span><span class="p">]</span><span class="w"> </span> +<h2 id="adding-records-to-eve">Adding records to Eve</h2> -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;{{student.name}} attends {{school.name}} at {{address}}&quot;</span><span class="p">]</span><span class="w"></span> +<p>Eve represents data as records, which are key value pairs attached to a unique ID. Eve programs are made up of small composable blocks that search for and create records. Let&rsquo;s start with a block that adds a record to Eve:</p> +<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">commit</span> + <span class="p">[</span><span class="err">#</span><span class="nv">greeting</span> <span class="nv">text</span><span class="nf">:</span> <span class="s">&quot;hello world&quot;</span><span class="p">]</span> </code></pre></div> -<p>But that didn&rsquo;t work. How come? In Eve, <strong>things with the same name are <a href="https://witheve.github.io/docs/handbook/equivalence/">equivalent</a></strong>. In this block, we&rsquo;ve used &ldquo;name&rdquo; three times, which says that the school&rsquo;s name, the student&rsquo;s name, and the student&rsquo;s school are all the same. Of course, there is no combination of students and schools that match this search, so nothing is displayed.</p> +<p>This record is tagged <code>#greeting</code>, and has an attribute &ldquo;text&rdquo; with the value &ldquo;hello world&rdquo;. Although tags have a special syntax, they are attributes like any other. We encourage you to classify groups of related records with tags.</p> -<p>Instead, we can use the dot operator to specifically ask for the name attribute in the <code>#school</code> records, and rename our variables to get a correct block:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">schools</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#school</span><span class="w"> </span><span class="x">address</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">students</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="x">school.name</span><span class="p">]</span><span class="w"></span> +<h2 id="finding-records-in-eve">Finding records in Eve</h2> -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;{{students.name}} attends {{schools.name}} at {{address}}&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> - -<p>This creates an implicit join over the school name without mixing up the names of the students and the names of the schools, giving us our desired output. You can actually bind attributes to any name you want to avoid collisions in a block:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#school</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="x">school</span><span class="nf">-</span><span class="x">name</span><span class="w"> </span><span class="x">address</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="x">student</span><span class="nf">-</span><span class="x">name</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="x">school</span><span class="nf">-</span><span class="x">name</span><span class="p">]</span><span class="w"></span> +<p>Eve finds every record that matches the supplied patterns, then binds new records to them. If no records match the search, then the block does not run at all. A block will only run if every pattern in a search matches at least one record. Let&rsquo;s search for the <code>#greeting</code> we just committed, and then display it in a text container:</p> +<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span> + <span class="p">[</span><span class="err">#</span><span class="nv">greeting</span> <span class="nv">text</span><span class="p">]</span> -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;{{student-name}} attends {{school-name}} at {{address}}&quot;</span><span class="p">]</span><span class="w"></span> +<span class="kr">bind</span> + <span class="p">[</span><span class="err">#</span><span class="nv">ui</span><span class="nf">/</span><span class="nv">text</span> <span class="nv">text</span><span class="p">]</span> </code></pre></div> -<h2 id="advanced-eve">Advanced Eve</h2> - -<p>Recall when we added our students, Celia was the only one we added an <code>age</code> to. Therefore, the following block only displays Celia&rsquo;s age, even though we ask for all the <code>#student</code>s:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="w"> </span><span class="x">age</span><span class="p">]</span><span class="w"></span> +<p>Variables with the same name are equivalent within a block; because they have the same name, the <code>text</code> in <code>[#greeting text]</code> and <code>[#ui/text text]</code> are equivalent. Go ahead and add another <code>#greeting</code> record to the first block to see what happens when more than one record matches the search.</p> -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;{{name}} is {{age}} years old&quot;</span><span class="p">]</span><span class="w"></span> -</code></pre></div> +<h2 id="records-update-as-data-changes">Records update as data changes</h2> -<p>Let&rsquo;s pretend that all students enter first grade at six years old. Therefore, if we know a student&rsquo;s grade, we can calculate their age and add it to the student&rsquo;s record:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">student</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">calculated</span><span class="nf">-</span><span class="x">age</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="kr">if</span><span class="w"> </span><span class="x">student.age</span><span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="x">student.age</span><span class="w"></span> -<span class="x">                  </span><span class="w"> </span><span class="kr">else</span><span class="w"> </span><span class="kr">if</span><span class="w"> </span><span class="x">student.grade</span><span class="w"> </span><span class="kr">then</span><span class="w"> </span><span class="x">student.grade</span><span class="w"> </span><span class="nf">+</span><span class="w"> </span><span class="m">5</span><span class="w"></span> +<p>Blocks in Eve react automatically to changes in data. When a record changes, any bound records are automatically updated. Let&rsquo;s search for the current time, and display it in a div:</p> +<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span> + <span class="p">[</span><span class="err">#</span><span class="nv">time</span> <span class="nv">seconds</span><span class="p">]</span> -<span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">student.age</span><span class="w"> </span><span class="nf">:=</span><span class="w"> </span><span class="x">calculated</span><span class="nf">-</span><span class="x">age</span><span class="w"></span> +<span class="kr">bind</span> + <span class="p">[</span><span class="err">#</span><span class="nv">ui</span><span class="nf">/</span><span class="nv">text</span> <span class="nv">text</span><span class="nf">:</span> <span class="nv">seconds</span><span class="p">]</span> </code></pre></div> -<p>This block selects all students, and uses and <a href="https://witheve.github.io/docs/handbook/if-then/"><code>if-then</code></a> expression to set the student&rsquo;s calculated age. If the student already has an age, we set it to that. Otherwise, if the student has no age, we can calculate it with some arithmetic. The <a href="https://witheve.github.io/docs/handbook/set/">set operator</a> <code>:=</code> sets an attribute to a specified value regardless of what it was before the block executed. That value can be anything, from a number to a string to another record.</p> - -<h3 id="aggregates">Aggregates</h3> +<p>As the time changes, the output updates to reflect the current state of the <code>#time</code> record. Records can be committed instead of bound, but the behavior is a little different &ndash; committed records persist until they are removed explicitly. Try changing <code>bind</code> to <code>commit</code> in the above block and see what happens.</p> -<p>So far everything we&rsquo;ve done has used one record at a time, but what happens when we want to work over a group of records, such as counting how many students there are? To solve such a problem, we&rsquo;ll need to use an <a href="https://witheve.github.io/docs/handbook/aggregates/">aggregate</a>. Aggregates take a set of values and turn them into a single value, akin to &ldquo;fold&rdquo; or &ldquo;reduce&rdquo; functions in other languages. In this case, we&rsquo;ll use the aggregate <a href="https://witheve.github.io/docs/handbook/statistics/count/"><code>count</code></a> to figure out how many <code>#students</code> are in the school district:  </p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">students</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">total</span><span class="nf">-</span><span class="x">students</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">count</span><span class="p">[</span><span class="x">given</span><span class="nf">:</span><span class="w"> </span><span class="x">students</span><span class="p">]</span><span class="w"></span> +<h2 id="reacting-to-events">Reacting to events</h2> -<span class="kr">bind</span><span class="w"> </span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;{{total-students}} are in the school district&quot;</span><span class="p">]</span><span class="w"></span> +<p>Let&rsquo;s draw a button on the screen:</p> +<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">commit</span> + <span class="p">[</span><span class="err">#</span><span class="nv">ui</span><span class="nf">/</span><span class="nv">button</span> <span class="err">#</span><span class="nv">increment</span> <span class="nv">text</span><span class="nf">:</span> <span class="s">&quot;+1&quot;</span><span class="p">]</span> </code></pre></div> -<p>A quick note on the syntax for <code>count</code> - it feels a lot like a function in other languages, since it has a return value and can be used inline in expressions. Under the hood, <a href="https://witheve.github.io/docs/handbook/functions/">functions</a> and aggregates are actually records; <code>total = count[given: students]</code> is shorthand for <code>[#count #function given: students, value: total]</code>. This distinction won&rsquo;t materially change the way you use <code>count</code>, but it goes to show that everything in Eve reduces to working with records.</p> - -<p>While <code>given</code> is a required argument in <code>count</code>, aggregates (and functions in general) can also have optional arguments. Let&rsquo;s say we want to know how many students attend each school. We can use the optional argument <code>per</code> to count students grouped by the school they attend:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">students</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">school</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">students</span><span class="nf">-</span><span class="x">per</span><span class="nf">-</span><span class="x">school</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="x">count</span><span class="p">[</span><span class="x">given</span><span class="nf">:</span><span class="w"> </span><span class="x">students</span><span class="p">,</span><span class="w"> </span><span class="x">per</span><span class="nf">:</span><span class="w"> </span><span class="x">school</span><span class="p">]</span><span class="w"></span> +<p>When you click anywhere on the screen, Eve creates an <code>#html/event/click</code> record representing the click. You can react to clicks on the <code>#increment</code> button by searching for the <code>#html/event/click</code> record, where the element attribute is the button:</p> +<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span> + <span class="nv">event</span> <span class="nf">=</span> <span class="p">[</span><span class="err">#</span><span class="nv">html</span><span class="nf">/</span><span class="nv">event</span><span class="nf">/</span><span class="nv">click</span> <span class="nv">element</span><span class="nf">:</span> <span class="p">[</span><span class="err">#</span><span class="nv">increment</span><span class="p">]]</span> -<span class="kr">bind</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;{{students-per-school}} attend {{school}}&quot;</span><span class="p">]</span><span class="w"></span> +<span class="kr">commit</span> + <span class="p">[</span><span class="err">#</span><span class="nv">clicked</span> <span class="nv">event</span><span class="p">]</span> </code></pre></div> -<p>All function-like records in Eve specify their arguments as attributes. This means you specify the argument and its value, unlike in other languages, where the order of the values determines the attribute to which they belong. As with everything else in Eve, order doesn&rsquo;t matter.</p> +<p>Clicks only last for an instant, but we want to create a permanent record of each click so we can search for them later. This block commits a <code>#clicked</code> record that will persist until it&rsquo;s explicitly removed. Much like the <code>#greeting</code> text we bound to the <code>#ui</code>, variables with the same name are equivalent, so the variable <code>event</code> in the <code>#clicked</code> record is a reference to the <code>#html/event/click</code> on the <code>#increment</code> button.</p> -<h2 id="extra-credit">Extra Credit</h2> +<p>The identity of a record is determined by its attribute/value pairs. Two records with the same attributes and values are identical in Eve. We included the <code>event</code> attribute in the <code>#clicked</code> record to differentiate each record. Without this differentiation, we could only ever create a single <code>#clicked</code> record. Try removing <code>event</code> from the record and click the button to test this out.</p> -<p>At this point, you know everything necessary about Eve to complete this extra credit portion (the only additional knowledge you need is domain knowledge of HTML and forms). Let&rsquo;s review some of the key concepts:</p> +<h2 id="count-the-number-of-clicks">Count the number of clicks</h2> -<ul> -<li>Eve programs are composed of blocks of code that search for and update records.</li> -<li>Records are sets of <code>attribute: value</code> pairs attached to a unique ID.</li> -<li>Eve works with sets, which have no ordering and contain unique elements.</li> -<li>Things with the same name are equivalent.</li> -</ul> +<p>Now let&rsquo;s count the number of times the button has been clicked. Make sure <code>event</code> is back in <code>#clicked</code>, and then we can count those records directly:</p> +<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span> + <span class="nv">how</span><span class="nf">-</span><span class="nv">many</span> <span class="nf">=</span> <span class="nv">gather</span><span class="nf">/</span><span class="nv">count</span><span class="p">[</span><span class="nv">for</span><span class="nf">:</span> <span class="p">[</span><span class="err">#</span><span class="nv">clicked</span><span class="p">]]</span> -<p>Your extra credit task is to build a web-based form that allows you to add students to the database. Take a moment to think about how this might be done in Eve, given everything we&rsquo;ve learned so far.</p> - -<p>First, let&rsquo;s make the form. We&rsquo;ve already displayed a <code>#div</code>, and in the same way we can draw <code>#input</code>s and a <code>#button</code>:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">bind</span><span class="w"> </span><span class="nt">@browser</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">children</span><span class="nf">:</span><span class="w"> </span> -<span class="x">   </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">sort</span><span class="nf">:</span><span class="w"> </span><span class="m">1</span><span class="p">,</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;Name:&quot;</span><span class="p">]</span><span class="w"></span> -<span class="x">   </span><span class="w"> </span><span class="p">[</span><span class="nt">#input</span><span class="w"> </span><span class="nt">#name-input</span><span class="w"> </span><span class="x">sort</span><span class="nf">:</span><span class="w"> </span><span class="m">2</span><span class="p">]</span><span class="w"></span> -<span class="x">   </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">sort</span><span class="nf">:</span><span class="w"> </span><span class="m">3</span><span class="p">,</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;Grade:&quot;</span><span class="p">]</span><span class="w"></span> -<span class="x">   </span><span class="w"> </span><span class="p">[</span><span class="nt">#input</span><span class="w"> </span><span class="nt">#grade-input</span><span class="w"> </span><span class="x">sort</span><span class="nf">:</span><span class="w"> </span><span class="m">4</span><span class="p">]</span><span class="w"></span> -<span class="x">   </span><span class="w"> </span><span class="p">[</span><span class="nt">#div</span><span class="w"> </span><span class="x">sort</span><span class="nf">:</span><span class="w"> </span><span class="m">5</span><span class="p">,</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;School:&quot;</span><span class="p">]</span><span class="w"></span> -<span class="x">   </span><span class="w"> </span><span class="p">[</span><span class="nt">#input</span><span class="w"> </span><span class="nt">#school-input</span><span class="w"> </span><span class="x">sort</span><span class="nf">:</span><span class="w"> </span><span class="m">6</span><span class="p">]</span><span class="w"></span> -<span class="x">   </span><span class="w"> </span><span class="p">[</span><span class="nt">#button</span><span class="w"> </span><span class="nt">#submit</span><span class="w"> </span><span class="x">sort</span><span class="nf">:</span><span class="w"> </span><span class="m">7</span><span class="w"> </span><span class="x">text</span><span class="nf">:</span><span class="w"> </span><span class="s">&quot;submit&quot;</span><span class="p">]]</span><span class="w"></span> +<span class="kr">bind</span> + <span class="p">[</span><span class="err">#</span><span class="nv">ui</span><span class="nf">/</span><span class="nv">text</span> <span class="nv">text</span><span class="nf">:</span> <span class="s">&quot;The button has been clicked {{how-many}} times&quot;</span><span class="p">]</span> </code></pre></div> -<p>We&rsquo;ve added some tags to the inputs and the button to distinguish them, so we can easily search for them from other blocks. Now that we have a form, we need to define what happens when the submit button is clicked.</p> - -<p>Remember, everything in Eve is a record, so the <code>#click</code> event is no different. When a user clicks the mouse in the browser, Eve records that click in the database.</p> - -<p>This record exists only for an instant, but we can react to it by searching for <code>[#click element: [#submit]]</code>. This record represents a <code>#click</code> on our <code>#submit</code> button. Then, all we need to do is capture the values of the input boxes and save them as a <code>#student</code> record:</p> -<div class="highlight"><pre><code class="language-eve" data-lang="eve"><span></span><span class="kr">search</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#click</span><span class="w"> </span><span class="x">element</span><span class="nf">:</span><span class="w"> </span><span class="p">[</span><span class="nt">#submit</span><span class="p">]]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">name</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#name-input</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">grade</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#grade-input</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">school</span><span class="w"> </span><span class="nf">=</span><span class="w"> </span><span class="p">[</span><span class="nt">#school-input</span><span class="p">]</span><span class="w"></span> - -<span class="kr">commit</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="c1">// save the new student</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="p">[</span><span class="nt">#student</span><span class="w"> </span><span class="x">name</span><span class="nf">:</span><span class="w"> </span><span class="x">name.value</span><span class="p">,</span><span class="w"> </span><span class="x">grade</span><span class="nf">:</span><span class="w"> </span><span class="x">grade.value</span><span class="p">,</span><span class="w"> </span><span class="x">school</span><span class="nf">:</span><span class="w"> </span><span class="x">school.value</span><span class="p">]</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="c1">// reset the form</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">name.value</span><span class="w"> </span><span class="nf">:=</span><span class="w"> </span><span class="s">&quot;&quot;</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">grade.value</span><span class="w"> </span><span class="nf">:=</span><span class="w"> </span><span class="s">&quot;&quot;</span><span class="w"></span> -<span class="x"> </span><span class="w"> </span><span class="x">school.value</span><span class="w"> </span><span class="nf">:=</span><span class="w"> </span><span class="s">&quot;&quot;</span><span class="w"></span> -</code></pre></div> +<p>This block searches for every unique <code>#clicked</code>, counts them, and returns that value in <code>how-many</code>. Then we display this value in a text container using the operator <code>{{ ... }}</code>, which inserts the value of the contained variable into the string. An important thing to remember here is that this block will only run when the button has been clicked at least once. Before then, this block will not run because there are no <code>#clicked</code> records to count.</p> -<h2 id="learning-more">Learning more</h2> +<h2 id="summary">Summary</h2> -<p>If you want to learn more about Eve, we have some resources to help with that:</p> +<p>That&rsquo;s it for the 5 minute introduction to Eve. To summarize:</p> <ul> -<li>Example applications - See some working programs and explore how they work.</li> -<li>Tutorials - Step by step instructions on building Eve applications.</li> -<li><a href="https://witheve.github.io/docs">The Eve Handbook</a> - Everything you need to know about Eve.</li> -<li><a href="https://witheve.github.io/assets/docs/SyntaxReference.pdf">Eve syntax reference</a> - Eve&rsquo;s syntax in one page.</li> -<li>Guides - In-depth documents on topics relating to Eve.</li> +<li>Eve programs are made up of blocks.</li> +<li>Data are represented by records, key value pairs associated to a unique ID.</li> +<li>There are two sections of a block: one where you search for records, and one where you bind or commit records.</li> +<li>Blocks update records automatically to reflect changes in data.</li> +<li>Bound records are replaced when data changes, while committed records must be removed manually.</li> +<li>Records are unique, uniqueness is determined by a record&rsquo;s attributes and their values.</li> </ul> -<p>We also invite you to join the Eve community! There are several ways to get involved:</p> +<p>This will get you started with Eve, but there&rsquo;s still more to learn. From here, you can:</p> <ul> -<li>Join our <a href="https://groups.google.com/forum/#!forum/eve-talk">mailing list</a> and get involved with the latest discussions on Eve.</li> -<li>Impact the future of Eve by getting involved with our <a href="https://github.com/witheve/rfcs">Request for Comments</a> process.</li> -<li>Read our <a href="http://incidentalcomplexity.com/">development diary</a> for the latest news and articles on Eve.</li> -<li>Follow us on <a href="https://twitter.com/with_eve">twitter</a>.</li> +<li>Advance to Level 2 of the introductory tutorial.</li> +<li>View the syntax reference or the Eve handbook.</li> +<li>Explore already made examples.</li> +<li>Or dive right in to the editor and try out the concepts you&rsquo;ve just learned.</li> </ul> diff --git a/tutorials/quickstart.eve/index.html b/tutorials/quickstart.eve/index.html new file mode 100644 index 0000000..fbcb634 --- /dev/null +++ b/tutorials/quickstart.eve/index.html @@ -0,0 +1,264 @@ + + + + + + + + + + + + Quickstart - Eve Documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + +
+ +
+
+ + + + + + +
+
+
+
+ +
+
+ + + + + +
+
+
+
+
+
+ + + +

Quickstart

+ +

In this guide we’re going to give you a 5 minute introduction to the essential concepts in Eve. If you’ve never used Eve before, you’re in the right place.

+ +

Adding records to Eve

+ +

Eve represents data as records, which are key value pairs attached to a unique ID. Eve programs are made up of small composable blocks that search for and create records. Let’s start with a block that adds a record to Eve:

+
commit
+  [#greeting text: "hello world"]
+
+ +

This record is tagged #greeting, and has an attribute “text” with the value “hello world”. Although tags have a special syntax, they are attributes like any other. We encourage you to classify groups of related records with tags.

+ +

Finding records in Eve

+ +

Eve finds every record that matches the supplied patterns, then binds new records to them. If no records match the search, then the block does not run at all. A block will only run if every pattern in a search matches at least one record. Let’s search for the #greeting we just committed, and then display it in a text container:

+
search
+  [#greeting text]
+
+bind
+  [#ui/text text]
+
+ +

Variables with the same name are equivalent within a block; because they have the same name, the text in [#greeting text] and [#ui/text text] are equivalent. Go ahead and add another #greeting record to the first block to see what happens when more than one record matches the search.

+ +

Records update as data changes

+ +

Blocks in Eve react automatically to changes in data. When a record changes, any bound records are automatically updated. Let’s search for the current time, and display it in a div:

+
search
+  [#time seconds]
+
+bind 
+  [#ui/text text: seconds]
+
+ +

As the time changes, the output updates to reflect the current state of the #time record. Records can be committed instead of bound, but the behavior is a little different – committed records persist until they are removed explicitly. Try changing bind to commit in the above block and see what happens.

+ +

Reacting to events

+ +

Let’s draw a button on the screen:

+
commit
+  [#ui/button #increment text: "+1"]
+
+ +

When you click anywhere on the screen, Eve creates an #html/event/click record representing the click. You can react to clicks on the #increment button by searching for the #html/event/click record, where the element attribute is the button:

+
search
+  event = [#html/event/click element: [#increment]]
+
+commit
+  [#clicked event]
+
+ +

Clicks only last for an instant, but we want to create a permanent record of each click so we can search for them later. This block commits a #clicked record that will persist until it’s explicitly removed. Much like the #greeting text we bound to the #ui, variables with the same name are equivalent, so the variable event in the #clicked record is a reference to the #html/event/click on the #increment button.

+ +

The identity of a record is determined by its attribute/value pairs. Two records with the same attributes and values are identical in Eve. We included the event attribute in the #clicked record to differentiate each record. Without this differentiation, we could only ever create a single #clicked record. Try removing event from the record and click the button to test this out.

+ +

Count the number of clicks

+ +

Now let’s count the number of times the button has been clicked. Make sure event is back in #clicked, and then we can count those records directly:

+
search
+  how-many = gather/count[for: [#clicked]]
+
+bind
+  [#ui/text text: "The button has been clicked {{how-many}} times"]
+
+ +

This block searches for every unique #clicked, counts them, and returns that value in how-many. Then we display this value in a text container using the operator {{ ... }}, which inserts the value of the contained variable into the string. An important thing to remember here is that this block will only run when the button has been clicked at least once. Before then, this block will not run because there are no #clicked records to count.

+ +

Summary

+ +

That’s it for the 5 minute introduction to Eve. To summarize:

+ +
    +
  • Eve programs are made up of blocks.
  • +
  • Data are represented by records, key value pairs associated to a unique ID.
  • +
  • There are two sections of a block: one where you search for records, and one where you bind or commit records.
  • +
  • Blocks update records automatically to reflect changes in data.
  • +
  • Bound records are replaced when data changes, while committed records must be removed manually.
  • +
  • Records are unique, uniqueness is determined by a record’s attributes and their values.
  • +
+ +

This will get you started with Eve, but there’s still more to learn. From here, you can:

+ +
    +
  • Advance to Level 2 of the introductory tutorial.
  • +
  • View the syntax reference or the Eve handbook.
  • +
  • Explore already made examples.
  • +
  • Or dive right in to the editor and try out the concepts you’ve just learned.
  • +
+ + +
+
+
+
+ + + diff --git a/tutorials/quickstart/index.html b/tutorials/quickstart/index.html deleted file mode 100644 index d88419b..0000000 --- a/tutorials/quickstart/index.html +++ /dev/null @@ -1,591 +0,0 @@ - - - - - - - - - - - - Quickstart - Eve Documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - - -

Eve Quick Start Tutorial

-
```
-bind @browser
-  [tag: "div", text: "Hello, world"]
-```
-
- -

Hello world! At its core, Eve is a pattern matching language. You match patterns of data by searching a database, then update or create new data according to what you’ve found. In this example, we created a record that has two attributes: a tag attribute with the value "div", and a text attribute with the value "Hello, world". We bound this record to the browser, which is how we displayed our venerable message.

- -

The three backticks ``` are called a code fence, and they allow us to denote blocks of code. This gives us the ability to embed Eve code in normal documents written in Markdown. This is how Eve programs are written: everything in a code fence is a block of Eve code, while everything outside is prose describing the program. In fact, this quick start tutorial is an example of an executable Eve program! In the subsequent blocks, you won’t see any code fences, but they still exist in the document’s source.

- -

So far we’ve created a record that displays “Hello, world!” but as I said, Eve is a pattern matching language. Let’s explore that by searching for something:

-
search
-  [name]
-
-bind @browser
-  [tag: "div", text: "Hello, world"]
-
- -

Our message disappeared! Before, we bound without searching, so the message displayed by default. Now we’re binding in the presence of a search action, so the bound record only exists if all the searched records are matched. Here, we’re searching for all records with a name attribute, but we haven’t added any records like that to Eve so none are matched. With no matching records, the bind cannot execute, and the message disappears from the screen.

- -

This is the flow of an Eve block: you search for records in a database, and if all the records you searched for are matched, you can modify the matched records or create new ones. If any part of your search is not matched, then no records will be created or updated.

- -

To get our message back, all we need is a record with a name attribute. We can create one permanently with the commit action:

-
commit
-  [name: "Celia"]
-
- -

Hello, world… again! Commit permanently updates or creates a record that will persist even if its matched records (the records matched in a search action) change. Since we aren’t searching for anything in this block, the commit executes by default and adds a record with a name attribute of "Celia". The addition of this new record satisfies the search in the previous block, so “Hello, world!” appears on the screen again.

- -

But what else can you do with matched records? For starters, we can use them to create new records:

-
search
-  [name]
-
-bind @browser
-  [#div, text: "Hello, {{name}}"]
-
- -

Since we matched on a record with a name attribute, we now have a reference to that name, and we can inject it into a string using {{ ... }} embedding. We can also swap out tag: "div" for the sugared #div. Tags are used a lot in Eve to talk about collections of related records. For example, we could search for all records with a #student tag, with name, grade, and school attributes.

-
search
-  [#student name grade school]
-
-bind @browser
-  [#div text: "{{name}} is a {{grade}}th grade student at {{school}}."]
-
- -

Since we’re matching on more attributes, this block is no longer satisfied by the record we added earlier; we’re missing a #student tag, as well as grade and school attributes. Even though these are currently missing, we can still write the code that would display them.

- -

Let’s display this new message by adding the missing attributes to Celia. We could add them to the block where we comitted Celia originally, but we can also do it programatically:

-
search
-  celia = [name: “Celia”]
-
-bind
-  celia <- [#student grade: 10, school: "East", age: 16]
-
- -

You can define variables within blocks, which act as handles on records that allow you to change them. In this case, we’re using the merge operator <- to combine two records. With the addition of this block, the sentence “Celia is a 10th grade student at East.” appears in the browser.

- -

Celia is cool and all, but let’s add some more students to our database:

-
commit
-  [#student name: “Diedra”, grade: 12, school: "West"]
-  [#student name: “Michelle”, grade: 11, school: "West"]
-  [#student name: “Jermaine”, grade: 9]
-
- -

Three sentences are now printed, one for each student that matches the search. Eve works on sets, so when we search for [#student name grade school], we find all records that match the given pattern. This includes Celia, Diedra and Michelle (but not Jermaine, as he has no school in his record). Therefore, when we bind the record [#div text: "{{name}} is a ... "], we are actually binding three records, one for each matching #student.

- -

If you re-compile the program a couple times, you’ll see the order of sentences may change. This is because there is no ordering in Eve - blocks are not ordered, statements are not ordered, and results are not ordered. If you want to order elements, you must impose an ordering yourself. We can ask the browser to draw elements in an order with the “sort” attribute:

-
search
-  [#student name grade school]
-
-bind @browser
-  [#div sort: name, text: "{{name}} is a {{grade}}th grade student at {{school}}."]
-
- -

This time when you recompile your program, the order will stay fixed, sorted alphabetically by name.

- -

Let’s make things a little more interesting by adding some records about the schools the students attend:

-
commit
-  [#school name: “West”, address: "1234 Main Street"]
-  [#school name: “East”, address: "5678 Broad Street"]
-
- -

What if we want to display the address of the school each student attends? Although #students and #schools are in different records, we can relate two records by associating attributes from one record with attributes from the other. This is an operation known as joining. In this case, we want to relate the name attribute on #schools with the school attribute on #students. This compares the values of the attributes between records, and matches up those with the same value. For instance, since Celia’s school is “East”, she can join with the #school named “East”.

- -

Our first attempt may come out looking a little something like this:

-
search
-  school = [#school name address]
-  student = [#student name school: name] 
-
-bind @browser
-  [#div text: "{{student.name}} attends {{school.name}} at {{address}}"]
-
- -

But that didn’t work. How come? In Eve, things with the same name are equivalent. In this block, we’ve used “name” three times, which says that the school’s name, the student’s name, and the student’s school are all the same. Of course, there is no combination of students and schools that match this search, so nothing is displayed.

- -

Instead, we can use the dot operator to specifically ask for the name attribute in the #school records, and rename our variables to get a correct block:

-
search
-  schools = [#school address]
-  students = [#student school: school.name]
-
-bind @browser
-  [#div text: "{{students.name}} attends {{schools.name}} at {{address}}"]
-
- -

This creates an implicit join over the school name without mixing up the names of the students and the names of the schools, giving us our desired output. You can actually bind attributes to any name you want to avoid collisions in a block:

-
search
-  [#school name: school-name address]
-  [#student name: student-name school: school-name]
-
-bind @browser
-  [#div text: "{{student-name}} attends {{school-name}} at {{address}}"]
-
- -

Advanced Eve

- -

Recall when we added our students, Celia was the only one we added an age to. Therefore, the following block only displays Celia’s age, even though we ask for all the #students:

-
search
-  [#student name age]
-
-bind @browser
-  [#div text: "{{name}} is {{age}} years old"]
-
- -

Let’s pretend that all students enter first grade at six years old. Therefore, if we know a student’s grade, we can calculate their age and add it to the student’s record:

-
search
-  student = [#student]
-  calculated-age = if student.age then student.age
-                   else if student.grade then student.grade + 5
-
-bind @browser
-  student.age := calculated-age
-
- -

This block selects all students, and uses and if-then expression to set the student’s calculated age. If the student already has an age, we set it to that. Otherwise, if the student has no age, we can calculate it with some arithmetic. The set operator := sets an attribute to a specified value regardless of what it was before the block executed. That value can be anything, from a number to a string to another record.

- -

Aggregates

- -

So far everything we’ve done has used one record at a time, but what happens when we want to work over a group of records, such as counting how many students there are? To solve such a problem, we’ll need to use an aggregate. Aggregates take a set of values and turn them into a single value, akin to “fold” or “reduce” functions in other languages. In this case, we’ll use the aggregate count to figure out how many #students are in the school district:  

-
search
-  students = [#student]
-  total-students = count[given: students]
-
-bind 
-  [#div text: "{{total-students}} are in the school district"]
-
- -

A quick note on the syntax for count - it feels a lot like a function in other languages, since it has a return value and can be used inline in expressions. Under the hood, functions and aggregates are actually records; total = count[given: students] is shorthand for [#count #function given: students, value: total]. This distinction won’t materially change the way you use count, but it goes to show that everything in Eve reduces to working with records.

- -

While given is a required argument in count, aggregates (and functions in general) can also have optional arguments. Let’s say we want to know how many students attend each school. We can use the optional argument per to count students grouped by the school they attend:

-
search
-  students = [#student school]
-  students-per-school = count[given: students, per: school]
-
-bind
-  [#div text: "{{students-per-school}} attend {{school}}"]
-
- -

All function-like records in Eve specify their arguments as attributes. This means you specify the argument and its value, unlike in other languages, where the order of the values determines the attribute to which they belong. As with everything else in Eve, order doesn’t matter.

- -

Extra Credit

- -

At this point, you know everything necessary about Eve to complete this extra credit portion (the only additional knowledge you need is domain knowledge of HTML and forms). Let’s review some of the key concepts:

- -
    -
  • Eve programs are composed of blocks of code that search for and update records.
  • -
  • Records are sets of attribute: value pairs attached to a unique ID.
  • -
  • Eve works with sets, which have no ordering and contain unique elements.
  • -
  • Things with the same name are equivalent.
  • -
- -

Your extra credit task is to build a web-based form that allows you to add students to the database. Take a moment to think about how this might be done in Eve, given everything we’ve learned so far.

- -

First, let’s make the form. We’ve already displayed a #div, and in the same way we can draw #inputs and a #button:

-
bind @browser
-  [#div children: 
-    [#div sort: 1, text: "Name:"]
-    [#input #name-input sort: 2]
-    [#div sort: 3, text: "Grade:"]
-    [#input #grade-input sort: 4]
-    [#div sort: 5, text: "School:"]
-    [#input #school-input sort: 6]
-    [#button #submit sort: 7 text: "submit"]]
-
- -

We’ve added some tags to the inputs and the button to distinguish them, so we can easily search for them from other blocks. Now that we have a form, we need to define what happens when the submit button is clicked.

- -

Remember, everything in Eve is a record, so the #click event is no different. When a user clicks the mouse in the browser, Eve records that click in the database.

- -

This record exists only for an instant, but we can react to it by searching for [#click element: [#submit]]. This record represents a #click on our #submit button. Then, all we need to do is capture the values of the input boxes and save them as a #student record:

-
search
-  [#click element: [#submit]]
-  name = [#name-input]
-  grade = [#grade-input]
-  school = [#school-input]
-
-commit
-  // save the new student
-  [#student name: name.value, grade: grade.value, school: school.value]
-  // reset the form
-  name.value := ""
-  grade.value := ""
-  school.value := ""
-
- -

Learning more

- -

If you want to learn more about Eve, we have some resources to help with that:

- -
    -
  • Example applications - See some working programs and explore how they work.
  • -
  • Tutorials - Step by step instructions on building Eve applications.
  • -
  • The Eve Handbook - Everything you need to know about Eve.
  • -
  • Eve syntax reference - Eve’s syntax in one page.
  • -
  • Guides - In-depth documents on topics relating to Eve.
  • -
- -

We also invite you to join the Eve community! There are several ways to get involved:

- - - - -
-
- -
-