🔱

Alpha Language Specification - Compute Engine

Introduction

What is the best way to express and deliver our ideas?

Language

Types

Complex Number. Real number. Rational number. Integer number. Natural number. x:Xx:X such that X={...}X=\{...\}, x∈Xx\in X. Char. Array.

All types are first-class.

Expressions

Should expressions admit whitespaces in names?

Closure.

Some expressions

$ +(||(0.7,0.2)-(0.2,0.3)||_2)

$ + . ||(0.7,0.2)-(0.2,0.3)||_2

$ ||(0.7,0.2)-(0.2,0.3)||_2 | +

$ (x => x+1)(1)
1

$ interval(1000) | reduce(p => [p[1],p[0]+p[1]],[0,1])

$ connect(protocol=WebRTC) | chat
abc

connect(protocol=WebRTC, key="abc") | 
interval(1000) | 
reduce(p => [p[1],p[0]+p[1]],[0,1]) | 
echo

Comments

Declarations and assignments

You can declare new terms but alpha doesn’t allow assignments.

Expressions

Alpha follows the convention that every expression has a value. The declarations or definitions return their references such that

x=6
// x
f(x)=x
// f

Functions

The type of argument is by default real numbers.

f(x)=x^2

f (a,b,c) = (x1, x2) where 
   expressions

Pattern matching

Regular expressions

a ~ /REGULAR_EXPRESSION/g

Program

UTF-8

Programs are not evaluated on the fly.

Every expression can ask about itself (quine and operational quine).

f(x) = x^2
f.self
// f(x)=x^2 : self
f.self.body.self
// x^2 : self
f.self.body.self.evaluate({"x": 1})
// 1^2
f.self.body.self.evaluate({"x": 1}).apply()
// 1

Streams, composition, and pipes

The means of combinations are streams, composition (f.gf.g), and pipes (g|f).

Lexical Structure

id: Unicode symbols

Syntax

Type rules

Operational semantics

Environment

Commands

Examples

Grammar

Consider a grammar G4 where its production rules are
S: `X`*
what is its type?

Consider G4:Grammar where its production rules are
S: X*
what is its type?

Consider G4:Grammar where we have a environment e and its production rules are
S: X* {x=$$1}

W
graph TD
  G --> Expr
  Expr --> Expr+Expr
  Expr+Expr --> Expr
  Expr+Expr --> Expr
  Expr --> 1

G —> Expr —> 1

G —> Expr —> Expr+Expr —>

Read–eval–print loop and notebook

Kernels

%% html
%% prolog
%% alpha

Modes

Authoring

Interactive

References

https://xtermjs.org/

https://www.npmjs.com/package/react-terminal#features

https://mljar.com/mercury/

Jupyter

Wolfram Alpha