The Binding Generator C->Haskell : Implementation of Haskell Binding Modules : Call Hooks
Previous: Enumeration Hooks
Next: Function Hooks

2.6. Call Hooks

{#call [pure] [unsafe] cid [as (hsid | ^)]#}

A call hook rewrites to a call to the C function cid and also ensures that the appropriate foreign import declaration is generated. The tags pure and unsafe specify that the external function is purely functional and cannot re-enter the Haskell runtime, respectively. If hsid is present, it is used as the identifier for the foreign declaration, which otherwise defaults to the cid. When instead of hsid, the symbol is given, the cid after conversion from C's underscore notation to a capitalised identifier is used.

As an example, consider

sin :: Float -> Float
sin  = {#call pure sin as "_sin"#}


The Binding Generator C->Haskell : Implementation of Haskell Binding Modules : Call Hooks
Previous: Enumeration Hooks
Next: Function Hooks