Actually, looking at the docs, I&#39;m not sure if case expressions work on unboxed ints; you may need<br><br>addCarry (I# x) (I# y) = case addIntC# x y of (# s, c #) -&gt; (I# s, c /=# 0#)<br><br>which is somewhat simpler anyways.<br>
<br>&nbsp; -- ryan<br><br><div class="gmail_quote">On Tue, Jul 31, 2012 at 1:56 AM, Ryan Ingram <span dir="ltr">&lt;<a href="mailto:ryani.spam@gmail.com" target="_blank">ryani.spam@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">
Sure, but it&#39;s easy to roll your own from those primitives:<br><br>{-# LANGUAGE MagicHash, UnboxedTuples #-}<br>import GHC.Exts<br><br>addCarry :: Int -&gt; Int -&gt; (Int, Bool)<br>addCarry (I# x) (I# y) = case addIntC# x y of<br>

&nbsp; &nbsp;&nbsp; (# s, c #) -&gt; case c of<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0# -&gt; (I# s, False)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _ -&gt; (I# s, True)<br><br>or something along those lines.<span class="HOEnZb"><font color="#888888"><br><br>&nbsp; -- ryan</font></span><div class="HOEnZb">
<div class="h5"><br><br><div class="gmail_quote">On Mon, Jul 30, 2012 at 1:43 PM, Евгений Пермяков <span dir="ltr">&lt;<a href="mailto:permeakra@gmail.com" target="_blank">permeakra@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"><div><div>On 07/31/2012 12:04 AM, Artyom Kazak wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Евгений Пермяков &lt;<a href="mailto:permeakra@gmail.com" target="_blank">permeakra@gmail.com</a>&gt; писал в своём письме Mon, 30 Jul 2012 09:47:48 +0300:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Can someone tell me if there are any primitives, that used to detect machine type overflows, in ghc haskell ? I perfectly understand, that I can build something based on preconditioning of variables, but this will kill any performance, if needed.<br>


</blockquote>
<br>
In GHC.Prim &mdash; primitives addIntC# and subIntC#:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
addIntC# :: Int# -&gt; Int# -&gt; (#Int#, Int##)<br>
Add with carry. First member of result is (wrapped) sum; second member is 0 iff no overflow occured.<br>
</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
subIntC# :: Int# -&gt; Int# -&gt; (#Int#, Int##)<br>
Subtract with carry. First member of result is (wrapped) difference; second member is 0 iff no overflow occured.<br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/<u></u>mailman/listinfo/haskell-cafe</a><br>
</blockquote></div></div>
Still no way to detect overflow in *.<br>
<br>
Strangely enough, I found some relevant descriptions in *.pp in dev branch, so I expect them in 7.6.1. They applies to native-size Word and Int only.<div><div><br>
<br>
______________________________<u></u>_________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/<u></u>mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br>