@@ -177,7 +177,17 @@ prefix n = loc "prefix" n $ memo prefixed n typ
177177 -> [CI Text]
178178 -> Set (CI Text)
179179 -> AST Text
180− uniq _ [] ks = failure ("Unable to generate unique prefix: " % fid) n
180+ uniq seen [] ks = do
181+ s <- use seen
182+ let hs = acronymPrefixes n
183+ f x = sformat ("\n" % stext % " => " % shown)
184+ (CI.foldedCase x) (Map.lookup x s)
185+ throwError $
186+ format ("Error prefixing: " % fid %
187+ "\n Fields: " % shown %
188+ "\n Matches: " % stext)
189+ n (Set.toList ks) (foldMap f hs)
190+
181191 uniq seen (x:xs) ks = do
182192 m <- uses seen (Map.lookup x)
183193 case m of
@@ -191,7 +201,7 @@ overlap :: (Eq a, Hashable a) => Set a -> Set a -> Bool
191201overlap xs ys = not . Set.null $ Set.intersection xs ys
192202
193203acronymPrefixes :: 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)
195205 where
196206 -- Take the next char
197207 suffix x = Text.snoc x c
@@ -199,6 +209,8 @@ acronymPrefixes (idToText -> n) = map CI.mk (xs ++ map suffix ys)
199209 c | Text.length x >= 2 = Text.head (Text.drop 1 x)
200210 | otherwise = Text.head x
201211
212+ zs = zipWith (\n x -> Text.snoc x (head (show n))) ([1..] :: [Int]) xs
213+
202214 xs = catMaybes [r1, r2, r3, r4, r5, r6]
203215 ys = catMaybes [r1, r2, r3, r4, r6]
204216