{-# 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' ::
  -- | The given character to convert.
  Char ->
  -- | The corresponding symbol in sans-serifs not in bold, unspecified outside the the range.
  Char
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 ::
  -- | The given character to convert.
  Char ->
  -- | The corresponding symbol in sans-serifs not in bold wrapped in a 'Just',
  -- 'Nothing' if the character is outside the range.
  Maybe Char
digitSansSerifRegular :: Char -> Maybe Char
digitSansSerifRegular = 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' ::
  -- | The given character to convert.
  Char ->
  -- | The corresponding symbol in sans-serifs in bold, unspecified outside the the range.
  Char
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 ::
  -- | The given character to convert.
  Char ->
  -- | The corresponding symbol in sans-serifs in bold wrapped in a 'Just',
  -- 'Nothing' if the character is outside the range.
  Maybe Char
digitSansSerifBold :: Char -> Maybe Char
digitSansSerifBold = 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' ::
  -- | The given /emphasis/ style.
  Emphasis ->
  -- | The given character to convert.
  Char ->
  -- | The corresponding symbol in sans-serifs for the given /emphasis/ style, unspecified outside the the range.
  Char
digitSansSerif' :: Emphasis -> Char -> Char
digitSansSerif' = 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 ::
  -- | The given /emphasis/ style.
  Emphasis ->
  -- | The given character to convert.
  Char ->
  -- | The corresponding symbol in sans-serifs for the given /emphasis/ style wrapped in a 'Just',
  -- 'Nothing' if the character is outside the range.
  Maybe Char
digitSansSerif :: Emphasis -> Char -> Maybe Char
digitSansSerif = 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' ::
  -- | The given number to convert.
  Int ->
  -- | The corresponding symbol in sans-serifs not in bold, unspecified outside the the range.
  Char
intToDigitSansSerifRegular' :: Int -> Char
intToDigitSansSerifRegular' = Char -> Char
digitSansSerifRegular' 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 ::
  -- | The given number to convert.
  Int ->
  -- | The corresponding symbol in sans-serifs not in bold wrapped in a 'Just',
  -- 'Nothing' if the character is outside the range.
  Maybe Char
intToDigitSansSerifRegular :: Int -> Maybe Char
intToDigitSansSerifRegular = 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' ::
  -- | The given number to convert.
  Int ->
  -- | The corresponding symbol in sans-serifs in bold, unspecified outside the the range.
  Char
intToDigitSansSerifBold' :: Int -> Char
intToDigitSansSerifBold' = Char -> Char
digitSansSerifBold' 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 ::
  -- | The given number to convert.
  Int ->
  -- | The corresponding symbol in sans-serifs in bold wrapped in a 'Just',
  -- 'Nothing' if the character is outside the range.
  Maybe Char
intToDigitSansSerifBold :: Int -> Maybe Char
intToDigitSansSerifBold = 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' ::
  -- | The given /emphasis/ style.
  Emphasis ->
  -- | The given number to convert.
  Int ->
  -- | The corresponding symbol in sans-serifs in the given /emphasis/ style, unspecified outside the the range.
  Char
intToDigitSansSerif' :: Emphasis -> Int -> Char
intToDigitSansSerif' = 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 ::
  -- | The given /emphasis/ style.
  Emphasis ->
  -- | The given number to convert
  Int ->
  -- | The corresponding symbol in sans-serifs in the given /emphasis/ style wrapped in a 'Just',
  -- 'Nothing' if the character is outside the range.
  Maybe Char
intToDigitSansSerif :: Emphasis -> Int -> Maybe Char
intToDigitSansSerif = forall a. a -> a -> Emphasis -> a
splitEmphasis Int -> Maybe Char
intToDigitSansSerifRegular Int -> Maybe Char
intToDigitSansSerifBold