Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numbers are broken #1

Open
nwolverson opened this issue Jul 19, 2018 · 2 comments
Open

Numbers are broken #1

nwolverson opened this issue Jul 19, 2018 · 2 comments

Comments

@nwolverson
Copy link
Member

Erlang numbers do not admit NaN or infinity values, and division by zero raises an error. The types in the EuclidianRing instance div :: Number -> Number -> Number is thus a lie.

Options:

  1. Remove the EuclidianRing instance (and maybe provide a div that is in Effect or returns a Maybe)
  2. Represent Number as something like number() | nan | infinity | minusinfinity with corresponding code on all operations

I suspect that really both make sense and the question is which gets to be called Number here.

@drathier
Copy link

I have an untested but carefully written implementation of f64 math in erlang, adding +inf, -inf and NaN. If anyone wants it as a baseline for implementing this, I'd be happy to send it. I'm in the purescript discord, @ me in the #purerl channel. I'm not entirely convinced it wouldn't move the problem elsewhere, though; any other erlang code that thinks it's getting a float might now get an atom.

@nwolverson
Copy link
Member Author

At this point I feel like a different type (Int53 style) might be the better option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants