forked from GitHub/gf-core
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%.
This commit is contained in:
@@ -10,7 +10,7 @@ module GF.Grammar.Analyse (
|
||||
|
||||
import GF.Grammar.Grammar
|
||||
import GF.Infra.Ident
|
||||
import GF.Infra.Option ---
|
||||
--import GF.Infra.Option ---
|
||||
import GF.Grammar.Macros
|
||||
import GF.Grammar.Lookup
|
||||
|
||||
@@ -18,7 +18,7 @@ import GF.Data.Operations
|
||||
|
||||
import qualified Data.Map as Map
|
||||
import Data.List (nub)
|
||||
import Debug.Trace
|
||||
--import Debug.Trace
|
||||
|
||||
stripSourceGrammar :: SourceGrammar -> SourceGrammar
|
||||
stripSourceGrammar sgr = mGrammar [(i, m{jments = Map.map stripInfo (jments m)}) | (i,m) <- modules sgr]
|
||||
|
||||
@@ -12,9 +12,9 @@ module GF.Grammar.Binary(decodeModule,decodeModuleHeader,encodeModule) where
|
||||
import Prelude hiding (catch)
|
||||
import Control.Exception(catch,ErrorCall(..),throwIO)
|
||||
|
||||
import Data.Char
|
||||
--import Data.Char
|
||||
import Data.Binary
|
||||
import Control.Monad
|
||||
--import Control.Monad
|
||||
import qualified Data.Map as Map
|
||||
import qualified Data.ByteString.Char8 as BS
|
||||
|
||||
@@ -23,7 +23,7 @@ import GF.Infra.Ident
|
||||
import GF.Infra.Option
|
||||
import GF.Grammar.Grammar
|
||||
|
||||
import PGF.Binary
|
||||
import PGF() -- Binary instances
|
||||
|
||||
-- Please change this every time when the GFO format is changed
|
||||
gfoVersion = "GF02"
|
||||
@@ -346,3 +346,5 @@ decodeFile' fpath = addFPath fpath (decodeFile fpath)
|
||||
addFPath fpath m = m `catch` handle
|
||||
where
|
||||
handle (ErrorCall msg) = throwIO (ErrorCall (fpath++": "++msg))
|
||||
|
||||
decodingError = fail "This file was compiled with different version of GF"
|
||||
|
||||
@@ -25,7 +25,7 @@ import GF.Data.Utilities (nub')
|
||||
|
||||
import Data.Char
|
||||
import Data.List
|
||||
import System.FilePath
|
||||
--import System.FilePath
|
||||
|
||||
getCF :: FilePath -> String -> Err SourceGrammar
|
||||
getCF fpath = fmap (cf2gf fpath) . pCF
|
||||
|
||||
@@ -24,7 +24,7 @@ import GF.Grammar.Grammar
|
||||
|
||||
import Data.Char
|
||||
import Data.List
|
||||
import System.FilePath
|
||||
--import System.FilePath
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -68,15 +68,15 @@ import GF.Data.Operations
|
||||
|
||||
import PGF.Data (FId, FunId, SeqId, LIndex, Sequence, BindType(..))
|
||||
|
||||
import Data.List
|
||||
--import Data.List
|
||||
import Data.Array.IArray
|
||||
import Data.Array.Unboxed
|
||||
import qualified Data.Map as Map
|
||||
import qualified Data.Set as Set
|
||||
import qualified Data.IntMap as IntMap
|
||||
--import qualified Data.Set as Set
|
||||
--import qualified Data.IntMap as IntMap
|
||||
import Text.PrettyPrint
|
||||
import System.FilePath
|
||||
import Control.Monad.Identity
|
||||
--import System.FilePath
|
||||
--import Control.Monad.Identity
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{-# LANGUAGE CPP,MagicHash,BangPatterns #-}
|
||||
{-# LINE 3 "lexer/Lexer.x" #-}
|
||||
-- {-# LINE 3 "lexer/Lexer.x" #-}
|
||||
|
||||
module GF.Grammar.Lexer
|
||||
( Token(..), Posn(..)
|
||||
@@ -8,7 +8,7 @@ module GF.Grammar.Lexer
|
||||
) where
|
||||
|
||||
import GF.Infra.Ident
|
||||
import GF.Data.Operations
|
||||
--import GF.Data.Operations
|
||||
import qualified Data.ByteString.Char8 as BS
|
||||
import qualified Data.Map as Map
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@ import GF.Grammar.Predef
|
||||
import GF.Grammar.Lockfield
|
||||
|
||||
import Data.List (sortBy)
|
||||
import Data.Maybe (maybe)
|
||||
import Control.Monad
|
||||
--import Data.Maybe (maybe)
|
||||
--import Control.Monad
|
||||
import Text.PrettyPrint
|
||||
import qualified Data.Map as Map
|
||||
|
||||
|
||||
@@ -22,14 +22,14 @@ import GF.Data.Operations
|
||||
import GF.Data.Str
|
||||
import GF.Infra.Ident
|
||||
import GF.Grammar.Grammar
|
||||
import GF.Grammar.Values
|
||||
--import GF.Grammar.Values
|
||||
import GF.Grammar.Predef
|
||||
import GF.Grammar.Printer
|
||||
|
||||
import Control.Monad.Identity(Identity(..))
|
||||
import qualified Data.Traversable as T(mapM)
|
||||
import Control.Monad (liftM, liftM2, liftM3)
|
||||
import Data.Char (isDigit)
|
||||
--import Data.Char (isDigit)
|
||||
import Data.List (sortBy,nub)
|
||||
import Text.PrettyPrint
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@ import GF.Infra.Ident
|
||||
import GF.Grammar.Macros
|
||||
import GF.Grammar.Printer
|
||||
|
||||
import Data.List
|
||||
--import Data.List
|
||||
import Control.Monad
|
||||
import Text.PrettyPrint
|
||||
import Debug.Trace
|
||||
--import Debug.Trace
|
||||
|
||||
matchPattern :: [(Patt,rhs)] -> Term -> Err (rhs, Substitution)
|
||||
matchPattern pts term =
|
||||
|
||||
@@ -29,15 +29,15 @@ import GF.Infra.Option
|
||||
import GF.Grammar.Values
|
||||
import GF.Grammar.Grammar
|
||||
|
||||
import PGF.Expr (ppMeta)
|
||||
import PGF.Data (ppMeta)
|
||||
import PGF.Printer (ppFId, ppFunId, ppSeqId, ppSeq)
|
||||
|
||||
import Text.PrettyPrint
|
||||
import Data.Maybe (maybe, isNothing)
|
||||
import Data.Maybe (isNothing)
|
||||
import Data.List (intersperse)
|
||||
import qualified Data.Map as Map
|
||||
import qualified Data.IntMap as IntMap
|
||||
import qualified Data.Set as Set
|
||||
--import qualified Data.IntMap as IntMap
|
||||
--import qualified Data.Set as Set
|
||||
import qualified Data.Array.IArray as Array
|
||||
|
||||
data TermPrintQual
|
||||
|
||||
@@ -24,7 +24,7 @@ module GF.Grammar.Values (-- * values used in TC type checking
|
||||
--Z tree2exp, loc2treeFocus
|
||||
) where
|
||||
|
||||
import GF.Data.Operations
|
||||
--import GF.Data.Operations
|
||||
---Z import GF.Data.Zipper
|
||||
|
||||
import GF.Infra.Ident
|
||||
|
||||
Reference in New Issue
Block a user