crates | ||
example | ||
runtime | ||
.gitignore | ||
Cargo.lock | ||
Cargo.toml | ||
FUNDING.yml | ||
LICENSE-APACHE | ||
LICENSE-MIT | ||
README.md |
Hazure
Programming language that compiles to Typescript!
fun main: void = do
@write("Hello, World!");
end;
or with the pipeline operator:
fun main: void = do
"Hello, World!\n"
|> @write(_);
end;
Note: Everything in this project can be changed at anytime! (I'm still finding out what work best for lots of thing) if you have an idea, feel free to create an issues about it, or even create a PR! (I'd be very happy)
Prerequistie
deno
- Rust (if you're going to build from source)
Contributing
Found a bug? Found a better way to do something? Make a pull request or tell me in the issues tab! Anything contributions helps :D
Steps to build:
- Clone this repo
https://github.com/azur1s/hazure.git
- Build executable
cargo build
- Try running some examples!
path/to/executable compile path/to/file.hz
Syntax
This language is still in development, the syntax can be changed at anytime.
Hazure is a free-form syntax style, so the indentation is purely for readability.
fun main: void = do
@write("Hello, World!");
end;
is the same as
fun main: void = do @write("Hello, World!"); end;
Hazure is also expression-oriented like OCaml. There are currently 10 expressions:
- Comment
-- Comment! -{ Block Comment }-
- Values / Types
1 true "string" variable
- Unary and Binary
1 + 2 !true
- Call and Intrinsic. Intrinsic starts with a
@
@write("Hello") foo("bar")
- Pipeline
"Hello, World" |> @write(_)
- Variable declaration
let foo: int = 727; let bar: string = "Hi"; let baz: boolean = true;
- Function declaration
fun foo: void = @write("void returns nothing"); fun bar (x: int): int = x + 1; fun baz (x: int) (y: int): int = x + y;
- If conditions
let cond: bool = true; if cond then @write("True"); else do @write("False"); end; end;
- Case matching
case 1 + 1 of | 2 -> @write("Yes"); \ @write("How?"); end;
- Do notation. It allows you to have multiple expression because something like right hand side of the function declaration
fun a: int = ...
can only have 1 expression. Do allows you to bypass that.do @write("Hello, World"); foo(bar); let baz: int = 6 + 10; end;
Hazure isn't a scripting language, so, you will need a main function.
fun main: void = do
@write("Hello, World");
@write(34 + 35);
end;
License
Hazure is licensed under both MIT license and Apache License