on master help sign in
Merge branch 'master' of github.com:idris-lang/Idris-dev
commit33f8cda336dc478564d5b8848dc3b9c44c4e1783 authorEdwin Brady <ecb10@st-andrews.ac.uk> dateMon 27 Oct 2014, 09:53 (12 years ago) parent7037cb0f8a6746
2 files changed+14−8
src/Idris/Elab/Clause.hs+13−7 src/Idris/Transforms.hs+1−1
src/Idris/Elab/Clause.hs+13−7
@@ -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.
src/Idris/Transforms.hs+1−1
@@ -93,7 +93,7 @@ matchTerm lhs tm = matchVars [] lhs tm
9393 = do fm <- doMatch ns f f'
9494 am <- doMatch ns a a'
9595 return (fm ++ am)
96− doMatch ns x y | x == y = return []
96+ doMatch ns x y | vToP x == vToP y = return []
9797 | otherwise = Nothing
9898
9999