[Haskell-beginners] Parsec problem

Kees Bleijenberg k.bleijenberg at lijbrandt.nl
Sat Feb 2 15:00:52 CET 2013


module Main(main) where 

import Text.ParserCombinators.Parsec  

 

parseToNewLine = do

                    line <- manyTill anyChar newline

                    return line

                                              

keyValue = do 

                    fieldName <- many letter 

                    spaces

                    char '='

                    spaces

                    fieldValue <- parseToNewLine 

                    return (fieldName,fieldValue)

 

main = parseTest keyValue "key=\n"

 

I don't understand why te code above doesn't parse to ("key","")

parseToNewLine "\n" parses to ""

parseTest keyValue "a=b\n" works fine and parses to ("a","b") 

 

Kees

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130202/8a2f3b3c/attachment.htm>


More information about the Beginners mailing list