From: Axel S. <Axe...@en...> - 2009-09-17 17:35:15
|
Hi Andy, sorry for being so unreliable in answering. I of course welcome any contributions and people who try to contribute! On Sep 16, 2009, at 16:45, Andy Stewart wrote: > > 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? You need to say {#import Gtk.Graphics.UI.Types#} in your import list. This will be parsed by c2hs and inform it that it should read the declarations in the corresponding .chi files. Then it will know that the Widget* type in the C header file should be translated into a Ptr Widget. Btw, you only need to say castPtr, you don't have to give it a full type signature. Cheers, Axel. |