The meaning of #{}
I've been pouring over the Xlib bindings for Haskell, and I've come across the following code: peekXButtonEvent p = do root <- #{peek XButtonEvent,root} p subwindow <- #{peek XButtonEvent,subwindow} p time <- #{peek XButtonEvent,time} p x <- #{peek XButtonEvent,x} p y <- #{peek XButtonEvent,y} p x_root <- #{peek XButtonEvent,x_root} p y_root <- #{peek XButtonEvent,y_root} p state <- #{peek XButtonEvent,state} p button <- #{peek XButtonEvent,button} p same_screen <- #{peek XButtonEvent,same_screen} p return (root, subwindow, time, x, y, x_root, y_root, state, button, same_screen) I can't seem to find a definition or an explanation for #{}. Is this some kind of operator for dealing with monads or something? Thanks, Rob Hoelz
hoelz:
I've been pouring over the Xlib bindings for Haskell, and I've come across the following code:
peekXButtonEvent p = do root <- #{peek XButtonEvent,root} p subwindow <- #{peek XButtonEvent,subwindow} p time <- #{peek XButtonEvent,time} p x <- #{peek XButtonEvent,x} p y <- #{peek XButtonEvent,y} p x_root <- #{peek XButtonEvent,x_root} p y_root <- #{peek XButtonEvent,y_root} p state <- #{peek XButtonEvent,state} p button <- #{peek XButtonEvent,button} p same_screen <- #{peek XButtonEvent,same_screen} p return (root, subwindow, time, x, y, x_root, y_root, state, button, same_screen)
I can't seem to find a definition or an explanation for #{}. Is this some kind of operator for dealing with monads or something?
Nope! But nice guess - if in doubt, its probably to do with monads :-) Its actually hsc2hs preprocessor code, http://www.haskell.org/ghc/docs/latest/html/users_guide/hsc2hs.html#id318486... #peek struct_type, field A function that peeks a field of a C struct will be output. It will have the type Storable b => Ptr a -> IO b. The intention is that #peek and #poke can be used for implementing the operations of class Storable for a given C struct (see the Foreign.Storable module in the library documentation). -- Done
On Tue, Feb 13, 2007 at 12:40:00AM -0600, Rob Hoelz wrote:
I've been pouring over the Xlib bindings for Haskell, and I've come across the following code:
peekXButtonEvent p = do root <- #{peek XButtonEvent,root} p [...] I can't seem to find a definition or an explanation for #{}. Is this some kind of operator for dealing with monads or something?
It's a directive for hsc2hs, a preprocessor that helps glue haskell and C: http://www.haskell.org/ghc/docs/latest/html/users_guide/hsc2hs.html -- Gaal Yahas <gaal@forum2.org> http://gaal.livejournal.com/
participants (3)
-
dons@cse.unsw.edu.au -
Gaal Yahas -
Rob Hoelz