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

Safe HaskellNone
LanguageHaskell2010

Data.Digit.Hexadecimal

Synopsis

Documentation

type HexadecimalNoZero d = (D1 d, D2 d, D3 d, D4 d, D5 d, D6 d, D7 d, D8 d, D9 d, Da d, Db d, Dc d, Dd d, De d, De d, Df d) Source #

parseHexadecimalNoZero :: (HexadecimalNoZero d, CharParsing p) => p d Source #

>>> parse (parseHexadecimalNoZero <* eof) "test" "1" :: Either ParseError Digit
Right 1
>>> parse parseHexadecimalNoZero "test" "1xyz" :: Either ParseError Digit
Right 1
>>> parse (parseHexadecimalNoZero <* eof) "test" "2" :: Either ParseError Digit
Right 2
>>> parse parseHexadecimalNoZero "test" "2xyz" :: Either ParseError Digit
Right 2
>>> parse (parseHexadecimalNoZero <* eof) "test" "3" :: Either ParseError Digit
Right 3
>>> parse parseHexadecimalNoZero "test" "3xyz" :: Either ParseError Digit
Right 3
>>> parse (parseHexadecimalNoZero <* eof) "test" "4" :: Either ParseError Digit
Right 4
>>> parse parseHexadecimalNoZero "test" "4xyz" :: Either ParseError Digit
Right 4
>>> parse (parseHexadecimalNoZero <* eof) "test" "5" :: Either ParseError Digit
Right 5
>>> parse parseHexadecimalNoZero "test" "5xyz" :: Either ParseError Digit
Right 5
>>> parse (parseHexadecimalNoZero <* eof) "test" "6" :: Either ParseError Digit
Right 6
>>> parse parseHexadecimalNoZero "test" "6xyz" :: Either ParseError Digit
Right 6
>>> parse (parseHexadecimalNoZero <* eof) "test" "7" :: Either ParseError Digit
Right 7
>>> parse parseHexadecimalNoZero "test" "7xyz" :: Either ParseError Digit
Right 7
>>> parse (parseHexadecimalNoZero <* eof) "test" "8" :: Either ParseError Digit
Right 8
>>> parse parseHexadecimalNoZero "test" "8xyz" :: Either ParseError Digit
Right 8
>>> parse (parseHexadecimalNoZero <* eof) "test" "9" :: Either ParseError Digit
Right 9
>>> parse parseHexadecimalNoZero "test" "9xyz" :: Either ParseError Digit
Right 9
>>> parse (parseHexadecimalNoZero <* eof) "test" "a" :: Either ParseError Digit
Right a
>>> parse parseHexadecimalNoZero "test" "axyz" :: Either ParseError Digit
Right a
>>> parse (parseHexadecimalNoZero <* eof) "test" "b" :: Either ParseError Digit
Right b
>>> parse parseHexadecimalNoZero "test" "bxyz" :: Either ParseError Digit
Right b
>>> parse (parseHexadecimalNoZero <* eof) "test" "c" :: Either ParseError Digit
Right c
>>> parse parseHexadecimalNoZero "test" "cxyz" :: Either ParseError Digit
Right c
>>> parse (parseHexadecimalNoZero <* eof) "test" "d" :: Either ParseError Digit
Right d
>>> parse parseHexadecimalNoZero "test" "dxyz" :: Either ParseError Digit
Right d
>>> parse (parseHexadecimalNoZero <* eof) "test" "e" :: Either ParseError Digit
Right e
>>> parse parseHexadecimalNoZero "test" "exyz" :: Either ParseError Digit
Right e
>>> parse (parseHexadecimalNoZero <* eof) "test" "f" :: Either ParseError Digit
Right f
>>> parse parseHexadecimalNoZero "test" "fxyz" :: Either ParseError Digit
Right f
>>> isn't _Right (parse parseHexadecimalNoZero "test" "xyz" :: Either ParseError Digit)
True
\c -> (c `notElem` "123456789abcdef") ==> isn't _Right (parse parseHexadecimalNoZero "test" [c] :: Either ParseError Digit)

parseHexadecimal :: (Hexadecimal d, CharParsing p) => p d Source #

>>> parse (parseHexadecimal <* eof) "test" "0" :: Either ParseError Digit
Right 0
>>> parse parseHexadecimal "test" "0xyz" :: Either ParseError Digit
Right 0
>>> parse (parseHexadecimal <* eof) "test" "1" :: Either ParseError Digit
Right 1
>>> parse parseHexadecimal "test" "1xyz" :: Either ParseError Digit
Right 1
>>> parse (parseHexadecimal <* eof) "test" "2" :: Either ParseError Digit
Right 2
>>> parse parseHexadecimal "test" "2xyz" :: Either ParseError Digit
Right 2
>>> parse (parseHexadecimal <* eof) "test" "3" :: Either ParseError Digit
Right 3
>>> parse parseHexadecimal "test" "3xyz" :: Either ParseError Digit
Right 3
>>> parse (parseHexadecimal <* eof) "test" "4" :: Either ParseError Digit
Right 4
>>> parse parseHexadecimal "test" "4xyz" :: Either ParseError Digit
Right 4
>>> parse (parseHexadecimal <* eof) "test" "5" :: Either ParseError Digit
Right 5
>>> parse parseHexadecimal "test" "5xyz" :: Either ParseError Digit
Right 5
>>> parse (parseHexadecimal <* eof) "test" "6" :: Either ParseError Digit
Right 6
>>> parse parseHexadecimal "test" "6xyz" :: Either ParseError Digit
Right 6
>>> parse (parseHexadecimal <* eof) "test" "7" :: Either ParseError Digit
Right 7
>>> parse parseHexadecimal "test" "7xyz" :: Either ParseError Digit
Right 7
>>> parse (parseHexadecimal <* eof) "test" "8" :: Either ParseError Digit
Right 8
>>> parse parseHexadecimal "test" "8xyz" :: Either ParseError Digit
Right 8
>>> parse (parseHexadecimal <* eof) "test" "9" :: Either ParseError Digit
Right 9
>>> parse parseHexadecimal "test" "9xyz" :: Either ParseError Digit
Right 9
>>> parse (parseHexadecimal <* eof) "test" "a" :: Either ParseError Digit
Right a
>>> parse parseHexadecimal "test" "axyz" :: Either ParseError Digit
Right a
>>> parse (parseHexadecimal <* eof) "test" "b" :: Either ParseError Digit
Right b
>>> parse parseHexadecimal "test" "bxyz" :: Either ParseError Digit
Right b
>>> parse (parseHexadecimal <* eof) "test" "c" :: Either ParseError Digit
Right c
>>> parse parseHexadecimal "test" "cxyz" :: Either ParseError Digit
Right c
>>> parse (parseHexadecimal <* eof) "test" "d" :: Either ParseError Digit
Right d
>>> parse parseHexadecimal "test" "dxyz" :: Either ParseError Digit
Right d
>>> parse (parseHexadecimal <* eof) "test" "e" :: Either ParseError Digit
Right e
>>> parse parseHexadecimal "test" "exyz" :: Either ParseError Digit
Right e
>>> parse (parseHexadecimal <* eof) "test" "f" :: Either ParseError Digit
Right f
>>> parse parseHexadecimal "test" "fxyz" :: Either ParseError Digit
Right f
>>> isn't _Right (parse parseHexadecimal "test" "xyz" :: Either ParseError Digit)
True
\c -> (c `notElem` "0123456789abcdef") ==> isn't _Right (parse parseHexadecimal "test" [c] :: Either ParseError Digit)