forked from gleam-lang/gleam
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
1,409 additions
and
403 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
# Comparison to Erlang and Elixir | ||
# Language Tour | ||
|
||
Being another functional language on the BEAM (the Erlang virual machine) | ||
Gleam is very similar to both Erlang and Elixir, albeit with a static type | ||
system. | ||
In this chapter we explore the fundamentals of the Gleam language, namely its | ||
syntax, core data structures, flow control features, and static type system. | ||
|
||
This chapter aims to give Erlang and Elixir users enough knowledge to start | ||
writing reading and writing Gleam code. | ||
After completion the reader should know enough to start reading and writing | ||
Gleam code, assuming they have some prior programming experience. | ||
|
||
In some section we touch on the runtime representation of various features. | ||
This is useful for programmers with Erlang or Elixir experience who wish to | ||
use Gleam alongside these languages. If you are using Gleam alone this | ||
information can be safely ignored. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Case |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# External function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# External type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,14 @@ | ||
# Variables | ||
# Let bindings | ||
|
||
A value can be given a name using `let`. Names can be reused by later let | ||
bindings, but the values contained are _immutable_, meaning the values | ||
themselves cannot be changed. | ||
|
||
```rust,noplaypen | ||
// Gleam | ||
let x = 1 | ||
let x = 2 | ||
``` | ||
``` | ||
# Elixir | ||
x = 1 | ||
x = 2 | ||
``` | ||
``` | ||
% Erlang | ||
X = 1. | ||
X = 2. % Runtime error! Erlang doesn't allow rebinding | ||
``` | ||
|
||
Pattern matching can be used to extract contained values from data structures | ||
when defining variables with `let`. | ||
let y = x | ||
let y = 2 | ||
```rust,noplaypen | ||
// Gleam | ||
let {x, y} = {1, 2.0} | ||
``` | ||
``` | ||
# Elixir | ||
{x, y} = {1, 2.0} | ||
``` | ||
``` | ||
% Erlang | ||
{X, Y} = {1, 2.0}. | ||
x // => 1 | ||
y // => 2 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# String | ||
|
||
Gleam's has UTF-8 binary strings, written as text surrounded by double quotes. | ||
|
||
```rust,noplaypen | ||
"Hello, Gleam!" | ||
``` | ||
|
||
Strings can span multiple lines. | ||
|
||
```rust,noplaypen | ||
"Hello | ||
Gleam!" | ||
``` | ||
|
||
Special characters such as `"` need to be escaped with a `\` character. | ||
|
||
```rust,noplaypen | ||
"Here is a double quote -> \" <-" | ||
``` |
Oops, something went wrong.