Graphic composition using painters algorithm&nbsp;can be seen as a monoid.<div><div><br></div><div>data Graphic = Empty&nbsp;<br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| Graphic `Over` Graphic</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| Ellipse Bounds</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| ....</div><div><br></div><div>instance Monoid Graphic where</div><div>&nbsp;&nbsp; &nbsp;mempty = Empty</div><div>&nbsp;&nbsp; &nbsp;mappend = Over</div><div><br></div><div>So all functions that operate on monoids can be used on Graphic as well, like mconcat that converts a [Graphic] into a Graphic</div>
<div><br></div><div><br></div><div><div><div class="gmail_quote">On Thu, Jan 15, 2009 at 9:51 PM, Don Stewart <span dir="ltr">&lt;<a href="mailto:dons@galois.com">dons@galois.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
duncan.coutts:<br>
<div class="Ih2E3d">&gt; On Thu, 2009-01-15 at 19:46 +0000, Andrew Coppin wrote:<br>
&gt;<br>
&gt; &gt; PS. As a small aside... Is the Monoid class actually used *anywhere* in<br>
&gt; &gt; all of Haskell?<br>
&gt;<br>
&gt; Yes.<br>
&gt;<br>
&gt; They&#39;re used quite a lot in Cabal. Package databases are monoids.<br>
&gt; Configuration files are monoids. Command line flags and sets of command<br>
&gt; line flags are monoids. Package build information is a monoid.<br>
&gt;<br>
&gt; It is also used in the Foldable class which is a nice interface for<br>
&gt; traversing/visiting structures. Binary serialisation is also a monoid.<br>
<br>
</div>Also, xmonad configuration hooks are monoidal. So all those xmonad users<br>
gluing together keybindings are using the Monoid class.<br>
<font color="#888888"><br>
-- Don<br>
</font><div><div></div><div class="Wj3C7c">_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br></div></div></div>