Skip to content

Instantly share code, notes, and snippets.

@Eckankar
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save Eckankar/b6e215586b98eca55c0c to your computer and use it in GitHub Desktop.

Select an option

Save Eckankar/b6e215586b98eca55c0c to your computer and use it in GitHub Desktop.
import Text.ParserCombinators.ReadP
import Data.Char
schar :: Char -> ReadP Char
schar c = skipSpaces >> char c
word :: ReadP String
word = skipSpaces >> munch1 isAlphaNum
wordlist :: ReadP [String]
wordlist = sepBy word (schar ',')
input :: ReadP [String]
input = do ls <- wordlist
skipSpaces
eof
return ls
main :: IO ()
main = do line <- getLine
print $ show $ readP_to_S input line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment