<br><br><div class="gmail_quote"><br><div class="gmail_quote">2010/3/24 Stephen Tetley <span dir="ltr">&lt;<a href="mailto:stephen.tetley@gmail.com" target="_blank">stephen.tetley@gmail.com</a>&gt;</span><div class="im"><div>
 </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If you consider containers as the containers package, the data<br>
structures are all (?) functorial  - but they have different shapes,<br>
so e.g. a cons operation makes sense on the linear ones<br>
(Data.Sequence, Data.List) but not on Data.Map, Data.Tree. &#39;cons&#39; is<br>
analogous to &#39;insert&#39; but &#39;insert&#39; exactly describes the operation on<br>
maps whereas &#39;cons&#39; doesn&#39;t, similarly &#39;insert&#39; doesn&#39;t describe the<br>
&#39;cons&#39; operation on lists exactly as it doesn&#39;t indicate the position<br>
of where it adds to the list.<br></blockquote><div><br></div></div><div>Some operations like insert in list could be inefficient, some operations like cons in maps could be an inefficient hack, but at this does not means that a list can do  create, insert,  map , lookup faster that a Map in the case of sort lists, for example. A generalized cons applied to a Map can make less sense, but a program made for lists with occasional cons&#39;s can happen to perform better with Maps and so on.  So a library with generality in mind can perform optimally in two or more different scenarios with different instances/implementations.  . A genetic algoritm can have the opportunity to detect this. </div>

<div><br></div><div> I think also that a complex list of class hierarchies is neither necessary nor recommended. We are not talking about mathemathical concepts. This is a performance issue.  </div><div><br></div><div>Even if a definitive class hierarchy is a problem, hopefully it may be worth to define tentative and temporal classes for performance testing purposes, that warps the common primitives with the sole purpose of executing the testing algorithm for different instance implementations, compilation flags and fusion rules.</div>
<div class="im">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Now, if you partition the type classes into small groups you get over<br>
the fact that some operations make sense on certain &#39;shapes&#39; of data<br>
structure, but there are still subtle type differences that aren&#39;t<br>
conducive to type classes - e.g. ByteString and Data.Text aren&#39;t<br>
functorial so map is type restricted:<br>
<br>
map  :: (Word8  -&gt; Word8) -&gt; ByteString  -&gt; ByteString<br>
<br></blockquote><div><br></div></div><div>For this purpose,  specific testing classes for Word8 data -with no claim to be &quot;official&quot; can be defined by the programmer, leaving to the library user to run the testing process for the different instances in his particular program. </div>

<div><br></div><div>I know that this add extra work and that not many would do this extra level of abstraction, but perhaps this is less work than spending even more time exchanging emails, discussing low level issues, performing tests, trying to figure out what will be the most common sceniarios for wich the library could be used, testing manually what is the container that has the most performance here and now, not tomorrow for these scenarios, to worry about the obsolescence of the library for reasons not related with the library algorithm  etc</div>
<div class="im">
<div><br></div><div>Regards</div></div></div></div>