Skip to content

Commit

Permalink
v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Champii committed Apr 19, 2022
2 parents 552e0bd + 204fc24 commit ffcd530
Show file tree
Hide file tree
Showing 83 changed files with 3,980 additions and 2,785 deletions.
5 changes: 5 additions & 0 deletions .github/templates/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ bincode = "*"
colored = "2.0.0"
paste = "1.0.5"
rustyline = "9.0.0"
nom = "7.0.0"
nom_locate = "4.0.0"

[build-dependencies]
walkdir = "2"

[lib]
name = "rock"
Expand Down
109 changes: 61 additions & 48 deletions .github/templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

[![Rust](https://github.com/Champii/Rock/actions/workflows/rust.yml/badge.svg?branch={branch})](https://github.com/Champii/Rock/actions/workflows/rust.yml)

Little toy language made with Rust and LLVM.
Aim to follow the Rust model with enforced safeness with a borrow checker and native performances thanks to LLVM.
It's highly inspired from Livescript, and will borrow (pun intended) some features and syntaxes from Crystal, from functional languages like Haskell, or even from Rust itself.
Little language made with Rust and LLVM.

Aim to follow the enforced safeness of the Rust model with a borrow checker (Soon™) and achieve high native performances thanks to LLVM.
Rock is highly inspired from Livescript and Rust, and will also borrow (pun intended) some features from Crystal, from functional languages like Haskell, and even from Rust itself.

No to be taken seriously (yet)

# VTable
- [Features]( #features )
Expand All @@ -13,9 +16,11 @@ It's highly inspired from Livescript, and will borrow (pun intended) some featur
- [With cargo from Git]( #with-cargo-from-git )
- [From sources]( #from-sources )
- [Quickstart]( #quickstart )
- [Basic setup]( #basic-setup )
- [REPL]( #repl )
- [Showcases]( #showcases )
- [Polymorphic function]( #polymorphic-function )
- [Custom infix operator]( #custom-infix-operator )
- [Trait definition]( #trait-definition )
- [REPL]( #repl )
- [Development notes]( #development-notes )

## Features
Expand All @@ -24,7 +29,7 @@ It's highly inspired from Livescript, and will borrow (pun intended) some featur
- Type inference
- Custom operators
- Typeclass (Traits)
- Parametric Polymorphism by default
- Polymorphism by default
- Compile to LLVM IR
- REPL (ALPHA)

Expand Down Expand Up @@ -55,7 +60,7 @@ You will need `llvm-12.0.1` and `clang-12.0.1` somewhere in your $PATH
#### With cargo from git

``` sh
cargo install --git https://github.com/Champii/Rock
cargo install --git https://github.com/Champii/Rock --locked
rock -V
```

Expand All @@ -69,8 +74,6 @@ cargo run -- -V

## Quickstart

### Basic setup

Lets create a new project folder to compute some factorials

``` sh
Expand All @@ -79,14 +82,14 @@ mkdir -P factorial/src && cd factorial

Add some files like this:

- Copy the std lib files from [std](https://github.com/Champii/Rock/blob/master/std/src) into `./src/`
- Copy all the stdlib files from [std/src/\*.rk](https://github.com/Champii/Rock/blob/master/std/src) into `factorial/src/`

- Create a `./src/main.rk` file:
- Create a `factorial/src/main.rk` file:

```haskell
mod lib

use lib::prelude::*
use lib::prelude::(*)

fact a =
if a <= 1
Expand All @@ -110,45 +113,17 @@ Should output

Take a look at `rock --help` for a quick tour of its flags and arguments

### REPL

You can start a REPL session with

``` sh
rock -r
# OR
rock --repl
```

``` sh
Rock: {version}
----

Type ':?' for help

> add a b = a + b
> let x = 30
30
> let y = 12
12
> add x, y
42
> :t add
add: (Int64 -> Int64 -> Int64)
> _
```

Only supports basic expressions for now.
Note that you currently must be at the project root to run the compiler. (i.e. inside the `./factorial/` folder)

## Showcases

### Polymophic function
### Polymorphic function


``` haskell
mod lib

use lib::prelude::*
use lib::prelude::(*)

id a = a

Expand All @@ -175,7 +150,7 @@ Test
``` haskell
mod lib

use lib::prelude::*
use lib::prelude::(*)

infix |> 1
|> x f = f x
Expand All @@ -198,7 +173,7 @@ This `trait ToString` is redondant with the `trait Show` implemented in the lib,
``` haskell
mod lib

use lib::prelude::*
use lib::prelude::(*)

trait ToString a
toString :: a -> String
Expand Down Expand Up @@ -231,7 +206,7 @@ Prints
``` haskell
mod lib

use lib::prelude::*
use lib::prelude::(*)

struct Player
level :: Int64
Expand All @@ -255,8 +230,46 @@ rock run

Prints `MyName`

## REPL

Only supports basic expressions for now.
Very unstable, very work in progress.

Be warned that for a given session, the whole code is re-executed at each entry.
This includes I/O of all sorts (Looking at you, open/read/write in loops)

Note that the REPL expects to be run from the project root, and expects some version of the stdlib
to be available in the `./src` folder

You can start a REPL session with

``` sh
rock -r
# OR
rock --repl
```

``` sh
Rock: {version}
----

Type ':?' for help

> add a b = a + b
> let x = 30
30
> let y = 12
12
> add x, y
42
> :t add
add: (Int64 -> Int64 -> Int64)
> _
```

## Development notes

This project, its syntax and its APIs are subject to change at any moment.
This is a personal project, so please bear with me
(Differently put: this is a big red hot pile of experimental garbage right now)
This is a personal project, so please bear with me

Differently put: this is a big red hot pile of experimental garbage right now
2 changes: 1 addition & 1 deletion .github/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.1.7
v0.2.0
69 changes: 66 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rock"
version = "0.1.7"
version = "0.2.0"
authors = ["champii <contact@champii>"]
edition = "2018"

Expand All @@ -20,6 +20,11 @@ bincode = "*"
colored = "2.0.0"
paste = "1.0.5"
rustyline = "9.0.0"
nom = "7.0.0"
nom_locate = "4.0.0"

[build-dependencies]
walkdir = "2"

[lib]
name = "rock"
Expand Down
Loading

0 comments on commit ffcd530

Please sign in to comment.