@@ -177,7 +177,17 @@ prefix n = loc "prefix" n $ memo prefixed n typ
177 -> [CI Text]
177 -> [CI Text]
178 -> Set (CI Text)
178 -> Set (CI Text)
179 -> AST Text
179 -> AST Text
180− uniq _ [] ks = failure ("Unable to generate unique prefix: " % fid) n
180+ uniq seen [] ks = do
182+ let hs = acronymPrefixes n
183+ f x = sformat ("\n" % stext % " => " % shown)
184+ (CI.foldedCase x) (Map.lookup x s)
186+ format ("Error prefixing: " % fid %
187+ "\n Fields: " % shown %
188+ "\n Matches: " % stext)
189+ n (Set.toList ks) (foldMap f hs)
181 uniq seen (x:xs) ks = do
191 uniq seen (x:xs) ks = do
182 m <- uses seen (Map.lookup x)
192 m <- uses seen (Map.lookup x)
183 case m of
193 case m of
@@ -191,7 +201,7 @@ overlap :: (Eq a, Hashable a) => Set a -> Set a -> Bool
191overlap xs ys = not . Set.null $ Set.intersection xs ys
201overlap xs ys = not . Set.null $ Set.intersection xs ys
193acronymPrefixes :: Id -> [CI Text]
203acronymPrefixes :: Id -> [CI Text]
194−acronymPrefixes (idToText -> n) = map CI.mk (xs ++ map suffix ys)
204+acronymPrefixes (idToText -> n) = map CI.mk (xs ++ map suffix ys ++ zs)
196 -- Take the next char
206 -- Take the next char
197 suffix x = Text.snoc x c
207 suffix x = Text.snoc x c
@@ -199,6 +209,8 @@ acronymPrefixes (idToText -> n) = map CI.mk (xs ++ map suffix ys)
199 c | Text.length x >= 2 = Text.head (Text.drop 1 x)
209 c | Text.length x >= 2 = Text.head (Text.drop 1 x)
200 | otherwise = Text.head x
210 | otherwise = Text.head x
212+ zs = zipWith (\n x -> Text.snoc x (head (show n))) ([1..] :: [Int]) xs
202 xs = catMaybes [r1, r2, r3, r4, r5, r6]
214 xs = catMaybes [r1, r2, r3, r4, r5, r6]
203 ys = catMaybes [r1, r2, r3, r4, r6]
215 ys = catMaybes [r1, r2, r3, r4, r6]