Language design

This language is based on expressions just like OCaml

Entry

let main () = ...
// Example 1
let main () = 0;

// Example 2
let main () = {
    ...
    0
};

Primitive Types

int32 int64 string char bool

'a - Is a any type from the list above 'a list 'a array

Symbols

':=' -> defines '=' -> compares '>' -> bigger than '>=' -> bigger or equal than '<' -> lower than '<=' -> lower or equal than '&' -> AND '|' -> OR '->' -> Used for anonymous functions '?' ':' -> Ternary operator

aritmetic operators

'+' -> Plus '-' -> Minus '*' -> Multiply '/' -> Divide '%' -> Mod

Variables

let <name>: <type> = <value>

let a: int = 10;
let a: string = "Hello, World!";

Type inference

let <name> = <value>

value must be a valid type

let a = 10;

Named Functions

let print (x: int): int = println x;

// functions with blocks
let works (x: int): int = {
    println x;
    x + 2
};

// prints 2 and returns 4
works 2;

let sum (x: int): int = x + 1;

let sum x = x + 1;

sum a;
sum 10;

This syntax is a syntatic sugar for

let sum = (x: int) -> x + 1;
let add: int -> int -> int = (x: int) -> (y: int) -> x + y;

Anonymous Functions

// Anonymous
(x: int) -> x + 1;
let sum: int -> int = (x: int) -> x + 1;

Blocks

// New block of code
// Allocate here
let sum x = x + 1;

let b = {
  let a = 10;

  // Return a value
  add a
};
// Deallocate here

Types

// Enums
type typ = Enum(int * typ) | None;

// Structs
type typ2 = {
    name: string,
};

let a = typ2 {
    name: string,
}

// initialize the Enum??
// let b = 

Conditions

Booleans will be used

a = b ? ... : ...
if a = b { ... } else { ... }

Loops

for i = 0 to 10 {
  ...
}

for true {
  if 1 = 1 {
    break;
  }
}

Interfaces

Interface is any struct that have these expr names and signatures

interface intername {
    name: string
    name2: string -> string
};

type typ2 = {
    name: string,
    name2: string -> string,
};

let a = typ2 {
    name: "Hello",
    name2: a -> a + " " + "World!",
};

let abc (i: intername) = {
    print i.name
}

abc a;;

Simbols

let sum = ( + );;

let (>>) = fun a -> fun b -> (a + b)*10 

5 >> 10