@@ -196,8 +196,8 @@ goModule onlyTypes infoTable Internal.Module {..} =
196
196
}
197
197
where
198
198
argnames =
199
- map (overNameText quote) $ filterTypeArgs 0 ty $ map (fromMaybe (defaultName (getLoc name) " _" ) . (^. Internal. argInfoName)) argsInfo
200
- name' = overNameText quote name
199
+ map quoteName $ filterTypeArgs 0 ty $ map (fromMaybe (defaultName (getLoc name) " _" ) . (^. Internal. argInfoName)) argsInfo
200
+ name' = quoteName name
201
201
loc = getLoc name
202
202
203
203
isFunction :: [Name ] -> Internal. Expression -> Maybe Internal. Expression -> Bool
@@ -377,18 +377,18 @@ goModule onlyTypes infoTable Internal.Module {..} =
377
377
378
378
goTypeIden :: Internal. Iden -> Type
379
379
goTypeIden = \ case
380
- Internal. IdenFunction name -> mkIndType (overNameText quote name) []
380
+ Internal. IdenFunction name -> mkIndType (quoteName name) []
381
381
Internal. IdenConstructor name -> error (" unsupported type: constructor " <> Internal. ppTrace name)
382
- Internal. IdenVar name -> TyVar $ TypeVar (overNameText quote name)
383
- Internal. IdenAxiom name -> mkIndType (overNameText quote name) []
384
- Internal. IdenInductive name -> mkIndType (overNameText quote name) []
382
+ Internal. IdenVar name -> TyVar $ TypeVar (quoteName name)
383
+ Internal. IdenAxiom name -> mkIndType (quoteName name) []
384
+ Internal. IdenInductive name -> mkIndType (quoteName name) []
385
385
386
386
goTypeApp :: Internal. Application -> Type
387
387
goTypeApp app = mkIndType name params
388
388
where
389
389
(ind, args) = Internal. unfoldApplication app
390
390
params = map goType (toList args)
391
- name = overNameText quote $ case ind of
391
+ name = quoteName $ case ind of
392
392
Internal. ExpressionIden (Internal. IdenFunction n) -> n
393
393
Internal. ExpressionIden (Internal. IdenAxiom n) -> n
394
394
Internal. ExpressionIden (Internal. IdenInductive n) -> n
@@ -417,8 +417,8 @@ goModule onlyTypes infoTable Internal.Module {..} =
417
417
setNameText " None" name
418
418
Just Internal. BuiltinMaybeJust ->
419
419
setNameText " Some" name
420
- _ -> overNameText quote name
421
- Nothing -> overNameText quote name
420
+ _ -> quoteName name
421
+ Nothing -> quoteName name
422
422
423
423
getArgtys :: Internal. ConstructorInfo -> [Internal. FunctionParameter ]
424
424
getArgtys ctrInfo = fst $ Internal. unfoldFunType $ ctrInfo ^. Internal. constructorInfoType
@@ -431,8 +431,8 @@ goModule onlyTypes infoTable Internal.Module {..} =
431
431
Just funInfo ->
432
432
case funInfo ^. Internal. functionInfoPragmas . pragmasIsabelleFunction of
433
433
Just PragmaIsabelleFunction {.. } -> setNameText _pragmaIsabelleFunctionName name
434
- Nothing -> overNameText quote name
435
- Nothing -> overNameText quote name
434
+ Nothing -> quoteName name
435
+ Nothing -> quoteName name
436
436
x -> x
437
437
438
438
lookupName :: forall r . (Member (Reader NameMap ) r ) => Name -> Sem r Expression
@@ -491,8 +491,8 @@ goModule onlyTypes infoTable Internal.Module {..} =
491
491
Nothing -> return $ ExprIden (goConstrName name)
492
492
Internal. IdenVar name -> do
493
493
lookupName name
494
- Internal. IdenAxiom name -> return $ ExprIden (overNameText quote name)
495
- Internal. IdenInductive name -> return $ ExprIden (overNameText quote name)
494
+ Internal. IdenAxiom name -> return $ ExprIden (quoteName name)
495
+ Internal. IdenInductive name -> return $ ExprIden (quoteName name)
496
496
497
497
goApplication :: Internal. Application -> Sem r Expression
498
498
goApplication app@ Internal. Application {.. }
@@ -1218,6 +1218,20 @@ goModule onlyTypes infoTable Internal.Module {..} =
1218
1218
++ map (^. Internal. inductiveInfoName . namePretty) (HashMap. elems (infoTable ^. Internal. infoInductives))
1219
1219
++ map (^. Internal. axiomInfoDef . Internal. axiomName . namePretty) (HashMap. elems (infoTable ^. Internal. infoAxioms))
1220
1220
1221
+ quoteName :: Name -> Name
1222
+ quoteName name = overNameText goNameText name
1223
+ where
1224
+ goNameText :: Text -> Text
1225
+ goNameText txt
1226
+ | Text. elem ' .' txt =
1227
+ let idenName = snd $ Text. breakOnEnd " ." txt
1228
+ modulePath = name ^. nameId . nameIdModuleId . moduleIdPath
1229
+ modulePathText = Text. intercalate " ." (modulePath ^. modulePathKeyDir ++ [modulePath ^. modulePathKeyName])
1230
+ moduleName' = toIsabelleTheoryName modulePathText
1231
+ idenName' = quote idenName
1232
+ in moduleName' <> " ." <> idenName'
1233
+ | otherwise = quote txt
1234
+
1221
1235
quote :: Text -> Text
1222
1236
quote txt0
1223
1237
| Text. elem ' .' txt0 = moduleName' <> " ." <> idenName'
0 commit comments