Skip to content

Fix broken links and some cases of an Gren => a Gren. #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions builder/src/Reporting/Exit.hs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ diffToReport diff =
[ D.indent 4 $ D.red $ D.fromChars $ Pkg.toChars pkg,
"Maybe you want one of these instead?",
D.indent 4 $ D.dullyellow $ D.vcat $ map (D.fromChars . Pkg.toChars) suggestions,
"But check <https://package.gren-lang.org> to see all possibilities!"
"But check <https://packages.gren-lang.org> to see all possibilities!"
]
DiffUnknownVersion _pkg vsn realVersions ->
Help.docReport
Expand Down Expand Up @@ -226,7 +226,7 @@ bumpToReport bump =
"that",
"version",
"on",
"<https://package.gren-lang.org>.",
"<https://packages.gren-lang.org>.",
"That",
"means",
"there",
Expand Down Expand Up @@ -2107,7 +2107,7 @@ makeToReport make =
D.indent 2 $ D.fillSep [D.cyan "Html" <> ".text", D.dullyellow "\"Hello!\""]
],
D.reflow $
"Or use https://package.gren-lang.org/packages/gren/core/latest/Platform#worker to\
"Or use https://packages.gren-lang.org/package/gren-lang/core/latest/module/Platform#worker to\
\ make a `main` with no user interface."
]
_ : _ ->
Expand All @@ -2134,7 +2134,7 @@ makeToReport make =
D.indent 2 $ D.fillSep [D.cyan "Html" <> ".text", D.dullyellow "\"Hello!\""]
],
D.reflow $
"Or use https://package.gren-lang.org/packages/gren/core/latest/Platform#worker to\
"Or use https://packages.gren-lang.org/package/gren-lang/core/latest/module/Platform#worker to\
\ make a `main` with no user interface."
]
MakeCannotBuild buildProblem ->
Expand Down
83 changes: 2 additions & 81 deletions compiler/src/Reporting/Error/Canonicalize.hs
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,10 @@ toReport source err =
D.stack
[ D.reflow $
"If you want the behavior of (%) like in JavaScript, switch to:\
\ <https://package.gren-lang.org/packages/gren/core/latest/Basics#remainderBy>",
\ <https://packages.gren-lang.org/package/gren-lang/core/latest/module/Math#remainderBy>",
D.reflow $
"If you want modular arithmetic like in math, switch to:\
\ <https://package.gren-lang.org/packages/gren/core/latest/Basics#modBy>",
\ <https://packages.gren-lang.org/package/gren-lang/core/latest/module/Math#modBy>",
D.reflow $
"The difference is how things work when negative numbers are involved."
]
Expand Down Expand Up @@ -1097,85 +1097,6 @@ toQualString :: Name.Name -> Name.Name -> String
toQualString prefix name =
Name.toChars prefix ++ "." ++ Name.toChars name

{-- VAR ERROR

varErrorToReport :: VarError -> Report.Report
varErrorToReport (VarError kind name problem suggestions) =
let
learnMore orMaybe =
D.reflow $
orMaybe <> " `import` works different than you expect? Learn all about it here: "
<> D.hintLink "imports"

namingError overview maybeStarter specializedSuggestions =
Report.reportDoc "NAMING ERROR" Nothing overview $
case D.maybeYouWant' maybeStarter specializedSuggestions of
Nothing ->
learnMore "Maybe"
Just doc ->
D.stack [ doc, learnMore "Or maybe" ]

specialNamingError specialHint =
Report.reportDoc "NAMING ERROR" Nothing (cannotFind kind name) (D.hsep specialHint)
in
case problem of
Ambiguous ->
namingError (ambiguous kind name) Nothing suggestions

UnknownQualifier qualifier localName ->
namingError
(cannotFind kind name)
(Just $ text $ "No module called `" <> qualifier <> "` has been imported.")
(map (\modul -> modul <> "." <> localName) suggestions)

QualifiedUnknown qualifier localName ->
namingError
(cannotFind kind name)
(Just $ text $ "`" <> qualifier <> "` does not expose `" <> localName <> "`.")
(map (\v -> qualifier <> "." <> v) suggestions)

ExposedUnknown ->
case name of
"!=" -> specialNamingError (notEqualsHint name)
"!==" -> specialNamingError (notEqualsHint name)
"===" -> specialNamingError equalsHint
"%" -> specialNamingError modHint
_ -> namingError (cannotFind kind name) Nothing suggestions

cannotFind :: VarKind -> Text -> [Doc]
cannotFind kind rawName =
let ( a, thing, name ) = toKindInfo kind rawName in
[ "Cannot", "find", a, thing, "named", D.dullyellow name <> ":" ]

ambiguous :: VarKind -> Text -> [Doc]
ambiguous kind rawName =
let ( _a, thing, name ) = toKindInfo kind rawName in
[ "This", "usage", "of", "the", D.dullyellow name, thing, "is", "ambiguous." ]

notEqualsHint :: Text -> [Doc]
notEqualsHint op =
[ "Looking", "for", "the", "“not", "equal”", "operator?", "The", "traditional"
, D.dullyellow $ text $ "(" <> op <> ")"
, "is", "replaced", "by", D.green "(/=)", "in", "Gren.", "It", "is", "meant"
, "to", "look", "like", "the", "“not", "equal”", "sign", "from", "math!", "(≠)"
]

equalsHint :: [Doc]
equalsHint =
[ "A", "special", D.dullyellow "(===)", "operator", "is", "not", "needed"
, "in", "Gren.", "We", "use", D.green "(==)", "for", "everything!"
]

modHint :: [Doc]
modHint =
[ "Rather", "than", "a", D.dullyellow "(%)", "operator,"
, "Gren", "has", "a", D.green "modBy", "function."
, "Learn", "more", "here:"
, "<https://package.gren-lang.org/packages/gren/core/latest/Basics#modBy>"
]

-}

