-
-
Save virtualsafety/7857074 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 Text.Parsec | |
import Text.Parsec.String | |
input_text :: String | |
input_text = "foo123:" | |
main :: IO () | |
main = do | |
case parse aParser "example" input_text of | |
Left err -> print err | |
Right res -> putStrLn $ "I parsed: '" ++ res ++ "'" | |
aParser :: Parser String | |
aParser = do | |
s <- many1 alphaNum | |
_ <- char ':' | |
return s | |
{- | |
- Output: | |
- > runhaskell -Wall parsec_example.hs | |
- I parsed: 'foo123' | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment