The goal of this project is to implement a programming language of our own design in Haskell.
The best way to install Haskell, is using GHCup.
After installing the necessary dependencies, in order to build the project, use the Makefile. Follow these steps:
- Clone the project:
git clone git@github.com:anpawo/mary.git- Go to the project directory:
cd mary- Build using Makefile:
make- First, you need to write a file according to the
Marysyntax. - You should consider installing the vscode-extension for better readability.
- Once your file is done, you can run it with
./glados <filename>
For starters, here's a little file with a guess the number game.
import std
function guess_the_number(n: int) -> void {
print("guess the number between 0 and 100");
guess: int = n + 1;
while guess != n then
{
guess = toInt(getline());
if guess == n then
{
print("you won");
}
else
{
if guess < n then
{
print("higher");
}
else
{
print("lower");
}
}
}
}
function main() -> void {
guess_the_number(random(0, 100));
}function main() -> void {
print("hello world");
}operator ** precedence 8 (n: int, power: int) -> int {
if power == 0 then
{
return 1;
}
else
{
return n * n ** (power - 1);
}
}type number = int | floatstruct person {
name: str,
age: int
}import list
// provides the function map
// and the operator `..` (range)
// which are both coded in the mary language.
// check out the stdlib directory for more.
function main() -> void {
print(map(\x -> x * 2, 1..10));
// ^^^^^^^^^^^
// lambda
}
// output [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
You can do great things with this much!
For more information about the language, check out the Mary User Manual.
Zacharie Rodde |
Jean-Garice Denoncin |
Ryan Hercule |
Camil Kaddouri |
Marius Rousset |
|---|