Skip to content

Migrate to new roc#198

Draft
ageron wants to merge 124 commits into
mainfrom
migrate-to-new-roc
Draft

Migrate to new roc#198
ageron wants to merge 124 commits into
mainfrom
migrate-to-new-roc

Conversation

@ageron

@ageron ageron commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

This PR migrates the Roc track to the new zig-based Roc compiler and its new syntax.

At the time of writing:

  • 92 exercises have been migrated and all their tests pass.
  • 4 exercises have been migrated but compilation fails: alphametics, complex-numbers, protein-translation and strain.
  • 14 exercises are partially migrated (i.e., only the tests):
    • 7 exercises shouldn't be too hard to finish migrating: forth, go-counting, grep, poker, rational-numbers, tournament, and zebra-puzzle.
    • 7 exercises depend on external libraries, so they will be impossible to migrate until these libraries are migrated. This includes anagram (unicode), gigasecond (isodate), meetup (isodate), micro-blog (unicode), rest-api (json), reverse-string (unicode) and sgf-parsing (roc-parser)

ageron added 30 commits June 9, 2026 16:55
@github-actions

Copy link
Copy Markdown
Contributor

This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested.

If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos.

[no important files changed]

For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping @exercism/maintainers-admin in a comment. Thank you!

Comment on lines +21 to +22
app [main!] {
pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.7/DuRUyJh31Gt41YArMcVcvybLa2bCWboccWQ7Zq1KZPZ6.tar.zst"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

roc-platform-template-zig 0.8 is already out, it is possible that you need 0.9 (not out yet) with the latest Roc nightly due to https://roc.zulipchat.com/#narrow/channel/397893-announcements/topic/nominal.20field.20ordering.20is.20now.20preserved/near/605353849

?? ""
}

# List.reverse should soon be available in Roc's builtins

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List.rev is available now.

Comment on lines +9 to +10
result = solve("I + BB == ILL")
Set.from_list(result ?? []) == Set.from_list(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We typically like to steer people away from using ?? for default value fallbacks because they fail silently.
I just tried changing it to:

result = solve("I + BB == ILL")?

And that works in both cases Err or Ok.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the silent failure is not a problem of course but we want to make sure people don't see this as the way to handle errors in Roc.

app [main!] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.20.0/X73hGh05nNTkDHU06FHC0YfFaQB1pimX7gncRcao5mU.tar.br",
unicode: "https://github.com/roc-lang/unicode/releases/download/0.3.0/9KKFsA4CdOz0JIOL7iBSI_2jGIXQ6TsFBXgd086idpY.tar.br",
pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.7/DuRUyJh31Gt41YArMcVcvybLa2bCWboccWQ7Zq1KZPZ6.tar.zst",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should be updated to latest release as well.

result = [1, 3, 4, 6, 8, 9, 11] |> find(6)
result == Ok(3)
expect {
result = [1, 3, 4, 6, 8, 9, 11]->find(6)

@Anton-4 Anton-4 Jun 21, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We typically write this as result = find([1, 3, 4, 6, 8, 9, 11], 6), that looks more familiar to most people.

Comment on lines +10 to +25
rolls.fold_until(
Ok(new_game),
|state, pins| {
match state {
Ok(game) => {
match game.roll(pins) {
Ok(updated_game) => Continue(Ok(updated_game))
Err(err) => Break(Err(err))
}
}
Err(_) => {
crash "Impossible, we don't start or continue with an Err"
}
}
},
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turning this into a for loop would probably make it easier to understand.

result == Ok([1])
expect {
coins = [1, 5, 10, 25]
result = coins->find_fewest_coins(1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before, it should preferably be find_fewest_coins(coins, 1)

Comment on lines +21 to +30
expect {
_result = CircularBuffer.create({ capacity: 1 })
.write(
1,
)?
.read()?
->expect_value(1)

Bool.True
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks unconventional, I personally would prefer more duplication that is easier to understand.

app [main!] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.20.0/X73hGh05nNTkDHU06FHC0YfFaQB1pimX7gncRcao5mU.tar.br",
isodate: "https://github.com/imclerran/roc-isodate/releases/download/v0.6.2/73w_H-aSJNcWqtXvMG4JQw_HoaApMBLnE92XD4OcVGU.tar.br",
pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.7/DuRUyJh31Gt41YArMcVcvybLa2bCWboccWQ7Zq1KZPZ6.tar.zst",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another one to update to the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants