Skip to content

Instantly share code, notes, and snippets.

@sshine

sshine/Thing.hs Secret

Last active September 13, 2021 15:39
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 sshine/1a62e4225dc9df9612ffb908b1898310 to your computer and use it in GitHub Desktop.
Save sshine/1a62e4225dc9df9612ffb908b1898310 to your computer and use it in GitHub Desktop.
{-# 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