Created
February 24, 2022 06:01
-
-
Save chris-martin/67535b315f5b00905c98f16dbded444f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Text.Megaparsec as P | |
import qualified Text.Megaparsec.Char as P | |
type P a = P.Parsec Void Text a | |
match :: P a -> P Text | |
match = fmap fst . P.match | |
replace :: P Text -> Text -> Text | |
replace p t = x | |
where | |
Right x = P.runParser p' "" t | |
p' = P.try (p <* P.eof) <|> P.takeRest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment