Skip to content

Possibility to invert units automatically #720

@GideonBear

Description

@GideonBear

Hi! Sometimes I run into this problem:

>>> 5 min/km -> km/h
error: while type checking
  ┌─ <input:22>:1:1
  │
1 │ 5 min/km -> km/h
  │ ^^^^^^^^ -- ^^^^ Velocity
  │ │        │   
  │ │        incompatible dimensions in unit conversion
  │ Time / Length
  │
  =  left hand side: Length⁻¹ × Time
    right hand side: Length   × Time⁻¹    [= Velocity]
    
    Suggested fix: invert the expression on the right hand side

>>> 1 / (5 min/km) -> km/h

  1 / (5 minute / kilometre) ➞ kilometre / hour

    = 12.0 km/h    [Velocity]

In my perfect world, I would just be allowed to convert Length⁻¹ × Time ➞ Length × Time⁻¹. Of course that only make sense in some situations, so it's good that it's not allowed. But maybe this is something that should be configurable? Because in a lot of cases it makes perfect sense. Another big one is fuel economy (miles / gallon -> liters / 100 km, both are widely used).

>>> 5 min/km -> km/h

  5 minute / kilometre ➞ kilometre / hour
  note: automatic inversion from Length⁻¹ × Time to Length × Time⁻¹

    = 12.0 km/h    [Velocity]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions