summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2011-08-30 20:20:45 +0000
committerhallgren <hallgren@chalmers.se>2011-08-30 20:20:45 +0000
commitb743abb375bda7a758bbdde8cabe47e3b38b78c9 (patch)
tree21f316d658a4967c005f8dee234aadda351b24ed
parentba10b5b0ca0c906b1b5c94f64b37b5a34f200f71 (diff)
GF.Infra.Modules: restore module dependency order invariant
It is needed by greatestResource (and similar functions, presumably). So keep both the list and the finite map of modules. This slows down some things, but the compilation of PhrasebookFin.pgf benefits from it. To be continued...
-rw-r--r--src/compiler/GF/Infra/Modules.hs20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/compiler/GF/Infra/Modules.hs b/src/compiler/GF/Infra/Modules.hs
index 8c54ddf30..05d18a33e 100644
--- a/src/compiler/GF/Infra/Modules.hs
+++ b/src/compiler/GF/Infra/Modules.hs
@@ -23,13 +23,13 @@ module GF.Infra.Modules (
mGrammar,modules,
extends, isInherited,inheritAll,
updateMGrammar, updateModule, replaceJudgements, addFlag,
- addOpenQualif, flagsModule, allFlags, mapModules,
+ addOpenQualif, flagsModule, allFlags,
OpenSpec(..),
ModuleStatus(..),
openedModule, depPathModule, allDepsModule, partOfGrammar,
allExtends, allExtendSpecs, allExtendsPlus, allExtensions,
searchPathModule,
- -- addModule,
+ -- addModule, mapModules,
emptyMGrammar, emptyModInfo,
abstractOfConcrete, abstractModOfConcrete,
lookupModule, lookupModuleType, lookupInfo,
@@ -51,16 +51,15 @@ import Text.PrettyPrint
-- The same structure will be used in both source code and canonical.
-- The parameters tell what kind of data is involved.
--- No longer maintained invariant (TH 2011-08-30):
--- modules are stored in dependency order
+-- Invariant: modules are stored in dependency order
--mGrammar = MGrammar
--newtype MGrammar a = MGrammar {modules :: [(Ident,ModInfo a)]}
-newtype MGrammar a = MGrammar {moduleMap :: Map.Map Ident (ModInfo a)}
+data MGrammar a = MGrammar {moduleMap :: Map.Map Ident (ModInfo a),
+ modules :: [(Ident,ModInfo a)] }
deriving Show
-modules = Map.toList . moduleMap
-mGrammar = MGrammar . Map.fromList
+mGrammar ms = MGrammar (Map.fromList ms) ms
data ModInfo a = ModInfo {
mtype :: ModuleType,
@@ -126,11 +125,10 @@ flagsModule (_,mi) = flags mi
allFlags :: MGrammar a -> Options
allFlags gr = concatOptions [flags m | (_,m) <- modules gr]
-
+{-
mapModules :: (ModInfo a -> ModInfo a) -> MGrammar a -> MGrammar a
---mapModules f (MGrammar ms) = MGrammar (map (onSnd f) ms)
-mapModules f (MGrammar ms) = MGrammar (fmap f ms)
-
+mapModules f = mGrammar . map (onSnd f) . modules
+-}
data OpenSpec =
OSimple Ident
| OQualif Ident Ident