https://github.com/liby99/menhera
Menhera, a javascript like functional programming language
https://github.com/liby99/menhera
Last synced: 3 months ago
JSON representation
Menhera, a javascript like functional programming language
- Host: GitHub
- URL: https://github.com/liby99/menhera
- Owner: Liby99
- Created: 2018-05-26T17:20:52.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-12-29T03:44:07.000Z (over 6 years ago)
- Last Synced: 2024-10-25T01:39:33.590Z (over 1 year ago)
- Language: OCaml
- Homepage:
- Size: 255 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Menhera Lang
A toy language & interpreter mocking the design of OCaml and JavaScript, statically typed with inference.
```
let sum = (a, b) => a + b in
sum(3, 5)
```
## Syntax
Integer, boolean, let and if:
```
let a: bool = true in
let b: int = 3 in
if b == 4 then a
else false
```
If you don't want to write the type explicitly, the above program will become
```
let a = true in
let b = 3 in
if b == 4 then a
else false
```
Function and function calls:
```
let sum = (a, b) => a + b in
sum(3, 5)
```
You can of course add explicit type definition
```
let sum : (int, int) -> int =
(a : int, b : int) : int =>
a + b
in
sum(3, 5)
```
## How to build & run
Clone the repository. First please make sure you installed `ocaml` >= 4.08, `ocamlbuild`, `menhir` and `ppx_derive`. Then you can simply do
```
$ make
```
To run one of our examples, please
```
$ ./menhera -show-result examples/function/sum.mhr
```
The argument `-show-result` means that it will print out the raw format of the result value after running this file.
## How to test
```
$ make test
$ ./test
```