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

Support for types like Int with U <: UnitExpr #2

Closed
erikerlandson opened this issue Jan 21, 2017 · 2 comments
Closed

Support for types like Int with U <: UnitExpr #2

erikerlandson opened this issue Jan 21, 2017 · 2 comments

Comments

@erikerlandson
Copy link
Owner

This might be a very powerful feature, although it comes with some drawbacks and problems to solve:

  1. the with U part isn't closed under various numeric operations
  2. easy to drop the with U part by assigning to non-qualified numeric values
  3. have to figure out rules and support for operations with differing types
  4. e.g. what is result type of Int with U <+> Float with U
  5. Numeric[N] doesn't seem to support construction of new N from arbitrary other values
@erikerlandson
Copy link
Owner Author

@non, do you have any advice on whether spire can help with problems 3,4,5 above?
Currently I'm just sort of punting by doing everything in Double space, which isn't terrible but I feel like it could be better and standard Scala Numeric doesn't quite get me there.

@erikerlandson
Copy link
Owner Author

I have decided to not direcly use with, instead it is safer to use a type alias WithUnit and/or %# such that Int WithUnit Meter is equivalent to Quantity[Int, Meter]. This also makes it behave more like require
I'm closing this issue.

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