Hmm, neato.  but didn&#39;t make life any easier!<div><br></div><div>Data.Monoid&gt; (appEndo . mconcat . map Endo) [(+10), (+20)] 3</div><div>33</div><div>Data.Monoid&gt; (foldr (.) id) [(+10), (+20)] 3</div><div>33</div>

<div><br></div><div>I had hoped for something like:</div><div><br></div><div>&gt; mconcat [(+10), (+20)] 3</div><div><br></div><div>But I suppose that&#39;s nonsense, considering this works:</div><div><br></div><div>&gt; mconcat [(++&quot;10&quot;), (++&quot;20&quot;)] &quot;3&quot;</div>

<div>&quot;310320&quot;</div><div><br></div><div><br></div><div>I think this is the most general solution?</div><div><br></div><div>import Control.Category</div><div>import Data.Foldable</div><div>import Prelude hiding (foldr, (.), id)</div>

<div><br></div><div>compose :: (Foldable t, Category cat) =&gt; t (cat a a) -&gt; cat a a</div><div>compose = foldr (.) id</div><div><br></div><div><br></div><div>Usage:</div><div><br></div><div>&gt; compose [(+10), (+20)] 3</div>

<div><br></div><div>Real-world use case:</div><div><br></div><div>&gt; let parseOrIgnore p = either (const s) id . parse p s</div><div>&gt; parseAllOrIgnore = compose . map parseOrIgnore [p1, p2, p3]</div><div><br></div>
<div>
Naming:</div><div><br></div><div>&quot;(.)/compose&quot; is consistent with &quot;(+)/sum&quot;, &quot;(*)/product&quot;, &quot;(&amp;&amp;)/and&quot;, etc.</div><div><br></div><div>Thoughts?</div><div><br></div><div>-Greg</div>

<div><br></div><br><div class="gmail_quote">On Fri, Oct 26, 2012 at 12:31 PM, John Wiegley <span dir="ltr">&lt;<a href="mailto:jwiegley@gmail.com" target="_blank">jwiegley@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 class="im">&gt;&gt;&gt;&gt;&gt; Greg Fitzgerald &lt;<a href="mailto:garious@gmail.com">garious@gmail.com</a>&gt; writes:<br>
<br>
&gt; I&#39;ve recently found myself using the expression: &quot;foldr (.) id&quot; to compose a<br>
&gt; list (or Foldable) of functions.<br>
<br>
</div>You want the Endo monoid:<br>
<br>
    ghci&gt; appEndo (Endo (+ 10) &lt;&gt; Endo (+ 20)) $ 3<br>
      33<br>
<span class="HOEnZb"><font color="#888888"><br>
John<br>
</font></span></blockquote></div><br>