[Haskell-cafe] Some question about c2hs.
Andy Stewart
lazycat.manatee at gmail.com
Wed Sep 16 10:56:15 EDT 2009
Hi all,
I try to binding Haskell to VTE library.
Below are Vte.chs file i wrote.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Vte.chs
Type: application/octet-stream
Size: 26264 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090916/36debd98/Vte-0001.obj
-------------- next part --------------
I use c2hs with below command
LANG=C c2hs -d trace -l $(pkg-config --cflags vte | sed 's/-I/-C-I/g') vte/vte.h Vte.chs
generate Vte.hs file.
When i compile Vte.hs file, i got below error:
Vte.chs:67:89:
Couldn't match expected type `Widget' against inferred type `()'
Expected type: IO (Ptr Widget)
Inferred type: IO (Ptr ())
In the second argument of `($)', namely `vte_terminal_new'
In the second argument of `($)', namely
`liftM (castPtr :: Ptr Widget -> Ptr Terminal) $ vte_terminal_new'
for binding code:
terminalNew :: IO Terminal
terminalNew =
makeNewObject mkTerminal $ liftM (castPtr :: Ptr Widget -> Ptr Terminal) $ {#call unsafe
terminal_new#}
In C code, fucntion `GtkWidget *vte_terminal_new(void);' return `IO (Ptr
Widget), then i use castPtr transform (Ptr Widget) to (Ptr Terminal),
right?
Why GHC report function `vte_terminal_new` return `IO (Ptr ())', I do
something wrong?
Any help?
Thanks!
-- Andy
More information about the Haskell-Cafe
mailing list