{-# LANGUAGE DeriveFoldable         #-}
{-# LANGUAGE DeriveFunctor          #-}
{-# LANGUAGE DeriveTraversable      #-}
{-# LANGUAGE FlexibleInstances      #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE LambdaCase             #-}
{-# LANGUAGE MultiParamTypeClasses  #-}
{-# LANGUAGE NoImplicitPrelude      #-}
-- |
--
-- Types and functions for handling \\u0000 values in JSON.
--
module Waargonaut.Types.JChar.HexDigit4
  (
    -- * Types
    HexDigit4 (..)
  , HasHexDigit4 (..)

    -- * Parse / Build
  , parseHexDigit4

    -- * Conversion
  , hexDigit4ToChar
  , charToHexDigit4
  ) where

import           Prelude             (Eq, Ord (..), Show, otherwise, (||))

import           Control.Applicative ((<*>))
import           Control.Category    (id, (.))
import           Control.Lens        (Lens')
import           Control.Monad       ((=<<))

import           Control.Error.Util  (hush)

import           Data.List.NonEmpty  (NonEmpty ((:|)))

import           Data.Foldable       (Foldable)
import           Data.Function       (($))
import           Data.Functor        (Functor, fmap, (<$>))
import           Data.Traversable    (Traversable)

import           Data.Char           (Char, chr, ord)
import           Data.Either         (Either (..))
import           Data.Maybe          (Maybe (..))
import           Text.Parser.Char    (CharParsing)

import           Data.Digit          (HeXDigit, HeXaDeCiMaL)
import qualified Data.Digit          as D

-- $setup
-- >>> :set -XOverloadedStrings
-- >>> import Control.Monad (return)
-- >>> import Data.Either(Either (..), isLeft)
-- >>> import Data.Digit (HeXDigit(..))
-- >>> import qualified Data.Digit as D
-- >>> import Waargonaut.Decode.Error (DecodeError)
-- >>> import Utils
----

-- | JSON Characters may be single escaped UTF16 "\uab34".
data HexDigit4 d =
  HexDigit4 d d d d
  deriving (HexDigit4 d -> HexDigit4 d -> Bool
(HexDigit4 d -> HexDigit4 d -> Bool)
-> (HexDigit4 d -> HexDigit4 d -> Bool) -> Eq (HexDigit4 d)
forall d. Eq d => HexDigit4 d -> HexDigit4 d -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HexDigit4 d -> HexDigit4 d -> Bool
$c/= :: forall d. Eq d => HexDigit4 d -> HexDigit4 d -> Bool
== :: HexDigit4 d -> HexDigit4 d -> Bool
$c== :: forall d. Eq d => HexDigit4 d -> HexDigit4 d -> Bool
Eq, Int -> HexDigit4 d -> ShowS
[HexDigit4 d] -> ShowS
HexDigit4 d -> String
(Int -> HexDigit4 d -> ShowS)
-> (HexDigit4 d -> String)
-> ([HexDigit4 d] -> ShowS)
-> Show (HexDigit4 d)
forall d. Show d => Int -> HexDigit4 d -> ShowS
forall d. Show d => [HexDigit4 d] -> ShowS
forall d. Show d => HexDigit4 d -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HexDigit4 d] -> ShowS
$cshowList :: forall d. Show d => [HexDigit4 d] -> ShowS
show :: HexDigit4 d -> String
$cshow :: forall d. Show d => HexDigit4 d -> String
showsPrec :: Int -> HexDigit4 d -> ShowS
$cshowsPrec :: forall d. Show d => Int -> HexDigit4 d -> ShowS
Show, Eq (HexDigit4 d)
Eq (HexDigit4 d)
-> (HexDigit4 d -> HexDigit4 d -> Ordering)
-> (HexDigit4 d -> HexDigit4 d -> Bool)
-> (HexDigit4 d -> HexDigit4 d -> Bool)
-> (HexDigit4 d -> HexDigit4 d -> Bool)
-> (HexDigit4 d -> HexDigit4 d -> Bool)
-> (HexDigit4 d -> HexDigit4 d -> HexDigit4 d)
-> (HexDigit4 d -> HexDigit4 d -> HexDigit4 d)
-> Ord (HexDigit4 d)
HexDigit4 d -> HexDigit4 d -> Bool
HexDigit4 d -> HexDigit4 d -> Ordering
HexDigit4 d -> HexDigit4 d -> HexDigit4 d
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
forall d. Ord d => Eq (HexDigit4 d)
forall d. Ord d => HexDigit4 d -> HexDigit4 d -> Bool
forall d. Ord d => HexDigit4 d -> HexDigit4 d -> Ordering
forall d. Ord d => HexDigit4 d -> HexDigit4 d -> HexDigit4 d
min :: HexDigit4 d -> HexDigit4 d -> HexDigit4 d
$cmin :: forall d. Ord d => HexDigit4 d -> HexDigit4 d -> HexDigit4 d
max :: HexDigit4 d -> HexDigit4 d -> HexDigit4 d
$cmax :: forall d. Ord d => HexDigit4 d -> HexDigit4 d -> HexDigit4 d
>= :: HexDigit4 d -> HexDigit4 d -> Bool
$c>= :: forall d. Ord d => HexDigit4 d -> HexDigit4 d -> Bool
> :: HexDigit4 d -> HexDigit4 d -> Bool
$c> :: forall d. Ord d => HexDigit4 d -> HexDigit4 d -> Bool
<= :: HexDigit4 d -> HexDigit4 d -> Bool
$c<= :: forall d. Ord d => HexDigit4 d -> HexDigit4 d -> Bool
< :: HexDigit4 d -> HexDigit4 d -> Bool
$c< :: forall d. Ord d => HexDigit4 d -> HexDigit4 d -> Bool
compare :: HexDigit4 d -> HexDigit4 d -> Ordering
$ccompare :: forall d. Ord d => HexDigit4 d -> HexDigit4 d -> Ordering
$cp1Ord :: forall d. Ord d => Eq (HexDigit4 d)
Ord, a -> HexDigit4 b -> HexDigit4 a
(a -> b) -> HexDigit4 a -> HexDigit4 b
(forall a b. (a -> b) -> HexDigit4 a -> HexDigit4 b)
-> (forall a b. a -> HexDigit4 b -> HexDigit4 a)
-> Functor HexDigit4
forall a b. a -> HexDigit4 b -> HexDigit4 a
forall a b. (a -> b) -> HexDigit4 a -> HexDigit4 b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> HexDigit4 b -> HexDigit4 a
$c<$ :: forall a b. a -> HexDigit4 b -> HexDigit4 a
fmap :: (a -> b) -> HexDigit4 a -> HexDigit4 b
$cfmap :: forall a b. (a -> b) -> HexDigit4 a -> HexDigit4 b
Functor, HexDigit4 a -> Bool
(a -> m) -> HexDigit4 a -> m
(a -> b -> b) -> b -> HexDigit4 a -> b
(forall m. Monoid m => HexDigit4 m -> m)
-> (forall m a. Monoid m => (a -> m) -> HexDigit4 a -> m)
-> (forall m a. Monoid m => (a -> m) -> HexDigit4 a -> m)
-> (forall a b. (a -> b -> b) -> b -> HexDigit4 a -> b)
-> (forall a b. (a -> b -> b) -> b -> HexDigit4 a -> b)
-> (forall b a. (b -> a -> b) -> b -> HexDigit4 a -> b)
-> (forall b a. (b -> a -> b) -> b -> HexDigit4 a -> b)
-> (forall a. (a -> a -> a) -> HexDigit4 a -> a)
-> (forall a. (a -> a -> a) -> HexDigit4 a -> a)
-> (forall a. HexDigit4 a -> [a])
-> (forall a. HexDigit4 a -> Bool)
-> (forall a. HexDigit4 a -> Int)
-> (forall a. Eq a => a -> HexDigit4 a -> Bool)
-> (forall a. Ord a => HexDigit4 a -> a)
-> (forall a. Ord a => HexDigit4 a -> a)
-> (forall a. Num a => HexDigit4 a -> a)
-> (forall a. Num a => HexDigit4 a -> a)
-> Foldable HexDigit4
forall a. Eq a => a -> HexDigit4 a -> Bool
forall a. Num a => HexDigit4 a -> a
forall a. Ord a => HexDigit4 a -> a
forall m. Monoid m => HexDigit4 m -> m
forall a. HexDigit4 a -> Bool
forall a. HexDigit4 a -> Int
forall a. HexDigit4 a -> [a]
forall a. (a -> a -> a) -> HexDigit4 a -> a
forall m a. Monoid m => (a -> m) -> HexDigit4 a -> m
forall b a. (b -> a -> b) -> b -> HexDigit4 a -> b
forall a b. (a -> b -> b) -> b -> HexDigit4 a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: HexDigit4 a -> a
$cproduct :: forall a. Num a => HexDigit4 a -> a
sum :: HexDigit4 a -> a
$csum :: forall a. Num a => HexDigit4 a -> a
minimum :: HexDigit4 a -> a
$cminimum :: forall a. Ord a => HexDigit4 a -> a
maximum :: HexDigit4 a -> a
$cmaximum :: forall a. Ord a => HexDigit4 a -> a
elem :: a -> HexDigit4 a -> Bool
$celem :: forall a. Eq a => a -> HexDigit4 a -> Bool
length :: HexDigit4 a -> Int
$clength :: forall a. HexDigit4 a -> Int
null :: HexDigit4 a -> Bool
$cnull :: forall a. HexDigit4 a -> Bool
toList :: HexDigit4 a -> [a]
$ctoList :: forall a. HexDigit4 a -> [a]
foldl1 :: (a -> a -> a) -> HexDigit4 a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> HexDigit4 a -> a
foldr1 :: (a -> a -> a) -> HexDigit4 a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> HexDigit4 a -> a
foldl' :: (b -> a -> b) -> b -> HexDigit4 a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> HexDigit4 a -> b
foldl :: (b -> a -> b) -> b -> HexDigit4 a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> HexDigit4 a -> b
foldr' :: (a -> b -> b) -> b -> HexDigit4 a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> HexDigit4 a -> b
foldr :: (a -> b -> b) -> b -> HexDigit4 a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> HexDigit4 a -> b
foldMap' :: (a -> m) -> HexDigit4 a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> HexDigit4 a -> m
foldMap :: (a -> m) -> HexDigit4 a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> HexDigit4 a -> m
fold :: HexDigit4 m -> m
$cfold :: forall m. Monoid m => HexDigit4 m -> m
Foldable, Functor HexDigit4
Foldable HexDigit4
Functor HexDigit4
-> Foldable HexDigit4
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> HexDigit4 a -> f (HexDigit4 b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    HexDigit4 (f a) -> f (HexDigit4 a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> HexDigit4 a -> m (HexDigit4 b))
-> (forall (m :: * -> *) a.
    Monad m =>
    HexDigit4 (m a) -> m (HexDigit4 a))
-> Traversable HexDigit4
(a -> f b) -> HexDigit4 a -> f (HexDigit4 b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
HexDigit4 (m a) -> m (HexDigit4 a)
forall (f :: * -> *) a.
Applicative f =>
HexDigit4 (f a) -> f (HexDigit4 a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> HexDigit4 a -> m (HexDigit4 b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> HexDigit4 a -> f (HexDigit4 b)
sequence :: HexDigit4 (m a) -> m (HexDigit4 a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
HexDigit4 (m a) -> m (HexDigit4 a)
mapM :: (a -> m b) -> HexDigit4 a -> m (HexDigit4 b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> HexDigit4 a -> m (HexDigit4 b)
sequenceA :: HexDigit4 (f a) -> f (HexDigit4 a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
HexDigit4 (f a) -> f (HexDigit4 a)
traverse :: (a -> f b) -> HexDigit4 a -> f (HexDigit4 b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> HexDigit4 a -> f (HexDigit4 b)
$cp2Traversable :: Foldable HexDigit4
$cp1Traversable :: Functor HexDigit4
Traversable)

-- | Typeclass for things that contain a 'HexDigit4'.
class HasHexDigit4 c d | c -> d where
  hexDigit4 :: Lens' c (HexDigit4 d)

instance HasHexDigit4 (HexDigit4 d) d where
  hexDigit4 :: (HexDigit4 d -> f (HexDigit4 d)) -> HexDigit4 d -> f (HexDigit4 d)
hexDigit4 = (HexDigit4 d -> f (HexDigit4 d)) -> HexDigit4 d -> f (HexDigit4 d)
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id

hexHeX :: D.HexDigit -> D.HeXDigit
hexHeX :: HexDigit -> HeXDigit
hexHeX = \case
  HexDigit
D.HexDigit0 -> HeXDigit
D.HeXDigit0
  HexDigit
D.HexDigit1 -> HeXDigit
D.HeXDigit1
  HexDigit
D.HexDigit2 -> HeXDigit
D.HeXDigit2
  HexDigit
D.HexDigit3 -> HeXDigit
D.HeXDigit3
  HexDigit
D.HexDigit4 -> HeXDigit
D.HeXDigit4
  HexDigit
D.HexDigit5 -> HeXDigit
D.HeXDigit5
  HexDigit
D.HexDigit6 -> HeXDigit
D.HeXDigit6
  HexDigit
D.HexDigit7 -> HeXDigit
D.HeXDigit7
  HexDigit
D.HexDigit8 -> HeXDigit
D.HeXDigit8
  HexDigit
D.HexDigit9 -> HeXDigit
D.HeXDigit9
  HexDigit
D.HexDigita -> HeXDigit
D.HeXDigita
  HexDigit
D.HexDigitb -> HeXDigit
D.HeXDigitb
  HexDigit
D.HexDigitc -> HeXDigit
D.HeXDigitc
  HexDigit
D.HexDigitd -> HeXDigit
D.HeXDigitd
  HexDigit
D.HexDigite -> HeXDigit
D.HeXDigite
  HexDigit
D.HexDigitf -> HeXDigit
D.HeXDigitf

-- | Convert a given 'HexDigit4' to a Haskell 'Char'.
hexDigit4ToChar :: HexDigit4 HeXDigit -> Char
hexDigit4ToChar :: HexDigit4 HeXDigit -> Char
hexDigit4ToChar (HexDigit4 HeXDigit
a HeXDigit
b HeXDigit
c HeXDigit
d) = Int -> Char
chr (Either (NonEmpty HeXDigit) (NonEmpty HeXDigit) -> Int
forall a.
Integral a =>
Either (NonEmpty HeXDigit) (NonEmpty HeXDigit) -> a
D._HeXDigitsIntegral (NonEmpty HeXDigit -> Either (NonEmpty HeXDigit) (NonEmpty HeXDigit)
forall a b. b -> Either a b
Right (NonEmpty HeXDigit
 -> Either (NonEmpty HeXDigit) (NonEmpty HeXDigit))
-> NonEmpty HeXDigit
-> Either (NonEmpty HeXDigit) (NonEmpty HeXDigit)
forall a b. (a -> b) -> a -> b
$ HeXDigit
a HeXDigit -> [HeXDigit] -> NonEmpty HeXDigit
forall a. a -> [a] -> NonEmpty a
:| [HeXDigit
b,HeXDigit
c,HeXDigit
d]))

-- | Try to convert a Haskell 'Char' to a JSON acceptable character. NOTE: This
-- cannot preserve the upper or lower casing of any original 'Waargonaut.Types.Json.Json' data structure
-- inputs that may have been used to create this 'Char'. Also the JSON RFC
-- specifies a "limited" range of @U+0000@ to @U+FFFF@ as permissible as a six
-- character sequence: @\u0000@.
charToHexDigit4 :: Char -> Maybe (HexDigit4 HeXDigit)
charToHexDigit4 :: Char -> Maybe (HexDigit4 HeXDigit)
charToHexDigit4 Char
x
  | Char
x Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
< Char
'\x0' Bool -> Bool -> Bool
|| Char
x Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
> Char
'\xffff' = Maybe (HexDigit4 HeXDigit)
forall a. Maybe a
Nothing
  | Bool
otherwise                 = NonEmpty HeXDigit -> Maybe (HexDigit4 HeXDigit)
toHexDig (NonEmpty HeXDigit -> Maybe (HexDigit4 HeXDigit))
-> (NonEmpty HexDigit -> NonEmpty HeXDigit)
-> NonEmpty HexDigit
-> Maybe (HexDigit4 HeXDigit)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (HexDigit -> HeXDigit) -> NonEmpty HexDigit -> NonEmpty HeXDigit
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap HexDigit -> HeXDigit
hexHeX (NonEmpty HexDigit -> Maybe (HexDigit4 HeXDigit))
-> Maybe (NonEmpty HexDigit) -> Maybe (HexDigit4 HeXDigit)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Either (NonEmpty HexDigit) (NonEmpty HexDigit)
-> Maybe (NonEmpty HexDigit)
forall a b. Either a b -> Maybe b
hush (Int -> Either (NonEmpty HexDigit) (NonEmpty HexDigit)
forall a.
Integral a =>
a -> Either (NonEmpty HexDigit) (NonEmpty HexDigit)
D.integralHexDigits (Char -> Int
ord Char
x))
  where
    z :: HeXDigit
z = HeXDigit
forall d. D0 d => d
D.x0

    toHexDig :: NonEmpty HeXDigit -> Maybe (HexDigit4 HeXDigit)
toHexDig (HeXDigit
a :| [HeXDigit
b,HeXDigit
c,HeXDigit
d]) = HexDigit4 HeXDigit -> Maybe (HexDigit4 HeXDigit)
forall a. a -> Maybe a
Just (HeXDigit -> HeXDigit -> HeXDigit -> HeXDigit -> HexDigit4 HeXDigit
forall d. d -> d -> d -> d -> HexDigit4 d
HexDigit4 HeXDigit
a HeXDigit
b HeXDigit
c HeXDigit
d)
    toHexDig (  HeXDigit
b :| [HeXDigit
c,HeXDigit
d]) = HexDigit4 HeXDigit -> Maybe (HexDigit4 HeXDigit)
forall a. a -> Maybe a
Just (HeXDigit -> HeXDigit -> HeXDigit -> HeXDigit -> HexDigit4 HeXDigit
forall d. d -> d -> d -> d -> HexDigit4 d
HexDigit4 HeXDigit
z HeXDigit
b HeXDigit
c HeXDigit
d)
    toHexDig (    HeXDigit
c :| [HeXDigit
d]) = HexDigit4 HeXDigit -> Maybe (HexDigit4 HeXDigit)
forall a. a -> Maybe a
Just (HeXDigit -> HeXDigit -> HeXDigit -> HeXDigit -> HexDigit4 HeXDigit
forall d. d -> d -> d -> d -> HexDigit4 d
HexDigit4 HeXDigit
z HeXDigit
z HeXDigit
c HeXDigit
d)
    toHexDig (     HeXDigit
d :| []) = HexDigit4 HeXDigit -> Maybe (HexDigit4 HeXDigit)
forall a. a -> Maybe a
Just (HeXDigit -> HeXDigit -> HeXDigit -> HeXDigit -> HexDigit4 HeXDigit
forall d. d -> d -> d -> d -> HexDigit4 d
HexDigit4 HeXDigit
z HeXDigit
z HeXDigit
z HeXDigit
d)
    toHexDig              NonEmpty HeXDigit
_ = Maybe (HexDigit4 HeXDigit)
forall a. Maybe a
Nothing

{-# INLINE charToHexDigit4 #-}

-- | Parse a single 'HexDigit4'.
--
-- >>> testparse parseHexDigit4 "1234" :: Either DecodeError (HexDigit4 HeXDigit)
-- Right (HexDigit4 HeXDigit1 HeXDigit2 HeXDigit3 HeXDigit4)
--
-- >>> testparse parseHexDigit4 "12aF" :: Either DecodeError (HexDigit4 HeXDigit)
-- Right (HexDigit4 HeXDigit1 HeXDigit2 HeXDigita HeXDigitF)
--
-- >>> testparse parseHexDigit4 "aBcD" :: Either DecodeError (HexDigit4 HeXDigit)
-- Right (HexDigit4 HeXDigita HeXDigitB HeXDigitc HeXDigitD)
--
-- >>> testparsetheneof parseHexDigit4 "12aF" :: Either DecodeError (HexDigit4 HeXDigit)
-- Right (HexDigit4 HeXDigit1 HeXDigit2 HeXDigita HeXDigitF)
--
-- >>> testparsethennoteof parseHexDigit4 "12aFx" :: Either DecodeError (HexDigit4 HeXDigit)
-- Right (HexDigit4 HeXDigit1 HeXDigit2 HeXDigita HeXDigitF)
parseHexDigit4 ::
  ( CharParsing f, HeXaDeCiMaL digit ) =>
  f ( HexDigit4 digit )
parseHexDigit4 :: f (HexDigit4 digit)
parseHexDigit4 = digit -> digit -> digit -> digit -> HexDigit4 digit
forall d. d -> d -> d -> d -> HexDigit4 d
HexDigit4
  (digit -> digit -> digit -> digit -> HexDigit4 digit)
-> f digit -> f (digit -> digit -> digit -> HexDigit4 digit)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f digit
forall d (p :: * -> *). (HeXaDeCiMaL d, CharParsing p) => p d
D.parseHeXaDeCiMaL
  f (digit -> digit -> digit -> HexDigit4 digit)
-> f digit -> f (digit -> digit -> HexDigit4 digit)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> f digit
forall d (p :: * -> *). (HeXaDeCiMaL d, CharParsing p) => p d
D.parseHeXaDeCiMaL
  f (digit -> digit -> HexDigit4 digit)
-> f digit -> f (digit -> HexDigit4 digit)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> f digit
forall d (p :: * -> *). (HeXaDeCiMaL d, CharParsing p) => p d
D.parseHeXaDeCiMaL
  f (digit -> HexDigit4 digit) -> f digit -> f (HexDigit4 digit)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> f digit
forall d (p :: * -> *). (HeXaDeCiMaL d, CharParsing p) => p d
D.parseHeXaDeCiMaL