summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Data/Utilities.hs
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2013-11-05 13:11:10 +0000
committerhallgren <hallgren@chalmers.se>2013-11-05 13:11:10 +0000
commit3814841d7d3b77b3f033cb98c1c0a04ac39435d7 (patch)
tree1ad913a0a7ca870b7ec62db86afbc422cab97df1 /src/compiler/GF/Data/Utilities.hs
parent74357cdedf90178253d5d812931cb78a9bdf54aa (diff)
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%.
Diffstat (limited to 'src/compiler/GF/Data/Utilities.hs')
-rw-r--r--src/compiler/GF/Data/Utilities.hs19
1 files changed, 2 insertions, 17 deletions
diff --git a/src/compiler/GF/Data/Utilities.hs b/src/compiler/GF/Data/Utilities.hs
index f953938c8..792f7aa4a 100644
--- a/src/compiler/GF/Data/Utilities.hs
+++ b/src/compiler/GF/Data/Utilities.hs
@@ -12,12 +12,12 @@
-----------------------------------------------------------------------------
-module GF.Data.Utilities where
+module GF.Data.Utilities(module GF.Data.Utilities, module PGF.Utilities) where
import Data.Maybe
import Data.List
import Control.Monad (MonadPlus(..),liftM)
-import qualified Data.Set as Set
+import PGF.Utilities
-- * functions on lists
@@ -68,17 +68,6 @@ safeInit :: [a] -> [a]
safeInit [] = []
safeInit xs = init xs
--- | Like 'nub', but O(n log n) instead of O(n^2), since it uses a set to lookup previous things.
--- The result list is stable (the elements are returned in the order they occur), and lazy.
--- Requires that the list elements can be compared by Ord.
--- Code ruthlessly taken from http://hpaste.org/54411
-nub' :: Ord a => [a] -> [a]
-nub' = loop Set.empty
- where loop _ [] = []
- loop seen (x : xs)
- | Set.member x seen = loop seen xs
- | otherwise = x : loop (Set.insert x seen) xs
-
-- | Sorts and then groups elements given an ordering of the
-- elements.
sortGroupBy :: (a -> a -> Ordering) -> [a] -> [[a]]
@@ -108,10 +97,6 @@ buildMultiMap :: Ord a => [(a,b)] -> [(a,[b])]
buildMultiMap = map (\g -> (fst (head g), map snd g) )
. sortGroupBy (compareBy fst)
--- | Replace all occurences of an element by another element.
-replace :: Eq a => a -> a -> [a] -> [a]
-replace x y = map (\z -> if z == x then y else z)
-
-- * equality functions
-- | Use an ordering function as an equality predicate.