On Sat, Jun 21, 2008 at 1:28 PM, Ryan Ingram <ryani.spam@gmail.com> wrote:
You just have the arguments to "poke" wrong:
  poke :: Storable a => Ptr a -> a -> IO ()

So you are missing the pointer argument
  poke p Signal = poke p signal_int_value
                                              ^^ what is "signal_int_value"?


I didn't know about the (#const) syntax.  Interesting.

Also, alignment of signal should match the alignment of the underlying
type (although I think that isn't really used at the moment).

 -- ryan

2008/6/20 Galchin, Vasili <vigalchin@gmail.com>:
> I am still reading the web pages. Here is what I tried:
>
> data SigNotify = Signal | None | Thread | ThreadId
>
>
> instance Storable SigNotify where
>
>    sizeOf _ = (#const sizeof (int))
>
>    alignment _ = 1
>
>    poke Signal = (#const SIGEV_SIGNAL)
>
>    poke None = poke (#const SIGEV_NONE)
>
>    poke Thread = poke (#const SIGEV_THREAD)
>
>    poke ThreadId = poke (#const SIGEV_THREAD_ID)
>
>
> but I got ...
>
>     Couldn't match expected type `Ptr SigNotify'
>            against inferred type `SigNotify'
>     In the pattern: Signal
>     In the definition of `poke': poke Signal = poke (0)
>     In the definition for method `poke'
>
> Basically I want to marshall SigInfo constructors to CInt values. ??
>
> Regards, Vasili
>
>
> On Fri, Jun 20, 2008 at 3:20 PM, Bulat Ziganshin <bulat.ziganshin@gmail.com>
> wrote:
>>
>> Hello Vasili,
>>
>> Friday, June 20, 2008, 11:51:11 PM, you wrote:
>> > data Bonzo = A | B |C
>>
>> > How do I write the poke functions and call them?
>>
>> instance Storable Bonzo
>>  poke A = poke 0
>>  poke B = poke 1
>>  poke C = poke 4
>>
>> call as "poke x"
>>
>> probably, you don't understand differences between OOP classes and
>> type classes. look at http://haskell.org/haskellwiki/OOP_vs_type_classes
>> and papers mentioned there
>>
>>
>> --
>> Best regards,
>>  Bulat                            mailto:Bulat.Ziganshin@gmail.com
>>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>