Doug Burke avatar Doug Burke committed 800c5cb

Support using containers 0.4 as well as 0.5

Comments (0)

Files changed (3)

   Ord instances for a number of containers; removed some un-needed
   constraints; added Network.URI.Ord.
 
-  Bumped the minimum containers requirement to 0.5.
+  The containers upper limit has been increased to support version 0.5.
 
 0.7.0.2:
 

src/Swish/GraphMatch.hs

+{-# LANGUAGE CPP #-}
 {-# LANGUAGE FlexibleInstances #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
 
 --
 --  Maintainer  :  Douglas Burke
 --  Stability   :  experimental
---  Portability :  FlexibleInstances, MultiParamTypeClasses
+--  Portability :  CPP, FlexibleInstances, MultiParamTypeClasses
 --
 --  This module contains graph-matching logic.
 --
         LabelMap gen2 lm2 =
             remapLabels gs2 lmap $ foldl1 (++) $ map (ecLabels . snd) ecpairs
 
-        -- replace values in lm with those from (lm1+lm2), but do not copy
-        -- over new keys from (lm1+lm2)
-        lm' = M.mergeWithKey (\_ _ v -> Just v) id (const M.empty) lm $ M.union lm1 lm2
+        lm' = classifyCombine lm $ M.union lm1 lm2
         
         tmap f (a,b) = (f a, f b)
         
         remapEc = pairGroup . map (newIndex lm') . pairUngroup 
         newIndex x (_,lab) = (M.findWithDefault nullLabelVal lab x,lab)
 
+-- Replace the values in lm1 with those from lm2, but do not copy over new
+-- keys from lm2
+classifyCombine :: (Ord a) => M.Map a b -> M.Map a b -> M.Map a b
+#if MIN_VERSION_containers(0,5,0)
+classifyCombine = M.mergeWithKey (\_ _ v -> Just v) id (const M.empty)
+#else
+-- rely on the left-biased nature of union
+classifyCombine lm1 lm2 = M.intersection lm2 lm1 `M.union` lm1
+#endif
+
 -- | Calculate a new index value for a supplied set of labels based on the
 --  supplied label map and adjacency calculations in the supplied graph
 --
   instances for a number of containers; removed some un-needed constraints;
   added @Network.URI.Ord@.
   .
-  * Bumped the minimum containers requirement to @0.5@.
+  * The containers upper limit has been increased to support version 0.5.
   .
   Changes in previous versions can be found at <https://bitbucket.org/doug_burke/swish/src/tip/CHANGES>.
   .
    Build-Depends:
       base >=3 && < 5,
       binary == 0.5.*,
-      containers == 0.5.*,
+      containers >= 0.4 && < 0.6,
       directory >= 1.0 && < 1.2,
       filepath >= 1.1 && < 1.4,
       hashable == 1.1.*,
 
  -- How can we include data files that are only used for
  -- benchmark/tests and do not get installed?
- Benchmark            bench-ntriples
+Benchmark            bench-ntriples
    Type:             exitcode-stdio-1.0
    Hs-Source-Dirs:   bench/
    Other-Modules:    Paths_swish
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.