Parsec problem

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Parsec problem

Kees Bleijenberg
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>