I feel like I'm missing something obvious, but how do I import and use e.g.roc-json
outside the app entrypoint file? I'm not finding many examples.
You reference the same package shorthand used in the main file. So if your main.roc has
json: “https://….
Then you can do
import json.Core
OK I got it, thanks
main.roc
app [main] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br",
json: "https://github.com/lukewilliamboswell/roc-json/releases/download/0.10.0/KbIfTNbxShRX1A1FgXei1SpO5Jn8sgP6HP6PXbi-xyA.tar.br",
}
import pf.Stdout
import Mod
main =
Mod.stringify {}
|> Str.fromUtf8
|> Result.withDefault ""
|> Stdout.line
Mod.roc
module [stringify]
import json.Json
stringify = \rec -> Encode.toBytes rec Json.utf8
Alex Nuttall has marked this topic as resolved.
Last updated: Jul 06 2025 at 12:14 UTC