@@ -414,18 +414,24 @@ elabPE info fc caller r =
414414 -- get the clause of a specialised application
415415 getSpecClause ist (n, args)
416416 = let newnm = sUN ("PE_" ++ show (nsroot n) ++ "_" ++
417− qhash 0 (showSep "_" (map showArg args))) in
417+ qhash 5381 (showSep "_" (map showArg args))) in
418418 -- UN (show n ++ show (map snd args)) in
419419 (n, newnm, mkPE_TermDecl ist newnm n args)
420− where showArg (ExplicitS, n) = show n
421− showArg (ImplicitS, n) = show n
420+ where showArg (ExplicitS, n) = qshow n
421+ showArg (ImplicitS, n) = qshow n
422422 showArg _ = ""
423423
424− -- TMP for readability! This is obviously a really bad hashing
425− -- function.
424+ qshow (Bind _ _ _) = "fn"
425+ qshow (App f a) = qshow f ++ qshow a
426+ qshow (P _ n _) = show n
427+ qshow (Constant c) = show c
428+ qshow _ = ""
429+
430+ -- Simple but effective string hashing...
431+ -- Keep it to 32 bits for readability/debuggability
426432 qhash :: Int -> String -> String
427− qhash acc [] = showHex acc ""
428− qhash acc (x:xs) = qhash (fromEnum x + acc) xs
433+ qhash hash [] = showHex (abs hash `mod` 0xffffffff) ""
434+ qhash hash (x:xs) = qhash (hash * 33 + fromEnum x) xs
429435
430436-- checks if the clause is a possible left hand side. Returns the term if
431437-- possible, otherwise Nothing.