Replies: 4 comments 1 reply
-
From the discord discussion - coulomb isn't going to work with Scala3 just yet. I'm not using a lot of Scala3 features, so shifting back is just a lot of typing. I'll try that. |
Beta Was this translation helpful? Give feedback.
-
Hi @dwalend ! I am still working on coulomb for scala 3. My goal was a ground-up redesign to take full advantage of Scala 3 features, and I have not had much spare time to push it forward in the last few months. My scala-3 design has been living here: https://github.com/erikerlandson/poc-coulomb-scala3, but will eventually pull it back into this repository. If you can work with Scala 2.13+, coulomb should work fine. I'm happy to help, and I will try to get back to scala 3 support soon. Regarding numeric operators, they are based on spire algebra definitions, for example: import spire.std.any._ // import algebras for common numeric types Int, Long, Float, Double
import spire.std.double._ // import algebras for Double See also: And for deeper dive: |
Beta Was this translation helpful? Give feedback.
-
Thanks! I'll go digging. Do you think it's worth my trying poc-coulomb-scala3 early? I only need a few types, but I do need the arithmetic for them, but it looks like you're still finding your way in the proof-of-concept. From my end - I eventually need to have this working for some very young students. For the short attention span the tech has to work. I'm guessing my best choice is to shift to Scala 2.13 and have them use units. (That might open scala-native to our work earlier, which solves a slow-start-up problem neatly.) |
Beta Was this translation helpful? Give feedback.
-
Thanks. After some consideration, I decided to hold off on units of measure until coulomb is ready for scala 3, or I'm driven back to Scala 2.13 by something else. Proper units are valuable - a much better for the kids - but not essential to the project. ... (Then I tried out my custom value classes with units and a universal trait and somehow got a performance boost I don't think I deserve. I'm going to give the kids those to work with until coulomb is ready for scala 3.) |
Beta Was this translation helpful? Give feedback.
-
Thanks for putting together coulomb. It looks like a really good fit for my students' robotics projects.
I need some help finding my way through the implicits to make arithmetic work in coulomb. (Asked on spire's discord channel if that's a better place.)
Here's the body of code I'd like to compile:
`
object CalculateWithUnits:
def calculate() =
val heading = 45.withUnit[Degree]
val goalHeading = 50.withUnit[Degree]
val dutyCycle = 80.withUnit[Percent]
I tried the tactic of "slinging more and more wildcard imports until it compiles, then whittle down to exactly what the code uses, no wildcards." I haven't been able to get beyond the first step. I'm currently importing all this:
import coulomb.accepted.*
import spire.std.int.*
import spire.std.any.*
import coulomb.*
import shapeless.*
import coulomb.define.*
import coulomb.unitops.*
import shapeless.~?>.witness
`
I've been able to change the error messages a little, but I haven't found anything that I've been able to interpret as a way forward. I think I don't understand what I'm chasing, but I'm doubtful of the compiler's suggestion that I add what looks like pieces of a Map.
Latest is
[error] -- Error: /Users/dwalend/projects/scala-ev3/ev3dev-lang-scala/Ev3LangScalaExample/src/ev3dev4s/sensors/gyroscope/examples/CalculateWithUnits.scala:20:56 [error] 20 | val adjust = (goalHeading - heading) * dutyCycle / 100.withUnit[Degree] [error] | ^ [error] |no implicit argument of type coulomb.unitops.UnitMul[Int, coulomb.accepted.Degree, Int, [error] | coulomb.accepted.Percent [error] |] was found for parameter um of method * in class Quantity. [error] |I found: [error] | [error] | coulomb.unitops.UnitMul.evidenceMSG1[Int, coulomb.accepted.Degree, Int, [error] | coulomb.accepted.Percent [error] | , ORT](spire.std.any.IntAlgebra, [error] | coulomb.unitops.UnitConverter.witnessIdentity[Int, coulomb.accepted.Percent] [error] | , [error] | coulomb.infra.MulResultType.result[coulomb.accepted.Degree, [error] | coulomb.accepted.Percent [error] | , OL, OR, OU, ORT]( [error] | coulomb.infra.StandardSig.evidenceDerivedUnit[coulomb.accepted.Degree]( [error] | coulomb.accepted.defineUnitDegree [error] | ) [error] | , [error] | coulomb.infra.StandardSig.evidenceDerivedUnit[coulomb.accepted.Percent]( [error] | coulomb.accepted.defineUnitPercent [error] | ) [error] | , [error] | coulomb.infra.UnifySigMul.unify1[coulomb.accepted.Degree, (1 : Int), [error] | shapeless.HNil [error] | , ((coulomb.accepted.Percent, (1 : Int)) :: shapeless.HNil), [error] | [error] | ((coulomb.accepted.Percent, (1 : Int)) :: [error] | ((coulomb.accepted.Degree, (1 : Int)) :: shapeless.HNil) [error] | ) [error] | [error] | , OU]( [error] | coulomb.infra.InsertSigMul.insert2[coulomb.accepted.Degree, (1 : Int), [error] | coulomb.accepted.Percent [error] | , (1 : Int), shapeless.HNil, [error] | ((coulomb.accepted.Degree, (1 : Int)) :: shapeless.HNil) [error] | ](shapeless.neq[coulomb.accepted.Degree, coulomb.accepted.Percent], [error] | coulomb.infra.InsertSigMul.insert0[coulomb.accepted.Degree, (1 : Int)] [error] | ) [error] | , [error] | coulomb.infra.UnifySigMul.unify0[ [error] | [error] | ((coulomb.accepted.Percent, (1 : Int)) :: (coulomb.accepted.Degree, [error] | (1 : Int) [error] | ) :: shapeless.HNil) [error] | [error] | ] [error] | ) [error] | , [error] | coulomb.infra.ResType.evidence[ [error] | [error] | ((coulomb.accepted.Percent, (1 : Int)) :: (coulomb.accepted.Degree, [error] | (1 : Int) [error] | ) :: shapeless.HNil) [error] | [error] | , NS, DS, ORT]( [error] | coulomb.infra.SortUnitSig.evidence[ [error] | [error] | ((coulomb.accepted.Percent, (1 : Int)) :: (coulomb.accepted.Degree, [error] | (1 : Int) [error] | ) :: shapeless.HNil) [error] | [error] | , NS, DS]( [error] | coulomb.infra.SortUnitSigCall.evidence2[coulomb.accepted.Percent, [error] | (1 : Int) [error] | , ((coulomb.accepted.Degree, (1 : Int)) :: shapeless.HNil), [error] | shapeless.HNil [error] | , shapeless.HNil, NP, DO, NS, DS]( [error] | coulomb.infra.XIntLT.witness[(1 : Int), (0 : Int)]( [error] | singleton.ops.impl.OpMacro.call[N, S1, S2, S3, OutWide, Out, OutNat [error] | , [error] | OutChar, OutInt, OutLong, OutFloat, OutDouble, OutString, OutBoolean [error] | ] [error] | ) [error] | , ???, ???, ???) [error] | ) [error] | , ???) [error] | ) [error] | ) [error] | [error] |But method call in object OpMacro does not match type (1 : Int) < (0 : Int). [error] | [error] |One of the following imports might make progress towards fixing the problem: [error] | [error] | import shapeless.~?>.idKeyWitness [error] | import shapeless.~?>.idValueWitness
It's fine to tell me to go read something. Thanks again,
David
Beta Was this translation helpful? Give feedback.
All reactions