-
-
Save sshine/1a62e4225dc9df9612ffb908b1898310 to your computer and use it in GitHub Desktop.
This file contains 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
{-# LANGUAGE OverloadedStrings #-} | |
import Text.Megaparsec | |
import Data.Text (Text) | |
import Data.Void (Void) | |
type Parser = Parsec Void Text | |
type Error = ParseErrorBundle Text Void | |
thing :: Text -> Either Error (Text, Text) | |
thing = parse (thingP <* eof) "" | |
thingP :: Parser (Text, Text) | |
thingP = do | |
xxx <- takeWhileP Nothing (/= '(') | |
yyy <- parens (takeWhileP Nothing (/= ')')) | |
pure (xxx, yyy) | |
parens = between (chunk "(") (chunk ")") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment