I'm currently walking through the tutorial, and reached the point where the tutorial describes destructured record, in which an optional field is assigned a default expression which references another field in the destructured record.
These default values can reference other expressions in the record destructure; if you wanted, you could write
{ height, width, title ? "", description ? Str.concat "A table called " title }
Thus we have a destructured record in which the default value for the optional description
field references the value of the title
field of the same record.
To test this out, I wrote a short program to use this record, but get an error message on run, which tells me that The #UserApp module does not expose anything by the name title.
My code is the following:
app "records"
packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.7.1/Icc3xJoIixF3hCcfXrDwLCu4wQHtNdPyoJkEbkgIElA.tar.br" }
imports [pf.Stdout]
provides [main] to pf
main =
Stdout.line (tableDesc { height: 10, width: 20 })
tableDesc =\{
height,
width,
title ? "My Table",
description ? Str.concat "A table called " title
} -> Str.concat description " with dimensions \(Num.toStr width) x \(Num.toStr height)"
Am I missing something here? It would appear that the self-referential destructuring functionality is currently broken.
Interesting. My gut feeling is it never worked (at least I don't recall ever seeing it working). Maybe the tutorial is ahead of the actual implementation there.
Thanks! If its true that the tutorial is ahead of the implementation, I'm curious what the workflow is for building the tutorial...
I think the tutorial is all manually written currently without any compilation verification, but that could have changed since I last looked at that. Not really familiar with the code.
I'm on my phone right now, but I dug into this a while ago and made a few GitHub issues
I've created some issues to test tutorial snippets on CI #6328 #6329.
#6328 is a good first issue :)
Anton said:
#6328 is a good first issue :)
Thanks! I forked the repo and gonna give it a shot
@Ian McLerran , I was looking for a first issue and took the first one that was unassigned: #6328. I started working on it and I only noticed that you are also working on it when I tried to find the origin of the issue. If you are still working on the issue, please let me know. Otherwise, I will open a pull request.
Michael Pfeifer go ahead, I'm finding that I have a lot to learn on Rust before I can easily dive into any issue. Its all yours!
@Ian McLerran, thanks for your response. I'll see what I can do.
4 messages were moved from this topic to #contributing > Roc formatter replaces ### by # ## by Brendan Hansknecht.
Last updated: Jul 05 2025 at 12:14 UTC