diff options
Diffstat (limited to 'src/GF/Infra/Modules.hs')
| -rw-r--r-- | src/GF/Infra/Modules.hs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/GF/Infra/Modules.hs b/src/GF/Infra/Modules.hs index 4b642fd72..4eba62283 100644 --- a/src/GF/Infra/Modules.hs +++ b/src/GF/Infra/Modules.hs @@ -126,6 +126,16 @@ allDepsModule gr m = iterFix add os0 where m <- depPathModule n] mods = modules gr +-- select just those modules that a given one depends on, including itself +partOfGrammar :: Ord i => MGrammar i f a -> (i,ModInfo i f a) -> MGrammar i f a +partOfGrammar gr (i,m) = MGrammar [mo | mo@(j,_) <- mods, elem j modsFor] + where + mods = modules gr + modsFor = case m of + ModMod n -> (i:) $ map openedModule $ allDepsModule gr n + _ -> [i] ---- ModWith? + + -- all modules that a module extends, directly or indirectly allExtends :: (Show i,Ord i) => MGrammar i f a -> i -> [i] allExtends gr i = case lookupModule gr i of @@ -164,6 +174,11 @@ addModule gr name mi = MGrammar $ (modules gr ++ [(name,mi)]) emptyMGrammar :: MGrammar i f a emptyMGrammar = MGrammar [] +emptyModInfo :: ModInfo i f a +emptyModInfo = ModMod emptyModule + +emptyModule :: Module i f a +emptyModule = Module MTResource MSComplete [] Nothing [] NT -- we store the module type with the identifier |
