This idea with new level of abstraction is good but in some cases it can make things overcomplicated / less efficient. Does that mean &quot;leave simple built-in types as is&quot;?<br>But probably that&#39;s all is the matter of habit and style.<br>
<br>Thanks guys<br><br><br><div class="gmail_quote">On Tue, Sep 29, 2009 at 8:58 PM, Luke Palmer <span dir="ltr">&lt;<a href="mailto:lrpalmer@gmail.com">lrpalmer@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="h5">On Tue, Sep 29, 2009 at 11:40 AM, Olex P &lt;<a href="mailto:hoknamahn@gmail.com">hoknamahn@gmail.com</a>&gt; wrote:<br>
&gt; Hi everyone,<br>
&gt;<br>
&gt; Dumb question about declaring a function and type synonyms.<br>
&gt; There are to different declarations of the same function:<br>
&gt;<br>
&gt; attrNames :: String -&gt; AttrDict -&gt; [String]<br>
&gt;<br>
&gt; attrNames :: AttrClass -&gt; AttrDict -&gt; AttrNames<br>
&gt;<br>
&gt; First gives you the idea about exact types it expects (except AttrDict for<br>
&gt; which user has to take a look into the docs or sources) while the second one<br>
&gt; gives you the idea about meaning of parameters.<br>
&gt; Both reasons make sense. The question is when which one should be used? I&#39;m<br>
&gt; using type synonyms everywhere and possibly without too much reasons...<br>
&gt; Maybe I should stop doing it? :)<br>
<br>
</div></div>I get the impression that it is still largely a matter of style, and<br>
the community hasn&#39;t reached a consensus.<br>
<br>
Personally, I don&#39;t usually use type synonyms for this purpose.  The<br>
function name and type are usually enough.  Eg in attrNames above it<br>
should be clear what&#39;s going on: you are taking one AttrDict and one<br>
String, so the String is probably a key into the dictionary.  The<br>
return is a list of Strings, and your function is called &quot;attrNames&quot;,<br>
so it&#39;s probably a list of attr names.<br>
<br>
In the cases when it is not as obvious, I usually increase the level<br>
of abstraction (typechecked documentation) instead of introducing<br>
synonyms (un-typechecked documentation).  Take for example the<br>
function which checks whether a point is inside a bounding box:<br>
<br>
insideBoundingBox :: Point -&gt; Point -&gt; Point -&gt; Bool<br>
<br>
I could use synonyms to rename those arguments:<br>
<br>
insideBoundingBox :: LowerLeftPoint -&gt; UpperRightPoint -&gt; Point -&gt; Bool<br>
<br>
But I would prefer to introduce a new abstraction:<br>
<br>
data BoundingBox = BoundingBox { lowerLeft :: Point, upperRight :: Point }<br>
insideBoundingBox :: BoundingBox -&gt; Point -&gt; Bool<br>
<br>
And now the roles of the arguments are clear again.<br>
<font color="#888888"><br>
Luke<br>
</font></blockquote></div><br>