I need to work with time (milliseconds), angles (degrees), and distance (millimeters), and dimensionless numbers. I want to write methods in terms of these, not just numbers.
In Opaque Types | Scala 3 — Book | Scala Documentation I see how I can use opaque types to do it. That makes sense, and looks very efficient. (The processor I’m using is pretty limited; 32-bit, not a lot of memory, slow IO, in a feedback loop) Is this the best way? What will the pitfalls be?
The system I’ll be talking to only knows Ints. Floats might make for fewer edge cases. Are there any pitfalls with opaque types backed by Ints vs Floats?
I’ll need to express angular velocity (degrees per second) (not degrees per millisecond), and speed. Will the combinations of units and methods to manipulate them get out of hand? Is there a way to avoid that growth that also resolves everything at compile time?
A “go read …” answer is fine.