Stream: beginners

Topic: ✔ dbg not working?


view this post on Zulip Lukas Hermann (Dec 02 2023 at 22:40):

Hi! I have the following Roc program:

app "hello"
    packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.7.0/bkGby8jb0tmZYsy2hg1E_B2QrCgcSTxdUlHtETwm5m4.tar.br" }
    imports [pf.Stdout]
    provides [main] to pf

input = "hello\nworld"

dbg Str.split input "\n"

main =
    Stdout.line input

I built it with nix build in a clone of the roc repo, and when I run:

./result/bin/roc dev main.roc

I get:

── NOT END OF FILE ────────────────────────────────────────────────── main.roc ─

I expected to reach the end of the file, but got stuck here:

8│  dbg Str.split input "\n"

Any advice would be much appreciated

view this post on Zulip Luke Boswell (Dec 02 2023 at 22:52):

Does it work if you wrap them in braces dbg (Str.split input "\n")

view this post on Zulip Lukas Hermann (Dec 02 2023 at 22:53):

Nope, nor does it work if I assign Str.split input "\n" to a variable first and try to debug that variable

view this post on Zulip Luke Boswell (Dec 02 2023 at 22:53):

dbg can only take one argument, and I guess the parser thinks this is passing a function and two strings to the dbg function

view this post on Zulip Luke Boswell (Dec 02 2023 at 22:54):

I guess you cant have dbg as a top level statement

view this post on Zulip Luke Boswell (Dec 02 2023 at 22:54):

This works for me

input = "hello\nworld"

main =

    dbg Str.split input "\n"

    Stdout.line input

view this post on Zulip Lukas Hermann (Dec 02 2023 at 22:55):

Ah that works for me as well! Thank you!

view this post on Zulip Notification Bot (Dec 02 2023 at 22:56):

Lukas Hermann has marked this topic as resolved.


Last updated: Jul 06 2025 at 12:14 UTC