
Hello, I just browsed over the source of Data.Unique.newUnique[1]: newUnique :: IO Unique newUnique = do val <- takeMVar uniqSource let next = val+1 putMVar uniqSource next return (Unique next) I think asynchronous exceptions should be blocked. Currently if an asynchronous exception is thrown after taking the MVar, putMVar is not executed anymore, leaving the MVar in the empty state. A subsequent call to newUnique will then dead-lock when it tries to take the MVar. Another problem is the laziness of 'next'. When you put 'next' in the MVar you actually put the thunk 'val+1' not an Integer in WHNF. When you create say a million uniques the last unique will be a very large thunk like 0+1+1...+1. Forcing that thunk (when you print the hash of the unique for example) will probably overflow your stack. The attached patch adds the necessary block and strictly evaluates the next unique value. regards, Bas [1] http://haskell.org/ghc/docs/latest/html/libraries/base-4.2.0.0/src/Data-Uniq...