-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
It would be nice to have a modeling of unit names (actually, just what we now call NameAtoms, which are the leaf nodes of composite UnitNames that we model really well) that did better with handling other languages.
This would:
- Allow translation of unit names to other languages
- ... especially languages like LaTeX / siunitx
- Fix the issue where we treat UCUM names specially all over the place, and track the UCUM-ness of names
Current representation:
data NameAtom (m :: NameAtomType)
= NameAtom
{
_interchangeName :: InterchangeName, -- ^ The interchange name of the unit.
abbreviation_en :: String, -- ^ The abbreviated name of the unit in international English
name_en :: String -- ^ The full name of the unit in international English
}
deriving (Eq, Ord, Data, Typeable, Generic)
Sketch alternative:
import qualified Data.Map.Strict as M
type LanguageName = String
newtype NameAtom (m :: NameAtomType) = NameAtom (M.Map LanguageName String)
ucum :: LanguageName
ucum = "x-ucum"
siunitx :: LanguageName
siunitx = "x-siunitx"
internationalEnglish :: LanguageName
internationalEnglish = "en"
usEnglish :: LanguageName
usEnglish = "en-US"
internationalEnglishAbbreviation :: LanguageName
internationalEnglishAbbreviation = "en-x-abbrev"
The meter might have a name atom something like this one:
nMeter :: UnitName 'Metric
nMeter = MetricAtomic $ M.fromList [(ucum, "m"),
(internationalEnglish, "metre"),
(usEnglish, "meter"),
(siunitx, "\metre"),
(internationalEnglishAbbreviation, "m")]
(probably there would be a convenience function for making names like that from a lot of strings, as we do now).
Units that aren't in the UCUM or aren't in siunitx simply wouldn't have those entries.
As proposed this would require a containers dependency.