Stream: contributing

Topic: repl displays wrong type info


view this post on Zulip Sean Hagstrom (Apr 14 2022 at 22:56):

@Ayaz Hafiz question about the issue 2846 (https://github.com/rtfeldman/roc/issues/2846)

When the repl evals 3.1 + 2.0 what should the Symbol be for the result? Atm it says it’s Num.Num. But the expression 3.1 is Num.Float. Is this related to the issue?

view this post on Zulip Ayaz Hafiz (Apr 14 2022 at 23:38):

Really? I see F64 when I use it.

view this post on Zulip Brendan Hansknecht (Apr 14 2022 at 23:47):

I see F64 as well (web and local repl)

view this post on Zulip Sean Hagstrom (Apr 15 2022 at 00:11):

Sorry I don’t mean the string output in the repl. You’re both correct that it shows F64.

view this post on Zulip Sean Hagstrom (Apr 15 2022 at 00:12):

I mean the symbol value in the Alias data type

view this post on Zulip Sean Hagstrom (Apr 15 2022 at 00:12):

I’ll post a link to the exact spot, one second

view this post on Zulip Sean Hagstrom (Apr 15 2022 at 00:13):

This line here: https://github.com/rtfeldman/roc/blob/d23d5f249fb2fb1d6a3c5cc96b4fae9e1131eb9c/compiler/types/src/pretty_print.rs#L371

view this post on Zulip Sean Hagstrom (Apr 15 2022 at 00:16):

If I use a println!("symbol: {:?}", *symbol);

view this post on Zulip Sean Hagstrom (Apr 15 2022 at 00:16):

Inside that block of code I linked, I can see that the expressions have the symbols I mentioned earlier

view this post on Zulip Sean Hagstrom (Apr 15 2022 at 00:19):

Let me know if that makes sense please, I was poking around and thought maybe something with the repl expressions could be evaluating incorrectly. Thoughts?

view this post on Zulip Sean Hagstrom (Apr 15 2022 at 00:19):

I’m on London time, so I’ll be heading to bed now, but I’ll be back online soon. Thanks for your time

view this post on Zulip Ayaz Hafiz (Apr 15 2022 at 00:36):

Oh yes. That is expected.

view this post on Zulip Ayaz Hafiz (Apr 15 2022 at 00:41):

An F64 has Alias type should be “Num (FloatingPoint Binary64)”, F32 is “Num (FloatingPoint Binary32)”

view this post on Zulip Ayaz Hafiz (Apr 15 2022 at 00:42):

This is not actually strictly true all the time, but should be enough for this issue.

view this post on Zulip Ayaz Hafiz (Apr 15 2022 at 00:42):

Thanks for looking into this!

view this post on Zulip Sean Hagstrom (Apr 15 2022 at 07:32):

Can you explain a little more about the difference between these two expressions:
3.1
3.1 + 2.1

I feel like I may be misunderstanding the theory here. Like what’s the difference between something being Num_Float vs Num_FloatingPoint? Is one considered to be a Double or something?

view this post on Zulip Sean Hagstrom (Apr 15 2022 at 12:15):

Okay I think I've been able to learn some stuff by reading through the docs here:
https://github.com/rtfeldman/roc/blob/trunk/compiler/builtins/docs/Num.roc

What I learned:

What I found:

Seems like the pretty printer was mostly updated around then, but there was a code path that was not updated. Specifically the Num FloatingPoint a was still being mapped to F64, while Float a is being mapped to Float *. Now that I understand that one is an alias for the other, I think we just need to update the other code path.

I have branch on the way, just need to setup my commit signing stuff first.

view this post on Zulip Ayaz Hafiz (Apr 15 2022 at 12:38):

That sounds right! Thanks Sean.

view this post on Zulip Sean Hagstrom (Apr 15 2022 at 12:52):

Okay just pushed a pull request here: https://github.com/rtfeldman/roc/pull/2867
Thank you!

view this post on Zulip Ayaz Hafiz (Apr 15 2022 at 12:52):

thank you!!

view this post on Zulip Sean Hagstrom (Apr 15 2022 at 16:09):

Okay the pull request finally passed all the checks :raised_hands:


Last updated: Jul 06 2025 at 12:14 UTC