On Friday 12 Nov 2004 5:42 pm, Judah Jacobson wrote: > On Fri, 12 Nov 2004 14:53:33 +0000, Adrian Hey <[EMAIL PROTECTED]> wrote: > > On Thursday 11 Nov 2004 12:27 pm, Ben Rudiak-Gould wrote: > > > On the other hand, these are perfectly safe: > > > > > > once' :: IO a -> IO (IO a) > > > oncePerString :: String -> IO a -> IO a > > > oncePerType :: Typeable a => IO a -> IO a > > > > > > once' seems virtually useless unless you have top-level <-, but the > > > other two don't need it. I'm not sure which would be preferable. I lean > > > toward oncePerString as more flexible and predictable, though it > > > requires a certain discipline on the part of its users. > > > > Having taken a bit of time to look at this, I have to say that IMO > > saying they are "perfectly safe" is over stating things a bit :-) > > How is oncePerType in particular unsound?
Actually, I think I'd better retract that statement as looking at your definition closely I can't see obvious transformation that a compiler could do that would change the observable behaviour of a program. Reliance on current dynamics (which is it self a cheap and cheerful hack) worries me though. It certainly seems reasonable to eliminate your use of unsafePerformIO as the source of any unsoundness because this is exactly the sort of thing you'd do with top level <- bindings if they existed (and if they can't be given sound semantics I guess we'd better forget the whole idea :-). To be honest, all the alternatives that have been put forward have looked like extrordinarily complex hacks to me. I dislike having to use unsafePerformIO, but for one reason or another all the suggested alternatives come with so many strings attached (to get them to work properly) that I dislike them even more. A case of the cure(s) being worse than the disease :-( The problem just doesn't seem to be solvable at the library level. It's something that's just plain missing from the language. Regards -- Adrian Hey _______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe