Yep. It harkens to my days of forcing impure, non-thread-safe C libraries into nice, pure, Haskell FFI bindings. I suppose what I'd like to do here is work in the unsafe IO much more closely with GHC's existing facilities, so that we spend as much time as possible /not/ in unsafePerformIO. A kind of hybrid approach, if you will.
P.S. Don Stewart points out that Edward Kmett has can access GHC's pointer tags http://hackage.haskell.org/package/tag-bits, thus allowing us to approximate evaluated/not evaluated. Maybe I'll hack up a prototype next time round. Excerpts from Ketil Malde's message of Sun Apr 24 17:41:23 -0400 2011: > "Edward Z. Yang" <[email protected]> writes: > > > I've been toying around with some ideas where we do alternative > > forms of controlled mutation. One such idea has to do with memoization. > [..] > > Hash tables take advantage of this fact by simply chaining together values > > in a linked list if they land in the same bucket. [...] > > An obvious way to do this is to use unsafePerformIO to > > read out an IORef stating the value currently being looked up, and > > have the thunk evaluate to the pair of that key and the result. There > > are some synchronization concerns, of course: > > Seen this? > > http://augustss.blogspot.com/2011/04/ugly-memoization-heres-problem-that-i.html > > -k _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
