Skip to content

Instantly share code, notes, and snippets.

@angvillar
Last active August 23, 2020 12:07
Show Gist options
  • Select an option

  • Save angvillar/5145a945a9642eef88dd0896a6ee3d47 to your computer and use it in GitHub Desktop.

Select an option

Save angvillar/5145a945a9642eef88dd0896a6ee3d47 to your computer and use it in GitHub Desktop.
module Main where
import qualified Text.Parsec as P
ks :: [String]
ks =
[ "ABCD"
, "EFGH"
]
kp :: P.Parsec String () String
kp = P.choice $ map P.string ks
bp :: P.Parsec String () String
bp = P.manyTill P.anyChar (P.lookAhead kp)
p = do
a <- kp
b <- bp
return (a,b)
text = "ABCD asdasdasd EFGH asdsadas"
main :: IO ()
main = case (P.parse (P.many p) "" text) of
Left err -> print err
Right xs -> print xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment