1. Doug Burke
  2. swish

Commits

Doug Burke  committed f76462e

LookupMap: more removal of unused code

  • Participants
  • Parent commits f1e849d
  • Branches default

Comments (0)

Files changed (4)

File CHANGES

View file
  • Ignore whitespace
     to N3/Turtle.
 
   - Minor clean up of the LookupMap module: mergeReplaceOrAdd and mergeReplace
-    are now combined into mergeReplace; mapSelect has been removed; documentation
-    slightly improved, and a few minor internal clean ups.
+    are now combined into mergeReplace; mapSelect, mapApplytoAll, and
+    mapTranslate* have been removed; documentation slightly improved; and a
+    few minor internal clean ups.
 
   - Bump the upper constraint on the containers package to include
     version 0.5.

File src/Data/LookupMap.hs

View file
  • Ignore whitespace
     , mapReplace, mapReplaceAll, mapReplaceMap
     , mapAdd, mapAddIfNew
     , mapDelete, mapDeleteAll
-    , mapApplyToAll
     , mapEq, mapKeys, mapVals
     , mapMerge
-      
-    , mapTranslate
-    , mapTranslateKeys, mapTranslateVals
-    , mapTranslateEntries, mapTranslateEntriesM
-      
     )
     where
 
     let more = mapDeleteAll (LookupMap es) k
     in if entryKey e == k then more else mapAdd more e
         
--- |Return a list of values obtained by applying a function to each key
---  in the map.  Creates an alternative set of values that can be
---  retrieved using 'mapTranslate'.
---
-mapApplyToAll :: (LookupEntryClass a k v) =>
-    LookupMap a -> (k -> w) -> [w]
-mapApplyToAll es f = gLM $ fmap (f . entryKey) es
-
--- |Find a node in a lookup map list, and returns the
---  corresponding value from a supplied list.  The appropriate ordering
---  of the list is not specified here, but an appropriately ordered list
---  may be obtained by 'mapApplyToAll'.
---
-mapTranslate :: (LookupEntryClass a k v) =>
-    LookupMap a  -- ^ Used to provide a list of keys.
-    -> [w]       -- ^ Value to use when key is found.
-    -> k         -- ^ Key to search for
-    -> w         -- ^ The default value if the key does not exist.
-    -> w
-mapTranslate (LookupMap (e:es)) (w:ws) k def
-    | k == entryKey e   = w
-    | otherwise         = mapTranslate (LookupMap es) ws k def
-mapTranslate _ _ _ def = def
-
 -- |Compare two lookup maps for equality.
 --
 --  Two maps are equal if they have the same set of keys, and if
                                     ++ " with " ++ show e2)
                         else e1 : merge et1 et2
 
--- |An fmap-like function that returns a new lookup map that is a
---  copy of the supplied map with entry keys replaced according to
---  a supplied function.
---
-mapTranslateKeys :: (LookupEntryClass a1 k1 v, LookupEntryClass a2 k2 v) =>
-    (k1 -> k2) -> LookupMap a1 -> LookupMap a2
-mapTranslateKeys f = fmap (kmap f)
-
--- |An fmap-like function that returns a new lookup map that is a
---  copy of the supplied map with entry values replaced according to
---  a supplied function.
---
-mapTranslateVals :: (LookupEntryClass a1 k v1, LookupEntryClass a2 k v2) =>
-    (v1 -> v2) -> LookupMap a1 -> LookupMap a2
-mapTranslateVals f = fmap (vmap f)
-
--- |A function that returns a new lookup map that is a copy of the
---  supplied map with complete entries replaced according to
---  a supplied function.
---
-mapTranslateEntries :: (a1 -> a2) -> LookupMap a1 -> LookupMap a2
-mapTranslateEntries = fmap
-
--- |A monadic form of `mapTranslateEntries` which is
--- the same as `Data.Traversable.mapM`.
---
-mapTranslateEntriesM :: (Monad m)
-    => (a1 -> m a2) -> LookupMap a1 -> m (LookupMap a2)
-mapTranslateEntriesM = T.mapM 
-{-
-mapTranslateEntriesM f (LookupMap es) =
-    do  { m2 <- mapM f es
-        ; return $ LookupMap m2
-        }
--}
-
 --------------------------------------------------------------------------------
 --
 --  Copyright (c) 2003, Graham Klyne, 2009 Vasili I Galchin,

File swish.cabal

View file
  • Ignore whitespace
   and in the bnode counts when formatting to N3/Turtle.
   .
   * Minor clean up of the @LookupMap@ module: @mergeReplaceOrAdd@ and @mergeReplace@
-  are now combined into @mergeReplace@; @mapSelect@ has been removed; documentation
-  slightly improved, and a few minor internal clean ups.
+  are now combined into @mergeReplace@; @mapSelect@, @mapApplyToAll@, and
+  @mapTranslate*@ have been removed; documentation slightly improved;
+  and a few minor internal clean ups.
   .
   * Clarified that @Swish.RDF.RDFDatatypeXsdDecimal@ is for @xsd:decimal@ rather
   than @xsd:double@.

File tests/LookupMapTest.hs

View file
  • Ignore whitespace
     , mapReplace, mapReplaceAll, mapReplaceMap
     , mapAdd, mapAddIfNew
     , mapDelete, mapDeleteAll
