<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! <br>
<br><br>Regards, vasili<br><br><div class="gmail_quote">On Mon, Oct 6, 2008 at 12:47 AM, Don Stewart <span dir="ltr">&lt;<a href="mailto:dons@galois.com">dons@galois.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;">
Used wisely, newtype prevents accidentally constructing illegal values<br>
of Signal type, by treating them as CInts. You can restrict the valid<br>
values of the Signal type to be just those signals you define, not<br>
arbitrary bit patterns that fit in a CInt.<br>
<br>
vigalchin:<br>
<div class="Ih2E3d">&gt; &nbsp; &nbsp;Thanks Don. Maybe both for me and others in order to take the fight to the<br>
&gt; &nbsp; &nbsp;Klingons and other Baddies, please explain the &quot;typefulness&quot; protection<br>
&gt; &nbsp; &nbsp;that &quot;newtype&quot; affords over the &quot;Klingon &quot; &quot;type&quot; ... &nbsp;In the code that I<br>
&gt; &nbsp; &nbsp;contributed to the library, I like to think that I used &quot;newtype&quot;<br>
&gt; &nbsp; &nbsp;appropriately but not perhaps with full understanding.<br>
&gt;<br>
&gt; &nbsp; &nbsp;Thanks, Vasili<br>
&gt;<br>
</div><div class="Ih2E3d">&gt; &nbsp; &nbsp;On Mon, Oct 6, 2008 at 12:37 AM, Don Stewart &lt;[1]<a href="mailto:dons@galois.com">dons@galois.com</a>&gt; wrote:<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp;vigalchin:<br>
&gt; &nbsp; &nbsp; &nbsp;&gt; &nbsp; &nbsp;Hello,<br>
&gt; &nbsp; &nbsp; &nbsp;&gt;<br>
&gt; &nbsp; &nbsp; &nbsp;&gt; &nbsp; &nbsp; &nbsp; I am reading some extant Haskell code that uses Posix<br>
&gt; &nbsp; &nbsp; &nbsp;signals.... I am<br>
&gt; &nbsp; &nbsp; &nbsp;&gt; &nbsp; &nbsp;confused by the motivation of the following ...<br>
&gt; &nbsp; &nbsp; &nbsp;&gt;<br>
&gt; &nbsp; &nbsp; &nbsp;&gt; &nbsp; &nbsp;type [1]Signal = [2]CInt<br>
&gt; &nbsp; &nbsp; &nbsp;&gt; &nbsp; &nbsp;[3]nullSignal :: [4]Signal<br>
&gt; &nbsp; &nbsp; &nbsp;&gt; &nbsp; &nbsp;[5]internalAbort :: [6]Signal<br>
&gt; &nbsp; &nbsp; &nbsp;&gt; &nbsp; &nbsp;[7]sigABRT :: [8]CInt<br>
&gt; &nbsp; &nbsp; &nbsp;&gt; &nbsp; &nbsp;[9]realTimeAlarm :: [10]Signal<br>
&gt; &nbsp; &nbsp; &nbsp;&gt; &nbsp; &nbsp;[11]sigALRM :: [12]CInt<br>
&gt; &nbsp; &nbsp; &nbsp;&gt; &nbsp; &nbsp;[13]busError :: [14]Signal<br>
&gt; &nbsp; &nbsp; &nbsp;&gt; &nbsp; &nbsp;[15]sigBUS :: [16]CInt<br>
&gt; &nbsp; &nbsp; &nbsp;&gt;<br>
&gt; &nbsp; &nbsp; &nbsp;&gt; &nbsp; &nbsp;OK .. &quot;type&quot; is really just a synomym and doesn&#39;t invoke type<br>
&gt; &nbsp; &nbsp; &nbsp;checking<br>
&gt; &nbsp; &nbsp; &nbsp;&gt; &nbsp; &nbsp;like &quot;data&quot; type declarations do .. so why don&#39;t we have all the<br>
&gt; &nbsp; &nbsp; &nbsp;&quot;CInts&quot;<br>
&gt; &nbsp; &nbsp; &nbsp;&gt; &nbsp; &nbsp;substituted by &quot;Signal&quot;? I.e. what did I miss?<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp;Looks like it should all be Signal, and probably should be using a<br>
&gt; &nbsp; &nbsp; &nbsp;newtype, to prevent funky tricks. The Posix layer is a bit crufty.<br>
&gt; &nbsp; &nbsp; &nbsp;-- Don<br>
&gt;<br>
</div>&gt; References<br>
&gt;<br>
&gt; &nbsp; &nbsp;Visible links<br>
&gt; &nbsp; &nbsp;1. mailto:<a href="mailto:dons@galois.com">dons@galois.com</a><br>
</blockquote></div><br></div>