
8 Dec
2009
8 Dec
'09
5:06 a.m.
Luke Palmer
data Sym = Sym String Hash
fromString :: String -> Sym fromString s = Sym s (hash s)
instance Eq Sym where Sym _ h == Sym _ h' = h == h'
Much as I am uncomfortable with hash-based equality. 1/2^256, despite being very small, is not zero. It is begging for a mysterious failure someday.
How about: instance Eq Sym where Sym s h == Sym s' h' = h == h' && s == s' So, very fast if the hashes fail to match, only marginally slower than just the string comparison if they are equal. -k -- If I haven't seen further, it is by standing in the footprints of giants