I am having hard time understanding the following code.  The code is from Applicative Parser library:  <a href="http://hackage.haskell.org/packages/archive/uu-parsinglib/2.5.5.2/doc/html/src/Text-ParserCombinators-UU-BasicInstances.html">http://hackage.haskell.org/packages/archive/uu-parsinglib/2.5.5.2/doc/html/src/Text-ParserCombinators-UU-BasicInstances.html</a><br>
<br><pre> <a name="line-55"></a><span class="hs-keyword">instance</span> <span class="hs-layout">(</span><span class="hs-conid">Show</span> <span class="hs-varid">a</span><span class="hs-layout">,</span>  <span class="hs-varid">loc</span> <span class="hs-varop">`IsLocationUpdatedBy`</span> <span class="hs-varid">a</span><span class="hs-layout">)</span> <span class="hs-keyglyph">=&gt;</span> <span class="hs-conid">Provides</span>  <span class="hs-layout">(</span><span class="hs-conid">Str</span>  <span class="hs-varid">a</span> <span class="hs-varid">loc</span><span class="hs-layout">)</span>  <span class="hs-layout">(</span><span class="hs-varid">a</span> <span class="hs-keyglyph">-&gt;</span> <span class="hs-conid">Bool</span><span class="hs-layout">,</span> <span class="hs-conid">String</span><span class="hs-layout">,</span> <span class="hs-varid">a</span><span class="hs-layout">)</span>  <span class="hs-varid">a</span> <span class="hs-keyword">where<br>
</span>    <span class="hs-varid">splitState</span> <span class="hs-layout">(</span><span class="hs-varid">p</span><span class="hs-layout">,</span> <span class="hs-varid">msg</span><span class="hs-layout">,</span> <span class="hs-varid">a</span><span class="hs-layout">)</span> <span class="hs-varid">k</span> <span class="hs-layout">(</span><span class="hs-conid">Str</span>  <span class="hs-varid">tts</span>   <span class="hs-varid">msgs</span> <span class="hs-varid">pos</span>  <span class="hs-varid">del_ok</span><span class="hs-layout">)</span> <br>
<a name="line-57"></a>          <span class="hs-keyglyph">=</span> <span class="hs-keyword">let</span> <span class="hs-varid">ins</span> <span class="hs-varid">exp</span> <span class="hs-keyglyph">=</span>       <span class="hs-layout">(</span><span class="hs-num">5</span><span class="hs-layout">,</span> <span class="hs-varid">k</span> <span class="hs-varid">a</span> <span class="hs-layout">(</span><span class="hs-conid">Str</span> <span class="hs-varid">tts</span> <span class="hs-layout">(</span><span class="hs-varid">msgs</span> <span class="hs-varop">++</span> <span class="hs-keyglyph">[</span><span class="hs-conid">Inserted</span> <span class="hs-layout">(</span><span class="hs-varid">show</span> <span class="hs-varid">a</span><span class="hs-layout">)</span>  <span class="hs-varid">pos</span>  <span class="hs-varid">exp</span><span class="hs-keyglyph">]</span><span class="hs-layout">)</span> <span class="hs-varid">pos</span>  <span class="hs-conid">False</span><span class="hs-layout">)</span><span class="hs-layout">)</span><br>
<a name="line-58"></a>                <span class="hs-varid">del</span> <span class="hs-varid">exp</span> <span class="hs-keyglyph">=</span>       <span class="hs-layout">(</span><span class="hs-num">5</span><span class="hs-layout">,</span> <span class="hs-varid">splitState</span> <span class="hs-layout">(</span><span class="hs-varid">p</span><span class="hs-layout">,</span><span class="hs-varid">msg</span><span class="hs-layout">,</span> <span class="hs-varid">a</span><span class="hs-layout">)</span> <br>
<a name="line-59"></a>                                    <span class="hs-varid">k</span><br><a name="line-60"></a>                                    <span class="hs-layout">(</span><span class="hs-conid">Str</span> <span class="hs-layout">(</span><span class="hs-varid">tail</span> <span class="hs-varid">tts</span><span class="hs-layout">)</span> <br>
<a name="line-61"></a>                                         <span class="hs-layout">(</span><span class="hs-varid">msgs</span> <span class="hs-varop">++</span> <span class="hs-keyglyph">[</span><span class="hs-conid">Deleted</span>  <span class="hs-layout">(</span><span class="hs-varid">show</span><span class="hs-layout">(</span><span class="hs-varid">head</span> <span class="hs-varid">tts</span><span class="hs-layout">)</span><span class="hs-layout">)</span>  <span class="hs-varid">pos</span>  <span class="hs-varid">exp</span><span class="hs-keyglyph">]</span><span class="hs-layout">)</span> <br>
<a name="line-62"></a>                                         <span class="hs-layout">(</span><span class="hs-varid">advance</span> <span class="hs-varid">pos</span> <span class="hs-layout">(</span><span class="hs-varid">head</span> <span class="hs-varid">tts</span><span class="hs-layout">)</span><span class="hs-layout">)</span><br>
<a name="line-63"></a>                                         <span class="hs-conid">True</span> <span class="hs-layout">)</span><span class="hs-layout">)</span><br><a name="line-64"></a>            <span class="hs-keyword">in</span> <span class="hs-keyword">case</span> <span class="hs-varid">tts</span> <span class="hs-keyword">of</span><br>
<a name="line-65"></a>               <span class="hs-layout">(</span><span class="hs-varid">t</span><span class="hs-conop">:</span><span class="hs-varid">ts</span><span class="hs-layout">)</span>  <span class="hs-keyglyph">-&gt;</span>  <span class="hs-keyword">if</span> <span class="hs-varid">p</span> <span class="hs-varid">t</span> <br>
<a name="line-66"></a>                           <span class="hs-keyword">then</span>  <span class="hs-varid">show_symbol</span> <span class="hs-layout">(</span><span class="hs-str">&quot;Accepting symbol: &quot;</span> <span class="hs-varop">++</span> <span class="hs-varid">show</span> <span class="hs-varid">t</span> <span class="hs-varop">++</span> <span class="hs-str">&quot; at position: &quot;</span> <span class="hs-varop">++</span> <span class="hs-varid">show</span> <span class="hs-varid">pos</span> <span class="hs-varop">++</span><span class="hs-str">&quot;\n&quot;</span><span class="hs-layout">)</span> <br>
<a name="line-67"></a>                                 <span class="hs-layout">(</span><span class="hs-conid">Step</span> <span class="hs-num">1</span> <span class="hs-layout">(</span><span class="hs-varid">k</span> <span class="hs-varid">t</span> <span class="hs-layout">(</span><span class="hs-conid">Str</span> <span class="hs-varid">ts</span> <span class="hs-varid">msgs</span> <span class="hs-layout">(</span><span class="hs-varid">advance</span> <span class="hs-varid">pos</span> <span class="hs-varid">t</span><span class="hs-layout">)</span> <span class="hs-conid">True</span><span class="hs-layout">)</span><span class="hs-layout">)</span><span class="hs-layout">)</span><br>
<a name="line-68"></a>                           <span class="hs-keyword">else</span>  <span class="hs-conid">Fail</span> <span class="hs-keyglyph">[</span><span class="hs-varid">msg</span><span class="hs-keyglyph">]</span> <span class="hs-layout">(</span><b><span class="hs-varid">ins</span><span class="hs-conop">:</span></b> <span class="hs-keyword">if</span> <b><span class="hs-varid">del_ok</span></b> <span class="hs-keyword">then</span> <b><span class="hs-keyglyph">[</span><span class="hs-varid">del</span></b><span class="hs-keyglyph">]</span> <span class="hs-keyword">else</span> <span class="hs-conid">[]</span><span class="hs-layout">)</span><br>
<a name="line-69"></a>               <span class="hs-conid">[]</span>      <span class="hs-keyglyph">-&gt;</span>  <span class="hs-conid">Fail</span> <span class="hs-keyglyph">[</span><span class="hs-varid">msg</span><span class="hs-keyglyph">]</span> <span class="hs-keyglyph">[</span><b><span class="hs-varid">ins</span></b><span class="hs-keyglyph">]</span><br>
<br><br><br></pre><br>Specifically I am having hard time understanding how the &quot;ins exp&quot; and &quot;del exp&quot; in the &quot;let&quot; is related to &quot;ins:&quot;  &quot;del_ok&quot;, [del], [ins].<br>I don&#39;t understand how given the &quot;let&quot; expression the following expressions are expanded<br>
<br><pre> <span class="hs-conid">Fail</span> <span class="hs-keyglyph">[</span><span class="hs-varid">msg</span><span class="hs-keyglyph">]</span> <span class="hs-layout">(</span><b><span class="hs-varid">ins</span><span class="hs-conop">:</span></b> <span class="hs-keyword">if</span> <b><span class="hs-varid">del_ok</span></b> <span class="hs-keyword">then</span> <b><span class="hs-keyglyph">[</span><span class="hs-varid">del</span></b><span class="hs-keyglyph">]</span> <span class="hs-keyword">else</span> <span class="hs-conid">[]</span><span class="hs-layout">)</span></pre>

<br>and<br><br><pre><span class="hs-conid">Fail</span> <span class="hs-keyglyph">[</span><span class="hs-varid">msg</span><span class="hs-keyglyph">]</span> <span class="hs-keyglyph">[</span><b><span class="hs-varid">ins</span></b><span class="hs-keyglyph">]</span></pre>

<br>Appreciate any help.<br><br><br>Thanks<br><br>Daryoush<br><br><br><pre><a name="line-56"></a><br>
</pre>