Skip to content

repl: Introduce :defs and :t <identifier> commands#9755

Open
lukasjuhrich wants to merge 7 commits into
roc-lang:mainfrom
lukasjuhrich:repl/def-and-t
Open

repl: Introduce :defs and :t <identifier> commands#9755
lukasjuhrich wants to merge 7 commits into
roc-lang:mainfrom
lukasjuhrich:repl/def-and-t

Conversation

@lukasjuhrich

@lukasjuhrich lukasjuhrich commented Jun 22, 2026

Copy link
Copy Markdown

This is me elaborating on an idea I had in #ideas > Print type in `roc repl`, so feel free to discuss/reject/defer API decisions.

What was added

The repl can now

  • print the type of top-level definitions by name using :t <identifier>, like ghci can
  • print all definitions using the :defs command

It looks like this:
image

Note that :t is the actual feature I care about and :defs was the way to get me there. but I still think it is useful.
Feel free to reject this PR or parts of it or discuss naming / formatting. I'm happy to start a discussion over at zulip.

What was not added

  • general command dispatching whenever the line starts with :
  • allowing arbitrary expressions to be typed in after :t (which would not be too hard I think)
  • Tests (what should they look like? interpreter state is not changed here so it's a bit different from the rest)

AI usage disclaimer

  • No vibe coding
  • some chat assistance with the zig stdlib and questions about how to write zig code more idiomatically.

All mistakes are my own, so feel free to tell me what I did wrong.

This consistently applies two rules:

- user-provided information is normal,
  additional hints dim
- let-bindings are upright, everything else in
  italics  

Also, defs are separated by a newline except for
annotations, because usually they are directly
followed by the let-binding they belong to.
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.

1 participant