[Haskell-cafe] Lisp like symbols in haskell

Luke Palmer lrpalmer at gmail.com
Tue Dec 8 04:01:25 EST 2009

On Tue, Dec 8, 2009 at 1:48 AM, Michael Vanier <mvanier42 at gmail.com> wrote:
> Do you mean symbols as in "interned strings with an O(1) string comparison
> method"?  I would love to have those, but I don't see an easy way to get it
> without being in the IO or ST monad.

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


More information about the Haskell-Cafe mailing list