<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">I'm guessing this proposal is related
      to this Stack Overflow answer you gave:<br>
      <br>
      <a class="moz-txt-link-freetext" href="http://stackoverflow.com/a/18289075/1026598">http://stackoverflow.com/a/18289075/1026598</a><br>
      <br>
      Note that your solution is very similar to the solution in the
      `foldl` package I just released (also based off of the same blog
      post you got your solution from).&nbsp; The key differences are that:<br>
      <br>
      * The `foldl` solution is for left folds and uses a strict tuple
      internally to prevent space leaks<br>
      * Your solution is for right folds and uses an extra-lazy tuple
      internally to promote laziness<br>
      <br>
      This suggests to me that it would be better to keep this
      extra-lazy tuple as an internal implementation detail of a
      right-fold package that would be the lazy analogy of `foldl`,
      rather than modifying the standard Haskell tuple.<br>
      <br>
      On 08/18/2013 01:44 PM, Edward Kmett wrote:<br>
    </div>
    <blockquote
cite="mid:CAJumaK-vMBwe8QPhX1d+0Gv1Q9UDtfFnRzkprsM=4_Arn9W-sg@mail.gmail.com"
      type="cite">
      <div dir="ltr">This change would spontaneously introduce
        space-leaks in currently non-leaky code.
        <div><br>
        </div>
        <div>It'd be a debugging nightmare for existing users of the
          product Monoid instance, of whom there are many, who would
          just see their code start to throw away all their memory on
          newer GHC versions and have little or no idea why, if they
          missed news of this update.</div>
        <div><br>
        </div>
        <div>As a result I'm -1 on this proposal.</div>
        <div><br>
        </div>
        <div>That said, some kind of package that provides a
          well-reasoned Data.Tuple.Lazy data type could see use, as
          using it would imply consent to those semantics.</div>
        <div><br>
        </div>
        <div>I do not object morally to it, like Henning, merely
          pragmatically.</div>
        <div><br>
        </div>
        <div>-Edward</div>
        <div><br>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On Sat, Aug 17, 2013 at 4:31 PM, Petr
          Pudl&aacute;k <span dir="ltr">&lt;<a moz-do-not-send="true"
              href="mailto:petr.mvd@gmail.com" target="_blank">petr.mvd@gmail.com</a>&gt;</span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000">
              <div>
                <p style="margin:1.2em 0px!important">Dear haskellers,</p>
                <p style="margin:1.2em 0px!important">currently the
                  instances are defined as</p>
                <pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;overflow:auto;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:nowrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px 3px 3px 3px;display:inline;white-space:pre-wrap;border-radius:3px 3px 3px 3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block;padding:0.5em;color:rgb(51,51,51);background:none repeat scroll 0% 0% rgb(248,248,255)"><span style="color:rgb(68,85,136);font-weight:bold"><span style="color:rgb(51,51,51);font-weight:bold">instance</span> (<span>Monoid</span> a, <span>Monoid</span> b) =&gt; <span>Monoid</span> (a,b) <span>where</span></span>
        mempty = (mempty, mempty)
        (a1,b1) `mappend` (a2,b2) = (a1 `mappend` a2, b1 `mappend` b2)</code></pre>
                <p style="margin:1.2em 0px!important">However for some
                  applications this isn't lazy enough, for example</p>
                <pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;overflow:auto;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:nowrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px 3px 3px 3px;display:inline;white-space:pre-wrap;border-radius:3px 3px 3px 3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block;padding:0.5em;color:rgb(51,51,51);background:none repeat scroll 0% 0% rgb(248,248,255)"><span style="color:rgb(153,153,136);font-style:italic">-- | Build two lists by folding on a pair of `Endo` monoids.</span>
<span style="color:rgb(153,0,0);font-weight:bold">test</span> = head $ appEndo (fst $ foldMap (f &amp;&amp;&amp; f) [<span style="color:rgb(0,153,153)">1.</span>.]) []
  <span style="color:rgb(51,51,51);font-weight:bold">where</span>
    f = <span>Endo</span> . (:)</code></pre>
                <p style="margin:1.2em 0px!important">never terminates
                  because of the unnecessary pattern matching on the
                  constructor <code
                    style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px
                    0.15em;padding:0px
                    0.3em;white-space:nowrap;border:1px solid
                    rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px
                    3px 3px 3px;display:inline">(,)</code> forces
                  evaluation of the whole infinite list.</p>
                <p style="margin:1.2em 0px!important">I suggest to
                  change all Monoid instances for tuples to be like</p>
                <pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;overflow:auto;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:nowrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px 3px 3px 3px;display:inline;white-space:pre-wrap;border-radius:3px 3px 3px 3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block;padding:0.5em;color:rgb(51,51,51);background:none repeat scroll 0% 0% rgb(248,248,255)"> <span style="color:rgb(68,85,136);font-weight:bold"><span style="color:rgb(51,51,51);font-weight:bold">instance</span> (<span>Monoid</span> a, <span>Monoid</span> b) =&gt; <span>Monoid</span> (a,b) <span>where</span></span>
         mempty = (mempty, mempty)
         ~(a1,b1) `mappend` ~(a2,b2) = (a1 `mappend` a2, b1 `mappend` b2)
<span style="color:rgb(153,153,136);font-style:italic">--      ^^^                ^^^</span></code></pre>
                <p style="margin:1.2em 0px!important">which fixes the
                  problem.</p>
                <p style="margin:1.2em 0px!important"> Best regards,<br>
                  Petr</p>
              </div>
            </div>
            <br>
            _______________________________________________<br>
            Libraries mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
            <a moz-do-not-send="true"
              href="http://www.haskell.org/mailman/listinfo/libraries"
              target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
            <br>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Libraries mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Libraries@haskell.org">Libraries@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://www.haskell.org/mailman/listinfo/libraries">http://www.haskell.org/mailman/listinfo/libraries</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>