Hello,<div><br></div><div>ErrorT instance of MonadPlus define that in case of fail both arguments of mplus a value of Error will be the Error of second computation:</div><div><span class="Apple-style-span" style="font-family: &#39;Times New Roman&#39;; font-size: medium; "><pre>
    <span class="varid">m</span> <span class="varop">`mplus`</span> <span class="varid">n</span> <span class="keyglyph" style="color: red; ">=</span> <span class="conid">ErrorT</span> <span class="varop">$</span> <span class="keyword" style="color: blue; ">do</span>
<a name="line-147"></a>        <span class="varid">a</span> <span class="keyglyph" style="color: red; ">&lt;-</span> <span class="varid">runErrorT</span> <span class="varid">m</span>
<a name="line-148"></a>        <span class="keyword" style="color: blue; ">case</span> <span class="varid">a</span> <span class="keyword" style="color: blue; ">of</span>
<a name="line-149"></a>            <span class="conid">Left</span>  <span class="keyword" style="color: blue; ">_</span> <span class="keyglyph" style="color: red; ">-&gt;</span> <span class="varid">runErrorT</span> <span class="varid">n</span>
<a name="line-150"></a>            <span class="conid">Right</span> <span class="varid">r</span> <span class="keyglyph" style="color: red; ">-&gt;</span> <span class="varid">return</span> <span class="layout" style="color: red; ">(</span><span class="conid">Right</span> <span class="varid">r</span><span class="layout" style="color: red; ">)</span></pre>
<pre><span class="layout" style="color: red; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; white-space: normal; font-size: small; ">Could it be changed in this way: </span></span></pre><pre>
<span class="layout" style="color: red; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; white-space: normal; font-size: small; "><span class="Apple-style-span" style="font-family: &#39;Times New Roman&#39;; font-size: medium; "><pre>
    <span class="varid">m</span> <span class="varop">`mplus`</span> <span class="varid">n</span> <span class="keyglyph" style="color: red; ">=</span> <span class="conid">ErrorT</span> <span class="varop">$</span> <span class="keyword" style="color: blue; ">do</span>
<a name="line-147"></a>        <span class="varid">a</span> <span class="keyglyph" style="color: red; ">&lt;-</span> <span class="varid">runErrorT</span> <span class="varid">m</span>
<a name="line-148"></a>        <span class="keyword" style="color: blue; ">case</span> <span class="varid">a</span> <span class="keyword" style="color: blue; ">of</span>
<a name="line-149"></a>            <span class="conid">Left</span>  <font class="Apple-style-span" color="#33CC00">e</font> <span class="keyglyph" style="color: red; ">-&gt;</span> <font class="Apple-style-span" color="#33CC00">do</font></pre>
<pre><span class="varid"><font class="Apple-style-span" color="#33CC00">                  b &lt;- runErrorT</font></span><font class="Apple-style-span" color="#33CC00"> </font><span class="varid"><font class="Apple-style-span" color="#33CC00">n</font></span></pre>
<pre><font class="Apple-style-span" color="#33CC00"><span class="varid"></span>                  case b of</font></pre><pre><font class="Apple-style-span" color="#33CC00">                      Left e&#39; -&gt; return $ Left (e `eplus` e&#39;)</font></pre>
<pre><font class="Apple-style-span" color="#33CC00">                      r -&gt; return r</font></pre><pre><a name="line-150"></a>            <span class="varid">r</span> <span class="keyglyph" style="color: red; ">-&gt;</span> <span class="varid">return</span> <span class="varid">r</span></pre>
<div><font class="Apple-style-span" color="#FF0000"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><pre><span class="layout" style="color: red; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; white-space: normal; font-size: small; ">where `eplus` could be placed in class Error a:</span></span></pre>
<pre><span class="layout"><span class="Apple-style-span" style="font-family: arial; white-space: normal; font-size: small; "><font class="Apple-style-span" color="#33CC00">eplus :: a -&gt; a -&gt; a </font></span></span></pre>
<pre><span class="layout"><span class="Apple-style-span" style="font-family: arial; white-space: normal; font-size: small; "><font class="Apple-style-span" color="#33CC00">eplus x y = y -- default implementation</font></span></span></pre>
<pre><span class="layout" style="color: red; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; white-space: normal; font-size: small; "><br></span></span></pre><pre><font class="Apple-style-span" face="arial"><span class="Apple-style-span" style="white-space: normal; font-size: small;">In this case we could combine Errors more flexible.</span></font></pre>
<pre><font class="Apple-style-span" face="arial"><span class="Apple-style-span" style="white-space: normal; font-size: small;"><br></span></font></pre><pre><font class="Apple-style-span" face="arial"><span class="Apple-style-span" style="white-space: normal; font-size: small;">Best regards,</span></font></pre>
<pre><font class="Apple-style-span" face="arial"><span class="Apple-style-span" style="white-space: normal; font-size: small;">Dmitry</span></font></pre></span></font></div></span></span></span></pre></span></div>