    {-# OPTIONS_HADDOCK hide #-}
    -- | This module is only being exposed to work around a GHC bug, its API is not stable

    {-# LANGUAGE TemplateHaskell #-}
    {-# LANGUAGE GeneralizedNewtypeDeriving #-}
    {-# LANGUAGE FlexibleInstances #-}
    module Text.Internal.CssCommon where

    import Text.Internal.Css
    import Text.MkSizeType
    import qualified Data.Text as TS
    import Text.Printf (printf)
    import Language.Haskell.TH
    import Data.Word (Word8)
    import Data.Bits
    import qualified Data.Text.Lazy as TL

    renderCssUrl :: (url -> [(TS.Text, TS.Text)] -> TS.Text) -> CssUrl url -> TL.Text
    renderCssUrl :: forall url. (url -> [(Text, Text)] -> Text) -> CssUrl url -> Text
    renderCssUrl url -> [(Text, Text)] -> Text
    r CssUrl url
    s = Css -> Text
    renderCss (Css -> Text) -> Css -> Text
    forall a b. (a -> b) -> a -> b
    $ CssUrl url
    s url -> [(Text, Text)] -> Text
    r

    data Color = Color Word8 Word8 Word8
        deriving Int -> Color -> ShowS
    [Color] -> ShowS
    Color -> [Char]
    (Int -> Color -> ShowS)
    -> (Color -> [Char]) -> ([Color] -> ShowS) -> Show Color
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Color -> ShowS
    showsPrec :: Int -> Color -> ShowS
    $cshow :: Color -> [Char]
    show :: Color -> [Char]
    $cshowList :: [Color] -> ShowS
    showList :: [Color] -> ShowS
    Show
    instance ToCss Color where
        toCss :: Color -> Builder
    toCss (Color Word8
    r Word8
    g Word8
    b) =
            let (Char
    r1, Char
    r2) = Word8 -> (Char, Char)
    toHex Word8
    r
                (Char
    g1, Char
    g2) = Word8 -> (Char, Char)
    toHex Word8
    g
                (Char
    b1, Char
    b2) = Word8 -> (Char, Char)
    toHex Word8
    b
             in Text -> Builder
    fromText (Text -> Builder) -> Text -> Builder
    forall a b. (a -> b) -> a -> b
    $ [Char] -> Text
    TS.pack ([Char] -> Text) -> [Char] -> Text
    forall a b. (a -> b) -> a -> b
    $ Char
    '#' Char -> ShowS
    forall a. a -> [a] -> [a]
    :
                if Char
    r1 Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    == Char
    r2 Bool -> Bool -> Bool
    && Char
    g1 Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    == Char
    g2 Bool -> Bool -> Bool
    && Char
    b1 Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    == Char
    b2
                    then [Char
    r1, Char
    g1, Char
    b1]
                    else [Char
    r1, Char
    r2, Char
    g1, Char
    g2, Char
    b1, Char
    b2]
          where
            toHex :: Word8 -> (Char, Char)
            toHex :: Word8 -> (Char, Char)
    toHex Word8
    x = (Word8 -> Char
    toChar (Word8 -> Char) -> Word8 -> Char
    forall a b. (a -> b) -> a -> b
    $ Word8 -> Int -> Word8
    forall a. Bits a => a -> Int -> a
    shiftR Word8
    x Int
    4, Word8 -> Char
    toChar (Word8 -> Char) -> Word8 -> Char
    forall a b. (a -> b) -> a -> b
    $ Word8
    x Word8 -> Word8 -> Word8
    forall a. Bits a => a -> a -> a
    .&. Word8
    15)
            toChar :: Word8 -> Char
            toChar :: Word8 -> Char
    toChar Word8
    c
                | Word8
    c Word8 -> Word8 -> Bool
    forall a. Ord a => a -> a -> Bool
    < Word8
    10 = Word8 -> Word8 -> Char -> Char
    mkChar Word8
    c Word8
    0 Char
    '0'
                | Bool
    otherwise = Word8 -> Word8 -> Char -> Char
    mkChar Word8
    c Word8
    10 Char
    'A'
            mkChar :: Word8 -> Word8 -> Char -> Char
            mkChar :: Word8 -> Word8 -> Char -> Char
    mkChar Word8
    a Word8
    b' Char
    c =
                Int -> Char
    forall a. Enum a => Int -> a
    toEnum (Int -> Char) -> Int -> Char
    forall a b. (a -> b) -> a -> b
    $ Word8 -> Int
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (Word8 -> Int) -> Word8 -> Int
    forall a b. (a -> b) -> a -> b
    $ Word8
    a Word8 -> Word8 -> Word8
    forall a. Num a => a -> a -> a
    - Word8
    b' Word8 -> Word8 -> Word8
    forall a. Num a => a -> a -> a
    + Int -> Word8
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (Char -> Int
    forall a. Enum a => a -> Int
    fromEnum Char
    c)

    colorRed :: Color
    colorRed :: Color
    colorRed = Word8 -> Word8 -> Word8 -> Color
    Color Word8
    255 Word8
    0 Word8
    0

    colorBlack :: Color
    colorBlack :: Color
    colorBlack = Word8 -> Word8 -> Word8 -> Color
    Color Word8
    0 Word8
    0 Word8
    0

    -- CSS size wrappers

    -- | Create a CSS size, e.g. $(mkSize "100px").
    mkSize :: String -> ExpQ
    mkSize :: [Char] -> ExpQ
    mkSize [Char]
    s = ExpQ -> ExpQ -> ExpQ
    forall (m :: * -> *). Quote m => m Exp -> m Exp -> m Exp
    appE ExpQ
    nameE ExpQ
    valueE
      where [(Double
    value, [Char]
    unit)] = ReadS Double
    forall a. Read a => ReadS a
    reads [Char]
    s :: [(Double, String)]
            absoluteSizeE :: ExpQ
    absoluteSizeE = Name -> ExpQ
    forall (m :: * -> *). Quote m => Name -> m Exp
    varE (Name -> ExpQ) -> Name -> ExpQ
    forall a b. (a -> b) -> a -> b
    $ [Char] -> Name
    mkName [Char]
    "absoluteSize"
            nameE :: ExpQ
    nameE = case [Char]
    unit of
              [Char]
    "cm" -> ExpQ -> ExpQ -> ExpQ
    forall (m :: * -> *). Quote m => m Exp -> m Exp -> m Exp
    appE ExpQ
    absoluteSizeE (Name -> ExpQ
    forall (m :: * -> *). Quote m => Name -> m Exp
    conE (Name -> ExpQ) -> Name -> ExpQ
    forall a b. (a -> b) -> a -> b
    $ [Char] -> Name
    mkName [Char]
    "Centimeter")
              [Char]
    "em" -> Name -> ExpQ
    forall (m :: * -> *). Quote m => Name -> m Exp
    conE (Name -> ExpQ) -> Name -> ExpQ
    forall a b. (a -> b) -> a -> b
    $ [Char] -> Name
    mkName [Char]
    "EmSize"
              [Char]
    "ex" -> Name -> ExpQ
    forall (m :: * -> *). Quote m => Name -> m Exp
    conE (Name -> ExpQ) -> Name -> ExpQ
    forall a b. (a -> b) -> a -> b
    $ [Char] -> Name
    mkName [Char]
    "ExSize"
              [Char]
    "in" -> ExpQ -> ExpQ -> ExpQ
    forall (m :: * -> *). Quote m => m Exp -> m Exp -> m Exp
    appE ExpQ
    absoluteSizeE (Name -> ExpQ
    forall (m :: * -> *). Quote m => Name -> m Exp
    conE (Name -> ExpQ) -> Name -> ExpQ
    forall a b. (a -> b) -> a -> b
    $ [Char] -> Name
    mkName [Char]
    "Inch")
              [Char]
    "mm" -> ExpQ -> ExpQ -> ExpQ
    forall (m :: * -> *). Quote m => m Exp -> m Exp -> m Exp
    appE ExpQ
    absoluteSizeE (Name -> ExpQ
    forall (m :: * -> *). Quote m => Name -> m Exp
    conE (Name -> ExpQ) -> Name -> ExpQ
    forall a b. (a -> b) -> a -> b
    $ [Char] -> Name
    mkName [Char]
    "Millimeter")
              [Char]
    "pc" -> ExpQ -> ExpQ -> ExpQ
    forall (m :: * -> *). Quote m => m Exp -> m Exp -> m Exp
    appE ExpQ
    absoluteSizeE (Name -> ExpQ
    forall (m :: * -> *). Quote m => Name -> m Exp
    conE (Name -> ExpQ) -> Name -> ExpQ
    forall a b. (a -> b) -> a -> b
    $ [Char] -> Name
    mkName [Char]
    "Pica")
              [Char]
    "pt" -> ExpQ -> ExpQ -> ExpQ
    forall (m :: * -> *). Quote m => m Exp -> m Exp -> m Exp
    appE ExpQ
    absoluteSizeE (Name -> ExpQ
    forall (m :: * -> *). Quote m => Name -> m Exp
    conE (Name -> ExpQ) -> Name -> ExpQ
    forall a b. (a -> b) -> a -> b
    $ [Char] -> Name
    mkName [Char]
    "Point")
              [Char]
    "px" -> Name -> ExpQ
    forall (m :: * -> *). Quote m => Name -> m Exp
    conE (Name -> ExpQ) -> Name -> ExpQ
    forall a b. (a -> b) -> a -> b
    $ [Char] -> Name
    mkName [Char]
    "PixelSize"
              [Char]
    "%" -> Name -> ExpQ
    forall (m :: * -> *). Quote m => Name -> m Exp
    varE (Name -> ExpQ) -> Name -> ExpQ
    forall a b. (a -> b) -> a -> b
    $ [Char] -> Name
    mkName [Char]
    "percentageSize"
              [Char]
    _ -> [Char] -> ExpQ
    forall a. HasCallStack => [Char] -> a
    error ([Char] -> ExpQ) -> [Char] -> ExpQ
    forall a b. (a -> b) -> a -> b
    $ [Char]
    "In mkSize, invalid unit: " [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    unit
            valueE :: ExpQ
    valueE = Lit -> ExpQ
    forall (m :: * -> *). Quote m => Lit -> m Exp
    litE (Lit -> ExpQ) -> Lit -> ExpQ
    forall a b. (a -> b) -> a -> b
    $ Rational -> Lit
    rationalL (Double -> Rational
    forall a. Real a => a -> Rational
    toRational Double
    value)

    -- | Absolute size units.
    data AbsoluteUnit = Centimeter
                      | Inch
                      | Millimeter
                      | Pica
                      | Point
                      deriving (AbsoluteUnit -> AbsoluteUnit -> Bool
    (AbsoluteUnit -> AbsoluteUnit -> Bool)
    -> (AbsoluteUnit -> AbsoluteUnit -> Bool) -> Eq AbsoluteUnit
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: AbsoluteUnit -> AbsoluteUnit -> Bool
    == :: AbsoluteUnit -> AbsoluteUnit -> Bool
    $c/= :: AbsoluteUnit -> AbsoluteUnit -> Bool
    /= :: AbsoluteUnit -> AbsoluteUnit -> Bool
    Eq, Int -> AbsoluteUnit -> ShowS
    [AbsoluteUnit] -> ShowS
    AbsoluteUnit -> [Char]
    (Int -> AbsoluteUnit -> ShowS)
    -> (AbsoluteUnit -> [Char])
    -> ([AbsoluteUnit] -> ShowS)
    -> Show AbsoluteUnit
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> AbsoluteUnit -> ShowS
    showsPrec :: Int -> AbsoluteUnit -> ShowS
    $cshow :: AbsoluteUnit -> [Char]
    show :: AbsoluteUnit -> [Char]
    $cshowList :: [AbsoluteUnit] -> ShowS
    showList :: [AbsoluteUnit] -> ShowS
    Show)

    -- | Not intended for direct use, see 'mkSize'.
    data AbsoluteSize = AbsoluteSize
        { AbsoluteSize -> AbsoluteUnit
    absoluteSizeUnit :: AbsoluteUnit -- ^ Units used for text formatting.
        , AbsoluteSize -> Rational
    absoluteSizeValue :: Rational -- ^ Normalized value in centimeters.
        }

    -- | Absolute size unit convertion rate to centimeters.
    absoluteUnitRate :: AbsoluteUnit -> Rational
    absoluteUnitRate :: AbsoluteUnit -> Rational
    absoluteUnitRate AbsoluteUnit
    Centimeter = Rational
    1
    absoluteUnitRate AbsoluteUnit
    Inch = Rational
    2.54
    absoluteUnitRate AbsoluteUnit
    Millimeter = Rational
    0.1
    absoluteUnitRate AbsoluteUnit
    Pica = Rational
    12 Rational -> Rational -> Rational
    forall a. Num a => a -> a -> a
    * AbsoluteUnit -> Rational
    absoluteUnitRate AbsoluteUnit
    Point
    absoluteUnitRate AbsoluteUnit
    Point = Rational
    1 Rational -> Rational -> Rational
    forall a. Fractional a => a -> a -> a
    / Rational
    72 Rational -> Rational -> Rational
    forall a. Num a => a -> a -> a
    * AbsoluteUnit -> Rational
    absoluteUnitRate AbsoluteUnit
    Inch

    -- | Constructs 'AbsoluteSize'. Not intended for direct use, see 'mkSize'.
    absoluteSize :: AbsoluteUnit -> Rational -> AbsoluteSize
    absoluteSize :: AbsoluteUnit -> Rational -> AbsoluteSize
    absoluteSize AbsoluteUnit
    unit Rational
    value = AbsoluteUnit -> Rational -> AbsoluteSize
    AbsoluteSize AbsoluteUnit
    unit (Rational
    value Rational -> Rational -> Rational
    forall a. Num a => a -> a -> a
    * AbsoluteUnit -> Rational
    absoluteUnitRate AbsoluteUnit
    unit)

    instance Show AbsoluteSize where
      show :: AbsoluteSize -> [Char]
    show (AbsoluteSize AbsoluteUnit
    unit Rational
    value') = [Char] -> Double -> [Char]
    forall r. PrintfType r => [Char] -> r
    printf [Char]
    "%f" Double
    value [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    suffix
        where value :: Double
    value = Rational -> Double
    forall a. Fractional a => Rational -> a
    fromRational (Rational
    value' Rational -> Rational -> Rational
    forall a. Fractional a => a -> a -> a
    / AbsoluteUnit -> Rational
    absoluteUnitRate AbsoluteUnit
    unit) :: Double
              suffix :: [Char]
    suffix = case AbsoluteUnit
    unit of
                AbsoluteUnit
    Centimeter -> [Char]
    "cm"
                AbsoluteUnit
    Inch -> [Char]
    "in"
                AbsoluteUnit
    Millimeter -> [Char]
    "mm"
                AbsoluteUnit
    Pica -> [Char]
    "pc"
                AbsoluteUnit
    Point -> [Char]
    "pt"

    instance Eq AbsoluteSize where
      (AbsoluteSize AbsoluteUnit
    _ Rational
    v1) == :: AbsoluteSize -> AbsoluteSize -> Bool
    == (AbsoluteSize AbsoluteUnit
    _ Rational
    v2) = Rational
    v1 Rational -> Rational -> Bool
    forall a. Eq a => a -> a -> Bool
    == Rational
    v2

    instance Ord AbsoluteSize where
      compare :: AbsoluteSize -> AbsoluteSize -> Ordering
    compare (AbsoluteSize AbsoluteUnit
    _ Rational
    v1) (AbsoluteSize AbsoluteUnit
    _ Rational
    v2) = Rational -> Rational -> Ordering
    forall a. Ord a => a -> a -> Ordering
    compare Rational
    v1 Rational
    v2

    instance Num AbsoluteSize where
      (AbsoluteSize AbsoluteUnit
    u1 Rational
    v1) + :: AbsoluteSize -> AbsoluteSize -> AbsoluteSize
    + (AbsoluteSize AbsoluteUnit
    _ Rational
    v2) = AbsoluteUnit -> Rational -> AbsoluteSize
    AbsoluteSize AbsoluteUnit
    u1 (Rational
    v1 Rational -> Rational -> Rational
    forall a. Num a => a -> a -> a
    + Rational
    v2)
      (AbsoluteSize AbsoluteUnit
    u1 Rational
    v1) * :: AbsoluteSize -> AbsoluteSize -> AbsoluteSize
    * (AbsoluteSize AbsoluteUnit
    _ Rational
    v2) = AbsoluteUnit -> Rational -> AbsoluteSize
    AbsoluteSize AbsoluteUnit
    u1 (Rational
    v1 Rational -> Rational -> Rational
    forall a. Num a => a -> a -> a
    * Rational
    v2)
      (AbsoluteSize AbsoluteUnit
    u1 Rational
    v1) - :: AbsoluteSize -> AbsoluteSize -> AbsoluteSize
    - (AbsoluteSize AbsoluteUnit
    _ Rational
    v2) = AbsoluteUnit -> Rational -> AbsoluteSize
    AbsoluteSize AbsoluteUnit
    u1 (Rational
    v1 Rational -> Rational -> Rational
    forall a. Num a => a -> a -> a
    - Rational
    v2)
      abs :: AbsoluteSize -> AbsoluteSize
    abs (AbsoluteSize AbsoluteUnit
    u Rational
    v) = AbsoluteUnit -> Rational -> AbsoluteSize
    AbsoluteSize AbsoluteUnit
    u (Rational -> Rational
    forall a. Num a => a -> a
    abs Rational
    v)
      signum :: AbsoluteSize -> AbsoluteSize
    signum (AbsoluteSize AbsoluteUnit
    u Rational
    v) = AbsoluteUnit -> Rational -> AbsoluteSize
    AbsoluteSize AbsoluteUnit
    u (Rational -> Rational
    forall a. Num a => a -> a
    abs Rational
    v)
      fromInteger :: Integer -> AbsoluteSize
    fromInteger Integer
    x = AbsoluteUnit -> Rational -> AbsoluteSize
    AbsoluteSize AbsoluteUnit
    Centimeter (Integer -> Rational
    forall a. Num a => Integer -> a
    fromInteger Integer
    x)

    instance Fractional AbsoluteSize where
      (AbsoluteSize AbsoluteUnit
    u1 Rational
    v1) / :: AbsoluteSize -> AbsoluteSize -> AbsoluteSize
    / (AbsoluteSize AbsoluteUnit
    _ Rational
    v2) = AbsoluteUnit -> Rational -> AbsoluteSize
    AbsoluteSize AbsoluteUnit
    u1 (Rational
    v1 Rational -> Rational -> Rational
    forall a. Fractional a => a -> a -> a
    / Rational
    v2)
      fromRational :: Rational -> AbsoluteSize
    fromRational Rational
    x = AbsoluteUnit -> Rational -> AbsoluteSize
    AbsoluteSize AbsoluteUnit
    Centimeter (Rational -> Rational
    forall a. Fractional a => Rational -> a
    fromRational Rational
    x)

    instance ToCss AbsoluteSize where
      toCss :: AbsoluteSize -> Builder
    toCss = Text -> Builder
    fromText (Text -> Builder)
    -> (AbsoluteSize -> Text) -> AbsoluteSize -> Builder
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Char] -> Text
    TS.pack ([Char] -> Text)
    -> (AbsoluteSize -> [Char]) -> AbsoluteSize -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . AbsoluteSize -> [Char]
    forall a. Show a => a -> [Char]
    show

    -- | Not intended for direct use, see 'mkSize'.
    data PercentageSize = PercentageSize
        { PercentageSize -> Rational
    percentageSizeValue :: Rational -- ^ Normalized value, 1 == 100%.
        }
                        deriving (PercentageSize -> PercentageSize -> Bool
    (PercentageSize -> PercentageSize -> Bool)
    -> (PercentageSize -> PercentageSize -> Bool) -> Eq PercentageSize
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: PercentageSize -> PercentageSize -> Bool
    == :: PercentageSize -> PercentageSize -> Bool
    $c/= :: PercentageSize -> PercentageSize -> Bool
    /= :: PercentageSize -> PercentageSize -> Bool
    Eq, Eq PercentageSize
    Eq PercentageSize =>
    (PercentageSize -> PercentageSize -> Ordering)
    -> (PercentageSize -> PercentageSize -> Bool)
    -> (PercentageSize -> PercentageSize -> Bool)
    -> (PercentageSize -> PercentageSize -> Bool)
    -> (PercentageSize -> PercentageSize -> Bool)
    -> (PercentageSize -> PercentageSize -> PercentageSize)
    -> (PercentageSize -> PercentageSize -> PercentageSize)
    -> Ord PercentageSize
    PercentageSize -> PercentageSize -> Bool
    PercentageSize -> PercentageSize -> Ordering
    PercentageSize -> PercentageSize -> PercentageSize
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: PercentageSize -> PercentageSize -> Ordering
    compare :: PercentageSize -> PercentageSize -> Ordering
    $c< :: PercentageSize -> PercentageSize -> Bool
    < :: PercentageSize -> PercentageSize -> Bool
    $c<= :: PercentageSize -> PercentageSize -> Bool
    <= :: PercentageSize -> PercentageSize -> Bool
    $c> :: PercentageSize -> PercentageSize -> Bool
    > :: PercentageSize -> PercentageSize -> Bool
    $c>= :: PercentageSize -> PercentageSize -> Bool
    >= :: PercentageSize -> PercentageSize -> Bool
    $cmax :: PercentageSize -> PercentageSize -> PercentageSize
    max :: PercentageSize -> PercentageSize -> PercentageSize
    $cmin :: PercentageSize -> PercentageSize -> PercentageSize
    min :: PercentageSize -> PercentageSize -> PercentageSize
    Ord)

    -- | Constructs 'PercentageSize'. Not intended for direct use, see 'mkSize'.
    percentageSize :: Rational -> PercentageSize
    percentageSize :: Rational -> PercentageSize
    percentageSize Rational
    value = Rational -> PercentageSize
    PercentageSize (Rational
    value Rational -> Rational -> Rational
    forall a. Fractional a => a -> a -> a
    / Rational
    100)

    instance Show PercentageSize where
      show :: PercentageSize -> [Char]
    show (PercentageSize Rational
    value') = [Char] -> Double -> [Char]
    forall r. PrintfType r => [Char] -> r
    printf [Char]
    "%f" Double
    value [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    "%"
        where value :: Double
    value = Rational -> Double
    forall a. Fractional a => Rational -> a
    fromRational (Rational
    value' Rational -> Rational -> Rational
    forall a. Num a => a -> a -> a
    * Rational
    100) :: Double

    instance Num PercentageSize where
      (PercentageSize Rational
    v1) + :: PercentageSize -> PercentageSize -> PercentageSize
    + (PercentageSize Rational
    v2) = Rational -> PercentageSize
    PercentageSize (Rational
    v1 Rational -> Rational -> Rational
    forall a. Num a => a -> a -> a
    + Rational
    v2)
      (PercentageSize Rational
    v1) * :: PercentageSize -> PercentageSize -> PercentageSize
    * (PercentageSize Rational
    v2) = Rational -> PercentageSize
    PercentageSize (Rational
    v1 Rational -> Rational -> Rational
    forall a. Num a => a -> a -> a
    * Rational
    v2)
      (PercentageSize Rational
    v1) - :: PercentageSize -> PercentageSize -> PercentageSize
    - (PercentageSize Rational
    v2) = Rational -> PercentageSize
    PercentageSize (Rational
    v1 Rational -> Rational -> Rational
    forall a. Num a => a -> a -> a
    - Rational
    v2)
      abs :: PercentageSize -> PercentageSize
    abs (PercentageSize Rational
    v) = Rational -> PercentageSize
    PercentageSize (Rational -> Rational
    forall a. Num a => a -> a
    abs Rational
    v)
      signum :: PercentageSize -> PercentageSize
    signum (PercentageSize Rational
    v) = Rational -> PercentageSize
    PercentageSize (Rational -> Rational
    forall a. Num a => a -> a
    abs Rational
    v)
      fromInteger :: Integer -> PercentageSize
    fromInteger Integer
    x = Rational -> PercentageSize
    PercentageSize (Integer -> Rational
    forall a. Num a => Integer -> a
    fromInteger Integer
    x)

    instance Fractional PercentageSize where
      (PercentageSize Rational
    v1) / :: PercentageSize -> PercentageSize -> PercentageSize
    / (PercentageSize Rational
    v2) = Rational -> PercentageSize
    PercentageSize (Rational
    v1 Rational -> Rational -> Rational
    forall a. Fractional a => a -> a -> a
    / Rational
    v2)
      fromRational :: Rational -> PercentageSize
    fromRational Rational
    x = Rational -> PercentageSize
    PercentageSize (Rational -> Rational
    forall a. Fractional a => Rational -> a
    fromRational Rational
    x)

    instance ToCss PercentageSize where
      toCss :: PercentageSize -> Builder
    toCss = Text -> Builder
    fromText (Text -> Builder)
    -> (PercentageSize -> Text) -> PercentageSize -> Builder
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Char] -> Text
    TS.pack ([Char] -> Text)
    -> (PercentageSize -> [Char]) -> PercentageSize -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . PercentageSize -> [Char]
    forall a. Show a => a -> [Char]
    show

    -- | Converts number and unit suffix to CSS format.
    showSize :: Rational -> String -> String
    showSize :: Rational -> ShowS
    showSize Rational
    value' [Char]
    unit = [Char] -> Double -> [Char]
    forall r. PrintfType r => [Char] -> r
    printf [Char]
    "%f" Double
    value [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    unit
      where value :: Double
    value = Rational -> Double
    forall a. Fractional a => Rational -> a
    fromRational Rational
    value' :: Double

    mkSizeType "EmSize" "em"
    mkSizeType "ExSize" "ex"
    mkSizeType "PixelSize" "px"