On 09.10.2011, at 18:13, Daniel Fischer wrote: > On Sunday 09 October 2011, 17:51:06, Jean-Marie Gaillourdet wrote: >>> That sounds plausible. Do you see any workaround? Perhaps repeatedly >>> evaluating typeOf? >> >> typeOf' seems to be a working workaround: >> >> typeOf' val >> | t1 == t2 = t1 >> | otherwise = typeOf' val >> where >> t1 = typeOf'' val >> t2 = typeOf''' val >> {-# NOINLINE typeOf' #-} >> >> >> typeOf'' x = typeOf x >> {-# NOINLINE typeOf'' #-} >> typeOf''' x = typeOf x >> {-# NOINLINE typeOf''' #-} > > That'll make it very improbable to get bad results, but not impossible. > > Thread1: typeOf' (); typeOf'' (), lookup, not there > Thread2: typeOf' (); typeOf'' (), lookup, not there > Thread1: create and insert; typeOf''' (), entry present, use ~> Key 0 > Thread2: create and insert, overwites entry with Key 0, > new entry has Key 1; typeOf''' (), entry present, use ~> Key 1 > > It will probably take a long time until it bites, but when it does, it will > hurt. > A proper fix would need a lock to ensure only one thread at a time can > access the cache. Ok, you're right. I tried to avoid the IO monad, but there seems to be no way around it.
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users