uom-plugin- Units of measure as a GHC typechecker plugin

Safe HaskellNone



Experimental support for showing units of measure in a pretty syntax. This requires the units to be fully determined.

Apart from the definitions below, this module also exports a Show instance for Quantity a u, which is re-exported by Data.UnitsOfMeasure.



showQuantity :: forall a u. (Show a, KnownUnit (Unpack u)) => Quantity a u -> String Source

Render a quantity nicely, followed by its units:

>>> showQuantity (1 /: [u| 0.1 s / m kg |])
"10.0 kg m / s"

showUnit :: forall proxy u. KnownUnit (Unpack u) => proxy u -> String Source

Render a unit nicely:

>>> showUnit (undefined :: proxy [u| 1 / s |])