-- ARG MISMATCH

_argMismatchReport :: Code.Source -> A.Region -> String -> Name.Name -> Int -> Int -> Report.Report
Expand Down
12 changes: 4 additions & 8 deletions compiler/src/Reporting/Error/Docs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ toReports source err =
source
region
Nothing
( D.reflow $
( D.reflow
"You must have a documentation comment between the module\
\ declaration and the imports.",
D.reflow
"Learn more at <https://package.gren-lang.org/help/documentation-format>"
D.empty
)
ImplicitExposing region ->
NE.singleton $
Expand Down Expand Up @@ -97,11 +96,8 @@ toSyntaxProblemReport source problem =
region
Nothing
( D.reflow "I was partway through parsing your module documentation, but I got stuck here:",
D.stack $
[ D.reflow details,
D.toSimpleHint $
"Read through <https://package.gren-lang.org/help/documentation-format> for\
\ tips on how to write module documentation!"
D.stack
[ D.reflow details
]
)
in case problem of
Expand Down
6 changes: 3 additions & 3 deletions compiler/src/Reporting/Error/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ noteForPortsInPackage =
D.stack
[ D.toSimpleNote $
"One of the major goals of the package ecosystem is to be completely written\
\ in Gren. This means when you install an Gren package, you can be sure you are safe\
\ in Gren. This means when you install a Gren package, you can be sure you are safe\
\ from security issues on install and that you are not going to get any runtime\
\ exceptions coming from your new dependency. This design also sets the ecosystem\
\ up to target other platforms more easily (like mobile phones, WebAssembly, etc.)\
Expand Down Expand Up @@ -792,7 +792,7 @@ toParseErrorReport source modul =
"I got stuck here:",
D.stack
[ D.reflow $
"I am not sure what is going on, but I recommend starting an Gren\
"I am not sure what is going on, but I recommend starting a Gren\
\ file with the following lines:",
D.indent 4 $
D.vcat $
Expand All @@ -803,7 +803,7 @@ toParseErrorReport source modul =
],
D.reflow $
"You should be able to copy those lines directly into your file. Check out the\
\ examples at <https://gren-lang.org/examples> for more help getting started!",
\ examples at <https://github.com/gren-lang/example-projects> for more help getting started!",
D.toSimpleNote $
"This can also happen when something is indented too much!"
]
Expand Down
2 changes: 1 addition & 1 deletion hints/comparing-records.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ viewStudent student =
li [] [ text student.name ]
```

If you are worried about the performance of changing the order or updating information about particular students, you can start using the [`Html.Lazy`](https://package.gren-lang.org/packages/gren/html/latest/Html-Lazy) and [`Html.Keyed`](https://package.gren-lang.org/packages/gren/html/latest/Html-Keyed) modules. The updated code would look something like this:
If you are worried about the performance of changing the order or updating information about particular students, you can start using the [`Html.Lazy`](https://packages.gren-lang.org/package/gren-lang/browser/latest/module/Html.Lazy) and [`Html.Keyed`](https://packages.gren-lang.org/package/gren-lang/browser/latest/module/Html.Keyed) modules. The updated code would look something like this:

```gren
import Html exposing (..)
Expand Down
8 changes: 4 additions & 4 deletions hints/imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ When getting started with Gren, it is pretty common to have questions about how

An Gren file is called a **module**. To access code in other files, you need to `import` it!

So say you want to use the [`div`](http://package.gren-lang.org/packages/gren-lang/html/latest/Html#div) function from the [`gren-lang/html`](http://package.gren-lang.org/packages/gren-lang/html/latest) package. The simplest way is to import it like this:
So say you want to use the [`div`](https://packages.gren-lang.org/package/gren-lang/browser/latest/module/Html#div) function from the [`gren-lang/browser`](https://packages.gren-lang.org/package/gren-lang/browser/latest/overview) package. The simplest way is to import it like this:

```gren
import Html
Expand All @@ -20,7 +20,7 @@ main =
After saying `import Html` we can refer to anything inside that module as long as it is _qualified_. This works for:

- **Values** &mdash; we can refer to `Html.text`, `Html.h1`, etc.
- **Types** &mdash; We can refer to [`Attribute`](http://package.gren-lang.org/packages/gren-lang/html/latest/Html#Attribute) as `Html.Attribute`.
- **Types** &mdash; We can refer to [`Attribute`](https://packages.gren-lang.org/package/gren-lang/browser/latest/module/Html#Attribute) as `Html.Attribute`.

So if we add a type annotation to `main` it would look like this:

Expand All @@ -32,7 +32,7 @@ main =
Html.div [] []
```

We are referring to the [`Html`](http://package.gren-lang.org/packages/gren-lang/html/latest/Html#Html) type, using its _qualified_ name `Html.Html`. This can feel weird at first, but it starts feeling natural quite quickly!
We are referring to the [`Html`](https://packages.gren-lang.org/package/gren-lang/browser/latest/module/Html#Html) type, using its _qualified_ name `Html.Html`. This can feel weird at first, but it starts feeling natural quite quickly!

> **Note:** Modules do not contain other modules. So the `Html` module _does not_ contain the `Html.Attributes` module. Those are separate names that happen to have some overlap. So if you say `import Html` you _do not_ get access to `Html.Attributes.style`. You must `import Html.Attributes` module separately.

Expand All @@ -50,7 +50,7 @@ main =
Html.div [ A.style "color" "red" ] [ Html.text "Hello!" ]
```

Saying `import Html.Attributes as A` lets us refer to any value or type in `Html.Attributes` as long as it is qualified with an `A`. So now we can refer to [`style`](http://package.gren-lang.org/packages/gren-lang/html/latest/Html-Attributes#style) as `A.style`.
Saying `import Html.Attributes as A` lets us refer to any value or type in `Html.Attributes` as long as it is qualified with an `A`. So now we can refer to [`style`](https://packages.gren-lang.org/package/gren-lang/browser/version/6.0.0/module/Html.Attributes#style) as `A.style`.

<br>

Expand Down
6 changes: 3 additions & 3 deletions hints/init.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Creating an Gren project
# Creating a Gren project

The main goal of `gren init` is to get you to this page!

It just creates an `gren.json` file and a `src/` directory for your code.

## What is `gren.json`?

This file describes your project. It lists all of the packages you depend upon, so it will say the particular version of [`gren/core`](https://package.gren-lang.org/packages/gren/core/latest/) and [`gren/html`](https://package.gren-lang.org/packages/gren/html/latest/) that you are using. It makes builds reproducible! You can read a bit more about it [here](https://github.com/gren/compiler/blob/master/docs/gren.json/application.md).
This file describes your project. It lists all of the packages you depend upon, so it will say the particular version of [`gren-lang/core`](https://packages.gren-lang.org/package/gren-lang/core/latest/overview) and [`gren-lang/browser`](https://packages.gren-lang.org/package/gren-lang/browser/latest/overview) that you are using. It makes builds reproducible! You can read a bit more about it [here](https://gren-lang.org/book/appendix/gren_json/).

You should generally not edit it by hand. It is better to add new dependencies with commands like `gren install gren/http` or `gren install gren/json`.
You should generally not edit it by hand. It is better to add new dependencies with commands like `gren package install gren-lang/test` or `gren package install gren-lang/parser`.

## What goes in `src/`?

Expand Down
2 changes: 1 addition & 1 deletion hints/missing-patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Now the compiler will say "hey, what should `toName` do when it sees a `Visitor`

Imagine that the `User` type appears in 20 or 30 functions across your project. When we add a `Visitor` variant, the compiler points out all the places that need to be updated. That is very convenient, but in a big project, maybe you want to get through it extra quickly.

In that case, it can be helpful to use [`Debug.todo`](https://package.gren-lang.org/packages/gren-lang/core/latest/Debug#todo) to leave some code incomplete:
In that case, it can be helpful to use [`Debug.todo`](https://packages.gren-lang.org/package/gren-lang/core/latest/module/Debug#todo) to leave some code incomplete:

```gren
type User
Expand Down
2 changes: 1 addition & 1 deletion src/Terminal/Parser.gren
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ parser =
, PP.empty
, PP.words
"""
This tries to compile an Gren file named src/Main.gren, generating an index.html
This tries to compile a Gren file named src/Main.gren, generating an index.html
file if possible.
"""
]
Expand Down