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