[Haskell-cafe] Lisp like symbols in haskell
ketil at malde.org
Tue Dec 8 05:06:01 EST 2009
Luke Palmer <lrpalmer at gmail.com> writes:
> 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
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.
If I haven't seen further, it is by standing in the footprints of giants
More information about the Haskell-Cafe