Reputation:
I am writing a parser using megaparsec and want to parse hex number to Char.
The hex number parser should take exactly two chars and return a char that has the same numeric value.
Right now I have something like this.
type Parser = Parsec Void String
pByte :: Parser Char
pByte = chr . read . ("0x" ++) <$> count 2 hexDigitChar
I heard that using read
is considered bad practice.
Is there a built-in function that does something similar to this?
Upvotes: 1
Views: 533