{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE TemplateHaskell #-}
module Data.Digit.Binary(
BinDigit(..)
, BinaryNoZero
, Binary
, parseBinaryNoZero
, parseBinary
, _BinDigit0
, _BinDigit1
, module Data.Digit.Class.D0
, module Data.Digit.Class.D1
) where
import Prelude (Eq, Show, Ord)
import Control.Lens.TH (makePrisms)
import Text.Parser.Char(CharParsing)
import Text.Parser.Combinators((<?>), choice)
import Data.Digit.Class.D0
import Data.Digit.Class.D1
data BinDigit
= BinDigit0
| BinDigit1
deriving (Int -> BinDigit -> ShowS
[BinDigit] -> ShowS
BinDigit -> String
(Int -> BinDigit -> ShowS)
-> (BinDigit -> String) -> ([BinDigit] -> ShowS) -> Show BinDigit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BinDigit] -> ShowS
$cshowList :: [BinDigit] -> ShowS
show :: BinDigit -> String
$cshow :: BinDigit -> String
showsPrec :: Int -> BinDigit -> ShowS
$cshowsPrec :: Int -> BinDigit -> ShowS
Show, BinDigit -> BinDigit -> Bool
(BinDigit -> BinDigit -> Bool)
-> (BinDigit -> BinDigit -> Bool) -> Eq BinDigit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BinDigit -> BinDigit -> Bool
$c/= :: BinDigit -> BinDigit -> Bool
== :: BinDigit -> BinDigit -> Bool
$c== :: BinDigit -> BinDigit -> Bool
Eq, Eq BinDigit
Eq BinDigit
-> (BinDigit -> BinDigit -> Ordering)
-> (BinDigit -> BinDigit -> Bool)
-> (BinDigit -> BinDigit -> Bool)
-> (BinDigit -> BinDigit -> Bool)
-> (BinDigit -> BinDigit -> Bool)
-> (BinDigit -> BinDigit -> BinDigit)
-> (BinDigit -> BinDigit -> BinDigit)
-> Ord BinDigit
BinDigit -> BinDigit -> Bool
BinDigit -> BinDigit -> Ordering
BinDigit -> BinDigit -> BinDigit
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
min :: BinDigit -> BinDigit -> BinDigit
$cmin :: BinDigit -> BinDigit -> BinDigit
max :: BinDigit -> BinDigit -> BinDigit
$cmax :: BinDigit -> BinDigit -> BinDigit
>= :: BinDigit -> BinDigit -> Bool
$c>= :: BinDigit -> BinDigit -> Bool
> :: BinDigit -> BinDigit -> Bool
$c> :: BinDigit -> BinDigit -> Bool
<= :: BinDigit -> BinDigit -> Bool
$c<= :: BinDigit -> BinDigit -> Bool
< :: BinDigit -> BinDigit -> Bool
$c< :: BinDigit -> BinDigit -> Bool
compare :: BinDigit -> BinDigit -> Ordering
$ccompare :: BinDigit -> BinDigit -> Ordering
$cp1Ord :: Eq BinDigit
Ord)
makePrisms ''BinDigit
instance D0 BinDigit where; d0 :: p () (f ()) -> p BinDigit (f BinDigit)
d0 = p () (f ()) -> p BinDigit (f BinDigit)
Prism' BinDigit ()
_BinDigit0
instance D1 BinDigit where; d1 :: p () (f ()) -> p BinDigit (f BinDigit)
d1 = p () (f ()) -> p BinDigit (f BinDigit)
Prism' BinDigit ()
_BinDigit1
type BinaryNoZero d =
D1 d
parseBinaryNoZero ::
(BinaryNoZero d, CharParsing p) =>
p d
parseBinaryNoZero :: p d
parseBinaryNoZero =
p d
forall d (p :: * -> *). (D1 d, CharParsing p) => p d
parse1 p d -> String -> p d
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
"BinaryNoZero"
type Binary d =
(D0 d, BinaryNoZero d)
parseBinary ::
(Binary d, CharParsing p) =>
p d
parseBinary :: p d
parseBinary =
[p d] -> p d
forall (m :: * -> *) a. Alternative m => [m a] -> m a
choice
[
p d
forall d (p :: * -> *). (D0 d, CharParsing p) => p d
parse0
, p d
forall d (p :: * -> *). (D1 d, CharParsing p) => p d
parseBinaryNoZero
] p d -> String -> p d
forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
"Binary"