Paul Liu | 31 Aug 09:11 2012
Picon

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

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.
http://blog.sigfpe.com/2011/10/quick-and-dirty-reinversion-of-control.html
[2]: Functional Pearls: A Poor Man's Concurrency Monad, Koen Claessen, 1999
(Continue reading)


Gmane