From 472440c233fccf662ff41193db66c62e7bc6f6d1 Mon Sep 17 00:00:00 2001 From: Ɓukasz Hanuszczak Date: Fri, 31 Jul 2015 20:16:33 +0200 Subject: Make identifier generation also architecture-independent. --- haddock-api/src/Haddock/Backends/Xhtml/Decl.hs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'haddock-api/src/Haddock/Backends/Xhtml') diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs index c30d0e62..f1203210 100644 --- a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs +++ b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs @@ -31,10 +31,12 @@ import Haddock.Syb import Haddock.Doc (combineDocumentation) import Data.Bits +import Data.Char import Data.Data (Data, cast) import Data.List ( intersperse, sort ) import qualified Data.Map as Map import Data.Maybe +import Data.Word import Text.XHtml hiding ( name, title, p, quote ) import GHC @@ -636,16 +638,16 @@ instanceId orgin no ihd = concat -- section anchors in testing framework and that is not only inconvenient but -- also makes testing less viable. And it is only temporary solution so we can -- live with it. -instHeadId :: InstHead DocName -> Int +instHeadId :: InstHead DocName -> Word64 instHeadId (InstHead { .. }) = - djb2 . map key $ [ihdClsName] ++ names ihdTypes ++ names ihdKinds + djb2 id . map key $ [ihdClsName] ++ names ihdTypes ++ names ihdKinds where names = everything (++) $ maybeToList . (cast :: forall a. Data a => a -> Maybe DocName) - key = djb2 . occNameString . nameOccName . getName + key = djb2 (fromIntegral . ord) . occNameString . nameOccName . getName - djb2 :: Enum a => [a] -> Int - djb2 = foldl (\h c -> h * 33 `xor` fromEnum c) 5381 + djb2 :: (a -> Word64) -> [a] -> Word64 + djb2 conv = foldl (\h c -> h * 33 `xor` conv c) 5381 ------------------------------------------------------------------------------- -- cgit v1.2.3