This language is based on expressions just like OCaml
let main () = ...
// Example 1
let main () = 0;
// Example 2
let main () = {
...
0
};
int32 int64 string char bool
'a - Is a any type from the list above 'a list 'a array
':=' -> defines '=' -> compares '>' -> bigger than '>=' -> bigger or equal than '<' -> lower than '<=' -> lower or equal than '&' -> AND '|' -> OR '->' -> Used for anonymous functions '?' ':' -> Ternary operator
'+' -> Plus '-' -> Minus '*' -> Multiply '/' -> Divide '%' -> Mod
let <name>: <type> = <value>
let a: int = 10;
let a: string = "Hello, World!";
let <name> = <value>
value must be a valid type
let a = 10;
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
(x: int) -> x + 1;
let sum: int -> int = (x: int) -> x + 1;
// New block of code
// Allocate here
let sum x = x + 1;
let b = {
let a = 10;
// Return a value
add a
};
// Deallocate here
// Enums
type typ = Enum(int * typ) | None;
// Structs
type typ2 = {
name: string,
};
let a = typ2 {
name: string,
}
// initialize the Enum??
// let b =
Booleans will be used
a = b ? ... : ...
if a = b { ... } else { ... }
for i = 0 to 10 {
...
}
for true {
if 1 = 1 {
break;
}
}
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;;
let sum = ( + );;
let (>>) = fun a -> fun b -> (a + b)*10
5 >> 10