From 3814841d7d3b77b3f033cb98c1c0a04ac39435d7 Mon Sep 17 00:00:00 2001 From: hallgren Date: Tue, 5 Nov 2013 13:11:10 +0000 Subject: Eliminate mutual dependencies between the GF compiler and the PGF library + References to modules under src/compiler have been eliminated from the PGF library (under src/runtime/haskell). Only two functions had to be moved (from GF.Data.Utilities to PGF.Utilities) to make this possible, other apparent dependencies turned out to be vacuous. + In gf.cabal, the GF executable no longer directly depends on the PGF library source directory, but only on the exposed library modules. This means that there is less duplication in gf.cabal and that the 30 modules in the PGF library will no longer be compiled twice while building GF. To make this possible, additional PGF library modules have been exposed, even though they should probably be considered for internal use only. They could be collected in a PGF.Internal module, or marked as "unstable", to make this explicit. + Also, by using the -fwarn-unused-imports flag, ~220 redundant imports were found and removed, reducing the total number of imports by ~15%. --- src/compiler/GF/Command/Commands.hs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/compiler/GF/Command/Commands.hs') diff --git a/src/compiler/GF/Command/Commands.hs b/src/compiler/GF/Command/Commands.hs index 8a19d2729..a05b3cf20 100644 --- a/src/compiler/GF/Command/Commands.hs +++ b/src/compiler/GF/Command/Commands.hs @@ -14,13 +14,12 @@ import Prelude hiding (putStrLn) import PGF -import PGF.VisualizeTree(getDepLabels) import PGF.Macros(lookStartCat,functionsToCat,lookValCat,restrictPGF,hasLin) import PGF.Data(abstract,funs,cats,Literal(LStr),Expr(EFun,ELit)) ---- -import PGF.Morphology(isInMorpho,morphoKnown) +--import PGF.Morphology(isInMorpho,morphoKnown) import PGF.Printer(ppFun,ppCat) -import PGF.Probabilistic(rankTreesByProbs,probTree,setProbabilities) -import PGF.Generate (generateRandomFrom) ---- +--import PGF.Probabilistic(rankTreesByProbs,probTree,setProbabilities) +--import PGF.Generate (generateRandomFrom) ---- import PGF.Tree (Tree(Fun), expr2tree, tree2expr) import PGF.Optimize(optimizePGF) @@ -30,7 +29,7 @@ import GF.Compile.ExampleBased import GF.Infra.Option (noOptions, readOutputFormat, outputFormatsExpl) import GF.Infra.UseIO(writeUTF8File) import GF.Infra.SIO -import GF.Data.ErrM ---- +--import GF.Data.ErrM ---- import GF.Command.Abstract import GF.Command.Messages import GF.Text.Lexing @@ -43,13 +42,13 @@ import GF.Command.TreeOperations ---- temporary place for typecheck and compute import GF.Data.Operations import Data.Binary (encodeFile) -import Data.List +import Data.List(intersperse,nub) import Data.Maybe import qualified Data.Map as Map --import System.Cmd(system) -- use GF.Infra.UseIO.restricedSystem instead! import Text.PrettyPrint import Data.List (sort) -import Debug.Trace +--import Debug.Trace --import System.Random (newStdGen) ---- @@ -940,7 +939,7 @@ allCommands = Map.fromList [ let outp = valStrOpts "output" "dot" opts mlab <- case file of "" -> return Nothing - _ -> restricted (readFile file) >>= return . Just . getDepLabels . lines + _ -> (Just . getDepLabels . lines) `fmap` restricted (readFile file) let lang = optLang pgf opts let grphs = unlines $ map (graphvizDependencyTree outp debug mlab Nothing pgf lang) es if isFlag "view" opts || isFlag "format" opts then do -- cgit v1.2.3