{"id":23189559,"url":"https://github.com/champii/rock","last_synced_at":"2025-08-18T18:32:20.910Z","repository":{"id":37019080,"uuid":"209399674","full_name":"Champii/Rock","owner":"Champii","description":"Native language with Rust \u0026 LLVM","archived":false,"fork":false,"pushed_at":"2023-09-02T18:31:51.000Z","size":1997,"stargazers_count":66,"open_issues_count":54,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-28T00:34:14.736Z","etag":null,"topics":["ast","functional-programming","langage","llvm","llvm-ir","low-level","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Champii.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-09-18T20:37:21.000Z","updated_at":"2024-01-26T13:02:58.000Z","dependencies_parsed_at":"2024-01-29T08:09:48.787Z","dependency_job_id":"d584e7f1-2808-449e-ae77-bd3c82d88ad8","html_url":"https://github.com/Champii/Rock","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Champii%2FRock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Champii%2FRock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Champii%2FRock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Champii%2FRock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Champii","download_url":"https://codeload.github.com/Champii/Rock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230260586,"owners_count":18198594,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ast","functional-programming","langage","llvm","llvm-ir","low-level","rust"],"created_at":"2024-12-18T11:20:01.843Z","updated_at":"2024-12-18T11:20:02.648Z","avatar_url":"https://github.com/Champii.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rock v0.4.3\n\n[![Rust](https://github.com/Champii/Rock/actions/workflows/rust.yml/badge.svg?branch=master)](https://github.com/Champii/Rock/actions/workflows/rust.yml)\n[![Discord](https://img.shields.io/discord/990627124236939314.svg)](https://discord.gg/f6skPNB96J)\n\n[Documentation](https://champii.github.io/Rock)\n\nNative language made with Rust and LLVM.\n\nAim to follow the enforced safeness of the Rust model with a borrow checker (Soon™) and to achieve high native performances thanks to LLVM.\nRock is highly inspired from [Livescript](https://livescript.net/), [Haskell](https://www.haskell.org/) and [Rust](https://www.rust-lang.org/).\n\nNo to be taken seriously (yet).  \nRock is still in its early conception phase, and everything can change and/or break at any time.  \nFeel free to discuss any new feature or change you may like in an issue! We welcome and value every contribution.\n\n## Index\n\n- [Rock v0.4.3](#rock-v0.4.3)\n  - [Index](#index)\n  - [Features](#features)\n  - [Install](#install)\n    - [From source](#from-source)\n      - [With Cargo from Git (Recommanded)](#with-cargo-from-git-recommanded)\n      - [Manual Clone and Build from Git](#manual-clone-and-build-from-git)\n    - [Using Released Binary](#using-released-binary)\n  - [Quickstart](#quickstart)\n  - [Showcases](#showcases)\n    - [Polymorphic function](#polymorphic-function)\n    - [Custom infix operator](#custom-infix-operator)\n    - [Trait Definition](#trait-definition)\n    - [Trait default method](#trait-default-method)\n    - [Struct instance and methods]( #struct-instance-and-methods )\n    - [Show and Print implementation]( #show-and-print-implementation )\n    - [Modules and Code Separation](#modules-and-code-separation)\n  - [Development notes](#development-notes)\n\n---\n\n## Features\n\n- Strongly typed\n- Type inference\n- Custom operators\n- Typeclass (Traits)\n- Polymorphism by default\n- Compile to LLVM IR\n\n---\n\n## Install\n\n### From source\n\nYou will need `llvm-13` and `clang-13` somewhere in your $PATH\n\n#### With Cargo from Git (Recommanded)\n\n```sh\ncargo install --locked --git https://github.com/Champii/Rock --tag v0.4.3\nrock -V\n```\n\n#### Manual Clone and Build from Git\n\n```sh\ngit clone https://github.com/Champii/Rock.git\ncd Rock\ncargo run --release -- -V\n```\n\nNote: If you clone and build manually, make sure to add `Rock/target/release/` to you `$PATH` so you can run it anywhere on your system.  \nThis method uses the `master` branch of Rock, that is not stable. You can checkout the latest version tag.\n\nRock has been tested against Rust stable v1.60.0 and nightly\n\n[Adding Rust Nightly](https://github.com/Champii/Rock/wiki/Adding-Rust-Nightly)\n\n### Using Released Binary\n\n[Rock v0.4.3](https://github.com/Champii/Rock/releases/download/v0.4.3/rock)\n\n``` sh\nwget https://github.com/Champii/Rock/releases/download/v0.4.3/rock\nchmod +x rock\n./rock -V\n```\n\nThis install method is not well tested yet, and might not work for your environment.\nIt requires a x86_64 architecture and GLIBC 2.34. (Don't try to upgrade your GLIBC if you don't know what you are doing)\n\n---\n\n## Quickstart\n\n- Lets create a new project folder to compute some factorials\n\n``` sh\nrock new factorial \u0026\u0026 cd factorial\n```\n\n- Edit the `factorial/src/main.rk` file:\n\n```haskell\nfact: x -\u003e\n  if x \u003c= 1\n  then 1\n  else x * fact (x - 1)\n\nmain: -\u003e fact 4 .print!\n```\n\nAssuming that you built Rock and put its binary in your PATH:\n\n``` sh\n$ rock run\n24\n```\n\nRock should have produced a `./build/` folder, that contains your `a.out` executable.\nYou can execute it directly:\n\n```sh\n$ ./build/a.out\n24\n```\n\nTake a look at `rock --help` for a quick tour of its flags and arguments\n\nNote that you currently MUST be at the project root to run the compiler. (i.e. inside the `./factorial/` folder)\n\n---\n\n## Showcases\n\n### Polymorphic function\n\n``` haskell\nid: x -\u003e x\n\nmain: -\u003e\n  id 1 .print!\n  id 2.2 .print!\n  id \"Test\" .print!\n```\n\nPrints \n\n``` sh\n$ rock run\n1\n2.2\nTest\n```\n\nThe `id` function here is polymorphic by default, as we don't make any constraint on the type that we should take or return.  \nIf we did something like this  \n`id: x -\u003e x + x`  \nWe would have constrained `x` to types that implement [`Num`](https://github.com/Champii/Rock/blob/master/std/src/num.rk)\n\nNote that this example would still be valid, as `Int64`, `Float64` and `String` are all implementors of `Num`.  \n`String` is nowhere at its place here, and only implements `+` for string concatenation. This should change in the future with more traits like `Add` in rust\n\nThe output would be:\n\n``` sh\n2\n4.4\nTestTest\n```\n\n### Custom infix operator\n\n``` haskell\ninfix |\u003e 1\n|\u003e: x, f -\u003e f x\n\nf: x -\u003e x + 2\n\nmain: -\u003e (4 |\u003e f).print!\n```\n\n``` sh\n$ rock run\n6\n```\n\nYou can create any operator that is made of any combination of one or more of `'+', '-', '/', '*', '|', '\u003c', '\u003e', '=', '!', '$', '@', '\u0026'`  \n\nMost of the commonly defined operators like `+`, `\u003c=`, etc are already implemented by the [stdlib](https://github.com/Champii/Rock/tree/master/std) that is automaticaly compiled with every package.  \nThere is a `--nostd` option to allow you to use your own custom implementation. \n\n### Trait definition\n\nThis `trait ToString` is redondant with the `trait Show` implemented in the stdlib, and serves as a demonstration only\n\n``` haskell\ntrait ToString\n  @tostring: String\n\nimpl ToString Int64\n  @tostring: -\u003e @show!\n\nimpl ToString Float64\n  @tostring: -\u003e @show!\n\nmain: -\u003e\n  (33).tostring!.print!\n  (42.42).tostring!.print!\n```\n\n``` sh\n$ rock run\n33\n42.42\n```\n\n### Trait default method\n\n``` haskell\ntrait ToString\n  @tostring: -\u003e @show!\n\nimpl ToString Int64\nimpl ToString Float64\n\nmain: -\u003e\n  (33).tostring!.print!\n  (42.42).tostring!.print!\n```\n\n``` sh\n$ rock run\n33\n42.42\n```\n\n### Struct instance and methods\n\n``` haskell\nstruct Player\n  level: Int64\n  name: String\n\nimpl Player\n  new: level -\u003e\n    Player\n      level: level\n      name: \"Default\"\n  @getlevel: -\u003e @level\n\nmain: -\u003e\n  Player::new 1\n    .getlevel!\n    .print!\n```\n\n``` sh\n$ rock run\n1\n```\n\n### Show and Print implementation\n\n``` haskell\nstruct Player\n  level: Int64\n  name: String\n\nimpl Show Player\n  @show: -\u003e @name + \"(\" + @level.show! + \")\"\n\n# This will be automatic in the future\nimpl Print Player\n\nmain: -\u003e\n  let player = Player\n    level: 42\n    name: \"MyName\"\n\n  player.print!\n```\n\n``` sh\n$ rock run\nMyName(42)\n```\n\n### Modules and code separation\n\n- `./myproj/src/foo.rk`\n\n```haskell\nbar: x -\u003e x + 1\n```\n\n- `./myproj/src/main.rk`\n\n```haskell\nmod foo\n\nuse foo::bar\n\nmain: -\u003e bar 1 .print!\n```\n\n```sh\n$ rock run\n2\n```\n\nNote that we could have skiped the\n`use foo::bar`\nif we wrote\n`main: -\u003e foo::bar 1 .print!`\n\n---\n\n## Development notes\n\nThis project, its syntax and its APIs are subject to change at any moment.  \nThis is a personal project, so please bear with me\n\nDifferently put: this is a big red hot pile of experimental garbage right now\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchampii%2Frock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchampii%2Frock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchampii%2Frock/lists"}