Skip to content

Commit b552466

Browse files
authored
glossary: type signature + typos upgrade (#7776)
* glossary: type signature Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> * ignore toolchain for typos Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> * fix typos * put toolchain file back --------- Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com>
1 parent c320a1b commit b552466

23 files changed

Lines changed: 89 additions & 63 deletions

File tree

.github/workflows/alwayscheck.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ jobs:
2323
steps:
2424
- uses: actions/checkout@v4
2525

26-
- run: cargo install typos-cli --version 1.0.11
26+
- run: rm rust-toolchain.toml
2727

28-
- name: do spell check with typos-cli 1.0.11
28+
- run: cargo install typos-cli --version 1.32.0
29+
30+
- name: do spell check with typos-cli 1.32.0
2931
run: typos
3032

3133
- name: setup Roc
@@ -39,4 +41,4 @@ jobs:
3941
4042
- run: roc version
4143

42-
- run: roc ./ci/glossary-link-checker.roc
44+
- run: roc ./ci/glossary-link-checker.roc

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ roc_linux_x86_64.tar.gz
8181
# macOS .DS_Store files
8282
.DS_Store
8383

84-
# files geneated when formatting fails
84+
# files generated when formatting fails
8585
*.roc-format-failed
8686
*.roc-format-failed-ast-after
8787
*.roc-format-failed-ast-before

Glossary.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Here you can find definitions for words that are commonly used in the **compiler
22
with links to the codebase. Check https://www.roc-lang.org/tutorial if you want to know
33
about general Roc terms. Feel free to ask for a term to be added or add one yourself!
44

5-
Contributor note: definitons should be roughly ordered like in a tutorial, e.g.
5+
Contributor note: definitions should be roughly ordered like in a tutorial, e.g.
66
Parser should be explained before Canonicalization.
77

88
## CLI
@@ -132,12 +132,28 @@ Desugaring in the compiler:
132132

133133
## Type Signature
134134

135-
TODO
135+
Specifies the type of a variable. For example, the type signature of `Str.concat` is:
136+
```
137+
concat : Str, Str -> Str
138+
```
139+
Here it specifies `concat` takes two strings as input and produces one as output.
140+
141+
In the compiler, the type signature specified in the source code has priority over the type found by [type inference](#type-inference), although both need to match for your code to compile completely.
142+
143+
Type annotations are basically the same thing as type signatures and both terms are used interchangeably throughout the compiler.
144+
145+
Parsing of type signatures:
146+
- New compiler: [Parser.zig](src/check/parse/Parser.zig) (search signature)
147+
- Old compiler: [ast.rs](crates/compiler/parse/src/ast.rs) (search TypeAnnotation)
136148

137149
## Type Alias
138150

139151
TODO
140152

153+
## Type Variable
154+
155+
TODO
156+
141157
## Compiler Phase
142158

143159
A compiler phase is a distinct stage in the process the compiler goes through to translate high-level source code into machine code that a computer can execute. Compilers don’t just do this in one big step, they break it down into several phases, each handling a specific task. Some examples of phases: [tokenization](#tokenization), [parsing](#parsing), [code generation](#code-gen),... .

build.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ fn llvmPaths(
326326
};
327327
}
328328

329-
// No user specified llvm. Go download it from roc-boostrap.
329+
// No user specified llvm. Go download it from roc-bootstrap.
330330
const raw_triple = target.result.linuxTriple(b.allocator) catch @panic("OOM");
331331
if (!supported_deps_triples.has(raw_triple)) {
332332
std.log.err("Target triple({s}) not supported by roc-bootstrap.\n", .{raw_triple});

ci/glossary-link-checker.roc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ main! = |_args|
3030
3131
when full_check_res is
3232
Ok(_) ->
33-
Stdout.line!("Successfuly checked $(List.len(md_links) |> Num.to_str) links.")
33+
Stdout.line!("Successfully checked $(List.len(md_links) |> Num.to_str) links.")
3434
Err(_) ->
3535
Err(Exit(1, "Link check failed. Please check the above errors."))
3636

crates/docs/src/static/styles.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -962,8 +962,8 @@ code .keyword.operator {
962962
}
963963

964964
/* Delimieters */
965-
samp .delimeter,
966-
code .delimeter {
965+
samp .delimiter,
966+
code .delimiter {
967967
color: var(--gray);
968968
}
969969

crates/highlight/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub fn highlight(code: &str) -> Vec<String> {
8585
| Token::Comma
8686
| Token::Bar
8787
| Token::Decimal => {
88-
buf = push_html_span(buf, current_text, "delimeter");
88+
buf = push_html_span(buf, current_text, "delimiter");
8989
}
9090
// Types, Tags, and Modules
9191
Token::UpperIdent | Token::AtSign => {

crates/linker/src/elf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ fn gen_elf_le(
738738
}
739739
}
740740
// To correctly remove the JUMP_SLOT relocations for Roc functions we:
741-
// 1. collect the indicies of all of them.
741+
// 1. collect the indices of all of them.
742742
// 2. move them all to the end of the relocation sections.
743743
// 3. shrink the relocation section to ignore them.
744744
// 4. update the dynamic section to reflect the shrink as well.

design/editor/editor-ideas.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ e.g. you have a test `calculate_sum_test` that only uses the function `add`, whe
5555
- I think it could be possible to create a minimal reproduction of a program / block of code / code used by a single test. So for a failing unit test I would expect it to extract imports, the platform, types and functions that are necessary to run only that unit test and put them in a standalone roc project. This would be useful for sharing bugs with library+application authors and colleagues, for profiling or debugging with all "clutter" removed.
5656
- Ability to share program state at a breakpoint with someone else.
5757
- For debugging we should aim for maximal useful observability. For example Rust's enum values can not be easily viewed in the CodeLLDB debugger, you actually need to call a print method that does pattern matching to be able to view useful information.
58-
- We previuously discussed recording full traces of programs so they do not have to be re-run multiple times in the debugging process. We should encourage roc developers to experiment with creating debugging representations of this AST+"execution trace", it could lead to some cool stuff.
59-
- We previuously mentioned showing expression values next to the code. I think when debugging it would be valuable to focus more on these valuas/data. A possible way to do this would be to create scrollable view(without need to jump between files) of inputs and outputs of user defined functions. Clicking on a function could then show the code with the expression values side by side. Having a good overview of how the values change could make it easy to find where exactly things go wrong.
58+
- We previously discussed recording full traces of programs so they do not have to be re-run multiple times in the debugging process. We should encourage roc developers to experiment with creating debugging representations of this AST+"execution trace", it could lead to some cool stuff.
59+
- We previously mentioned showing expression values next to the code. I think when debugging it would be valuable to focus more on these valuas/data. A possible way to do this would be to create scrollable view(without need to jump between files) of inputs and outputs of user defined functions. Clicking on a function could then show the code with the expression values side by side. Having a good overview of how the values change could make it easy to find where exactly things go wrong.
6060

6161
- (Machine learning) algorithms to extract and show useful information from debug values.
6262
- Ability to mark e.g. a specific record field for tracking(filter out the noise) that is being repeatedly updated throughout the program.
@@ -147,7 +147,7 @@ e.g. you have a test `calculate_sum_test` that only uses the function `add`, whe
147147
- open google/github/duckduckgo search for error...
148148
- show editor plugins for library X
149149
- commands to control log filtering
150-
- collaps all arms of when
150+
- collapse all arms of when
151151
- "complex" filtered search: search for all occurrences of `"#` but ignore all like `"#,`
152152
- color this debug print orange
153153
- remove unused imports

design/language/Abilities.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ isNotEq : Dict k v, Dict k v -> Bool
348348
In this `Eq { isEq, isNotEq }` declaration, I'm saying that `isEq` and `isNotEq` are functions already in scope. I could also choose different names using record literal syntax, e.g. `Eq { isEq: dictIsEq, isNotEq: dictIsNotEq }` - the relevant part is that I'm specifying the names of the functions (which must also be in scope) which specify how `Eq` for Dict should work.
349349

350350
Now that I've specified this, when I use `==` on two `Dict` values, this `isEq` function will get run instead of the default `==` implementation. This solves [Problem #3](#problem-3-decoders-are-still-hard-to-learn)!
351-
I can also write something like has `Num` and provide the relevant functions to obtain a unit-ful number type - which solves [Problem #2](#problem-2-custom-number-types-cant-use-arithmetic-operators).
351+
I can also write something like has `Num` and provide the relevant functions to obtain a unit-ful number type, which solves [Problem #2](#problem-2-custom-number-types-cant-use-arithmetic-operators).
352352

353353
### Default Abilities for Newtypes
354354

0 commit comments

Comments
 (0)