> we need a function to allocate some memory for the creation of the foreign C structure, and then manipulate this foreign structure from within this function.
The needed function is allocaSetWindowAttributes, whose type indeed is:
allocaSetWindowAttributes :: (Ptr SetWindowAttributes -> IO a) -> IO a
Ну неужели они не могли написать обёртку над xlib уровнем повыше?