<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Sans Serif";
        panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.E-mailStijl18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=NL link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hi,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>> module Main(main) where <o:p></o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>> <o:p></o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>> import Text.ParserCombinators.Parsec<o:p></o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>><o:p> </o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>> parseToNewLine = do<o:p></o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>> line <- manyTill anyChar newline<o:p></o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>> return line<o:p></o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>><o:p> </o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>> keyValue = do<o:p></o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>> fieldName <- many letter <o:p></o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>> spaces<o:p></o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>> char '='<o:p></o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>> spaces<o:p></o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>> fieldValue <- parseToNewLine <o:p></o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>> return (fieldName,fieldValue)<o:p></o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>><o:p> </o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>> main = parseTest keyValue "key=\n"<o:p></o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>><o:p> </o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>> I don’t understand why te code above doesn’t parse to (“key”,””)<o:p></o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-paragraph-type:empty;-qt-block-indent:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'> <o:p></o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>Because the newline is already consumed by the `spaces`. So parseToNewLine gets an empty string as input, and fails on that.<o:p></o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-paragraph-type:empty;-qt-block-indent:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'> <o:p></o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>> parseToNewLine “\n” parses to “"<o:p></o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>><o:p> </o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>> parseTest keyValue “a=b\n” works fine and parses to (“a”,”b”) <o:p></o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt;-qt-paragraph-type:empty;-qt-block-indent:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'> <o:p></o:p></span></p><p style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm;-qt-block-indent:0;-qt-user-state:0'><span style='font-size:9.0pt;font-family:"Sans Serif","serif"'>The input of parseToNewLine must contain a newline, or it fails. In the last example, the `spaces` after `char '='` stops at reaching the 'b', so the newline remains. In the first (problematic) example, all the remaining input after the '=' consists of whitespace.<o:p></o:p></span></p><p style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thanks. This solves it. spaces does more then just reading spaces.<o:p></o:p></span></p><p style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Kees<o:p></o:p></span></p><p style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p></div></body></html>