<div dir="ltr"><br><br><div class="gmail_quote">2008/10/5 Galchin, Vasili <span dir="ltr">&lt;<a href="mailto:vigalchin@gmail.com">vigalchin@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr">ok ... by using &quot;newtype&quot;, we are constricting/constraining to a subset of CInt .. e.g. something like a &quot;subtype&quot; of CInt?? (where by &quot;subtype&quot;, I mean like the notion of subtype in languages like Ada). For our audience, can you perhaps distinguish (in a typeful way) between the Haskell notion of &quot;type&quot;, &quot;newtype&quot; and &quot;data&quot;? Or maybe let&#39;s distinguish between these notions not only in a typeful manner, but also in a historical motivation? .. ...&nbsp; motivations are always IMO very, very enlightening! </div>
</blockquote><div><br>If you like historical perspective check out this:<br><a href="http://research.microsoft.com/~simonpj/papers/history-of-haskell/index.htm">http://research.microsoft.com/~simonpj/papers/history-of-haskell/index.htm</a><br>
<br>type is similar to typedef in C.&nbsp; That is, it&#39;s more or less just for renaming.&nbsp; I say &quot;more or less&quot; because I&#39;m not sure exactly how the &quot;renaming&quot; works in the presence of rank-2 and higher types.<br>
<br>data is essentially for declaring new data structures.&nbsp; As a result of this it also defines a new type.<br><br>newtype is for reusing existing types or data structures but with a new distinct type.<br><br>data and newtype vary in one more subtle way, and that&#39;s how/when they evaluate to bottom.&nbsp; Most of the time they behave identically, but in the right cases they act sightly differently.&nbsp; newtype is usually regarded as more efficient than data.&nbsp; This is because the compiler can choose to optimize away the newtype so that it only exists at type check time.&nbsp; I think this is also possible with data in some, but not all, uses.<br>
<br>Jason<br></div></div><br></div>