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

Safe HaskellNone
LanguageHaskell2010

Data.UnitsOfMeasure.Show

Description

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.

Synopsis

Documentation

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 |])
"s^-1"