[Haskell-cafe] Callback functions?

Dan Piponi dpiponi at gmail.com
Mon Jul 2 19:48:13 EDT 2007

On 7/2/07, Hugh Perkins <hughperkins at gmail.com> wrote:

> Well... what about inside monads?  Does this break purity???  Does this
> require adding IO to the monad if the callback function does IO?

Check out the documentation for the HOpenGL callbacks here:
I think they do exactly what you are talking about in terms of doing

If, the callback needs to perform I/O then the callback itself will
likely be a function that returns an instance of IO, just like any
other function that does I/O. Any function that calls the callback
will likely also return an instance of IO because if a function is
'tainted' by IO, then so are its callers (usually). But in a sense you
don't really need to talk about callbacks in Haskell because passing
functions into other functions so that they can be called is the norm
rather than the exception in Haskell. You don't need to give them a
special name. (The HOpenGL API probably does so because it's
inheriting from an underlying C API that calls them callbacks.)

More information about the Haskell-Cafe mailing list