|
0 |
Description: Revert https://github.com/ndmitchell/hoogle/pull/339/files to possibly fix https://github.com/ndmitchell/hoogle/issues/359
|
|
1 |
|
|
2 |
--- haskell-hoogle-5.0.18.1+dfsg1.orig/src/Output/Types.hs
|
|
3 |
+++ haskell-hoogle-5.0.18.1+dfsg1/src/Output/Types.hs
|
|
4 |
@@ -128,15 +128,11 @@ searchFingerprintsDebug store query answ
|
|
5 |
|
|
6 |
data TypesNames a where TypesNames :: TypesNames (BStr0, V.Vector Name) deriving Typeable
|
|
7 |
|
|
8 |
--- At around 7000 packages, Word16 becomes insufficient
|
|
9 |
--- because there are more than 2^16 Names, so we use Word32.
|
|
10 |
-type NameWord = Word32
|
|
11 |
-
|
|
12 |
-- Must be a unique Name per String.
|
|
13 |
-- First 0-99 are variables, rest are constructors.
|
|
14 |
-- More popular type constructors have higher numbers.
|
|
15 |
-- There are currently about 14K names, so about 25% of the bit patterns are taken
|
|
16 |
-newtype Name = Name NameWord deriving (Eq,Ord,Show,Data,Typeable,Storable,Binary)
|
|
17 |
+newtype Name = Name Word16 deriving (Eq,Ord,Show,Data,Typeable,Storable,Binary)
|
|
18 |
|
|
19 |
name0 = Name 0 -- use to represent _
|
|
20 |
|
|
21 |
@@ -154,7 +150,7 @@ prettyName x@(Name i)
|
|
22 |
-- | Give a name a popularity, where 0 is least popular, 1 is most popular
|
|
23 |
popularityName :: Name -> Double
|
|
24 |
popularityName (Name n) | isVar $ Name n = error "Can't call popularityName on a Var"
|
|
25 |
- | otherwise = fromIntegral (n - 100) / fromIntegral (maxBound - 100 :: NameWord)
|
|
26 |
+ | otherwise = fromIntegral (n - 100) / fromIntegral (maxBound - 100 :: Word16)
|
|
27 |
|
|
28 |
newtype Names = Names {lookupName :: Str -> Maybe Name}
|
|
29 |
|
|
30 |
@@ -194,10 +190,10 @@ spreadNames [] = []
|
|
31 |
spreadNames (sortOn (negate . snd) -> xs@((_,limit):_)) = check $ f (99 + fromIntegral (length xs)) maxBound xs
|
|
32 |
where
|
|
33 |
check xs | all (isCon . snd) xs && length (nubOrd $ map snd xs) == length xs = xs
|
|
34 |
- | otherwise = error $ "Invalid spreadNames, length=" ++ show (length xs)
|
|
35 |
+ | otherwise = error "Invalid spreadNames"
|
|
36 |
|
|
37 |
-- I can only assign values between mn and mx inclusive
|
|
38 |
- f :: NameWord -> NameWord -> [(a, Int)] -> [(a, Name)]
|
|
39 |
+ f :: Word16 -> Word16 -> [(a, Int)] -> [(a, Name)]
|
|
40 |
f !mn !mx [] = []
|
|
41 |
f mn mx ((a,i):xs) = (a, Name real) : f (mn-1) (real-1) xs
|
|
42 |
where real = fromIntegral $ max mn $ min mx ideal
|
|
43 |
@@ -266,16 +262,14 @@ fpRaresFold :: (b -> b -> b) -> (Name ->
|
|
44 |
fpRaresFold g f Fingerprint{..} = f fpRare1 `g` f fpRare2 `g` f fpRare3
|
|
45 |
|
|
46 |
instance Storable Fingerprint where
|
|
47 |
- sizeOf _ = 3*sizeOf name0 + 2
|
|
48 |
+ sizeOf _ = 64
|
|
49 |
alignment _ = 4
|
|
50 |
peekByteOff ptr i = Fingerprint
|
|
51 |
- <$> peekByteOff ptr (i+0) <*> peekByteOff ptr (i+1*w) <*> peekByteOff ptr (i+2*w)
|
|
52 |
- <*> peekByteOff ptr (i+3*w) <*> peekByteOff ptr (i+3*w + 1)
|
|
53 |
- where w = sizeOf name0
|
|
54 |
+ <$> peekByteOff ptr (i+0) <*> peekByteOff ptr (i+2) <*> peekByteOff ptr (i+4)
|
|
55 |
+ <*> peekByteOff ptr (i+6) <*> peekByteOff ptr (i+7)
|
|
56 |
pokeByteOff ptr i Fingerprint{..} = do
|
|
57 |
- pokeByteOff ptr (i+0) fpRare1 >> pokeByteOff ptr (i+1*w) fpRare2 >> pokeByteOff ptr (i+2*w) fpRare3
|
|
58 |
- pokeByteOff ptr (i+3*w) fpArity >> pokeByteOff ptr (i+3*w + 1) fpTerms
|
|
59 |
- where w = sizeOf name0
|
|
60 |
+ pokeByteOff ptr (i+0) fpRare1 >> pokeByteOff ptr (i+2) fpRare2 >> pokeByteOff ptr (i+4) fpRare3
|
|
61 |
+ pokeByteOff ptr (i+6) fpArity >> pokeByteOff ptr (i+7) fpTerms
|
|
62 |
|
|
63 |
toFingerprint :: Sig Name -> Fingerprint
|
|
64 |
toFingerprint sig = Fingerprint{..}
|