Thanks a lot for the answers.<div><br></div><div>Another feature I really miss is type parameterized modules.</div><div><br></div><div>For example, suppose I have a module that defines simple geometry / linear algebra math, with types like Vector a, Matrix a, Point a, Size a, Rectangle a, etc...</div>
<div><br></div><div>Usually when you import such a module, you will be picking one particular type for &quot;a&quot; across the whole module or even program, e.g. Double, Float, Complex Double. </div><div><br></div><div>I see such a type more like a &quot;module global type&quot;, so instead of writing</div>
<div><br></div><div>import qualified MyGeometry (Vector, Matrix, Point, Size, Rectangle) as G</div><div><br></div><div>type Vector = G.Vector Float</div><div><div>type Matrix = G.Matrix Float</div><div><div>type Point = G.Point Float</div>
<div><div><br></div><div>etc</div><div><br></div><div>I would like to write</div><div><br></div><div>import (MyGeometry Float)</div><div><br></div><div><div><div>or even</div></div><div><br></div><div>module (MyGame real)</div>
<div><br></div><div>import (MyGeometry real)</div><div><br></div></div><div>and then I can just use Vector, Matrix, etc, without specifying the type. So it&#39;s as if (MyGeometry Float) performs a &quot;partial type application&quot;, just like ((+) 1) does &quot;partial value application&quot;</div>
<div><br></div><div>However, when writing</div><div><br></div><div><div>import MyGeometry </div><div><br></div><div>one would have to use the parametrized version of Vector etc again.</div><div><br></div><div>I&#39;m not sure if this makes any sense, or if it is even worth considering :-)</div>
<div><br></div></div></div></div></div><div><br></div><div><div><div><div><div class="gmail_quote">On Sat, Sep 26, 2009 at 6:30 AM, Sebastian Sylvan <span dir="ltr">&lt;<a href="mailto:sebastian.sylvan@gmail.com">sebastian.sylvan@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;"><br><br><div class="gmail_quote"><div class="im">On Fri, Sep 25, 2009 at 10:55 PM, Casey Hawthorne <span dir="ltr">&lt;<a href="mailto:caseyh@istar.ca" target="_blank">caseyh@istar.ca</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>On Fri, 25 Sep 2009 23:25:21 +0200, you wrote:<br>
<br>
&gt;On Fri, Sep 25, 2009 at 8:14 PM, Job Vranish &lt;<a href="mailto:jvranish@gmail.com" target="_blank">jvranish@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt; Supposedly OCaml has an OO feature that does this but I haven&#39;t tried it<br>
&gt;&gt; out.<br>
&gt;&gt;<br>
&gt;<br>
&gt;Indeed, OCaml has stuctural polymorphism, it&#39;s a wonderful feature.<br>
&gt;<br>
&gt;*# let f myobj = myobj#foo &quot;Hi !&quot;;;<br>
&gt;val f : &lt; foo : string -&gt; &#39;a; .. &gt; -&gt; &#39;a = &lt;fun&gt;*<br>
&gt;<br>
&gt;IIRC, there has been work on Template Haskell for structural polymorphism.<br>
<br>
</div>Structural subtyping/polymorphism:<br>
<br>
Pros:<br>
- an object can be coerced to any compatible type, the types do not<br>
have to be specified ahead of time, that is at compile time.<br>
<br>
Cons:<br>
- may be overly permissive; some coercions might not make sense<br>
semantically.<br>
<br>
I wonder how Haskell will minimize the cons, since it is strongly<br>
typed.<br><br></blockquote><div><br></div></div><div>I kind of think there&#39;s no real problem here. If you say that you can accept any record with a given set of fields, then you have to make sure you make no other assumptions. This is, in principle, no different from passing a speed Double to a function that expects a mass Double (e.g. it may produce garbage for negative values). In both cases a function that requires extra invariants can enforce it by using a newtype that&#39;s constructed and manipulated in a way which preserves the extra semantic rules.</div>

<div><br></div></div>-- <br><font color="#888888">Sebastian Sylvan<br>
</font><br>_______________________________________________<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>
<br></blockquote></div><br></div></div></div></div>