Use Data.Hash for templates hashing in TemplateGen.
Use Data.Hash for templates hashing in TemplateGen.
diff --git a/Framework/TGenerator/TemplateGen.hs b/Framework/TGenerator/TemplateGen.hs
index 6efff64..e532ab5 100644
--- a/Framework/TGenerator/TemplateGen.hs
+++ b/Framework/TGenerator/TemplateGen.hs
@@ -9,6 +9,7 @@ import System.Directory
import System.FilePath ((</>))
import Control.Monad
import qualified Data.Map as M
+import Data.Hash
import Framework.Utils
import TemplateParser
@@ -26,15 +27,15 @@ getvar v = "maybe \"\" showC (M.lookup "++quote v++" pairs)"
getlist n = "maybe (C ([]::[Int])) id (M.lookup "++quote n++" pairs)"
-hash t = sum $ map hashF t
-hash' = show.hash
+instance Hashable Format where
+ hash (Verbatim s) = hash s
+ hash (Quote ss) = foldr combine (hash (1::Int)) $ map hash ss
+ hash (ForTag ss t) = foldr combine (hash (2::Int)) (map hash ss) `combine` hash t
+ hash (IfTag ss t p) = foldr combine (hash (3::Int)) (map hash ss) `combine` hash t `combine` hash p
-hashF (Verbatim s) = hashS s
-hashF (Quote ss) = sum (map hashS ss)
-hashF (ForTag ss t) = sum (map hashS ss) + hash t
-hashF (IfTag ss t p) = sum (map hashS ss) + hash t + hash p
-
-hashS s = length s + (sum $ map ord s)
+hash' lst = if null lst
+ then "0"
+ else show $ asWord64 $ hash lst
nl = "\n"