Hugs’ page for Data.Unique seems like it indicates that Unique derives Eq, but I clearly don’t understand. For example, why can’t I do this?
Prelude> let a = Data.Unique.newUnique
Prelude> a == a
Also, I know you can hash Uniques into Integers, but Hugs says that “Two Uniques may hash to the same value, although in practice this is unlikely”. Does anyone know how unlikely?
Generating
Uniquevalues requiresIO, so your comparison fails because the type ofaisIO Unique, notUnique.newUnique >>= \u -> return (u == u)should work as expected.As for how likely a collision is, note that it produces
Int, notInteger. So if nothing else, there are only a finite number of possibleIntvalues, so if the hash values were entirely random finding a collision would simply be the Birthday “Paradox”. In practice, it may be slightly more likely than that, but probably not by very much.