0

If I define

charToText :: Char -> Text
charToText c = pack [c]

anyCharParser :: Parser Text
anyCharParser = mconcat <$> manyTill (charToText <$> anyChar) endOfInput

it seems to me that lifting charToText is inefficient, because for each character matched charToText creates a singleton list to pack it as a Text.

Is there or more efficient way to do it ? For example a Parser Text that matches any single character ?

vkubicki
  • 1,104
  • 1
  • 11
  • 26

1 Answers1

0
anyCharParser :: Parser Text
anyCharParser = pack <$> manyTill anyChar endOfInput
Li-yao Xia
  • 31,896
  • 2
  • 33
  • 56