I have a very specific StringLike typeclass in the web-encodings package so that I can- for example- to HTML entity encoding on String, (lazy) bytestrings and (lazy) text. Of course, I need to make assumptions about character encoding for the bytestring version.<div>
<br></div><div>Michael<br><br><div class="gmail_quote">On Wed, Mar 24, 2010 at 8:50 AM, John Lato <span dir="ltr">&lt;<a href="mailto:jwlato@gmail.com">jwlato@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;">
I still think that getting other authors to use it would be the<br>
biggest difficulty.  Another concern of mine is that RULEs-based<br>
fusion can be fragile; if the type classes prevent fusion from<br>
occurring you&#39;ll never approach the performance of monomorphic code.<br>
<br>
That said, I think this is worth pursuing further because of the<br>
benefits you describe.  I have spent a great deal of time on exactly<br>
this issue with the iteratee package, although my needs there are<br>
relatively simple.<br>
<br>
As a general question to the Haskell community: have you ever<br>
attempted to write container-polymorphic code?  I&#39;d like to hear about<br>
either successes or stumbling blocks.<br>
<div><div></div><div class="h5"><br>
On Wed, Mar 24, 2010 at 12:02 PM, Alberto G. Corona &lt;<a href="mailto:agocorona@gmail.com">agocorona@gmail.com</a>&gt; wrote:<br>
&gt; Once we have a  tree of type classes suitable for all containers, as you<br>
&gt; said, theoretically it  shouldn&#39;t very difficult to incorporate the testing<br>
&gt; of different instances for each class used in a program, besides  testing<br>
&gt; different compilation flags in a genetic algoritm. This latter has already<br>
&gt; been done.<br>
&gt; <a href="http://donsbot.wordpress.com/2010/03/01/evolving-faster-haskell-programs-now-with-" target="_blank">http://donsbot.wordpress.com/2010/03/01/evolving-faster-haskell-programs-now-with-</a><br>
&gt; To find automatically the best combination of class implementations and<br>
&gt; compilation flags in a single process would be very useful and would save a<br>
&gt; lot of manual testing.<br>
&gt;<br>
&gt; 2010/3/24 John Lato &lt;<a href="mailto:jwlato@gmail.com">jwlato@gmail.com</a>&gt;<br>
&gt;&gt;<br>
&gt;&gt; Hi Alberto,<br>
&gt;&gt;<br>
&gt;&gt; To some extent this already exists, it&#39;s just that nobody uses it.  I<br>
&gt;&gt; believe it&#39;s the approach taken by the Edison libraries.  Also the<br>
&gt;&gt; ListLike package provides the type classes ListLike, StringLike, and a<br>
&gt;&gt; few others.  Neither seems to have become very popular despite having<br>
&gt;&gt; well-respected authors (Okasaki and Goerzon, respectively).<br>
&gt;&gt;<br>
&gt;&gt; Some container functions are already provided by other classes, namely<br>
&gt;&gt; Foldable, Traversable, and Monoid.<br>
&gt;&gt;<br>
&gt;&gt; The first bit, creating a tree of type classes suitable for all<br>
&gt;&gt; containers, is probably a few hours work.<br>
&gt;&gt;<br>
&gt;&gt; An automated system to determine the best implementation is<br>
&gt;&gt; significantly more difficult; I can&#39;t say if the scope would be<br>
&gt;&gt; appropriate for SoC.<br>
&gt;&gt;<br>
&gt;&gt; Best,<br>
&gt;&gt; John<br>
&gt;&gt;<br>
&gt;&gt; &gt; From: &quot;Alberto G. Corona &quot; &lt;<a href="mailto:agocorona@gmail.com">agocorona@gmail.com</a>&gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Just a dream:<br>
&gt;&gt; &gt; -separate interface and implementation for all containers, via type<br>
&gt;&gt; &gt; classes<br>
&gt;&gt; &gt; -develop, by genetic programming techniques + quickcheck, a system that<br>
&gt;&gt; &gt; find<br>
&gt;&gt; &gt; the best container implementation for a particular program.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Is that suitable for a Google Summer of Code project?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; 2010/3/23 Alberto G. Corona &lt;<a href="mailto:agocorona@gmail.com">agocorona@gmail.com</a>&gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; The question can be generalized via type classes: Is there any common<br>
&gt;&gt; &gt; set of<br>
&gt;&gt; &gt;&gt; primitives encapsulated into a single type class that has instances for<br>
&gt;&gt; &gt;&gt; Strings (Data.List) ByteStrings, Data.Text, Lazy bytestrings, Arrays,<br>
&gt;&gt; &gt;&gt; vectors and wathever container that can store an boxed, unboxed, packed<br>
&gt;&gt; &gt;&gt; unpacked sequence of wathever including chars? All of them have folds,<br>
&gt;&gt; &gt;&gt; heads, tails and a lot of common functions with the same name, but<br>
&gt;&gt; &gt;&gt; since<br>
&gt;&gt; &gt;&gt; there is not a single type class, the library programmer can not<br>
&gt;&gt; &gt;&gt; abstract<br>
&gt;&gt; &gt;&gt; his code when it is possible, so the library user can chose the<br>
&gt;&gt; &gt;&gt; particular<br>
&gt;&gt; &gt;&gt; instance for his particular problem.<br>
&gt;<br>
&gt;<br>
</div></div><div><div></div><div class="h5">_______________________________________________<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>