[Haskell-cafe] FunPtr error?

Galchin, Vasili vigalchin at gmail.com
Mon Jun 9 14:18:29 EDT 2008


In any case, what I want to do is store FunPtr in  a data type and marshall
into a C struct as a C function pointer.

Vasili

On Mon, Jun 9, 2008 at 1:24 AM, Galchin, Vasili <vigalchin at gmail.com> wrote:

> Thanks. Clause?
>
> regards, Vasili
>
>
> On Mon, Jun 9, 2008 at 12:54 AM, Bulat Ziganshin <
> bulat.ziganshin at gmail.com> wrote:
>
>> Hello Vasili,
>>
>> Monday, June 9, 2008, 6:17:14 AM, you wrote:
>>
>> 1. standard place to import FunPtr from is Foreign.Ptr, not System.Posix
>> 2. FunPtr is exported as abstract type, without constructors. you
>> can't construct values of this type directly. instead you should use
>> "wrapper" generators as in the example that Clause has wrote. read it
>> carefully :)
>>
>>
>> > Hello,
>>
>> >      I am getting what is to me a mysterious error in a test case that I
>> am writing:
>> > vigalchin at ubuntu:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ runhaskell
>> Setup.lhs build
>> > Preprocessing executables for Test-1.0...
>> >  Building Test-1.0...
>> > [1 of 1] Compiling Main             ( ./timer.hs,
>> > dist/build/timer/timer-tmp/Main.o )
>>
>> > ./timer.hs:11:45: Not in scope: data constructor `FunPtr'
>>
>> > It seems like the compiler is complaining about the lack of FunPtr
>> > in it's symbol table but System.Posix is imported:
>> >
>> > module Main where
>>
>> > import System.Posix
>> > import Foreign
>> > import Foreign.C
>> > import Foreign.Ptr
>>
>> > main = do
>>
>> >          let event = Sigevent{sigevFunction=(FunPtr (notifyFunc))}
>> <<<<<< error here
>> >
>> >          timerId <- timerCreate Clock_Realtime Nothing
>>
>> >          timerDelete timerId
>>
>> >          return ()
>>
>> > notifyFunc :: Sigval -> IO ()
>> > notifyFunc sigval = do
>> >    putStrLn "timer POP!!!!!!!"
>> >     return ()
>>
>> > I am probably looking right at the answer and not seeing it. ??
>>
>> > Thanks, Vasili
>>
>>
>>
>> >
>>
>>
>> --
>> Best regards,
>>  Bulat                            mailto:Bulat.Ziganshin at gmail.com
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080609/2fb34a02/attachment.htm


More information about the Haskell-Cafe mailing list