Stream: compiler development

Topic: examples/ in roc repo


view this post on Zulip Richard Feldman (Dec 22 2024 at 02:50):

I think the current examples/ directory in the repo is pretty confusing to beginners - it doesn't have a "hello world" (although the README references one that's no longer there) but it does have a bunch of fairly advanced use cases :sweat_smile:

view this post on Zulip Richard Feldman (Dec 22 2024 at 02:51):

I'm concerned that beginners will come across the repo, look in examples/ out of habit because that's such a common place to look for beginner-friendly examples, and have a bad experience...if we're just going to use that directory for testing, can we move it somewhere else and maybe just have the examples folder contain a README linking to where to find actual beginner-friendly examples?

view this post on Zulip Luke Boswell (Dec 22 2024 at 02:55):

I've really wanted to move it into the cli crate with all the other cli tests.

view this post on Zulip Luke Boswell (Dec 22 2024 at 02:56):

I've pretty much removed or moved most things already. It's just platform-switching that is used now for anything. The others like node and python interop aren't really tested anywhere afaik

view this post on Zulip Richard Feldman (Dec 22 2024 at 02:56):

I don't have strong feelings on where examples should live, but I do have strong feelings about a top-level directory named examples/ not giving beginners the wrong impression :big_smile:

view this post on Zulip Luke Boswell (Dec 22 2024 at 02:56):

My thoughts were to have my platform templates as examples instead of that... but I haven't got a node, jvm, ruby, or python ones yet

view this post on Zulip Richard Feldman (Dec 22 2024 at 02:57):

I kinda think at this point it would probably be more helpful to just have a readme of links to other repos

view this post on Zulip Richard Feldman (Dec 22 2024 at 02:57):

like "hey check out basic-cli/examples" and then similar for other platforms

view this post on Zulip Luke Boswell (Dec 22 2024 at 02:58):

I'd be happy to create repo's and move them alongside these https://github.com/lukewilliamboswell?tab=repositories&q=platform-template&type=&language=&sort=

view this post on Zulip Luke Boswell (Dec 22 2024 at 02:58):

I would like to point people towards https://www.roc-lang.org/examples

view this post on Zulip Luke Boswell (Dec 22 2024 at 02:58):

We can provide markdown content, and potentially more interactive experiences in future with upgrades.

view this post on Zulip Luke Boswell (Dec 22 2024 at 02:59):

Luke Boswell said:

I'd be happy to create repo's and move them alongside these https://github.com/lukewilliamboswell?tab=repositories&q=platform-template&type=&language=&sort=

It's difficult for me to maintain all these, but I usually just update them when people need / ask in zulip

view this post on Zulip Richard Feldman (Dec 22 2024 at 03:00):

having the examples/ dir just be a README which links to roc-lang.org/examples sounds good to me! :thumbs_up:

view this post on Zulip Luke Boswell (Dec 22 2024 at 03:03):

You don't have thoughts about keeping the ruby, node, jvm, python interops?

view this post on Zulip Luke Boswell (Dec 22 2024 at 03:04):

Or where the WIP virtual dom thing could go?

view this post on Zulip Luke Boswell (Dec 22 2024 at 03:04):

@Anton has said he would like to keep platform-switching to help with debugging.. but that can move into the cli crate

view this post on Zulip Richard Feldman (Dec 22 2024 at 03:07):

I think it's nice to have those somewhere

view this post on Zulip Richard Feldman (Dec 22 2024 at 03:08):

but I think it's bad if examples/ has those and not something more basic like hello world

view this post on Zulip Richard Feldman (Dec 22 2024 at 03:08):

if we want to put more basic examples like hello world back in examples/, then I think it's fine to have stuff like python and JVM interop in there alongside the more basic ones

view this post on Zulip Richard Feldman (Dec 22 2024 at 03:09):

but if we're not going to put the basic ones in there, then I think we should put the interop examples somewhere else (not sure where though!)

view this post on Zulip Brendan Hansknecht (Dec 22 2024 at 03:23):

