Skip to content

Example for List as usage (#159) #183

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 7 commits into from
Jun 22, 2024
Merged

Example for List as usage (#159) #183

merged 7 commits into from
Jun 22, 2024

Conversation

bairymr
Copy link
Contributor

@bairymr bairymr commented Jun 17, 2024

Fixes #159

In this PR we are adding an example usage of lists and using the "as condition" to extract the tail of the list and continue processing the list.

I was able to test the code but I was not able to view the html files.

Screenshot 2024-06-16 at 11 29 22 PM

In the instructions here when I update the main.roc inside my example to have "packages {pf: /static-site-gen" - I got an error stating I should have interface, app, package or platform. When I changed it to be "package" - I got another error (I am expecting a package name next, like "roc/core". Package names
must be quoted). So I couldn't fully view the html files.

@lukewilliamboswell
Copy link
Collaborator

@bairymr I updated the script and instructions in #184 so you can see the site locally.

@bairymr
Copy link
Contributor Author

bairymr commented Jun 18, 2024

Thanks @lukewilliamboswell sorry one more question - in the instructions (your's & existing) it says to run this step
roc run main.roc -- examples build

Do I run my example code's main.roc ? but then I didn't see any build folder created. I cloned the roc repo, should I run this command in the examples there ? Sorry if this has already been mentioned, I couldn't get past this second step from the instructions to verify the html content.

@lukewilliamboswell
Copy link
Collaborator

That PR hasn't merged yet. But here is the link to the main.roc https://github.com/roc-lang/examples/blob/91cda53537d10cf5c6a126164a936829c7ca0e94/main.roc

If you copy that and run it in the root of the roc-lang/examples repository, it will use the basic-ssg platform to generate a static site for the examples. This makes it easier to see how the examples will look locally, before they are merged and ultimately Netlify servers build and host at roc-lang.org.

The roc run main.roc -- examples/ build/ should take the markdown files in examples/ and make a folder called build/ where it will put the generated HTML content.

So then you just need a file server to serve the files on your localhost. We have been using simple-http-server which is easy to get from cargo e.g. cargo install simple-http-server.

@bairymr
Copy link
Contributor Author

bairymr commented Jun 19, 2024

Thanks again for your help here Luke. This all makes sense now. I missed the main.roc from your PR. I copied it over and tried to build it but I got the below error. I guess I may have to try this on a different machine. As per the instructions in basic-ssg package should build in mac x86. I will continue to check this

ld: symbol(s) not found for architecture x86_64
thread 'main' panicked at crates/compiler/build/src/program.rs:1043:17:
not yet implemented: gracefully handle `ld` (or `zig` in the case of wasm with --optimize) returning exit code Some(1)

@lukewilliamboswell
Copy link
Collaborator

Thanks again for your help here Luke. This all makes sense now. I missed the main.roc from your PR. I copied it over and tried to build it but I got the below error. I guess I may have to try this on a different machine. As per the instructions in basic-ssg package should build in mac x86. I will continue to check this

ld: symbol(s) not found for architecture x86_64
thread 'main' panicked at crates/compiler/build/src/program.rs:1043:17:
not yet implemented: gracefully handle `ld` (or `zig` in the case of wasm with --optimize) returning exit code Some(1)

What machine are you on. basic-ssg should work on any of these targets.. maybe I need to cut another release. I noticed elsewhere that a later version of rustc fixes some of the musl issues, so I could switch back to that if your having issues on linux.

  • Arm64 MacOS
  • Arm64 Linux
  • x64 MacOS
  • x64 Linux

@bairymr
Copy link
Contributor Author

bairymr commented Jun 19, 2024

I was on x64 MacOS

@Anton-4 Anton-4 self-assigned this Jun 22, 2024
@Anton-4
Copy link
Collaborator

Anton-4 commented Jun 22, 2024

I apologize for the wasted effort here @bairymr, I wanted the existing pattern matching example to be expanded instead of creating a separate example. It's mentioned in the issue title but it is easy to miss, I should have linked to the existing pattern matching example.

@Anton-4 Anton-4 merged commit f48645d into roc-lang:main Jun 22, 2024
@bairymr bairymr deleted the rb/list-in-roc branch June 23, 2024 06:41
@bairymr
Copy link
Contributor Author

bairymr commented Jun 23, 2024

No worries at all @Anton-4 , Thank you for updating this PR with more details. This all makes sense

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.

add .. as syntax to pattern matching example
3 participants