Skip to content

Instantly share code, notes, and snippets.

@chris-martin
Created February 24, 2022 06:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chris-martin/67535b315f5b00905c98f16dbded444f to your computer and use it in GitHub Desktop.
Save chris-martin/67535b315f5b00905c98f16dbded444f to your computer and use it in GitHub Desktop.
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