Stream: beginners

Topic: dbg doesn't show type definition?


view this post on Zulip Brian Teague (Sep 12 2026 at 19:26):

Is there a way to see what the type of something is in roc repl or binary when using dbg?

dbg "hello" outputs value and type? "hello" : Str?

view this post on Zulip Luke Boswell (Sep 12 2026 at 20:24):

Use :t

$ roc repl

  The rockin' roc repl
────────────────────────

Enter an expression, or :help, or :q to quit.

» x = 2
assigned `x`
» :t x
x : Dec

view this post on Zulip Brian Teague (Sep 13 2026 at 01:20):

That is very helpful, but what about outside roc repl? I sometimes want to see the type in a debug statement from within a compiled roc program. For example, what is the type for echo! which is not exposed in roc repl?

view this post on Zulip Richard Feldman (Sep 13 2026 at 03:43):

what about lsp?

view this post on Zulip Richard Feldman (Sep 13 2026 at 03:43):

I think adding types to dbg would really clutter up its output, which would make it worse at its primary purpose

view this post on Zulip Richard Feldman (Sep 13 2026 at 03:44):

oh, also if you want to make a code change that results in your seeing the type of something, an old trick is to just add a type annotation you know is incorrect - e.g. main! : {} and then the type mismatch will tell you what the compiler thinks its type is :smile:

view this post on Zulip Brian Teague (Sep 13 2026 at 14:49):

Forcing a compile error will work, although a bit hacky :joy:. Thank you @Richard Feldman @Luke Boswell!!


Last updated: Sep 24 2026 at 15:59 UTC