Last active
August 23, 2020 12:07
-
-
Save angvillar/5145a945a9642eef88dd0896a6ee3d47 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
| 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