{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE FlexibleInstances #-}
module Data.Digit.D0(
D0(..)
, parse0
) where
import Data.Digit.Digit(Digit(Digit0))
import Papa
import Text.Parser.Char(CharParsing, char)
import Text.Parser.Combinators((<?>))
class D0 d where
d0 ::
Prism'
d
()
x0 ::
d
x0 =
d0 # ()
instance D0 () where
d0 =
id
parse0 ::
(D0 d, CharParsing p) =>
p d
parse0 =
x0 <$ char '0' <?> "0"
instance D0 Digit where
d0 =
prism'
(\() -> Digit0)
(\d -> case d of
Digit0 ->
Just ()
_ ->
Nothing)