[Haskell] The meaning of #{}
Donald Bruce Stewart
dons at cse.unsw.edu.au
Tue Feb 13 01:43:44 EST 2007
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#id3184862
#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
More information about the Haskell
mailing list