[Haskell-cafe] ANNOUCE: monad-task-0.1.0, GLFW-task-0.1.0 and a tutorial on invert the inversion of control

Paul Liu ninegua at gmail.com
Fri Aug 31 09:11:58 CEST 2012

Graphics program often relies on system frameworks such as GLUT or
GLFW to handle window and user input. But such frameworks often impose
a rigid style of callback programming, or inversion of control. It is
no secret that continuation monad can deal with this issue [1]. It is
also known that concurrency can be naturally expressed as continuation
monads [2], and a hybrid model of event and threads [3] brings the
best of both worlds.

But then I'm a bit surprised to find no single library on HackageDB
that can deal with this issue. Further more, I wanted something that
can escape the IO monad imposed by callbacks (and FFI) and be
flexible. (no, monad-control is not a solution here).

So I wrote a monad-task library to handle both co-operative threads
(or co-routines) and event processing in a TaskT transformer. To
demonstrate its usage, I also uploaded a GLFW-task library that helps
to program task monad with GLFW, which contains a sample application
if you unpack its source.

I documented the rationales behind this work in a (rather length but
runnable literal Haskell) tutorial "Invert the Inversion of Control",
and welcome any suggestions and feedbacks.

monad-task:    http://hackage.haskell.org/package/monad-task
GLFW-task:    http://hackage.haskell.org/package/GLFW-task
tutorial:      http://www.thev.net/PaulLiu/invert-inversion.html

[1]: Quick and dirty reinversion of control, Dan Piponi.
[2]: Functional Pearls: A Poor Man's Concurrency Monad, Koen Claessen, 1999
[3]: Combining Events And Threads For Scalable Network Services. Peng
Li and Steve Zdancewic. PLDI, 2007.

Paul Liu

More information about the Haskell-Cafe mailing list