{-# LANGUAGE Safe #-}

{-|
Module      : Data.Char.Math.SansSerif.Digit
Description : Sans serif mathematical alphanumeric symbols
Maintainer  : hapytexeu+gh@gmail.com
Stability   : experimental
Portability : POSIX

See "Data.Char.Math" for further documentation.
-}

module Data.Char.Math.SansSerif.Digit
  ( -- * Character conversion
    digitSansSerif,        digitSansSerif'
  , digitSansSerifRegular, digitSansSerifRegular'
  , digitSansSerifBold,    digitSansSerifBold'
    -- * Int to digit characters
  , intToDigitSansSerif,        intToDigitSansSerif'
  , intToDigitSansSerifRegular, intToDigitSansSerifRegular'
  , intToDigitSansSerifBold,    intToDigitSansSerifBold'
  ) where


import Data.Char (intToDigit, isDigit)
import Data.Char.Core(Emphasis, splitEmphasis)
import Data.Char.Math.Internal


-- | Convert the given digit character (@0@–@9@) to its corresponding character
-- in a non-bold sans-serif style. The result for characters outside this range is
-- unspecified.
digitSansSerifRegular'
  :: Char  -- ^ The given character to convert.
  -> Char  -- ^ The corresponding symbol in sans-serifs not in bold, unspecified outside the the range.
digitSansSerifRegular' :: Char -> Char
digitSansSerifRegular' = Int -> Char -> Char
_shiftC Int
0x1d7b2

-- | Convert the given digit character (@0@–@9@) to its corresponding character
-- in a non-bold sans-serif style wrapped in a 'Just' data constructor. For
-- characters outside this range, 'Nothing' is returned.
digitSansSerifRegular
  :: Char  -- ^ The given character to convert.
  -> Maybe Char  -- ^ The corresponding symbol in sans-serifs not in bold wrapped in a 'Just',
                -- 'Nothing' if the character is outside the range.
digitSansSerifRegular :: Char -> Maybe Char
digitSansSerifRegular = (Char -> Bool) -> (Char -> Char) -> Char -> Maybe Char
forall a b. (a -> Bool) -> (a -> b) -> a -> Maybe b
_withCondition Char -> Bool
isDigit Char -> Char
digitSansSerifRegular'

-- | Convert the given digit character (@0@–@9@) to its corresponding character
-- in a bold sans-serif style. The result for characters outside this range is
-- unspecified.
digitSansSerifBold'
  :: Char  -- ^ The given character to convert.
  -> Char  -- ^ The corresponding symbol in sans-serifs in bold, unspecified outside the the range.
digitSansSerifBold' :: Char -> Char
digitSansSerifBold' = Int -> Char -> Char
_shiftC Int
0x1d7bc

-- | Convert the given digit character (@0@–@9@) to its corresponding character
-- in a bold sans-serif style wrapped in a 'Just' data constructor. For
-- characters outside this range, 'Nothing' is returned.
digitSansSerifBold
  :: Char  -- ^ The given character to convert.
  -> Maybe Char  -- ^ The corresponding symbol in sans-serifs in bold wrapped in a 'Just',
                -- 'Nothing' if the character is outside the range.
digitSansSerifBold :: Char -> Maybe Char
digitSansSerifBold = (Char -> Bool) -> (Char -> Char) -> Char -> Maybe Char
forall a b. (a -> Bool) -> (a -> b) -> a -> Maybe b
_withCondition Char -> Bool
isDigit Char -> Char
digitSansSerifBold'

-- | Convert the given digit character (@0@–@9@) to its corresponding character
-- with a given 'Emphasis' in sans-serif style. The result for characters outside this
-- range is unspecified.
digitSansSerif'
  :: Emphasis  -- ^ The given /emphasis/ style.
  -> Char  -- ^ The given character to convert.
  -> Char  -- ^ The corresponding symbol in sans-serifs for the given /emphasis/ style, unspecified outside the the range.
digitSansSerif' :: Emphasis -> Char -> Char
digitSansSerif' = (Char -> Char) -> (Char -> Char) -> Emphasis -> Char -> Char
forall a. a -> a -> Emphasis -> a
splitEmphasis Char -> Char
digitSansSerifRegular' Char -> Char
digitSansSerifBold'

-- | Convert the given digit character (@0@–@9@) to its corresponding character
-- with the given 'Emphasis' in sans-serif style wrapped in a 'Just' data constructor.
-- For characters outside this range, 'Nothing' is returned.
digitSansSerif
  :: Emphasis  -- ^ The given /emphasis/ style.
  -> Char  -- ^ The given character to convert.
  -> Maybe Char  -- ^ The corresponding symbol in sans-serifs for the given /emphasis/ style wrapped in a 'Just',
                -- 'Nothing' if the character is outside the range.
digitSansSerif :: Emphasis -> Char -> Maybe Char
digitSansSerif = (Char -> Maybe Char)
-> (Char -> Maybe Char) -> Emphasis -> Char -> Maybe Char
forall a. a -> a -> Emphasis -> a
splitEmphasis Char -> Maybe Char
digitSansSerifRegular Char -> Maybe Char
digitSansSerifBold

-- | Convert the given number (@0@–@9@) to its corresponding character
-- in a non-bold sans-serif style. The result for numbers outside this range is
-- unspecified.
intToDigitSansSerifRegular'
  :: Int  -- ^ The given number to convert.
  -> Char  -- ^ The corresponding symbol in sans-serifs not in bold, unspecified outside the the range.
intToDigitSansSerifRegular' :: Int -> Char
intToDigitSansSerifRegular' = Char -> Char
digitSansSerifRegular' (Char -> Char) -> (Int -> Char) -> Int -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Char
intToDigit

-- | Convert the given number (@0@–@9@) to its corresponding character
-- in a non-bold sans-serif style wrapped in a 'Just' data constructor. For
-- numbers outside this range, 'Nothing' is returned.
intToDigitSansSerifRegular
  :: Int  -- ^ The given number to convert.
  -> Maybe Char  -- ^ The corresponding symbol in sans-serifs not in bold wrapped in a 'Just',
                -- 'Nothing' if the character is outside the range.
intToDigitSansSerifRegular :: Int -> Maybe Char
intToDigitSansSerifRegular = (Int -> Bool) -> (Int -> Char) -> Int -> Maybe Char
forall a b. (a -> Bool) -> (a -> b) -> a -> Maybe b
_withCondition Int -> Bool
_isValidInt Int -> Char
intToDigitSansSerifRegular'

-- | Convert the given number (@0@–@9@) to its corresponding character
-- in a bold sans-serif style. The result for numbers outside this range is
-- unspecified.
intToDigitSansSerifBold'
  :: Int  -- ^ The given number to convert.
  -> Char  -- ^ The corresponding symbol in sans-serifs in bold, unspecified outside the the range.
intToDigitSansSerifBold' :: Int -> Char
intToDigitSansSerifBold' = Char -> Char
digitSansSerifBold' (Char -> Char) -> (Int -> Char) -> Int -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Char
intToDigit

-- | Convert the given number (@0@–@9@) to its corresponding character
-- in a bold sans-serif style wrapped in a 'Just' data constructor. For
-- numbers outside this range, 'Nothing' is returned.
intToDigitSansSerifBold
  :: Int  -- ^ The given number to convert.
  -> Maybe Char  -- ^ The corresponding symbol in sans-serifs in bold wrapped in a 'Just',
                -- 'Nothing' if the character is outside the range.
intToDigitSansSerifBold :: Int -> Maybe Char
intToDigitSansSerifBold = (Int -> Bool) -> (Int -> Char) -> Int -> Maybe Char
forall a b. (a -> Bool) -> (a -> b) -> a -> Maybe b
_withCondition Int -> Bool
_isValidInt Int -> Char
intToDigitSansSerifBold'

-- | Convert the given number (@0@–@9@) to its corresponding character
-- with a given 'Emphasis' in sans-serif style. The result for numbers outside this
-- range is unspecified.
intToDigitSansSerif'
  :: Emphasis  -- ^ The given /emphasis/ style.
  -> Int  -- ^ The given number to convert.
  -> Char  -- ^ The corresponding symbol in sans-serifs in the given /emphasis/ style, unspecified outside the the range.
intToDigitSansSerif' :: Emphasis -> Int -> Char
intToDigitSansSerif' = (Int -> Char) -> (Int -> Char) -> Emphasis -> Int -> Char
forall a. a -> a -> Emphasis -> a
splitEmphasis Int -> Char
intToDigitSansSerifRegular' Int -> Char
intToDigitSansSerifBold'

-- | Convert the given number (@0@–@9@) to its corresponding character
-- with the given 'Emphasis' in sans-serif style wrapped in a 'Just' data constructor.
-- For numbers outside this range, 'Nothing' is returned.
intToDigitSansSerif
  :: Emphasis  -- ^ The given /emphasis/ style.
  -> Int  -- ^ The given number to convert
  -> Maybe Char  -- ^ The corresponding symbol in sans-serifs in the given /emphasis/ style wrapped in a 'Just',
                -- 'Nothing' if the character is outside the range.
intToDigitSansSerif :: Emphasis -> Int -> Maybe Char
intToDigitSansSerif = (Int -> Maybe Char)
-> (Int -> Maybe Char) -> Emphasis -> Int -> Maybe Char
forall a. a -> a -> Emphasis -> a
splitEmphasis Int -> Maybe Char
intToDigitSansSerifRegular Int -> Maybe Char
intToDigitSansSerifBold