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

Num.Linear and Ord #104

Closed
Divesh-Otwani opened this issue Apr 28, 2020 · 2 comments
Closed

Num.Linear and Ord #104

Divesh-Otwani opened this issue Apr 28, 2020 · 2 comments
Assignees

Comments

@Divesh-Otwani
Copy link
Contributor

Figure the following out:

  • Should Num be a superclass of Prelude.Ord? or Ord.Linear?
  • How about Eq?
  • In general, what is the relationship between ordering and numeric types that we should encode?
@Divesh-Otwani Divesh-Otwani self-assigned this Apr 28, 2020
@aspiwack
Copy link
Member

Eq might make sense, though I don't really see the point (there is no specific relation between Eq and Num that you want to express, beyond the blanket fact that functions must respect the Eq instance, which is not specific to Num).

The problem with Ord is more thorny. If, on the one hand, we may want to express some kind of ordered semiring property that way (there are standard notions), they are not respected by our numbers. On integer type, because arithmetic module 2^n doesn't have an order compatible with addition (a ⩽ b ⟺ a+c ⩽ b+c, if, e.g. a+c wraps around but not b+c, it will simply not hold). On floating point types because the Ord instance is a bit artificial on floating point numbers (also, generally, it's hard to give well-behaved laws to something which has infinities and NaNs).

I doubt that we can make this meaningfully, so probably, we shouldn't add this extra constraint.

@Divesh-Otwani
Copy link
Contributor Author

I'm closing this because I think Num.Linear is too complicated and needs to be simplified, at which point, this issue would be resolved anyway. I will probably make an issue about Num at some point.

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