If anything examples should be exclusively basic CLI and basic webserver

view this post on Zulip Brendan Hansknecht (Dec 22 2024 at 03:23):

Beginners should not really eat thinking about platforms

view this post on Zulip Brendan Hansknecht (Dec 22 2024 at 03:23):

I think having platform switching examples is a mistake for a beginner to the language

view this post on Zulip Brendan Hansknecht (Dec 22 2024 at 03:24):

That isn't useful until someone is sold on the language and wants to make a platform

view this post on Zulip Luke Boswell (Dec 22 2024 at 04:28):

Two PR's

  1. https://github.com/roc-lang/roc/pull/7401 - cleanup the examples/ folder in roc-lang/roc
  2. https://github.com/roc-lang/examples/pull/224 - move all the platform interops to roc-lang/examples

view this post on Zulip Joshua Warner (Dec 25 2024 at 11:39):

One useful thing the examples are doing right now is serving as a large(er) code base that we verify parsing and formatting on. Would be nice to make sure we don’t lose that coverage somehow.

view this post on Zulip Brendan Hansknecht (Dec 25 2024 at 15:15):

We still have CLI tests in the repo. They are used to keep some examples around

view this post on Zulip Brendan Hansknecht (Dec 25 2024 at 15:16):

Also, we should definitely set up a job to run all the code in the examples repo to make sure they don't break.

view this post on Zulip Brendan Hansknecht (Dec 25 2024 at 15:16):

Though I guess part of the reason for pulling things out of the roc repro was to decouple updates

view this post on Zulip Luke Boswell (Dec 25 2024 at 19:39):

Brendan Hansknecht said:

Also, we should definitely set up a job to run all the code in the examples repo to make sure they don't break.

They get tested with the nightlies, and when making a new release of basic-cli.

view this post on Zulip Luke Boswell (Dec 25 2024 at 19:41):

Joshua Warner said:

One useful thing the examples are doing right now is serving as a large(er) code base that we verify parsing and formatting on. Would be nice to make sure we don’t lose that coverage somehow.

The examples that are moved out above are the pthon/java/ruby interops which aren't used for anything like testing parsing etc, so we're not losing any coverage.

Platform switching was just moved into the cli crate with all the other tests.

view this post on Zulip Joshua Warner (Dec 25 2024 at 23:26):

There's this: https://github.com/roc-lang/roc/blob/57cab7f69ab2603a5e757bdabdc95fc05d910188/crates/compiler/test_syntax/tests/test_fmt.rs#L5668

view this post on Zulip Joshua Warner (Dec 25 2024 at 23:26):

Pretty sure that's explicitly using that code in tests

view this post on Zulip Joshua Warner (Dec 25 2024 at 23:28):

It has definitely caught some interesting bugs

view this post on Zulip Brendan Hansknecht (Dec 25 2024 at 23:29):

Probably should change it to the CLI test folder

view this post on Zulip Joshua Warner (Dec 26 2024 at 01:09):

Do you know where that'll be, relative to the repo root (in CI)?

view this post on Zulip Brendan Hansknecht (Dec 26 2024 at 01:24):

I think crates/cli/tests/

view this post on Zulip Brendan Hansknecht (Dec 26 2024 at 01:27):

test-projects would be examples but for general parsing, I would include the entire folder cause might as well test parsing and formatting the benchmarks too

view this post on Zulip Anton (Dec 27 2024 at 13:15):

One useful thing the examples are doing right now is serving as a large(er) code base that we verify parsing and formatting on. Would be nice to make sure we don’t lose that coverage somehow.

I've been thinking that we should add CI tests that use the exercism and examples repo. We can make it so that they're not required to pass, only to inform us.

view this post on Zulip Sam Mohr (Dec 27 2024 at 13:16):

That would be pretty helpful, if you get the opportunity

view this post on Zulip Sam Mohr (Dec 27 2024 at 13:17):

Nvm, you didn't say "I" but instead said "we". This could be a "good first issue"


Last updated: Jul 06 2025 at 12:14 UTC