Can I propose we move tutorial examples that are full programs out into their own code files and transclude them programatically?
It would:
roc check
on themI'm okay with it, it cleans up the code for now, and we'll be rewriting the tutorial in 6 months anyway
Can we make them roc-lang/examples
and then "import" them somehow?
They are pretty boring for roc-lang/examples
We don't have to put them in the examples/
folder, maybe we make a tutorial_bits/
or something -- they won't be published to the website then, but we'll still catch them in CI and upgrades
We can extend the www roc program to transclude them
That part is easy
And we don’t need them in the examples on the website
You're thinking about putting them in the roc-lang/examples
right? we don't want to re-introduce an external dependency in roc-lang/roc
External?
No I was going to put it in a subfolder of www in roc-lang/roc
We removed all the basic-cli and other platform examples out of roc because it complicates the breaking changes a lot
I think Anthony is talking about stuff like:
add_and_stringify = \num1, num2 ->
sum = num1 + num2
if sum == 0 then
""
else
if sum < 0 then
"negative"
else
Num.toStr sum
Barely a file
I guess that stuff is ok -- I'm concerned about anything with a header that references a URL platform release
Agreed
I think we should have a placeholder platform that’s built with the release
I’m not as worried about running them
But I’m worried about being able to format and check them
And take about 1000 LOC out of the tutorial
I can leave that for after this release
22 messages were moved here from #compiler development > breaking changes by Luke Boswell.
We've talked about moving the whole website out of roc-lang/roc
... maybe we could revisit that discussion. I'm not sure where we got to with that.
But if we did, then that would resolve this problem I think.
regarding /examples
, I think we should treat that folder as essentially a public website
because a common thing people do when visiting a repo is to go into the /examples
folder and look at the examples in there
That’s why I don’t want to put these code snippets there
so we should only put things it in there because we think they'll be good examples for newcomers to read
I'm referring to roc-lang/examples/examples/
... our roc-lang/roc/examples/
folder just contains a README pointing to the website.
I want to put them somewhere nested in www
And then just transclude them based on some kind of grepable comment string in the code block
As an example this block appears like 3 times:
```roc
app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.18.0/0APbwVN1_p1mJ96tXjaoiUCr8NBGamr8G8Ac_DrXR-o.tar.br" }
import pf.Stdout
import pf.Stdin
import pf.Arg exposing [Arg]
main! : List Arg => Result {} [Exit I32 Str]
main! = |_args|
Result.mapErr(my_function!({}), |err|
when err is
StdoutErr(_) -> Exit(1i32, "Error writing to stdout.")
StdinErr(_) -> Exit(2i32, "Error writing to stdin.")
EndOfFile -> Exit(3i32, "End of file reached.")
)
```
I'd like to replace it with
```roc
## TRANSCLUDE:/path/to/some/file_with_unique_name.roc
```
Or something like that
that seems fine to me if they're just there for the website
Just the tutorial yes
having it in a separate repo would make it annoying to coordinate updating the tutorial :sweat_smile:
Yes, in www/tutorial-snippets or something
And then we can have a shell script that can check them all with cargo run --bin roc -- check
And we could add that to CI eventually
Even could make sure they are formatted correctly
We already have a transclude feature
I see something that looks like transclusion here, but I have no idea what is doing anything
Oh I see now, that happens in roc-lang/roc in the www build script
The core functionality is in basic-ssg: https://github.com/lukewilliamboswell/basic-ssg/blob/de3b8ad535d1aaf767cce904e8994373d15ec088/crates/ssg/src/lib.rs#L323
Last updated: Jul 06 2025 at 12:14 UTC