Go to the first, previous, next, last section, table of contents.

Avoiding monads

The `_ccall_' construct is part of the `IO' monad because 9 out of 10 uses will be to call imperative functions with side effects such as `printf'. Use of the monad ensures that these operations happen in a predictable order in spite of laziness and compiler optimisations.

To avoid having to be in the monad to call a C function, it is possible to use `unsafePerformIO', which is available from the `IOExts' module. There are three situations where one might like to call a C function from outside the IO world:


Go to the first, previous, next, last section, table of contents.