Skip to content

Instantly share code, notes, and snippets.

@freakingawesome
Created August 3, 2017 13:02
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 freakingawesome/62046eb6a24d4c4f5bc0103f83317e40 to your computer and use it in GitHub Desktop.
Save freakingawesome/62046eb6a24d4c4f5bc0103f83317e40 to your computer and use it in GitHub Desktop.
so-45484832
GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from C:\Users\CHAD~1.GIL\AppData\Local\Temp\ghci34580\ghci-script
Prelude> import Text.Parsec
Prelude Text.Parsec> import Text.Parsec.String
Prelude Text.Parsec Text.Parsec.String> :{
Prelude Text.Parsec Text.Parsec.String| parsePair :: Parser (String, String)
Prelude Text.Parsec Text.Parsec.String| parsePair = do
Prelude Text.Parsec Text.Parsec.String| a <- manyTill anyChar $ string "--"
Prelude Text.Parsec Text.Parsec.String| b <- many1 alphaNum
Prelude Text.Parsec Text.Parsec.String| pure (a, b)
Prelude Text.Parsec Text.Parsec.String| :}
Prelude Text.Parsec Text.Parsec.String> parse parsePair "" "fo o--bar"
Right ("fo o","bar")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment