<div class="gmail_quote">2009/7/3 Ross Mellgren <span dir="ltr">&lt;<a href="mailto:rmm-haskell@z.odi.ac">rmm-haskell@z.odi.ac</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div style="word-wrap:break-word">Wordy (and yet technically accurate) names aside, isn&#39;t this basically the same thing, except that you must pass the dictionary around by hand?</div></blockquote><div><br></div><div>A SomeWidget is defined as &quot;any object which has a Widget dictionary&quot;.  It&#39;s still an object; the link from it to its dictionary is implicit.  But since you have no other qualifiers on that object, nothing can be determined from it but its dictionary. Why not just junk the indirection and make the object equal to its dictionary.</div>
<div><br></div><div>This is a different story if you a class like:</div><div><br></div><div>class Split a where</div><div>    split :: a -&gt; (a,a)</div><div>    join :: a -&gt; a -&gt; a</div><div>data SomeSplit = forall a. Split a =&gt; SomeSplit a</div>
<div><br></div><div>Here a SomeSplit can be split into two SomeSplits, but two SomeSplits can&#39;t be joined into one.  Two join two of these things, you must have split them off a common ancestor.</div><div><br></div><div>
<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="word-wrap:break-word"><div><br></div><div>What is the advantage of doing the dictionary passing manually, other than being able to avoid the scoping issue (that requires case) and the slightly odd syntax?</div>
</div></blockquote><div><br></div><div>The fact that it&#39;s exactly the same, except for the scoping issue and the slightly odd syntax.  You&#39;re not saving any parameter passing.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div style="word-wrap:break-word"><div></div><div><br></div><div>To expand your example, would you suggest something like:</div><div class="im"><div><br></div><div>data Widget = Widget { widgetRun :: IO () }</div><div><br>
</div></div><div class="im"><div>data Label = Label (String -&gt; IO ())</div></div><div>data Button = Button (IO ())</div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div style="word-wrap:break-word"><div></div><div><br></div><div>labelToWidget = Widget runLabel</div><div>buttonToWidget = Widget runButton</div><div><br></div><div>widgetList :: [(Integer, Integer, Widget)]</div><div>widgetList = [labelToWidget myLabel, buttonToWidget myButton]</div>
</div></blockquote><div><br></div><div>Yeah sure, something like that.</div><div><br></div><div>Except, concretely, I don&#39;t see how a Label is a String -&gt; IO ().  Is that a setter function for its text?  How is a Widget going to use that. I guess unless a &quot;label widget&quot; passed *you* a label when you create it.  I&#39;d say the other option in this paradigm is a MVar.  But I digress...</div>
<div><br></div><div>Luke</div></div>