The Binding Generator C->Haskell : Implementation of Haskell Binding Modules : Get Hooks
Previous: Function Hooks
Next: Set Hooks

## 2.8. Get Hooks

> `{#get apath#}`

A get hook supports accessing a member value of a C structure. The hook itself yields a function that, when given the address of a structure of the right type, performs the structure access. The member that is to be extracted is specified by the access path apath. Access paths are formed as follows (following a subset of the C expression syntax):

- The root of any access path is a simple identifier, which denotes either a type name or `struct` tag.
- An access path of the form `*`apath denotes dereferencing of the pointer yielded by accessing the access path apath.
- An access path of the form apath`.`cid specifies that the value of the `struct` member called cid should be accessed.
- Finally, an access path of the form apath`->`cid, as in C, specifies a combination of dereferencing and member selection.

For example, we may have

> `

>     visualGetType              :: Visual -> IO VisualType
>     visualGetType (Visual vis)  = liftM cToEnum $ {#get Visual->type#} vis

> `

The Binding Generator C->Haskell : Implementation of Haskell Binding Modules : Get Hooks
Previous: Function Hooks
Next: Set Hooks