On Fri, Oct 16, 2009 at 11:59 AM, Alan Carter <alangcarter@gmail.com> wrote:

Trouble is, my function is (ultimately) being called from the C kernel stuff. It isn't on the bottom of a call graph coming from a Haskell main. A driver really needs to know where it's at. So I seem to need some kind of global, persistent state, and Control.Monad.State seems to be out because I can't pass a State around my call graph.

You don't need anything special for this. A Linux kernel "struct device" has a "void *driver_data" member which is private for your use, and intended for precisely this purpose. Global persistent state makes no more sense for kernel drivers than for most other code: how would it work if you had two mice plugged into your system?

If you want a decent reference on writing Linux driver code, seeĀ http://lwn.net/Kernel/LDD3/

Your friendly kernel and Haskell hacker,
Bryan.