implicit

In scala, are there any condition where implicit view won't be able to propagate to other implicit function?

核能气质少年 提交于 2020-08-20 10:35:27
问题 Assuming that A class called 'summoner' was defined, that is capable of summoning implicit views from the scope: case class Summoner[R]() { def summon[T](v: T)(implicit ev: T => R): R = ev(v) } I found that it works most of the time, but there are cases where it doesn't work, e.g. the following is a (not too) short case which uses the singleton-ops library: import shapeless.Witness import singleton.ops.+ import singleton.ops.impl.Op trait Operand { def +[ X >: this.type <: Operand, Y <:

Gekko and CoolProp

ぐ巨炮叔叔 提交于 2020-08-08 06:03:34
问题 I'm using GEKKO and CoolProp for thermal systems simulation. When trying to use CoolProp's functions inside the model equations (as shown below for an isentropic expansion) I'm getting an error message regarding the variable type: " must be real number, not GKVariable ". Could someone please help me with this issue? from gekko import GEKKO import CoolProp.CoolProp as CP # p1 = 2e5 T1 = 300.0 + 273.15 p2 = 1e5 eta = 0.80 fluid = 'H2O' # h1 = CP.PropsSI('H','T',T1,'P',p1,fluid) s1 = CP.PropsSI(

Why do both of these implicits match when only one of them would type check?

断了今生、忘了曾经 提交于 2020-07-30 04:09:50
问题 I am trying to diagnose a compiler error which is caused by diverging implicit expansion errors. Here is what I am seeing: ❯ scala Welcome to Scala 2.13.1 (OpenJDK 64-Bit Server VM, Java 1.8.0_252). Type in expressions for evaluation. Or try :help. scala> :settings -Xlog-implicits scala> :paste // Entering paste mode (ctrl-D to finish) trait Invariant[A] trait Covariant[+A] trait Foo implicit def invariantTuple1[T1: Invariant]: Invariant[Tuple1[T1]] = ??? implicit def invariantFoo: Invariant