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

Derive spire typeclasses for Quantity #4

Closed
zainab-ali opened this issue Mar 18, 2017 · 3 comments
Closed

Derive spire typeclasses for Quantity #4

zainab-ali opened this issue Mar 18, 2017 · 3 comments

Comments

@zainab-ali
Copy link
Contributor

zainab-ali commented Mar 18, 2017

Use an approach similar to numeric-vc to derive typeclasses.

Note that this cannot work for multiplication, since the quantity type outputted is different.

EDIT: I realize that I don't actually mean this, since numeric-vc is meant for deriving all kinds of typeclass instances given a base AnyVal. What I actually want is derived spire typeclasses instances, given that A has a typeclass instance.
e.g. If A has an AdditiveSemigroup, then an AdditiveSemigroup[Quantity[A, D]] can be derived.

This is difficult because the quantities' dimensions are ordered, and an AdditiveSemigroup won't work on types which aren't exactly the same.

@zainab-ali
Copy link
Contributor Author

zainab-ali commented Mar 25, 2017

The following typeclasses can be derived:

  • Module
  • Eq
  • Order
  • PartialOrder
  • Signed

Groups

  • AdditiveGroup
  • AdditiveSemigroup
  • AdditiveMonoid
  • AdditiveCommutativeGroup
  • AdditiveCommutativeMonoid
  • AdditiveCommutativeSemigroup

Spaces

  • MetricSpace
  • CoordinateSpace
  • VectorSpace
  • InnerproductSpace

@zainab-ali
Copy link
Contributor Author

It might be possible to get around the quantity equivalence problem with implicit conversions from one quantity to another.

See here for an example.

@zainab-ali
Copy link
Contributor Author

Typeclasses have now been added.
Quantity equivalence will be tackled in #24

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