[Haskell-cafe] Genuine Need For Persistent Global State?
jvranish at gmail.com
Fri Oct 16 15:24:19 EDT 2009
Stable pointers might do what you want:
Though an IORef would probably work just as well, depending on how you
needed to use it..
On Fri, Oct 16, 2009 at 2:59 PM, Alan Carter <alangcarter at gmail.com> wrote:
> I've been looking at the patches given by Tom at Beware the Jabberwolk, for
> building Linux kernel modules in Haskell. Once I'd got Tom's stuff building,
> the next thing was to build a little driver which actually does something.
> Step by step I was making progress, and I've now got a little function which
> can see all the characters which are catted to the device file. That's when
> I got stuck.
> 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.
> I've thought about trying to create some State when I initialize, pass some
> kind of pointer back to the C shim which actually does the calling into
> Haskell, and then passing it back into Haskell on the writes and reads, but
> that seems dangerous because the Haskell garbage collector would
> (understandably) get the wrong idea and delete it. Also it's ugly - having
> to use C for something Haskell can't do.
> I've been looking at the Halfs Haskell file system, which surely must have
> solved its own version of this problem, but whatever it does in its FSState
> seems very complicated and is beyond my comprehension :-(
> So my questions are:
> 1) Am I right in thinking that I have a genuine need for global, persistent
> 2) Halfs works. Am I right in thinking it has (somehow) solved this
> 3) Is there a simple way to maintain global persistent state that I can
> stash between calls into a function, and access without needing to pass the
> state in? If so, is there an example anywhere?
> Thanks in advance,
> ... the PA system was moaning unctuously, like a lady hippopotamus reading
> A. E. Housman ..."
> -- James Blish, "They Shall Have Stars"
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe