Skip to content

Commit

Permalink
Merge pull request #119 from bzy-debug/zhiyuan/fix-markdown
Browse files Browse the repository at this point in the history
fix lint error
  • Loading branch information
bzy-debug authored Dec 5, 2023
2 parents 83cce83 + 2c072ee commit 98ffea6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# MoonBit

MoonBit is an end-to-end programming language toolchain for cloud and edge computing using WebAssembly.
The IDE environment is available at <https://try.moonbitlang.com> without any installation; it does not rely on any server either.
The IDE environment is available at [https://try.moonbitlang.com](https://try.moonbitlang.com) without any installation; it does not rely on any server either.

## Status

Expand Down Expand Up @@ -201,7 +201,7 @@ To improve readability, you may place underscores in the middle of numeric liter

- There is nothing surprising about decimal numbers.

```
```rust
let a = 1234
let b = 1_000_000 + a
let large_num = 9_223_372_036_854_775_807L // Integers of the Int64 type must have an 'L' as a suffix
Expand All @@ -210,23 +210,23 @@ let large_num = 9_223_372_036_854_775_807L // Integers of the Int64 type must ha
- A binary number has a leading zero followed by a letter "B", i.e. `0b`/`0B`.
Note that the digits after `0b`/`0B` must be `0` or `1`.

```
```rust
let bin = 0b110010
let another_bin = 0B110010
```

- An octal number has a leading zero followed by a letter "O", i.e. `0o`/`0O`.
Note that the digits after `0o`/`0O` must be in the range from `0` through `7`:

```
```rust
let octal = 0o1234
let another_octal = 0O1234
```

- A hexadecimal number has a leading zero followed by a letter "X", i.e. `0x`/`0X`.
Note that the digits after the `0x`/`0X` must be in the range `0123456789ABCDEF`.

```
```rust
let hex = 0XA
let another_hex = 0xA
```
Expand Down Expand Up @@ -359,13 +359,13 @@ struct Stack {

#### Constructing Struct with Shorthand

If you already have some variable like `name` and `email`, it's redundant to repeat those name when constructing a struct:
If you already have some variable like `name` and `email`, it's redundant to repeat those name when constructing a struct:

```go
fn init{
let name = "john"
let email = "[email protected]"
let u = { id: 0, name: name, email: email }
let u = { id: 0, name: name, email: email }
}
```

Expand All @@ -391,9 +391,9 @@ struct User {
}

fn to_string(self : User) -> String {
"{ id: " + self.id.to_string() +
", name: " + self.name +
", email: " + self.email + " }"
"{ id: " + self.id.to_string() +
", name: " + self.name +
", email: " + self.email + " }"
}

fn init {
Expand Down Expand Up @@ -767,8 +767,10 @@ fn two[X: I]() -> X {
```

## Automatically derive builtin interface

Moonbit can automatically derive implementations for some builtin interfaces:
```

```rust
struct T {
x: Int
y: Int
Expand Down
16 changes: 11 additions & 5 deletions build-system-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

Before you begin with this tutorial, make sure you have installed the following:

1. **MoonBit CLI Tools**: Download it from the <https://www.moonbitlang.com/download/>. This command line tool is needed for creating and managing MoonBit projects.
1. **MoonBit CLI Tools**: Download it from the [https://www.moonbitlang.com/download/](https://www.moonbitlang.com/download/). This command line tool is needed for creating and managing MoonBit projects.

Use `moon help` to view the usage instructions.

```
```bash
$ moon help
Moonbit's build system
Expand Down Expand Up @@ -39,7 +39,7 @@ Once you have these prerequisites fulfilled, let's start building a new module i
To create a new module, use the `moon new hello` command in your terminal:

```bash
$ moon new hello
moon new hello
```

This command will create a new module named `hello`.
Expand All @@ -64,7 +64,9 @@ Here's a brief explanation of the directory structure:
- `lib` and `main` directories: These are packages in the module. Each package can contain multiple `.mbt` files, which are the source code files in MoonBit language. However, regardless of the number of `.mbt` files in a package, they all share a common `moon.pkg.json` file.

- `moon.pkg.json` is package descriptor. It defines the properties of the package, such as whether it is the main package and the packages it imports.

- `main/moon.pkg.json`:

```json
{
"is_main": true,
Expand All @@ -73,11 +75,15 @@ Here's a brief explanation of the directory structure:
}
}
```

Here, "is_main: true" declares that the package needs to be linked by the build system into a wasm file.

- `lib/moon.pkg.json`:

```json
{}
```

This file is empty. Its purpose is simply to inform the build system that this folder is a package.

- `moon.mod.json` is used to identify a directory as a MoonBit module. It contains the module's name:
Expand Down Expand Up @@ -146,7 +152,7 @@ Here, `"hello/lib": ""` specifies that the `lib` package from the `hello` module
First, create a new directory named `fib` under `lib`:

```bash
$ mkdir lib/fib
mkdir lib/fib
```

Now, you can create new files under `lib/fib`:
Expand Down Expand Up @@ -187,7 +193,7 @@ pub fn fib2(num : Int) -> Int {

After creating these files, your directory structure should look like this:

```
```bash
.
├── lib
│ ├── fib
Expand Down

0 comments on commit 98ffea6

Please sign in to comment.