module Drasil.DocumentLanguage.Units where
import Language.Drasil (Sentence(S, Sy), usymb, MayHaveUnit(getUnit))
toSentence :: (MayHaveUnit u) => u -> Sentence
toSentence :: forall u. MayHaveUnit u => u -> Sentence
toSentence u
x = Sentence -> (UnitDefn -> Sentence) -> Maybe UnitDefn -> Sentence
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (String -> Sentence
S String
"--") (USymb -> Sentence
Sy (USymb -> Sentence) -> (UnitDefn -> USymb) -> UnitDefn -> Sentence
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UnitDefn -> USymb
forall u. HasUnitSymbol u => u -> USymb
usymb) (u -> Maybe UnitDefn
forall u. MayHaveUnit u => u -> Maybe UnitDefn
getUnit u
x)
toSentenceUnitless :: (MayHaveUnit u) => u -> Sentence
toSentenceUnitless :: forall u. MayHaveUnit u => u -> Sentence
toSentenceUnitless u
x = Sentence -> (UnitDefn -> Sentence) -> Maybe UnitDefn -> Sentence
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (String -> Sentence
S String
"Unitless") (USymb -> Sentence
Sy (USymb -> Sentence) -> (UnitDefn -> USymb) -> UnitDefn -> Sentence
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UnitDefn -> USymb
forall u. HasUnitSymbol u => u -> USymb
usymb) (u -> Maybe UnitDefn
forall u. MayHaveUnit u => u -> Maybe UnitDefn
getUnit u
x)