<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Dear Cafe,<div class=""><br class=""></div><div class="">This is a followup question to my previous one. Also asked as a Megaparsec question issue at <a href="https://github.com/mrkkrp/megaparsec/issues/429" class="">https://github.com/mrkkrp/megaparsec/issues/429</a></div><div class=""><br class=""></div><div class=""><p style="box-sizing: border-box; margin-bottom: 16px; color: rgb(206, 202, 195); font-family: -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px; font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(24, 26, 27); margin-top: 0px !important;" class="">As I observed (have no idea where a canonical definition could live for this) that for the contract of parser combinators:</p><ul style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(206, 202, 195); font-family: -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px; font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(24, 26, 27);" class=""><li style="box-sizing: border-box; margin-left: 0px;" class=""><code style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 11.9px; padding: 0.2em 0.4em; margin: 0px; background-color: rgba(220, 224, 228, 0.1) !important; border-radius: 6px;" class="">fail</code> with no input consumed will have next alternative to be tried with possible success</li><li style="box-sizing: border-box; margin-top: 0.25em; margin-left: 0px;" class=""><code style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 11.9px; padding: 0.2em 0.4em; margin: 0px; background-color: rgba(220, 224, 228, 0.1) !important; border-radius: 6px;" class="">fail</code> with some input consumed will err out immediately regardless rest alternatives</li></ul><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(206, 202, 195); font-family: -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px; font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(24, 26, 27);" class="">Am I right about these rules? Where is the official specification of such rules?</p><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(206, 202, 195); font-family: -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px; font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(24, 26, 27);" class="">Then I guess that <code style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 11.9px; padding: 0.2em 0.4em; margin: 0px; background-color: rgba(220, 224, 228, 0.1) !important; border-radius: 6px;" class="">empty</code> result of a parser could mean <em style="box-sizing: border-box;" class="">NoMatch</em> even after consumed some input, and want to leverage this semantic, but encountered error with current implementation <a href="https://github.com/complyue/dcp/blob/5be688396b7e2bda00ea80fd99d2a7b3ec5c788d/src/Parser.hs#L138-L146" style="box-sizing: border-box; color: rgb(76, 172, 252); background-color: initial; text-decoration: none;" class="">https://github.com/complyue/dcp/blob/5be688396b7e2bda00ea80fd99d2a7b3ec5c788d/src/Parser.hs#L138-L146</a></p><div class="highlight highlight-source-haskell" style="box-sizing: border-box; margin-bottom: 16px; background-color: rgb(24, 26, 27); color: rgb(206, 202, 195); font-family: -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px; font-variant-ligatures: normal; orphans: 2; widows: 2; overflow: visible !important;"><pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 11.9px; margin-top: 0px; margin-bottom: 0px; overflow-wrap: normal; padding: 16px; overflow: auto; line-height: 1.45; background-color: rgb(28, 30, 31); border-radius: 6px; word-break: normal;" class=""><span class="pl-en" style="box-sizing: border-box; color: rgb(125, 84, 199);">artifactDecl</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(218, 75, 88);">::</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(125, 84, 199);">Parser</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(125, 84, 199);">ArtDecl</span>
artifactDecl <span class="pl-k" style="box-sizing: border-box; color: rgb(218, 75, 88);">=</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(218, 75, 88);">do</span>
  artCmt <span class="pl-k" style="box-sizing: border-box; color: rgb(218, 75, 88);"><-</span> immediateDocComments
  (eof <span class="pl-k" style="box-sizing: border-box; color: rgb(218, 75, 88);">>></span> empty) <span class="pl-k" style="box-sizing: border-box; color: rgb(218, 75, 88);"><|></span> <span class="pl-k" style="box-sizing: border-box; color: rgb(218, 75, 88);">do</span>
    artBody <span class="pl-k" style="box-sizing: border-box; color: rgb(218, 75, 88);"><-</span> takeWhileP (<span class="pl-ent" style="box-sizing: border-box; color: rgb(121, 221, 145);">Just</span> <span class="pl-s" style="box-sizing: border-box; color: rgb(200, 195, 188);"><span class="pl-pds" style="box-sizing: border-box;">"</span>artifact body<span class="pl-pds" style="box-sizing: border-box;">"</span></span>)
                          (<span class="pl-c1" style="box-sizing: border-box; color: rgb(86, 177, 255);">not</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(218, 75, 88);">.</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(86, 177, 255);">flip</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(86, 177, 255);">elem</span> (<span class="pl-s" style="box-sizing: border-box; color: rgb(200, 195, 188);"><span class="pl-pds" style="box-sizing: border-box;">"</span>;{<span class="pl-pds" style="box-sizing: border-box;">"</span></span> <span class="pl-k" style="box-sizing: border-box; color: rgb(218, 75, 88);">::</span> [<span class="pl-en" style="box-sizing: border-box; color: rgb(125, 84, 199);"><span class="pl-c1" style="box-sizing: border-box; color: rgb(86, 177, 255);">Char</span></span>]))
    <span class="pl-k" style="box-sizing: border-box; color: rgb(218, 75, 88);">if</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(86, 177, 255);">T.</span><span class="pl-c1" style="box-sizing: border-box; color: rgb(86, 177, 255);">null</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(218, 75, 88);">$</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(86, 177, 255);">T.</span>strip artBody
      <span class="pl-k" style="box-sizing: border-box; color: rgb(218, 75, 88);">then</span> empty <span class="pl-c" style="box-sizing: border-box; color: rgb(159, 151, 138);"><span class="pl-c" style="box-sizing: border-box;">--</span> this is not possible in real cases</span>
      <span class="pl-k" style="box-sizing: border-box; color: rgb(218, 75, 88);">else</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(86, 177, 255);">return</span> (artCmt, artBody)</pre></div><div class="highlight highlight-text-shell-session" style="box-sizing: border-box; margin-bottom: 16px; background-color: rgb(24, 26, 27); color: rgb(206, 202, 195); font-family: -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px; font-variant-ligatures: normal; orphans: 2; widows: 2; overflow: visible !important;"><pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 11.9px; margin-top: 0px; margin-bottom: 0px; overflow-wrap: normal; padding: 16px; overflow: auto; line-height: 1.45; background-color: rgb(28, 30, 31); border-radius: 6px; word-break: normal;" class="">$ <span class="pl-s1" style="box-sizing: border-box;">cabal run dcp <span class="pl-k" style="box-sizing: border-box; color: rgb(218, 75, 88);"><</span> samples/full.txt</span>
<span class="pl-c1" style="box-sizing: border-box; color: rgb(86, 177, 255);">Up to date</span>
<span class="pl-c1" style="box-sizing: border-box; color: rgb(86, 177, 255);">dcp: 73:1:</span>
<span class="pl-c1" style="box-sizing: border-box; color: rgb(86, 177, 255);">   |</span>
<span class="pl-c1" style="box-sizing: border-box; color: rgb(86, 177, 255);">73 | <empty line></span>
<span class="pl-c1" style="box-sizing: border-box; color: rgb(86, 177, 255);">   | ^</span>
<span class="pl-c1" style="box-sizing: border-box; color: rgb(86, 177, 255);">expecting "{#", "{##", or artifact body</span>

<span class="pl-c1" style="box-sizing: border-box; color: rgb(86, 177, 255);">CallStack (from HasCallStack):</span>
<span class="pl-c1" style="box-sizing: border-box; color: rgb(86, 177, 255);">  error, called at src/Parser.hs:151:14 in main:Parser</span></pre></div><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(206, 202, 195); font-family: -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px; font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(24, 26, 27);" class="">So how can I achieve that?</p><div style="box-sizing: border-box; margin-top: 0px; color: rgb(206, 202, 195); font-family: -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px; font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(24, 26, 27); margin-bottom: 0px !important;" class="">Background is I'm trying to prototype an implementation of doc comment parsing as described at <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="728065666" data-permission-text="Title is private" data-url="https://github.com/mrkkrp/megaparsec/issues/428" data-hovercard-type="issue" data-hovercard-url="/mrkkrp/megaparsec/issues/428/hovercard" href="https://github.com/mrkkrp/megaparsec/issues/428" style="box-sizing: border-box; color: rgb(76, 172, 252); background-color: initial; text-decoration: none;">#428</a></div></div><div class=""><br class=""></div><div class="">Best regards,</div><div class="">Compl</div><div class=""><br class=""></div></body></html>