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?
(this is user-space parsing, to be clear. not in the compiler :) )
We've got some parsers here and here. But we don't have a released package (with url) yet.
This one may be useful as well
thanks!
these look like the types i was expecting :)
is there a way to use unreleased packages? i suppose I need the compiler source locally?
You can use a nightly release and a package in a local folder, like this
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
this looks great. does roc allow importing packages directly from github?
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
yeah, you can make one of those tarballs by using roc build --bundle
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!
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
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
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