refactor: give glossaryTerms better type

This commit is contained in:
Gregor Kleen 2021-03-19 16:58:10 +01:00
parent 0c37cbff64
commit 383d709620

View File

@ -16,7 +16,7 @@ glossaryTerms :: FilePath -> Q Exp
glossaryTerms basename = do
translationsAvailable <- i18nWidgetFilesAvailable' basename
let terms = Map.mapWithKey (\k _ -> "Msg" <> unPathPiece k) translationsAvailable
[e|Map.fromList $(listE . map (\(int, msg) -> tupE [litE . stringL $ repack int, conE $ mkName msg]) $ Map.toList terms)|]
[e|Map.fromList $(listE . map (\(int, msg) -> tupE [litE . stringL $ repack int, [e|SomeMessage $(conE $ mkName msg)|]]) $ Map.toList terms)|]
where
unPathPiece :: Text -> String
unPathPiece = repack . mconcat . map (over _head Char.toUpper) . Text.splitOn "-"