Stream: beginners

Topic: parsing


view this post on Zulip drew (May 31 2023 at 14:13):

What's the best place to start reading about parsing in roc? I've read the Decode docs and it seems effectively everything could be accomplished via custom, but has anyone written a parser combinator or applicative style library on top of this yet?

view this post on Zulip drew (May 31 2023 at 14:13):

(this is user-space parsing, to be clear. not in the compiler :) )

view this post on Zulip Anton (May 31 2023 at 14:26):

We've got some parsers here and here. But we don't have a released package (with url) yet.

view this post on Zulip Anton (May 31 2023 at 14:27):

This one may be useful as well

view this post on Zulip drew (May 31 2023 at 14:28):

thanks!

view this post on Zulip drew (May 31 2023 at 14:29):

these look like the types i was expecting :)

view this post on Zulip drew (May 31 2023 at 14:30):

is there a way to use unreleased packages? i suppose I need the compiler source locally?

view this post on Zulip Anton (May 31 2023 at 14:32):

You can use a nightly release and a package in a local folder, like this

view this post on Zulip Johan Lövgren (May 31 2023 at 16:07):

I started porting the parser library from Elm as well. But it is not battle tested and was a few months since I looked at it. Here it is:

https://github.com/Subtlesplendor/roc-parser

view this post on Zulip drew (May 31 2023 at 16:18):

this looks great. does roc allow importing packages directly from github?

view this post on Zulip Anton (May 31 2023 at 16:23):

No, not from a regular repository, you can of course do a release on github but I believe it has to be a tar.gz or tar.br with a BLAKE3 hash

view this post on Zulip Richard Feldman (May 31 2023 at 18:12):

yeah, you can make one of those tarballs by using roc build --bundle

view this post on Zulip Richard Feldman (May 31 2023 at 18:13):

you can see an example of installing a package from a URL in the tutorial - note that the long hash at the end of that URL is mandatory!

view this post on Zulip Richard Feldman (May 31 2023 at 18:13):

roc build --bundle will automatically name the file for you so you don't have to do it, but basically it's a BLAKE3 hash of the contents of what you're downloading

view this post on Zulip Richard Feldman (May 31 2023 at 18:14):

it's a security measure; means if the URL ever gets taken over by a malicious actor (e.g. if the domain expires), they can't change the contents of the URL to deliver malicious code because it will fail the hash validation when roc downloads it

view this post on Zulip Richard Feldman (May 31 2023 at 18:15):

and of course if they change the contents and change the URL, then nobody's existing Roc code is pointing at that URL anyway :big_smile:


Last updated: Jul 05 2025 at 12:14 UTC