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 ?
anyCharParser :: Parser Text
anyCharParser = pack <$> manyTill anyChar endOfInput