revert www changes from a292e07

This commit is contained in:
Anton-4 2025-01-22 17:57:06 +01:00
parent a8def1a974
commit 67c6c66f22
No known key found for this signature in database
GPG key ID: 0971D718C0A9B937
5 changed files with 23 additions and 22 deletions

View file

@ -73,7 +73,7 @@ tokens_to_str : List Token -> Str
tokens_to_str = \tokens ->
List.walk(tokens, "", \buf, token ->
buf_with_space =
if Str.is_empty(buf) or token == Literal(",") then
if Str.is_empty(buf) || token == Literal(",") then
buf
else
Str.concat(buf, " ")

View file

@ -242,14 +242,14 @@ fromU8 = \r, g, b, a -> @Color (RgbaU8 r g b a)
fromI16 : I16, I16, I16, I16 -> Result Color [OutOfRange]
fromI16 = \r, g, b, a ->
if r < 0 or r > 255 or g < 0 or g > 255 or b < 0 or b > 255 or a < 0 or a > 255 then
if r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255 || a < 0 || a > 255 then
Err OutOfRange
else
Ok (@Color (RgbaU8 (Num.toU8 r) (Num.toU8 g) (Num.toU8 b) (Num.toU8 a)))
fromF32 : F32, F32, F32, F32 -> Result Color [OutOfRange]
fromF32 = \r, g, b, a ->
if r < 0.0 or r > 1.0 or g < 0.0 or g > 1.0 or b < 0.0 or b > 1.0 or a < 0.0 or a > 1.0 then
if r < 0.0 || r > 1.0 || g < 0.0 || g > 1.0 || b < 0.0 || b > 1.0 || a < 0.0 || a > 1.0 then
Err OutOfRange
else
Ok (@Color (RgbaF32 r g b a))

View file

@ -359,8 +359,8 @@ As a historical note, these stylistic benefits (of `|> Num.sub 1` working as exp
### [Currying and learning curve](#curried-learning-curve) {#curried-learning-curve}
Currying leads to function signatures that look surprising to beginners. For example, in Roc, the
[`Str.concat`](https://www.roc-lang.org/builtins/Str#concat) function has the type `Str, Str -> Str`. If Roc were a
curried language, this function would instead have the type `Str -> Str -> Str`. Since no mainstream programming
[`Bool.and`](https://www.roc-lang.org/builtins/Bool#and) function has the type `Bool, Bool -> Bool`. If Roc were a
curried language, this function would instead have the type `Bool -> Bool -> Bool`. Since no mainstream programming
languages today are curried, anyone who knows a mainstream language and is learning their first curried language will
require additional explanation about why function types look this way.

View file

@ -640,7 +640,7 @@ We refer to whatever comes before a `->` in a `when` expression as a _pattern_
In many programming languages, `true` and `false` are special language keywords that refer to the two [boolean](https://en.wikipedia.org/wiki/Boolean_data_type) values. In Roc, booleans do not get special keywords; instead, they are exposed as the ordinary values `Bool.true` and `Bool.false`.
This design is partly to keep the number of special keywords in the language smaller, but mainly to suggest how booleans are intended to be used in Roc: for [_boolean logic_](https://en.wikipedia.org/wiki/Boolean_algebra) (`and`, `or`, and so on) as opposed to for data modeling. Tags are the preferred choice for data modeling, and having tag values be more concise than boolean values helps make this preference clear.
This design is partly to keep the number of special keywords in the language smaller, but mainly to suggest how booleans are intended to be used in Roc: for [_boolean logic_](https://en.wikipedia.org/wiki/Boolean_algebra) (`&&`, `||`, and so on) as opposed to for data modeling. Tags are the preferred choice for data modeling, and having tag values be more concise than boolean values helps make this preference clear.
As an example of why tags are encouraged for data modeling, in many languages it would be common to write a record like `{ name: "Richard", isAdmin: Bool.true }`, but in Roc it would be preferable to write something like `{ name: "Richard", role: Admin }`. At first, the `role` field might only ever be set to `Admin` or `Normal`, but because the data has been modeled using tags instead of booleans, it's much easier to add other alternatives in the future, like `Guest` or `Moderator` - some of which might also want payloads.
@ -2369,21 +2369,22 @@ Here are various Roc expressions involving operators, and what they desugar to.
| Expression | Desugars To |
| ---------------------------- | ---------------------------------------------------------------------------- |
| `a + b` | `Num.add(a, b)` |
| `a - b` | `Num.sub(a, b)` |
| `a * b` | `Num.mul(a, b)` |
| `a / b` | `Num.div(a, b)` |
| `a // b` | `Num.div_trunc(a, b)` |
| `a ^ b` | `Num.pow(a, b)` |
| `a % b` | `Num.rem(a, b)` |
| `-a` | `Num.neg(a)` |
| `a == b` | `Bool.is_eq(a, b)` |
| `a != b` | `Bool.is_not_eq(a, b)` |
| `a and b` | `if a then b else Bool.false` |
| `a or b` | `if a then Bool.true else b` |
| `!a` | `Bool.not(a)` |
| <code>a \|> f</code> | `f(a)` |
| <code>f a b \|> g x y</code> | `g(f(a, b), x, y)` |
| `a + b` | `Num.add a b` |
| `a - b` | `Num.sub a b` |
| `a * b` | `Num.mul a b` |
| `a / b` | `Num.div a b` |
| `a // b` | `Num.divTrunc a b` |
| `a ^ b` | `Num.pow a b` |
| `a % b` | `Num.rem a b` |
| `-a` | `Num.neg a` |
| `a == b` | `Bool.isEq a b` |
| `a != b` | `Bool.isNotEq a b` |
| `a && b` | `Bool.and a b` |
| <code>a \|\| b</code> | `Bool.or a b` |
| `!a` | `Bool.not a` |
| <code>a \|> f</code> | `f a` |
| <code>f a b \|> g x y</code> | `g (f a b) x y` |
| `f!` | [see example](https://www.roc-lang.org/examples/DesugaringAwait/README.html) |
| `f?` | [see example](https://www.roc-lang.org/examples/DesugaringTry/README.html) |
### [Additional Resources](#additional-resources) {#additional-resources}

View file

@ -111,7 +111,7 @@ view = \page_path_str, html_content ->
"/index.html" -> [id("homepage-main")]
"/tutorial.html" -> [id("tutorial-main"), class("article-layout")]
_ ->
if Str.starts_with(page_path_str, "/examples/") and page_path_str != "/examples/index.html" then
if Str.starts_with(page_path_str, "/examples/") && page_path_str != "/examples/index.html" then
# Individual examples should render wider than articles.
# Otherwise the width is unreasonably low for the code blocks,
# and those pages don't tend to have big paragraphs anyway.