convert-units-0: Arithmetic and type checked conversions between units.
Copyright(c) Alice Rixte 2025
LicenseBSD 3
Maintaineralice.rixte@u-bordeaux.fr
Stabilityunstable
Portabilitynon-portable (GHC extensions)
Safe HaskellNone
LanguageHaskell2010

Data.Units.Base.TH

Description

 
Synopsis
  • mkUnit :: String -> String -> Name -> Rational -> Q [Dec]
  • mkUnitNoFactor :: String -> String -> Name -> Q [Dec]
  • mkBaseUnit :: String -> String -> Name -> Q [Dec]
  • mkDim :: String -> String -> Integer -> Q [Dec]
  • mkPrefix :: String -> String -> Rational -> Q [Dec]

Units

mkUnit :: String -> String -> Name -> Rational -> Q [Dec] Source #

Make a unit that can be converted via a factor

Usage:
$(mkUnit Minute "min" ''Time 60)

mkUnitNoFactor :: String -> String -> Name -> Q [Dec] Source #

Make a unit without declaring any conversion instances.

Conversion instances must be added by hand.

Usage:
$(mkUnit "Bel" B ''NoUnit )

mkBaseUnit :: String -> String -> Name -> Q [Dec] Source #

Make a base unit.

In addition to calling mkUnit with factor 1, this also makes an instance of IsDim, which cannot be done in mkDim since the base unit is not yet declared.

Usage:
 $(mkBaseUnit Second "s" ''Time )

Dimensions

mkDim :: String -> String -> Integer -> Q [Dec] Source #

Make a dimension.

This will not declare an instance for IsDim, which is instead declared using mkBaseUnit.

Prefixes

mkPrefix :: String -> String -> Rational -> Q [Dec] Source #

Make a unit prefix.

Usage:
$(mkPrefix Kilo "k" 1000)