Given context and an expression, this method rewrites the tree to call the "desired" method with the lhs and rhs parameters.
Given context and an expression, this method rewrites the tree to call the "desired" method with the lhs and rhs parameters. We find the symbol which is applying the macro and use its name to determine what method to call.
Users write code like:
x + y
After typing and implicit resolution, we get trees like:
ringOps[A](x:A)(ev:R[A]).+(y:A)
and we want to get out:
ev.method(x:A, y:A)
So, we need to decompose ringOps[A](x)(ev) to get x and ev, and we need to map "+" into "plus".
Given an expression like: xyz(lhs)(ev0).
Given an expression like: xyz(lhs)(ev0).plus(rhs: Abc)(ev1) This will create a tree like: ev0.plus(lhs, ev1.fromAbc(rhs)) Notably, this let's us use Ring's fromInt method and ConvertableTo's fromDouble (etc.) before applying an op.
Provide a canonical mapping between "operator names" used in Ops classes and the actual method names used for type classes.
Provide a canonical mapping between "operator names" used in Ops classes and the actual method names used for type classes.
This is an interesting directory of the operators Spire supports. It's also worth noting that we don't (currently) have the capacity to dispatch to two different typeclass-method names for the same operator--typeclasses have to agree to use the same name for the same operator.
In general "textual" method names should just pass through to the typeclass... it is probably not wise to provide mappings for them here.
Like binop, but for right-associative operators (eg.
Like binop, but for right-associative operators (eg. +:).
Given context, this method rewrites the tree to call the desired method with the lhs parameter.
Given context, this method rewrites the tree to call the desired method with the lhs parameter. We find the symbol which is applying the macro and use its name to determine what method to call.
Users write code like:
-x
After typing and implicit resolution, we get trees like:
ringOps[A](x:A)(ev:R[A]).unary_-()
and we want to get out:
ev.negate(x:A)
So, we need to decompose ringOps[A](x)(ev) to get x and ev, and we need to map "unary_-" into "negate".
Given context, this method pulls 'evidence' and 'lhs' values out of instantiations of implicit -Ops classes.
Given context, this method pulls 'evidence' and 'lhs' values out of instantiations of implicit -Ops classes. For instance,
Given "new FooOps(x)(ev)", this method returns (ev, x).
This trait has some nice methods for working with implicit Ops classes.