How do I print a number? I tried dbg totalScore
and got
── TYPE MISMATCH ──────────────────────────────────────────────────── main.roc ─
This expect condition needs to be a Bool:
15│ dbg totalScore
^^^^^^^^^^
This totalScore value is a:
Num *
But I need every expect condition to evaluate to a Bool—either
Bool.true or Bool.false.
I tried the tag, too, but got:
── TYPE MISMATCH ──────────────────────────────────────────────────── main.roc ─
This expect condition needs to be a Bool:
15│ dbg T "the value of `totalScore` is:" totalScore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This T tag application has the type:
[T Str (Num *)]
But I need every expect condition to evaluate to a Bool—either
Bool.true or Bool.false.
────────────────────────────────────────────────────────────────────────────────
Maybe easier to just convert to a string; how do I do that?
You can use “Num.toStr”, though looks like the compiler is trying to constrain the wrong type here - cc @Folkert de Vries
hmm that should be fixed in the latest nightly I think
it was a parsing issue, really
Can you share a snippet of how you are using dbg? It's only a new feature so could be broken. Have you seen this thread where I think a similar problem was discussed?
Snippet here: https://gist.github.com/JesterXL/3e8b12ae456dafce5d159983659d53e3
odd... if I add:
|> sumScore
|> Num.toStr
To the end, and remove dbg
, it compiles. Even as a Str
, though, dbg still thinks it's supposed to be a Bool or something.
@JesterXL what does roc version
print out?
roc nightly pre-release, built from commit d2d8511 on Thu Dec 1 09:33:35 UTC 2022
I'm on Mac Silicon, 12.6 Monterey
ah, that dbg
issue got fixed in yesterday's nightly release :sweat_smile:
can you try downloading the latest roc
binary from Releases and see if it works now?
OH yeah baby, that fixed, thanks y'all!
Last updated: Jul 06 2025 at 12:14 UTC