<div dir="ltr">Thank you; I did read that thread, and it helped me better grasp typeclasses. However it confused me even more as to which is the most idiomatic solution in haskell for my problem. This thread is partly the reason why I asked this time ;-)<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Feb 8, 2013 at 11:58 AM, Mateusz Kowalczyk <span dir="ltr">&lt;<a href="mailto:fuuzetsu@fuuzetsu.co.uk" target="_blank">fuuzetsu@fuuzetsu.co.uk</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Greetings,<br>
<br>
I have recently asked for a difference between an interface as we know<br>
it from OOP and a type class in Haskell. Although it&#39;s not an answer to<br>
your question, you might find it useful. You can find the conversation<br>
archived on gmane at [1]<br>
<br>
[1] - <a href="http://comments.gmane.org/gmane.comp.lang.haskell.beginners/11341" target="_blank">http://comments.gmane.org/gmane.comp.lang.haskell.beginners/11341</a><br>
<div><div class="h5"><br>
On 08/02/13 09:50, Emmanuel Touzery wrote:<br>
&gt; Hello,<br>
&gt;<br>
&gt;  i wrote two programs in haskell which have the same problem: they<br>
&gt; define a common datatype (let&#39;s say Event for instance), and they have<br>
&gt; several modules, each one importing a list of Event from a specific data<br>
&gt; source.<br>
&gt;<br>
&gt;  So all these modules have a similar api:<br>
&gt;<br>
&gt; getEvents :: &lt;params&gt; -&gt; IO [Event]<br>
&gt;<br>
&gt;  And maybe a couple extra functions, more or less the same for each module.<br>
&gt;<br>
&gt;  In OO, I would make a base class, like EventProvider, with a couple<br>
&gt; abstract methods and in the main class of my app, I would have a list of<br>
&gt; EventProvider and loop over them. That way to add a new EventProvider, I<br>
&gt; would just add the import and an element in that list.<br>
&gt;<br>
&gt;  Currently in haskell I duplicate the function calls for each provider.<br>
&gt; And because there is no interface constraint, each module has a slightly<br>
&gt; different API.<br>
&gt;<br>
&gt;  The &quot;obvious&quot; way to do in haskell what I would do in OO would be<br>
&gt; through type classes. However I realize type classes are not quite<br>
&gt; interfaces. I&#39;m wondering what would be the &quot;haskell way&quot; to solve this<br>
&gt; problem?<br>
&gt;<br>
&gt;  For sure type classes do the job. But is it the idiomatic way of<br>
&gt; solving this problem?<br>
&gt;<br>
&gt;  Thank you!<br>
&gt;<br>
&gt; Emmanuel<br>
&gt;<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; Beginners mailing list<br>
&gt; <a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
&gt; <a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
&gt;<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</blockquote></div><br></div>