Num.sqrt
is planned to panic on negative values, yet Num.pow n 0.5
is equivalently a square root operation and returns NaN on negative values.
» Num.pow -1 0.5
NaN : Float *
Should we plan to make pow
panic on roots of negative values, and add a corresponding Num.powChecked
?
great catch!
I actually think we should leave this alone for now - once abilities have fully landed, and in particular once we disallow equality for floats (based on previous discussions) we'll presumably want to end up with both pow
and sqrt
being allowed to return NaN
I think it's okay if they're inconsistent in the meantime :big_smile:
What is the general intent? Are abilities providing a great way to express checked vs panicking vs nan'ing variants of an operation, or are abilities just changing enough lines of code everywhere that we don't want the abilities work to deal with too many merge conflicts?
More of the former, abilities will just allow us to express in Roc code things we can't readily do today
Last updated: Jul 06 2025 at 12:14 UTC