What's the (short) type of `10 *~ (watt / second)`

130 views Asked by At

Quick question: Using dimensional GHC infers the type of testRate = 10 *~ (watt / second) to be:

testRate
  :: Numeric.Units.Dimensional.Quantity
       (Numeric.Units.Dimensional.Dim
          (numtype-1.0.1:Numeric.NumType.Pos
             numtype-1.0.1:Numeric.NumType.Pos1)
          (numtype-1.0.1:Numeric.NumType.Pos
             numtype-1.0.1:Numeric.NumType.Zero)
          (numtype-1.0.1:Numeric.NumType.Neg
             (numtype-1.0.1:Numeric.NumType.Neg
                numtype-1.0.1:Numeric.NumType.Neg2))
          numtype-1.0.1:Numeric.NumType.Zero
          numtype-1.0.1:Numeric.NumType.Zero
          numtype-1.0.1:Numeric.NumType.Zero
          numtype-1.0.1:Numeric.NumType.Zero)
       a

What would be the short type of testRate? And how do I derive the type of other such units?

2

There are 2 answers

0
Sjoerd Visscher On BEST ANSWER

If you switch to dimensional-tf you can write it as

testRate :: Quantity (Div DPower DTime) a

I don't think there's a good generic way to derive these types, just write down the type equivalent of what you think the unit should be (using Mul and Div).

1
Chris Taylor On

What do you mean by the short type? The best you could do would be to remove all the module qualifiers, eg

testRate
  :: Quantity
       (Dim
          (Pos Pos1)
          (Pos Zero)
          (Neg (Neg Neg2))
          Zero
          Zero
          Zero
          Zero)
       a