I have been looking at the GHC 4.04 sources a little lately and in the
module FastString (in ghc/compiler/utils), the instance for Eq is defined as
follows:

  instance Eq FastString where
    a == b = case cmpFS a b of { LT -> False; EQ -> true; GT -> False }
    ...

and cmpFS will return EQ if the unique IDs of a and b match, otherwise it
just does a ccall to strcmp.

What I don't understand is why you don't just define (==) so that to
FastStrings are equal if and _only_ if their unique IDs are equal. Isn't the
whole point of FastString that identical strings and only identical strings
will get the same ID? The ID's not the string's hash value, as far as I can
see, and with the present definition you will check each character in the
string when the result of (==) is False.

Am I missing something?

- --FC

Reply via email to