<br><br><div class="gmail_quote">On Sat, Jun 21, 2008 at 1:28 PM, Ryan Ingram &lt;<a href="mailto:ryani.spam@gmail.com">ryani.spam@gmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
You just have the arguments to &quot;poke&quot; wrong:<br>
 &nbsp; poke :: Storable a =&gt; Ptr a -&gt; a -&gt; IO ()<br>
<br>
So you are missing the pointer argument<br>
 &nbsp; poke p Signal = poke p signal_int_value</blockquote><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ^^ what is &quot;signal_int_value&quot;? <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
I didn&#39;t know about the (#const) syntax. &nbsp;Interesting.<br>
<br>
Also, alignment of signal should match the alignment of the underlying<br>
type (although I think that isn&#39;t really used at the moment).<br>
<br>
 &nbsp;-- ryan<br>
<br>
2008/6/20 Galchin, Vasili &lt;<a href="mailto:vigalchin@gmail.com">vigalchin@gmail.com</a>&gt;:<br>
<div><div></div><div class="Wj3C7c">&gt; I am still reading the web pages. Here is what I tried:<br>
&gt;<br>
&gt; data SigNotify = Signal | None | Thread | ThreadId<br>
&gt;<br>
&gt;<br>
&gt; instance Storable SigNotify where<br>
&gt;<br>
&gt; &nbsp; &nbsp;sizeOf _ = (#const sizeof (int))<br>
&gt;<br>
&gt; &nbsp; &nbsp;alignment _ = 1<br>
&gt;<br>
&gt; &nbsp; &nbsp;poke Signal = (#const SIGEV_SIGNAL)<br>
&gt;<br>
&gt; &nbsp; &nbsp;poke None = poke (#const SIGEV_NONE)<br>
&gt;<br>
&gt; &nbsp; &nbsp;poke Thread = poke (#const SIGEV_THREAD)<br>
&gt;<br>
&gt; &nbsp; &nbsp;poke ThreadId = poke (#const SIGEV_THREAD_ID)<br>
&gt;<br>
&gt;<br>
&gt; but I got ...<br>
&gt;<br>
&gt; &nbsp; &nbsp; Couldn&#39;t match expected type `Ptr SigNotify&#39;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;against inferred type `SigNotify&#39;<br>
&gt; &nbsp; &nbsp; In the pattern: Signal<br>
&gt; &nbsp; &nbsp; In the definition of `poke&#39;: poke Signal = poke (0)<br>
&gt; &nbsp; &nbsp; In the definition for method `poke&#39;<br>
&gt;<br>
&gt; Basically I want to marshall SigInfo constructors to CInt values. ??<br>
&gt;<br>
&gt; Regards, Vasili<br>
&gt;<br>
&gt;<br>
&gt; On Fri, Jun 20, 2008 at 3:20 PM, Bulat Ziganshin &lt;<a href="mailto:bulat.ziganshin@gmail.com">bulat.ziganshin@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hello Vasili,<br>
&gt;&gt;<br>
&gt;&gt; Friday, June 20, 2008, 11:51:11 PM, you wrote:<br>
&gt;&gt; &gt; data Bonzo = A | B |C<br>
&gt;&gt;<br>
&gt;&gt; &gt; How do I write the poke functions and call them?<br>
&gt;&gt;<br>
&gt;&gt; instance Storable Bonzo<br>
&gt;&gt; &nbsp;poke A = poke 0<br>
&gt;&gt; &nbsp;poke B = poke 1<br>
&gt;&gt; &nbsp;poke C = poke 4<br>
&gt;&gt;<br>
&gt;&gt; call as &quot;poke x&quot;<br>
&gt;&gt;<br>
&gt;&gt; probably, you don&#39;t understand differences between OOP classes and<br>
&gt;&gt; type classes. look at <a href="http://haskell.org/haskellwiki/OOP_vs_type_classes" target="_blank">http://haskell.org/haskellwiki/OOP_vs_type_classes</a><br>
&gt;&gt; and papers mentioned there<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Best regards,<br>
&gt;&gt; &nbsp;Bulat &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mailto:<a href="mailto:Bulat.Ziganshin@gmail.com">Bulat.Ziganshin@gmail.com</a><br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; Haskell-Cafe mailing list<br>
&gt; <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
&gt; <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
&gt;<br>
&gt;<br>
</blockquote></div><br>