Stream: beginners

Topic: Browsing modules


view this post on Zulip grp (Jul 29 2025 at 05:23):

Hi. New here, aspiring to get proficent with Roc.

After wrestling with packaging in nix the roc-treesitter-grammar, I've managed to get emacs + roc-ts-mode working. So far it seems to be ok but...

how can I browse the definitions (types and functions) available in the chosen platform? how about imports?

e.g.:

  import platform.Arg exposing [Arg]

ok, what now?
how can I see what can I do with Arg? what's inside it?

I hoped there would be something like

:browse <type/module>

in the repl to get a listing of type signatures, but it's not there... so, where can I get something like that?

view this post on Zulip Luke Boswell (Jul 29 2025 at 05:36):

What platform are you looking at?

view this post on Zulip Luke Boswell (Jul 29 2025 at 05:37):

For example, here's the docs for basic-cli -- https://roc-lang.github.io/basic-cli/0.19.0/

view this post on Zulip grp (Jul 29 2025 at 05:38):

Yeah, documentation is one thing, but let's say I'm working on something that's not documented. I could get around just fine with type signatures, but most importantly, being able to query roughly "What's this and what functions can I use with this?"

view this post on Zulip grp (Jul 29 2025 at 05:43):

Years ago I wrote some Haskell, when it was deemed a good lang to learn "to be a better programmer". Parted ways with it long long ago, but I remember being able to browse modules definitions, searching by type signature, and that was really handy, because I could explore what I could use right where I was working instead of having to fire a web browser and shuffling through documentation.

Let's say there's a type Arg defined, ok, what's it's definition? what functions can I use to work with an Arg? If there's documentation, that'd be the next thing to look at IF the typesignature isn't obvious on it's own.

view this post on Zulip grp (Jul 29 2025 at 06:21):

For example, if I import the basic-cli platform, and do something like:

:browse Path

I'd get a list like this:

Path
DirEntry
IOErr
write! : val, Path, fmt => Result {} [FileWriteErr Path IOErr]
write_bytes! : List U8, Path => Result {} [FileWriteErr Path IOErr]
write_utf8! : Str, Path => Result {} [FileWriteErr Path IOErr]
from_str : Str -> Path
from_bytes : List U8 -> Path
display : Path -> Str
is_dir! : Path => Result Bool [PathErr IOErr]
is_file! : Path => Result Bool [PathErr IOErr]
is_sym_link! : Path => Result Bool [PathErr IOErr]
type! : Path => Result [IsFile, IsDir, IsSymLink] [PathErr IOErr]
with_extension : Path, Str -> Path
delete! : Path => Result {} [FileWriteErr Path IOErr]
read_utf8! : Path => Result Str [ FileReadErr Path IOErr, FileReadUtf8Err Path]
read_bytes! : Path => Result (List U8) [FileReadErr Path IOErr]
list_dir! : Path => Result (List Path) [DirErr IOErr]
delete_empty! : Path => Result {} [DirErr IOErr]
delete_all! : Path => Result {} [DirErr IOErr]
create_dir! : Path => Result {} [DirErr IOErr]
create_all! : Path => Result {} [DirErr IOErr]
hard_link! : Path => Result {} [LinkErr IOErr]

view this post on Zulip Luke Boswell (Jul 29 2025 at 07:09):

Love the idea. :smiley:

I think Roc will be well suited to building this kind of developer tooling. The REPL could probably do something like this.

view this post on Zulip Anton (Jul 29 2025 at 09:46):

Hi @grp,

what functions can I use to work with an Arg?

The most convenient way is probably to view the autocomplete when you enter Arg. in the IDE.

view this post on Zulip Anton (Jul 29 2025 at 09:52):

If you're new to Roc though I would probably recommend searching through the examples folder, e.g.:
https://github.com/search?q=repo%3Aroc-lang%2Fbasic-cli%20%22Arg.%22%20path%3Aexamples%2F&type=code


Last updated: Aug 17 2025 at 12:14 UTC