Skip to content

Commit

Permalink
Updated README with more concise instructions (#82)
Browse files Browse the repository at this point in the history
* Fixed up some of the README
Added Rust nightly install instructions for source building.
Cleared up some of the showcases so they were more compact (the expected output, not the code bits)
Fixed the index according to Common Markdown Linting
  • Loading branch information
oraqlle authored Jun 4, 2022
1 parent 97e477a commit 618b112
Show file tree
Hide file tree
Showing 30 changed files with 674 additions and 231 deletions.
1 change: 1 addition & 0 deletions .github/templates/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ paste = "1.0.5"
rustyline = "9.0.0"
nom = "7.0.0"
nom_locate = "4.0.0"
itertools = "0.10.3"

[build-dependencies]
walkdir = "2"
Expand Down
170 changes: 127 additions & 43 deletions .github/templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,29 @@ Rock is highly inspired from Livescript and Rust, and will also borrow (pun inte

No to be taken seriously (yet)

# Index
- [Features]( #features )
- [Install]( #install )
- [Using released binary]( #using-released-binary )
- [With cargo from Git]( #with-cargo-from-git )
- [From sources]( #from-sources )
- [Quickstart]( #quickstart )
- [Showcases]( #showcases )
- [Polymorphic function]( #polymorphic-function )
- [Custom infix operator]( #custom-infix-operator )
- [Trait definition]( #trait-definition )
- [REPL]( #repl )
- [Development notes]( #development-notes )
## Index

- [Rock {version}](#rock-{version})
- [Index](#index)
- [Features](#features)
- [Install](#install)
- [Using Released Binary](#using-released-binary)
- [From source](#from-source)
- [Adding Rust Nightly](#adding-rust-nightly)
- [With Cargo from Git](#with-cargo-from-git)
- [Manual Clone and Build from Git](#manual-clone-and-build-from-git)
- [Quickstart](#quickstart)
- [Showcases](#showcases)
- [Polymorphic function](#polymorphic-function)
- [Custom infix operator](#custom-infix-operator)
- [Trait Definition](#trait-definition)
- [Struct instance and methods]( #struct-instance-and-methods )
- [Show implementation]( #show-implementation )
- [Modules and Code Separation](#modules-and-code-separation)
- [REPL](#repl)
- [Development notes](#development-notes)

---

## Features

Expand All @@ -33,13 +43,15 @@ No to be taken seriously (yet)
- Compile to LLVM IR
- REPL (ALPHA)

---

## Install

Warning: This project has only been tested on Linux x86_64.

How to install and run the compiler:

### Using released binary
### Using Released Binary

You will need `clang` somewhere in your $PATH

Expand All @@ -57,21 +69,81 @@ chmod +x rock

You will need `llvm-12.0.1` and `clang-12.0.1` somewhere in your $PATH

#### With cargo from git
You will also want the nightly channel added for Rust.

#### Adding Rust Nightly

To check if you already have the nightly channel added for Rust, use:

```sh
rustup show
```

This will give you infomation about which build channels you have for rust and which one is active. If you have the nightly, you should see something like this:

```sh
Default host: x86_64-unknown-linux-gnu
rustup home: /home/<username>/.rustup

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu (default)
nightly-x86_64-unknown-linux-gnu

active toolchain
----------------

stable-x86_64-unknown-linux-gnu (default)
rustc 1.61.0 (fe5b13d68 2022-05-18)
```

If you don't see the nightly build you can add it using the following command:

```sh
rustup install nightly
```

This will add the option to use the nightly build of Rust for this and any other projects.
Note you don't have to switch to the nightly to be the active toolchain but can use it specific projects, see below.

#### With Cargo from Git

If your active toolchain is stable:

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

If your active rust toolchain is nightly:

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

#### Manual clone and build from git
#### Manual Clone and Build from Git

If your active toolchain is stable:

```sh
git clone https://github.com/Champii/Rock.git rock
cd rock
cargo +nightly run --<release|debug> -- -V
```

If your active toolchain is nightly:
You can pick the release or debug build

``` sh
git clone https://github.com/Champii/Rock.git
cd Rock
cargo run -- -V
git clone https://github.com/Champii/Rock.git rock
cd rock
cargo run --<release|debug> -- -V
```

Note: If you clone and build manually, make sure to add `path-to-install/rock/target/<release|debug>/` to you `$PATH` so you can run it anywhere on your system.

## Quickstart

- Lets create a new project folder to compute some factorials
Expand All @@ -94,12 +166,7 @@ main = print fact 4
Assuming that you built Rock and put its binary in your PATH:

``` sh
rock run
```

Should output

``` sh
$ rock run
24
```

Expand All @@ -111,7 +178,6 @@ Note that you currently must be at the project root to run the compiler. (i.e. i

### Polymorphic function


``` haskell
id a = a

Expand All @@ -121,13 +187,10 @@ main =
print id "Test"
```

``` sh
rock run
```

Prints

``` sh
$ rock run
1
2.2
Test
Expand All @@ -139,7 +202,8 @@ If we did something like this
We would have constrained `a` to types that implement [`Num`](https://github.com/Champii/Rock/blob/master/std/src/num.rk)

Note that this example would still be valid, as `Int64`, `Float64` and `String` are all implementors of `Num`(*).
The output would be

The output would be:

``` sh
2
Expand All @@ -161,11 +225,10 @@ main = print (4 |> f)
```

``` sh
rock run
$ rock run
6
```

Prints `6`

You can create any operator that is made of any combination of one or more of `'+', '-', '/', '*', '|', '<', '>', '=', '!', '$', '@', '&'`

Most of the commonly defined operators like `+`, `<=`, etc are already implemented by the [stdlib](https://github.com/Champii/Rock/tree/master/std) that is automaticaly compiled with every package.
Expand All @@ -192,17 +255,36 @@ main =
```

``` sh
rock run
$ rock run
33
42.42
```

Prints
### Struct instance and methods

``` haskell
struct Player
level :: Int64
name :: String

impl Player
new level =
Player
level: level
name: "Default"
getlevel player = player.level

main =
let player = Player::new 1
print Player::getlevel player
```
33
42.42

``` sh
$ rock run
1
```

### Struct instance and Show implementation
### Show implementation

``` haskell
struct Player
Expand All @@ -222,11 +304,10 @@ main =
```

``` sh
rock run
$ rock run
MyName
```

Prints `MyName`

### Modules and code separation

- `./myproj/src/foo.rk`
Expand All @@ -245,7 +326,10 @@ use foo::bar
main = print bar 1
```

Prints `2`
```sh
$ rock run
2
```

Note that we could have skiped the
`use foo::bar`
Expand Down
2 changes: 1 addition & 1 deletion .github/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.2.2
v0.2.3
12 changes: 11 additions & 1 deletion Cargo.lock

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

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

Expand All @@ -22,6 +22,7 @@ paste = "1.0.5"
rustyline = "9.0.0"
nom = "7.0.0"
nom_locate = "4.0.0"
itertools = "0.10.3"

[build-dependencies]
walkdir = "2"
Expand Down
Loading

0 comments on commit 618b112

Please sign in to comment.