Stream: beginners

Topic: things I cannot figure out on numbers


view this post on Zulip Uberto Barbini (Jan 05 2024 at 10:29):

there are a few things that I'm not sure about, I'm feeling stupid/frustrated:

view this post on Zulip Anton (Jan 05 2024 at 10:50):

is there an approx equal for Frac?

Not yet, but it does seem like a lot of languages have something available for that. I made an issue to explore the idea #6349.

view this post on Zulip Anton (Jan 05 2024 at 10:50):

is there a way to define infix function or overload operators?

No, this was a deliberate decision.

view this post on Zulip Anton (Jan 05 2024 at 10:54):

is there something like Haskell $?

I think you can use |> instead, but you'd have to change the order compared to $ in haskell.

view this post on Zulip Anton (Jan 05 2024 at 10:59):

is it possible to expand Num (i.e. for complex numbers)?

Not in the way your thinking of probably, but @Hannes does have some support for them in his roc-math package.

view this post on Zulip Anton (Jan 05 2024 at 11:22):

is there a toDec ? how can I convert a Fractional to a Decimal?

It does indeed seem like toDec is missing from Num, I'll check if we just forgot about it :p
You can do Num.toStr and Std.toDec.

view this post on Zulip Anton (Jan 05 2024 at 11:23):

Yes. we have an issue for it #5446

view this post on Zulip Brendan Hansknecht (Jan 05 2024 at 16:42):

It does indeed seem like toDec is missing from Num, I'll check if we just forgot about it :p
You can do Num.toStr and Std.toDec.

Amazing how a feature like this can go missing for so long. You would think that it would have been hit by now.


Last updated: Jul 06 2025 at 12:14 UTC