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

Safe HaskellNone
LanguageHaskell2010

Data.Digit.Decimal

Synopsis

Documentation

type DecimalNoZero d = (D1 d, D2 d, D3 d, D4 d, D5 d, D6 d, D7 d, D8 d, D9 d) Source #

type Decimal d = (D0 d, DecimalNoZero d) Source #

parseDecimalNoZero :: (DecimalNoZero d, CharParsing p) => p d Source #

>>> parse (parseDecimalNoZero <* eof) "test" "1" :: Either ParseError Digit
Right 1
>>> parse parseDecimalNoZero "test" "1xyz" :: Either ParseError Digit
Right 1
>>> parse (parseDecimalNoZero <* eof) "test" "2" :: Either ParseError Digit
Right 2
>>> parse parseDecimalNoZero "test" "2xyz" :: Either ParseError Digit
Right 2
>>> parse (parseDecimalNoZero <* eof) "test" "3" :: Either ParseError Digit
Right 3
>>> parse parseDecimalNoZero "test" "3xyz" :: Either ParseError Digit
Right 3
>>> parse (parseDecimalNoZero <* eof) "test" "4" :: Either ParseError Digit
Right 4
>>> parse parseDecimalNoZero "test" "4xyz" :: Either ParseError Digit
Right 4
>>> parse (parseDecimalNoZero <* eof) "test" "5" :: Either ParseError Digit
Right 5
>>> parse parseDecimalNoZero "test" "5xyz" :: Either ParseError Digit
Right 5
>>> parse (parseDecimalNoZero <* eof) "test" "6" :: Either ParseError Digit
Right 6
>>> parse parseDecimalNoZero "test" "6xyz" :: Either ParseError Digit
Right 6
>>> parse (parseDecimalNoZero <* eof) "test" "7" :: Either ParseError Digit
Right 7
>>> parse parseDecimalNoZero "test" "7xyz" :: Either ParseError Digit
Right 7
>>> parse (parseDecimalNoZero <* eof) "test" "8" :: Either ParseError Digit
Right 8
>>> parse parseDecimalNoZero "test" "8xyz" :: Either ParseError Digit
Right 8
>>> parse (parseDecimalNoZero <* eof) "test" "9" :: Either ParseError Digit
Right 9
>>> parse parseDecimalNoZero "test" "9xyz" :: Either ParseError Digit
Right 9
>>> isn't _Right (parse parseDecimalNoZero "test" "xyz" :: Either ParseError Digit)
True
\c -> (c `notElem` "123456789") ==> isn't _Right (parse parseDecimalNoZero "test" [c] :: Either ParseError Digit)

parseDecimal :: (Decimal d, CharParsing p) => p d Source #

>>> parse (parseDecimal <* eof) "test" "0" :: Either ParseError Digit
Right 0
>>> parse parseDecimal "test" "0xyz" :: Either ParseError Digit
Right 0
>>> parse (parseDecimal <* eof) "test" "1" :: Either ParseError Digit
Right 1
>>> parse parseDecimal "test" "1xyz" :: Either ParseError Digit
Right 1
>>> parse (parseDecimal <* eof) "test" "2" :: Either ParseError Digit
Right 2
>>> parse parseDecimal "test" "2xyz" :: Either ParseError Digit
Right 2
>>> parse (parseDecimal <* eof) "test" "3" :: Either ParseError Digit
Right 3
>>> parse parseDecimal "test" "3xyz" :: Either ParseError Digit
Right 3
>>> parse (parseDecimal <* eof) "test" "4" :: Either ParseError Digit
Right 4
>>> parse parseDecimal "test" "4xyz" :: Either ParseError Digit
Right 4
>>> parse (parseDecimal <* eof) "test" "5" :: Either ParseError Digit
Right 5
>>> parse parseDecimal "test" "5xyz" :: Either ParseError Digit
Right 5
>>> parse (parseDecimal <* eof) "test" "6" :: Either ParseError Digit
Right 6
>>> parse parseDecimal "test" "6xyz" :: Either ParseError Digit
Right 6
>>> parse (parseDecimal <* eof) "test" "7" :: Either ParseError Digit
Right 7
>>> parse parseDecimal "test" "7xyz" :: Either ParseError Digit
Right 7
>>> parse (parseDecimal <* eof) "test" "8" :: Either ParseError Digit
Right 8
>>> parse parseDecimal "test" "8xyz" :: Either ParseError Digit
Right 8
>>> parse (parseDecimal <* eof) "test" "9" :: Either ParseError Digit
Right 9
>>> parse parseDecimal "test" "9xyz" :: Either ParseError Digit
Right 9
>>> isn't _Right (parse parseDecimal "test" "xyz" :: Either ParseError Digit)
True
\c -> (c `notElem` "0123456789") ==> isn't _Right (parse parseDecimal "test" [c] :: Either ParseError Digit)