digit-0.5.2: A data-type representing digits 0-9 and other combinations

Safe HaskellNone
LanguageHaskell2010

Data.Digit.Binary

Synopsis

Documentation

type BinaryNoZero d = D1 d Source #

type Binary d = (D0 d, BinaryNoZero d) Source #

parseBinaryNoZero :: (BinaryNoZero d, CharParsing p) => p d Source #

>>> parse (parseBinaryNoZero <* eof) "test" "1" :: Either ParseError Digit
Right 1
>>> parse parseBinaryNoZero "test" "1xyz" :: Either ParseError Digit
Right 1
>>> isn't _Right (parse parseBinaryNoZero "test" "xyz" :: Either ParseError Digit)
True
\c -> (c `notElem` "1") ==> isn't _Right (parse parseBinaryNoZero "test" [c] :: Either ParseError Digit)

parseBinary :: (Binary d, CharParsing p) => p d Source #

>>> parse (parseBinary <* eof) "test" "0" :: Either ParseError Digit
Right 0
>>> parse parseBinary "test" "0xyz" :: Either ParseError Digit
Right 0
>>> parse (parseBinary <* eof) "test" "1" :: Either ParseError Digit
Right 1
>>> parse parseBinary "test" "1xyz" :: Either ParseError Digit
Right 1
>>> isn't _Right (parse parseBinary "test" "xyz" :: Either ParseError Digit)
True
\c -> (c `notElem` "01") ==> isn't _Right (parse parseBinary "test" [c] :: Either ParseError Digit)