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

Can't negate a Float64 #1345

Open
ararslan opened this issue Dec 31, 2023 · 1 comment
Open

Can't negate a Float64 #1345

ararslan opened this issue Dec 31, 2023 · 1 comment

Comments

@ararslan
Copy link

>=> -f_to_f64(1.0)
> Type error: can't synthesize a class dictionary for: (VSpace Float64)

This appears to be because there are no Float64 literals and unary - falls back to calling neg, which is only defined for VSpace, and there is no VSpace instance for Float64. I think this should be fixable by defining

instance VSpace(Float64)
  def (.*)(x, y) = x * y

alongside the current instance for Float (AKA Float32).

@ararslan
Copy link
Author

ararslan commented Jan 2, 2024

Actually, it seems a bit odd that sign flipping requires multiplication; perhaps it would suffice for neg to be defined instead as:

def neg(x:a) -> a given (a|Sub) = (zero::a) - x

?

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

1 participant