On Dec 17, 2007 8:18 AM, Nicholls, Mark &lt;<a href="mailto:Nicholls.Mark@mtvne.com">Nicholls.Mark@mtvne.com</a>&gt; wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
The approach is deliberate...but I accept may be harder than it needs to<br>be...I&#39;m interested in Haskell because of the alleged power/formality of<br>it&#39;s type system against the relatively weakness of OO ones...the irony
<br>at the moment is that they do not really seem to correspond<br>directly....and OO type system seems to (loosely) correlate to Haskell<br>type class system, and an OO class system (loosely) to Haskels type<br>system, though in OOP&#39;s they are unpleasantly tangled.
<br></blockquote></div><br>When I was learning Haskell, I found it helpful to think this way: In an OO system, classes describe objects. In Haskell, classes decribe types.<br><br>It may also be helpful to note that Haskell&#39;s class system can be emulated in the language itself[1] by a technique known as &quot;dictionary passing&quot;.
<br><br>For example, the Eq class is equivalent to a function of type a -&gt; a -&gt; Bool, for some a.<br><br>&nbsp;&nbsp;&nbsp; type EqD a = a -&gt; a -&gt; Bool<br><br>So any time I have a function that uses Eq,<br><br>&nbsp;&nbsp;&nbsp; foo :: Eq a =&gt; a -&gt; a -&gt; a -&gt; a
<br>&nbsp;&nbsp;&nbsp; foo a b c = if a == b then c else b<br><br>I could define an equivalent function without it<br><br>&nbsp;&nbsp;&nbsp; fooBy :: EqD a -&gt; a -&gt; a -&gt; a -&gt; a<br>&nbsp;&nbsp;&nbsp; fooBy eq a b c = if eq a b then c else b<br><br>The difference between foo and fooBy is that fooBy requires me to explicitly provide the Eq dictionary, whereas the compiler takes care of providing it to foo.
<br><br>A lot of functions in Data.List exist in &quot;foo&quot; and &quot;fooBy&quot; forms.<br><br><br>[1] This isn&#39;t entirely true if we&#39;re talking about Haskell 98. Some classes dictionaries can&#39;t be defined without an extension, but that extension is widely supported and will almost certainly be in the next language standard.
<br clear="all"><br>-- <br>Dave Menendez &lt;<a href="mailto:dave@zednenem.com">dave@zednenem.com</a>&gt;<br>&lt;<a href="http://www.eyrie.org/~zednenem/">http://www.eyrie.org/~zednenem/</a>&gt;