{-# LANGUAGE NoImplicitPrelude #-}

module Data.Digit.Class.D6(
  D6(..)
, parse6
) 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.Class
-- >>> import Text.Parsec(parse, ParseError, eof)
-- >>> import Data.Void(Void)

class D6 d where
  d6 ::
    Prism'
      d
      ()
  x6 ::
    d
  x6 =
    Tagged () (Identity ()) -> Tagged d (Identity d)
forall d. D6 d => Prism' d ()
d6 (Tagged () (Identity ()) -> Tagged d (Identity d)) -> () -> d
forall t b. AReview t b -> b -> t
# ()

instance D6 () where
  d6 :: p () (f ()) -> p () (f ())
d6 =
    p () (f ()) -> p () (f ())
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
    
-- |
--
-- >>> parse (parse6 <* eof) "test" "6" :: Either ParseError DecDigit
-- Right DecDigit6
--
-- >>> parse parse6 "test" "6xyz" :: Either ParseError DecDigit
-- Right DecDigit6
--
-- >>> isn't _Right (parse parse6 "test" "xyz" :: Either ParseError DecDigit)
-- True
parse6 ::
  (D6 d, CharParsing p) =>
  p d
parse6 :: p d
parse6 =
  d
forall d. D6 d => d
x6 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
'6' p d -> String -> p d
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
"6"