0

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?

fho
  • 6,787
  • 26
  • 71

2 Answers2

3

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).

Sjoerd Visscher
  • 11,840
  • 2
  • 47
  • 59
0

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
Chris Taylor
  • 46,912
  • 15
  • 110
  • 154
  • By "short" I mean something that makes obvious that we are dealing with `power over time` here. I could of course define `type powerOverTime :: Quantity (Dim ...` but I hope there is a better way. – fho Dec 13 '13 at 13:58