-    , mapApplyToAll, mapTranslate
     , mapEq, mapKeys, mapVals
     , mapMerge
-    , mapTranslateKeys, mapTranslateVals
-    , mapTranslateEntries, mapTranslateEntriesM
     )
 
 import Data.List ( sort )
 lm08 = mapDelete lm07 3
 lm09 = mapDeleteAll lm08 2
 
-la10 :: [String]
-la10 = mapApplyToAll lm03 (`replicate` '*')
-
-lt11, lt12, lt13, lt14 :: String
-lt11 = mapTranslate lm03 la10 1 "****"
-lt12 = mapTranslate lm03 la10 2 "****"
-lt13 = mapTranslate lm03 la10 3 "****"
-lt14 = mapTranslate lm03 la10 4 "****"
-
 lm20, lm21, lm22, lm33, lm34, lm35, lm36 :: TestMap
 lm20 = mapReplaceMap lm05 $ newMap [(2,"bbb20"),(3,"ccc20")]
 lm21 = mapReplaceMap lm05 $ newMap []
   , testLookupMapFind "08" lm08 2 "bbb"
   , testLookupMap     "09" lm09 [(1,"aaa")]
   , testLookupMapFind "09" lm09 2 ""
-  , testeq "LookupMapApplyToAll10" ["***","**","*"] la10
-  , testeq "LookupMapTranslate11" "*"   lt11
-  , testeq "LookupMapTranslate12" "**"  lt12
-  , testeq "LookupMapTranslate13" "***" lt13
-  , testeq "LookupMapTranslate14" "****" lt14
   , testLookupMap     "20" lm20 [(2,"bbb20"),(3,"ccc20"),(2,"bbb20"),(1,"aaa")]
   , testLookupMapFind "20" lm20 2 "bbb20"
   , testLookupMap     "21" lm21 [(2,"bbb1"),(3,"ccc"),(2,"bbb1"),(1,"aaa")]
   ] 
   
 ------------------------------------------------------------
---  Tranlation tests
-------------------------------------------------------------
-
--- Rather late in the day, generic versions of the testing functions used earlier
-type TestMapG a b = LookupMap (GenMapEntry a b)
-
-newMapG :: (Eq a, Show a, Eq b, Show b) => [(a,b)] -> TestMapG a b
-newMapG es = makeLookupMap (map newEntry es)
-
-testLookupMapG :: (Eq a, Show a, Eq b, Show b) => String -> TestMapG a b -> [(a,b)] -> Test
-testLookupMapG lab m1 m2 = testeq ("LookupMapG"++lab ) (newMapG m2) m1
-testLookupMapM ::
-    (Eq a, Show a, Eq b, Show b, Monad m,
-     Eq (m (TestMapG a b)), Show (m (TestMapG a b)))
-    => String -> m (TestMapG a b) -> m (TestMapG a b) -> Test
-testLookupMapM lab m1 m2 = testeq ("LookupMapM"++lab ) m2 m1
-
-tm101 :: TestMap
-tm101 = newMap [(1,"a"),(2,"bb"),(3,"ccc"),(4,"dddd")]
-
-tf102 :: Int -> String
-tf102 = flip replicate '*'
-
-tm102 :: StrTestMap
-tm102 = mapTranslateKeys tf102 tm101
-
-tm103 :: RevTestMap
-tm103 = mapTranslateVals length tm102
-
-tf104 :: (LookupEntryClass a Int [b],
-          LookupEntryClass c String Int) =>
-         a -> c
-tf104 e = newEntry (replicate k '#', 5 - length v) where (k,v) = keyVal e
-
-tm104 :: RevTestMap
-tm104 = mapTranslateEntries tf104 tm101
-
--- Test monadic translation, using Maybe monad
--- (Note that if Nothing is generated at any step,
--- it propagates to the result)
---
-tf105 :: (LookupEntryClass a Int [b],
-          LookupEntryClass c String Int) =>
-         a -> Maybe c
-tf105 e = Just $ tf104 e
-
-tm105 :: MayTestMap
-tm105 = mapTranslateEntriesM tf105 tm101
-
-tf106 :: (LookupEntryClass a Int [b],
-          LookupEntryClass c String Int) =>
-         a -> Maybe c
-tf106 e = if k == 2 then Nothing else tf105 e where (k,_) = keyVal e
-
-tm106 :: MayTestMap
-tm106 = mapTranslateEntriesM tf106 tm101
-
-mapTranslateSuite :: Test
-mapTranslateSuite = 
-  TestList
-  [ testLookupMapG "tm101" tm101 [(1,"a"),(2,"bb"),(3,"ccc"),(4,"dddd")]
-  , testLookupMapG "tm102" tm102 [("*","a"),("**","bb"),("***","ccc"),("****","dddd")]
-  , testLookupMapG "tm103" tm103 [("*",1),("**",2),("***",3),("****",4)]
-  , testLookupMapG "tm104" tm104 [("#",4),("##",3),("###",2),("####",1)]
-  , testLookupMapM "tm105" tm105 (Just tm104)
-  , testLookupMapM "tm106" tm106 Nothing
-  ] 
-  
-------------------------------------------------------------
 --  All tests
 ------------------------------------------------------------
 
   , testMapValsSuite
   , testMapEqSuite
   , mapMergeSuite
-  , mapTranslateSuite
   ]
 
 main :: IO ()