{-# LANGUAGE NoImplicitPrelude #-}

module Data.Digit.Class.LowerCase (

  -- * Classes
    Da(..)
  , Db(..)
  , Dc(..)
  , Dd(..)
  , De(..)
  , Df(..)

  -- * Parsers
 , parsea
 , parseb
 , parsec
 , parsed
 , parsee
 , parsef

) where

import           Control.Category        (id)
import           Control.Lens            (Prism', ( # ))

import           Data.Functor            ((<$))

import           Text.Parser.Char        (CharParsing, char)
import           Text.Parser.Combinators ((<?>))

-- $setup
-- >>> import Data.Digit
-- >>> import Text.Parsec(parse, ParseError, eof)
-- >>> import Data.Void(Void)

class Da d where
  da ::
    Prism'
      d
      ()
  xa ::
    d
  xa =
    Tagged () (Identity ()) -> Tagged d (Identity d)
forall d. Da d => Prism' d ()
da (Tagged () (Identity ()) -> Tagged d (Identity d)) -> () -> d
forall t b. AReview t b -> b -> t
# ()

instance Da () where
  da :: p () (f ()) -> p () (f ())
da =
    p () (f ()) -> p () (f ())
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id

class Db d where
  db ::
    Prism'
      d
      ()
  xb ::
    d
  xb =
    Tagged () (Identity ()) -> Tagged d (Identity d)
forall d. Db d => Prism' d ()
db (Tagged () (Identity ()) -> Tagged d (Identity d)) -> () -> d
forall t b. AReview t b -> b -> t
# ()

instance Db () where
  db :: p () (f ()) -> p () (f ())
db =
    p () (f ()) -> p () (f ())
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id

class Dc d where
  dc ::
    Prism'
      d
      ()
  xc ::
    d
  xc =
    Tagged () (Identity ()) -> Tagged d (Identity d)
forall d. Dc d => Prism' d ()
dc (Tagged () (Identity ()) -> Tagged d (Identity d)) -> () -> d
forall t b. AReview t b -> b -> t
# ()

instance Dc () where
  dc :: p () (f ()) -> p () (f ())
dc =
    p () (f ()) -> p () (f ())
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id

class Dd d where
  dd ::
    Prism'
      d
      ()
  xd ::
    d
  xd =
    Tagged () (Identity ()) -> Tagged d (Identity d)
forall d. Dd d => Prism' d ()
dd (Tagged () (Identity ()) -> Tagged d (Identity d)) -> () -> d
forall t b. AReview t b -> b -> t
# ()

instance Dd () where
  dd :: p () (f ()) -> p () (f ())
dd =
    p () (f ()) -> p () (f ())
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id

class De d where
  de ::
    Prism'
      d
      ()
  xe ::
    d
  xe =
    Tagged () (Identity ()) -> Tagged d (Identity d)
forall d. De d => Prism' d ()
de (Tagged () (Identity ()) -> Tagged d (Identity d)) -> () -> d
forall t b. AReview t b -> b -> t
# ()

instance De () where
  de :: p () (f ()) -> p () (f ())
de =
    p () (f ()) -> p () (f ())
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id

class Df d where
  df ::
    Prism'
      d
      ()
  xf ::
    d
  xf =
    Tagged () (Identity ()) -> Tagged d (Identity d)
forall d. Df d => Prism' d ()
df (Tagged () (Identity ()) -> Tagged d (Identity d)) -> () -> d
forall t b. AReview t b -> b -> t
# ()

instance Df () where
  df :: p () (f ()) -> p () (f ())
df =
    p () (f ()) -> p () (f ())
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id

-- |
--
-- >>> parse (parsea <* eof) "test" "a" :: Either ParseError HexDigit
-- Right HexDigita
--
-- >>> parse parsea "test" "axyz" :: Either ParseError HexDigit
-- Right HexDigita
--
-- >>> isn't _Right (parse parsea "test" "xyz" :: Either ParseError HexDigit)
-- True
parsea ::
  (Da d, CharParsing p) =>
  p d
parsea :: p d
parsea =
  d
forall d. Da d => d
xa d -> p Char -> p d
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> p Char
forall (m :: * -> *). CharParsing m => Char -> m Char
char Char
'a' p d -> String -> p d
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
"a"

-- |
--
-- >>> parse (parseb <* eof) "test" "b" :: Either ParseError HexDigit
-- Right HexDigitb
--
-- >>> parse parseb "test" "bxyz" :: Either ParseError HexDigit
-- Right HexDigitb
--
-- >>> isn't _Right (parse parseb "test" "xyz" :: Either ParseError HexDigit)
-- True
parseb ::
  (Db d, CharParsing p) =>
  p d
parseb :: p d
parseb =
  d
forall d. Db d => d
xb d -> p Char -> p d
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> p Char
forall (m :: * -> *). CharParsing m => Char -> m Char
char Char
'b' p d -> String -> p d
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
"b"

-- |
--
-- >>> parse (parsec <* eof) "test" "c" :: Either ParseError HexDigit
-- Right HexDigitc
--
-- >>> parse parsec "test" "cxyz" :: Either ParseError HexDigit
-- Right HexDigitc
--
-- >>> isn't _Right (parse parsec "test" "xyz" :: Either ParseError HexDigit)
-- True
parsec ::
  (Dc d, CharParsing p) =>
  p d
parsec :: p d
parsec =
  d
forall d. Dc d => d
xc d -> p Char -> p d
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> p Char
forall (m :: * -> *). CharParsing m => Char -> m Char
char Char
'c' p d -> String -> p d
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
"c"

-- |
--
-- >>> parse (parsed <* eof) "test" "d" :: Either ParseError HexDigit
-- Right HexDigitd
--
-- >>> parse parsed "test" "dxyz" :: Either ParseError HexDigit
-- Right HexDigitd
--
-- >>> isn't _Right (parse parsed "test" "xyz" :: Either ParseError HexDigit)
-- True
parsed ::
  (Dd d, CharParsing p) =>
  p d
parsed :: p d
parsed =
  d
forall d. Dd d => d
xd d -> p Char -> p d
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> p Char
forall (m :: * -> *). CharParsing m => Char -> m Char
char Char
'd' p d -> String -> p d
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
"d"

-- |
--
-- >>> parse (parsee <* eof) "test" "e" :: Either ParseError HexDigit
-- Right HexDigite
--
-- >>> parse parsee "test" "exyz" :: Either ParseError HexDigit
-- Right HexDigite
--
-- >>> isn't _Right (parse parsee "test" "xyz" :: Either ParseError HexDigit)
-- True
parsee ::
  (De d, CharParsing p) =>
  p d
parsee :: p d
parsee =
  d
forall d. De d => d
xe d -> p Char -> p d
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> p Char
forall (m :: * -> *). CharParsing m => Char -> m Char
char Char
'e' p d -> String -> p d
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
"e"

-- |
--
-- >>> parse (parsef <* eof) "test" "f" :: Either ParseError HexDigit
-- Right HexDigitf
--
-- >>> parse parsef "test" "fxyz" :: Either ParseError HexDigit
-- Right HexDigitf
--
-- >>> isn't _Right (parse parsef "test" "xyz" :: Either ParseError HexDigit)
-- True
parsef ::
  (Df d, CharParsing p) =>
  p d
parsef :: p d
parsef =
  d
forall d. Df d => d
xf d -> p Char -> p d
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> p Char
forall (m :: * -> *). CharParsing m => Char -> m Char
char Char
'f' p d -> String -> p d
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
"f"