{-# LANGUAGE TypeOperators, TemplateHaskell #-}
module Data.Units.SI.Prefixes where
import Language.Haskell.TH ( Name )
import Data.Metrology.Poly
data Deca = Deca
instance UnitPrefix Deca where
multiplier _ = 1e1
instance Show Deca where
show _ = "da"
deca :: unit -> Deca :@ unit
deca = (Deca :@)
data Hecto = Hecto
instance UnitPrefix Hecto where
multiplier _ = 1e2
instance Show Hecto where
show _ = "h"
hecto :: unit -> Hecto :@ unit
hecto = (Hecto :@)
data Kilo = Kilo
instance UnitPrefix Kilo where
multiplier _ = 1e3
instance Show Kilo where
show _ = "k"
kilo :: unit -> Kilo :@ unit
kilo = (Kilo :@)
data Mega = Mega
instance UnitPrefix Mega where
multiplier _ = 1e6
instance Show Mega where
show _ = "M"
mega :: unit -> Mega :@ unit
mega = (Mega :@)
data Giga = Giga
instance UnitPrefix Giga where
multiplier _ = 1e9
instance Show Giga where
show _ = "G"
giga :: unit -> Giga :@ unit
giga = (Giga :@)
data Tera = Tera
instance UnitPrefix Tera where
multiplier _ = 1e12
instance Show Tera where
show _ = "T"
tera :: unit -> Tera :@ unit
tera = (Tera :@)
data Peta = Peta
instance UnitPrefix Peta where
multiplier _ = 1e15
instance Show Peta where
show _ = "P"
peta :: unit -> Peta :@ unit
peta = (Peta :@)
data Exa = Exa
instance UnitPrefix Exa where
multiplier _ = 1e18
instance Show Exa where
show _ = "E"
exa :: unit -> Exa :@ unit
exa = (Exa :@)
data Zetta = Zetta
instance UnitPrefix Zetta where
multiplier _ = 1e21
instance Show Zetta where
show _ = "Z"
zetta :: unit -> Zetta :@ unit
zetta = (Zetta :@)
data Yotta = Yotta
instance UnitPrefix Yotta where
multiplier _ = 1e24
instance Show Yotta where
show _ = "Y"
yotta :: unit -> Yotta :@ unit
yotta = (Yotta :@)
data Deci = Deci
instance UnitPrefix Deci where
multiplier _ = 1e-1
instance Show Deci where
show _ = "d"
deci :: unit -> Deci :@ unit
deci = (Deci :@)
data Centi = Centi
instance UnitPrefix Centi where
multiplier _ = 1e-2
instance Show Centi where
show _ = "c"
centi :: unit -> Centi :@ unit
centi = (Centi :@)
data Milli = Milli
instance UnitPrefix Milli where
multiplier _ = 1e-3
instance Show Milli where
show _ = "m"
milli :: unit -> Milli :@ unit
milli = (Milli :@)
data Micro = Micro
instance UnitPrefix Micro where
multiplier _ = 1e-6
instance Show Micro where
show _ = "μ"
micro :: unit -> Micro :@ unit
micro = (Micro :@)
data Nano = Nano
instance UnitPrefix Nano where
multiplier _ = 1e-9
instance Show Nano where
show _ = "n"
nano :: unit -> Nano :@ unit
nano = (Nano :@)
data Pico = Pico
instance UnitPrefix Pico where
multiplier _ = 1e-12
instance Show Pico where
show _ = "p"
pico :: unit -> Pico :@ unit
pico = (Pico :@)
data Femto = Femto
instance UnitPrefix Femto where
multiplier _ = 1e-15
instance Show Femto where
show _ = "f"
femto :: unit -> Femto :@ unit
femto = (Femto :@)
data Atto = Atto
instance UnitPrefix Atto where
multiplier _ = 1e-18
instance Show Atto where
show _ = "a"
atto :: unit -> Atto :@ unit
atto = (Atto :@)
data Zepto = Zepto
instance UnitPrefix Zepto where
multiplier _ = 1e-21
instance Show Zepto where
show _ = "z"
zepto :: unit -> Zepto :@ unit
zepto = (Zepto :@)
data Yocto = Yocto
instance UnitPrefix Yocto where
multiplier _ = 1e-24
instance Show Yocto where
show _ = "y"
yocto :: unit -> Yocto :@ unit
yocto = (Yocto :@)
siPrefixes :: [Name]
siPrefixes =
[ ''Deca, ''Hecto, ''Kilo, ''Mega, ''Giga, ''Tera, ''Peta, ''Exa
, ''Zetta, ''Yotta, ''Deci, ''Centi, ''Milli, ''Micro, ''Nano
, ''Pico, ''Femto, ''Atto, ''Zepto, ''Yocto
]