
On Thu, 11 Nov 2004 20:14:24 +0000, Keean Schupke
I think you are right... The only safe operation I can see for a one-time init is type IO (). All results have to be returned via side effects. Hence with my named-MVar proposal the first execution of the init function initialises certain named-MVars, and subsequent executions do nothing at all. The functions in the library would use the names-MVars directly. Therefore the once function in the NamedSem library is:
once :: IO () -> IO ()
Keean.
Actually, I don't see anything wrong on the face of it with oncePerType :: Typeable a => IO a -> IO a since the only instances of Typeable are monomorphic. Indeed, the implementation seems pretty straightforward: store the results of already-run computations as Dynamic values in a global dictionary, keyed by TypeRep. -Judah