uom-plugin-0.4.0.0: Units of measure as a GHC type-checker plugin
Safe HaskellSafe-Inferred
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"

Orphan instances

(Show a, KnownUnit (Unpack u)) => Show (Quantity a u) Source # 
Instance details

Methods

showsPrec :: Int -> Quantity a u -> ShowS #

show :: Quantity a u -> String #

showList :: [Quantity a u] -> ShowS #