This can be replaced with

```haskell
encodedChar :: Parser (Doc RdrName)
encodedChar = "&#" *> c <* ";"
  where
    c = DocString . return . chr <$> num
    num = hex <|> decimal
    hex = ("x" <|> "X") *> hexadecimal
```