Commits

Doug Burke  committed 35cb828

removal of deprecated functionality and modules

  • Participants
  • Parent commits 72f0306
  • Branches parser-rewrite-polyparse

Comments (0)

Files changed (13)

     some conversion between the two types is introduced). The eventual
     plan is to use Text internally.
 
+  - removed Swish.Utils.DateTime and Swish.Utils.TraceHelpers
+
+  - removed the following exported symbols from Swish.Utils.LookupMap:
+        mapSortByKey, mapSortByVal
+
+  - removed the following exported symbols from Swish.Utils.ListHelpers:
+        allf, anyf, combinations, ffold, hasPartitions,
+        mapset, pairsUngroup, powerSequences, powerSequences_inf
+
+  - removed the following exported symbols from Swish.Utils.MiscHelpers:
+        assert, stricmp, lower, quote
+
 0.3.2.1:
 
   - use foldl' rather than foldl in some modules

File Swish/RDF/GraphMatch.hs

         graphMatch1, graphMatch2, equivalenceClasses, reclassify
       ) where
 
+import Control.Exception.Base (assert)
+
 import Data.Ord (comparing)
 import Data.List (foldl', nub, sortBy, partition)
 import qualified Data.List
                               makeLookupMap, listLookupMap, mapFind, mapReplaceAll,
                               mapAddIfNew, mapReplaceMap, mapMerge)
 import Swish.Utils.ListHelpers (select, equiv, pairSort, pairGroup, pairUngroup)
-import Swish.Utils.MiscHelpers (assert, hash, hashModulus)
+import Swish.Utils.MiscHelpers (hash, hashModulus)
 
 --------------------------
 --  Label index value type
         --  NOTE:  final test is call of external matchable function
         glp = [ (l1,l2) | l1 <- ls1 , l2 <- ls2 , matchable l1 l2 ]
     in
-        assert (ev1==ev2) "GraphMatch2: Equivalence class value mismatch" $
-        try glp
+        assert (ev1==ev2) -- "GraphMatch2: Equivalence class value mismatch" $
+        $ try glp
 
 -- | Returns a string representation  of a LabelMap value
 --
   --     then `True`, otherwise `False`.
 
 reclassify gs1 gs2 lmap@(LabelMap _ lm) ecpairs =
-    assert (gen1==gen2) "Label map generation mismatch"
+    assert (gen1==gen2) -- "Label map generation mismatch"
       (LabelMap gen1 lm',ecpairs',newPart,matchPart)
     where
         LabelMap gen1 lm1 =

File Swish/RDF/N3Formatter.hs

   getArcs, labels,
   setNamespaces, getNamespaces,
   getFormulae,
-  emptyRDFGraph,
-  res_rdf_first, res_rdf_rest, res_rdf_nil
+  emptyRDFGraph
+  , quote
+  , res_rdf_first, res_rdf_rest, res_rdf_nil
   )
 
 import Swish.RDF.Vocabulary (
 import Swish.Utils.Namespace
     ( ScopedName(..), getScopeURI )
 
-import Data.Char (ord, isDigit, toLower)
+import Data.Char (isDigit, toLower)
 
 import Data.List (foldl', delete, groupBy, partition, sort)
 
-import Text.Printf (printf)
-
 import Control.Monad (liftM, when)
 import Control.Monad.State (State, get, put, runState)
 
                     | otherwise = '^':'^': showScopedName a
 
 {-
-Swish.Utils.MiscHelpers contains a quote routine
-which we expand upon here to match the N3 syntax.
-
 We have to decide whether to use " or """ to quote
 the string.
 
       qch = replicate n '"'                              
   in qch ++ qst ++ qch
 
--- The boolean flag is True if the string is being displayed
--- with single quotes, which should mean that there are
--- no newline or quote characters in the string.
---
--- TODO: when flag == False need to worry about n > 2 quotes
--- in a row.
---
-quote :: Bool -> String -> String
-quote _     []           = ""
-quote False s@(c:'"':[]) | c == '\\'  = s -- handle triple-quoted strings ending in "
-                         | otherwise  = [c, '\\', '"']
-
--- quote True  ('"': st)    = '\\':'"': quote True  st  -- this should not happen
--- quote True  ('\n':st)    = '\\':'n': quote True  st  -- this should not happen
-
-quote True  ('\t':st)    = '\\':'t': quote True  st
-quote False ('"': st)    =      '"': quote False st
-quote False ('\n':st)    =     '\n': quote False st
-quote False ('\t':st)    =     '\t': quote False st
-quote f ('\r':st)    = '\\':'r': quote f st
-quote f ('\\':st)    = '\\':'\\': quote f st -- not sure about this
-quote f (c:st) = 
-  let nc = ord c
-      rst = quote f st
-      
-      -- lazy way to convert to a string
-      hstr = printf "%08X" nc
-      ustr = hstr ++ rst
-
-  in if nc > 0xffff 
-     then '\\':'U': ustr
-     else if nc > 0x7e || nc < 0x20
-          then '\\':'u': drop 4 ustr
-          else c : rst
-                      
 formatNodeId :: RDFLabel -> Formatter String
 formatNodeId lab@(Blank (lnc:_)) =
     if isDigit lnc then mapBlankNode lab else return $ show lab

File Swish/RDF/RDFGraph.hs

     , isLiteral, isUntypedLiteral, isTypedLiteral, isXMLLiteral
     , isDatatyped, isMemberProp, isUri, isBlank, isQueryVar
     , getLiteralText, getScopedName, makeBlank
-                                     
+    , quote
+      
       -- * RDF Graphs
     , RDFTriple
     , toRDFTriple, fromRDFTriple
 import Swish.RDF.GraphMatch (graphMatch, LabelMap, ScopedLabel(..))
 
 import Swish.Utils.QName (QName)
-import Swish.Utils.MiscHelpers (hash, quote)
+import Swish.Utils.MiscHelpers (hash)
 import Swish.Utils.ListHelpers (addSetElem)
 
 import Swish.Utils.LookupMap
 import Network.URI (URI, parseURI, uriToString)
 
 import Data.Monoid (Monoid(..))
-import Data.Char (isDigit, toLower)
+import Data.Char (ord, isDigit, toLower)
 import Data.List (intersect, union, findIndices, foldl')
 import Data.Ord (comparing)
 import Data.String (IsString(..))
 
 instance Show RDFLabel where
     show (Res sn)           = show sn
-    show (Lit st Nothing)   = quote st
+    show (Lit st Nothing)   = quote1Str st
     show (Lit st (Just nam))
-        | isLang nam = quote st ++ "@"  ++ langTag nam
+        | isLang nam = quote1Str st ++ "@"  ++ langTag nam
         | nam `elem` [xsd_boolean, xsd_double, xsd_decimal, xsd_integer] = st
-        | otherwise  = quote st ++ "^^" ++ show nam
+        | otherwise  = quote1Str st ++ "^^" ++ show nam
     show (Blank ln)         = "_:"++ln
     show (Var ln)           = '?' : ln
     show NoNode             = "<NoNode>"
 showCanon :: RDFLabel -> String
 showCanon (Res sn)           = "<"++getScopedNameURI sn++">"
 showCanon (Lit st (Just nam))
-        | isLang nam = quote st ++ "@"  ++ langTag nam
-        | otherwise  = quote st ++ "^^" ++ getScopedNameURI nam
+        | isLang nam = quote1Str st ++ "@"  ++ langTag nam
+        | otherwise  = quote1Str st ++ "^^" ++ getScopedNameURI nam
 showCanon s                  = show s
 
+{-
+N3-style quoting rules for a string.
+
+The boolean flag is True if the string is being displayed
+with single quotes, which means that newlines and quote 
+characters need protecting.
+
+TODO: when flag == False need to worry about n > 2 quotes
+in a row.
+-}
+
+quote :: Bool -> String -> String
+quote _     []           = ""
+quote False s@(c:'"':[]) | c == '\\'  = s -- handle triple-quoted strings ending in "
+                         | otherwise  = [c, '\\', '"']
+
+quote True  ('"': st)    = '\\':'"': quote True  st
+quote True  ('\n':st)    = '\\':'n': quote True  st
+
+quote True  ('\t':st)    = '\\':'t': quote True  st
+quote False ('"': st)    =      '"': quote False st
+quote False ('\n':st)    =     '\n': quote False st
+quote False ('\t':st)    =     '\t': quote False st
+quote f ('\r':st)    = '\\':'r': quote f st
+quote f ('\\':st)    = '\\':'\\': quote f st -- not sure about this
+quote f (c:st) = 
+  let nc = ord c
+      rst = quote f st
+      
+      -- lazy way to convert to a string
+      hstr = printf "%08X" nc
+      ustr = hstr ++ rst
+
+  in if nc > 0xffff 
+     then '\\':'U': ustr
+     else if nc > 0x7e || nc < 0x20
+          then '\\':'u': drop 4 ustr
+          else c : rst
+
+-- surround a string with quotes ("...")
+
+quote1Str :: String -> String
+quote1Str s = '"' : quote False s ++ ['"']
 
 ---------------------------------------------------------
 --  Selected RDFLabel values

File Swish/RDF/Vocabulary.hs

 where
 
 import Swish.Utils.Namespace (Namespace(..), ScopedName(..))
-import Swish.Utils.MiscHelpers (lower)
+
+import Data.Char (toLower)
 
 ------------------------------------------------------------
 --  Define some common namespace values
     -- To be replaced by urn:ietf:params:lang?
 
 langName :: String -> ScopedName
-langName = ScopedName namespaceLang . lower
+langName = ScopedName namespaceLang . map toLower
 
 langTag :: ScopedName -> String
 langTag = snLocal

File Swish/Utils/DateTime.hs

---------------------------------------------------------------------------------
---  See end of this file for licence information.
---------------------------------------------------------------------------------
--- |
---  Module      :  DateTime
---  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011 Douglas Burke
---  License     :  GPL V2
---
---  Maintainer  :  Douglas Burke
---  Stability   :  experimental
---  Portability :  H98
---
---  This Module defines a collection of date/time manipulation functions. It
---  is deprecated - since it's functionality is available from other
---  modules - and will be removed in the next minor release of Swish
---  (@0.3.3@).
---
---------------------------------------------------------------------------------
---
---  Date/time value manipulation.
---
---  Date/time can be date-only or time-only
---
---  type DateTime is an instance of built-in classes Eq and Show
---
---  type DateTime has a constructor that accepts a string in the format
---      defined by RFC 3339.
---      Timezone interpretation is per RFC3339.
---
---
---            year,month,day,hour,min,sec,millisec,timezone
---class (Show a,Eq a) => DateTimeClass a where
---  newDateTime  :: Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> a
---  toString     :: a -> String
---  size         :: a -> Int
---  toDateTime   :: String -> a
---  toDate       :: String -> a
---  toTime       :: String -> a
---  (==)         :: a -> a -> Bool   -- same date/time
---  (<)        :: a -> a -> Bool   -- first precedes second
---  (+)        :: a -> a -> a  -- advance by time
---  (-)        :: a -> a -> a  -- difference between times
---  dtShow     :: a -> String             -- return string form
---  dtYear       :: a -> Int
---  dtMonth      :: a -> Int
---  dtDay        :: a -> Int
---  dtHour       :: a -> Int
---  dtMinute     :: a -> Int
---  dtSecond     :: a -> Int
---  dtMillisecs  :: a -> Int
---  dtTimezone   :: a -> Int                -- time zone offset in minutes
---
---------------------------------------------------------------------------------
-
-module Swish.Utils.DateTime where
-
-data DateTime
-  = DateTime Int Int Int Int Int Int Int Int
-
-instance Eq DateTime where
-  d1 == d2 = simpleEq ( normTZ d1 ) ( normTZ d2 )
-
-instance Show DateTime where
-  show = dtShow
-
-instance Ord DateTime where
-  dt1 <  dt2  = simpleLT ( normTZ dt1 ) ( normTZ dt2 )
-  dt1 >  dt2  = dt2 < dt1
-  dt1 <= dt2  = (dt1 < dt2)||(dt1==dt2)
-  dt1 >= dt2  = (dt2 < dt1)||(dt1==dt2)
-
-leapYear :: Int -> Bool
-leapYear year
-  | ( year `mod` 4 == 0 ) &&
-    not ( ( year `mod` 100 == 0 ) &&
-          ( (year `mod` 400) /= 0 ) ) = True
-  | otherwise                         = False
-
-daysInMonth :: Int -> Int -> Int
-daysInMonth month year
-  | month==1   = 31  --Jan
-  | month==2   = if leapYear year then 29 else 28 --Feb
-  | month==3   = 31  --Mar
-  | month==4   = 30  --Apr
-  | month==5   = 31  --May
-  | month==6   = 30  --Jun
-  | month==7   = 31  --Jul
-  | month==8   = 31  --Aug
-  | month==9   = 30  --Sep
-  | month==10  = 31  --Oct
-  | month==11  = 30  --Nov
-  | month==12  = 31  --Dec
-  | otherwise  = 0
-
-validJulianDate :: Int -> Int -> Int -> Bool
-validJulianDate yr mo da
-  | yr < 1900              = False
-  | mo > 12                = False
-  | da > daysInMonth mo yr = False
-  | otherwise              = True
-
-toJulianDate1 :: DateTime -> Int
-toJulianDate1 (DateTime y m d _ _ _ _ _) = toJulianDate y m d
-
-toJulianDate :: Int -> Int -> Int -> Int
-toJulianDate year month day
---  | not (validJulianDate year month day) = -1
-  | year==1900 && month<=2               = if month==2 then day + 30 else day - 1
-  | month>=3                             = toJD1 (year-1900) (month-3) day
-  | otherwise                            = toJD1 (year-1901) (month+9) day
-  where
-    toJD1 :: Int -> Int -> Int -> Int
-    toJD1 y m d
-      = ( (1461*y) `div` 4 ) -
-        (y `div` 100) +
-        ((y+300) `div` 400) +
-        ( ( (153*m) + 2 ) `div` 5 ) +
-        d + 58
-
-fromJulianDate:: Int -> DateTime
-fromJulianDate jdate
-  | jdate <= 58 = fromJD1 jdate
-  | otherwise   = fromJD2 jdate
-  where
-    fromJD1 :: Int -> DateTime
-    fromJD1 j
-      | j<=30     = DateTime 1900 1 (j+1 ) 0 0 0 0 0
-      | otherwise = DateTime 1900 2 (j-30) 0 0 0 0 0
-
-    fromJD2 :: Int -> DateTime
-    fromJD2 j
-      = DateTime y2 m2 d1 0 0 0 0 0
-      where
---          t1 = (400*(j+((j+36467)`div`36525)-((j+109517)`div`dc))) - 23638 -- 1/400-days from 1900-02-28 [t]
-          t1 = (400*
-                    (j
-               +((4*(j+36465))`div`146097)
-                  -((j+109513)`div`146097))) - 23638 -- 1/400-days from 1900-02-28 [t]
-          dc = 146100                                -- days in cycle period (400 years) = 1/400-days in year
-          t2 = ( ( t1 `mod` dc ) `div` 400 )*5 + 2   -- fifth-days into year, +2                      [j3]
-          d1 = ( t2 `mod` 153 ) `div` 5 + 1          -- day of month (magic number 153)               [d]
-          m1 = t2 `div` 153                          -- month Mar=0 -> Feb=11                         [j4]
-          m2 = if m1 <= 9 then m1+3 else m1-9        -- correct month to Jan=1 -> Dec=12              [m]
-          y1 = t1 `div` dc + 1900                    -- year from 1900-02-28
-          y2 = if m1 <= 9 then y1   else y1+1        -- correct year for month wrap-around
-          -- 36525  = days/century, not counting century adjustments
-          -- 109517 = 146100 * (1900-1600)/400 - 58
-          -- 23238  = 58*400 + 38  ???   38=152/4 ??
-
-{-          -- this code works for dates before 2100 only
-          t1 = (4*j) - 233                           -- quarter-days from 1900-02-28
-          dc = 1461                                  -- days in cycle period (4 years) = quarter-days in year
-          t2 = ( ( t1 `mod` dc ) `div` 4 )*5 + 2     -- fifth-days into year, +2
-          d1 = ( t2 `mod` 153 ) `div` 5 + 1          -- day of month (magic number 153)
-          m1 = t2 `div` 153                          -- month Mar=0 -> Feb=11
-          m2 = if m1 <= 9 then m1+3 else m1-9        -- correct month to Jan=1 -> Dec=12
-          y1 = t1 `div` dc + 1900                    -- year from 1900-02-28
-          y2 = if m1 <= 9 then y1   else y1+1        -- correct year for month wrap-around
--}
-
-date :: Int -> Int -> Int -> DateTime
-date y m d = DateTime y m d 0 0 0 0 0
-
-time :: Int -> Int -> Int -> Int -> Int -> DateTime
-time = DateTime 0 0 0
-
-dtYear       :: DateTime -> Int
-dtMonth      :: DateTime -> Int
-dtDay        :: DateTime -> Int
-dtHour       :: DateTime -> Int
-dtMinute     :: DateTime -> Int
-dtSecond     :: DateTime -> Int
-dtMillisecs  :: DateTime -> Int
-dtTimezone   :: DateTime -> Int                -- time zone offset in minutes
-dtYear      ( DateTime x _ _ _ _ _ _ _ ) = x
-dtMonth     ( DateTime _ x _ _ _ _ _ _ ) = x
-dtDay       ( DateTime _ _ x _ _ _ _ _ ) = x
-dtHour      ( DateTime _ _ _ x _ _ _ _ ) = x
-dtMinute    ( DateTime _ _ _ _ x _ _ _ ) = x
-dtSecond    ( DateTime _ _ _ _ _ x _ _ ) = x
-dtMillisecs ( DateTime _ _ _ _ _ _ x _ ) = x
-dtTimezone  ( DateTime _ _ _ _ _ _ _ x ) = x
-
-lenFix     :: String -> Int -> String
-lenFix inStr newLen
-  | length inStr >= newLen  = inStr
-  | otherwise               = lenFix ('0':inStr) newLen
-
-showTZ     :: Int -> String
-showTZ tz
-  | tz<0         = '-' : showTZabs (-tz)
-  | tz==0        = showTZabs tz
-  | otherwise    = '+' : showTZabs tz
-
-showTZabs  :: Int -> String
-showTZabs tz
-  | tz==0        = "Z"
-  | otherwise    = lenFix ( show ( tz `div` 60 ) ) 2 ++  ":" ++
-                   lenFix ( show ( tz `mod` 60 ) ) 2
-
-showTime :: DateTime -> String
-showTime ( DateTime _ _ _ hr mi se ms _ )
-  | ms==0     = lenFix ( show hr ) 2 ++  ":" ++
-                lenFix ( show mi ) 2 ++  ":" ++
-                lenFix ( show se ) 2
-  | otherwise = lenFix ( show hr ) 2 ++ ":" ++
-                lenFix ( show mi ) 2 ++ ":" ++
-                lenFix ( show se ) 2 ++ "." ++
-                lenFix ( show ms ) 3
-
-showDate :: DateTime -> String
-showDate ( DateTime yr mo da _ _ _ _ _ )
-  = lenFix ( show yr ) 4 ++ "-" ++
-    lenFix ( show mo ) 2 ++ "-" ++
-    lenFix ( show da ) 2
-
-dtShow     :: DateTime -> String             -- return string form
-dtShow ( DateTime yr mo da hr mi se ms tz )
-  = showDate ( DateTime yr mo da hr mi se ms tz ) ++ "T" ++
-    showTime ( DateTime yr mo da hr mi se ms tz ) ++ showTZ tz
-
-carryMins :: DateTime -> DateTime
-carryMins ( DateTime yr mo da hr mi se ms tz )
-  | newhrs >= 24 = carryHours ( DateTime yr mo da newhrs (mi`mod`60) se ms tz )
-  | otherwise    = DateTime yr mo da newhrs (mi`mod`60) se ms tz
-  where
-    newhrs = hr + (mi`div`60)
-
-carryHours :: DateTime -> DateTime
-carryHours ( DateTime yr mo da hr mi se ms tz )
-  = DateTime y m d (hr`mod`24) mi se ms tz
-  where
-    (DateTime y m d _ _ _ _ _) = fromJulianDate (toJulianDate yr mo da + (hr`div`24))
-
-normTZ :: DateTime -> DateTime
-normTZ ( DateTime yr mo da hr mi se ms tz )
-  = carryMins ( DateTime yr mo da hr (mi-tz) se ms 0 )
---  = addMinutes (-tz) ( DateTime yr mo da hr mi se ms tz )
-
-{- another way -}
-
-addMilliSecs :: Int -> DateTime -> DateTime
-addMilliSecs addms ( DateTime yr mo da hr mi se ms tz )
-    | totms < 1000 = DateTime yr mo da hr mi se totms tz
-    | otherwise    = addSeconds addse ( DateTime yr mo da hr mi se newms tz )
-    where
-        totms = ms + addms
-        newms = totms `mod` 1000
-        addse = totms `div` 1000
-
-addSeconds :: Int -> DateTime -> DateTime
-addSeconds addse ( DateTime yr mo da hr mi se ms tz )
-    | totse < 60 = DateTime yr mo da hr mi totse ms tz
-    | otherwise  = addMinutes addmi ( DateTime yr mo da hr mi newse ms tz )
-    where
-        totse = se + addse
-        newse = totse `mod` 60
-        addmi = totse `div` 60
-
-addMinutes :: Int -> DateTime -> DateTime
-addMinutes addmi ( DateTime yr mo da hr mi se ms tz )
-    | totmi < 60 = DateTime yr mo da hr totmi se ms tz
-    | otherwise  = addHours addhr ( DateTime yr mo da hr newmi se ms tz )
-    where
-        totmi = mi + addmi
-        newmi = totmi `mod` 60
-        addhr = totmi `div` 60
-
-addHours :: Int -> DateTime -> DateTime
-addHours addhr ( DateTime yr mo da hr mi se ms tz )
-    | tothr < 24 = DateTime yr mo da tothr mi se ms tz
-    | otherwise  = addDays addda ( DateTime yr mo da newhr mi se ms tz )
-    where
-        tothr = hr + addhr
-        newhr = tothr `mod` 24
-        addda = tothr `div` 24
-
-addDays :: Int -> DateTime -> DateTime
-addDays addda ( DateTime yr mo da hr mi se ms tz )
-    = DateTime newyr newmo newda hr mi se ms tz
-    where
-        -- newdate = fromJulianDate (toJulianDate yr mo (da+addda) )
-        -- newyr   = dtYear newdate
-        -- newmo   = dtMonth newdate
-        -- newda   = dtDay newdate
-        DateTime newyr newmo newda _ _ _ _ _ = fromJulianDate ( toJulianDate yr mo da + addda )
-
-{- another way -}
-
-simpleEq :: DateTime -> DateTime -> Bool
---simpleEq ( DateTime yr1 mo1 da1 hr1 mi1 se1 ms1 tz1 ) ( DateTime yr2 mo2 da2 hr2 mi2 se2 ms2 tz2 ) = ( ( yr1 mo1 da1 hr1 mi1 se1 ms1 tz1 ) == ( yr2 mo2 da2 hr2 mi2 se2 ms2 tz2 ) )
-simpleEq ( DateTime yr1 mo1 da1 hr1 mi1 se1 ms1 tz1 ) ( DateTime yr2 mo2 da2 hr2 mi2 se2 ms2 tz2 ) =
-  ( yr1 == yr2 ) && ( mo1 == mo2 ) && ( da1 == da2 ) && ( hr1 == hr2 ) && ( mi1 == mi2 ) && ( se1 == se2 ) && ( ms1 == ms2 ) && ( tz1 == tz2 )
-
-simpleLT :: DateTime -> DateTime -> Bool
-simpleLT ( DateTime yr1 mo1 da1 hr1 mi1 se1 ms1 _ ) ( DateTime yr2 mo2 da2 hr2 mi2 se2 ms2 _ )
-  | yr1 < yr2  = True
-  | (yr1==yr2)&&(mo1<mo2) = True
-  | (yr1==yr2)&&(mo1==mo2)&&(da1<da2) = True
-  | (yr1==yr2)&&(mo1==mo2)&&(da1==da2)&&(hr1<hr2) = True
-  | (yr1==yr2)&&(mo1==mo2)&&(da1==da2)&&(hr1==hr2)&&(mi1<mi2) = True
-  | (yr1==yr2)&&(mo1==mo2)&&(da1==da2)&&(hr1==hr2)&&(mi1==mi2)&&(se1<se2) = True
-  | (yr1==yr2)&&(mo1==mo2)&&(da1==da2)&&(hr1==hr2)&&(mi1==mi2)&&(se1==se2)&&(ms1<ms2) = True
-  | otherwise = False
-
---------------------------------------------------------------------------------
---
---  Copyright (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011 Douglas Burke
---  All rights reserved.
---
---  This file is part of Swish.
---
---  Swish is free software; you can redistribute it and/or modify
---  it under the terms of the GNU General Public License as published by
---  the Free Software Foundation; either version 2 of the License, or
---  (at your option) any later version.
---
---  Swish is distributed in the hope that it will be useful,
---  but WITHOUT ANY WARRANTY; without even the implied warranty of
---  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
---  GNU General Public License for more details.
---
---  You should have received a copy of the GNU General Public License
---  along with Swish; if not, write to:
---    The Free Software Foundation, Inc.,
---    59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
---
---------------------------------------------------------------------------------

File Swish/Utils/ListHelpers.hs

 --  Stability   :  experimental
 --  Portability :  H98
 --
---  This module defines some generic list and related helper functions. Although
---  some routines are explicitly marked as deprecated, the intention is to
---  move this functionality into the modules that need it, or replace it by
---  other modules, where possible.
+--  This module defines some generic list and related helper functions. 
 --
 --------------------------------------------------------------------------------
 
        , allp -- RDFQuery
        , anyp -- RDFQuery
         
-        -- * Deprecated routines
-        --
-        -- | These routines will be removed at the next minor release of
-        -- of Swish (@0.3.3@).
-        --
-       , mapset
-       , pairsUngroup
-       , ffold
-       , hasPartitions
-       , powerSequences
-       , powerSequences_inf
-       , allf
-       , anyf
-       , combinations -- used by powerSet
-        
       )
 where
   
 import Data.Ord (comparing)  
-import Data.List (union, intersect, sortBy, groupBy)
+import Data.List (sortBy, groupBy)
 
 ------------------------------------------------------------
 --  Generic helpers
     | otherwise = select f l1 l2
 select _ _ _    = error "select supplied with different length lists"
 
--- |Collect set of values from list under supplied mapping function
-mapset :: Eq b => ( a -> b ) -> [a] -> [b]
-mapset _ []    = []
-mapset f (e:l) = [f e] `union` mapset f l
-
 -- |Delete the n'th element of a list, returning the result
 --
 --  If the list doesn't have an n'th element, return the list unchanged.
 equiv           :: (Eq a) => [a] -> [a] -> Bool
 a `equiv` b     = a `subset` b && b `subset` a
 
--- |Set partition test
---
---  Is it possible to be more efficient here?
---  Maybe something like sort\/merge\/compare?
-hasPartitions   :: (Eq a) => [a] -> ([a],[a]) -> Bool
-a `hasPartitions` (b1,b2) =
-    null (b1 `intersect` b2) && (a `equiv` (b1 `union` b2))
-
 -- |Add element to set
 
 addSetElem :: (Eq a) => a -> [a] -> [a]
 pairUngroup :: (a,[b]) -> [(a,b)]
 pairUngroup (a,bs) = [ (a,b) | b <- bs ]
 
-pairsUngroup :: [(a,[b])] -> [(a,b)]
-pairsUngroup ps = [ (a,b) | (a,bs) <- ps, b <- bs ]
-
 pairSort :: (Ord a) => [(a,b)] -> [(a,b)]
 pairSort = sortBy (comparing fst)
 
 --  Powersequence (?) -- all sequences from some base values
 ------------------------------------------------------------
 
--- |Function to choose all sequences of any length
---  from a supplied set of values, returned in
---  increasing length.
-powerSequences :: [a] -> [[a]]
-powerSequences rs = concat $ powerSeq_bylen rs [[]]
-
 -- |Construct list of lists of sequences of increasing length
 powerSeq_bylen :: [a] -> [[a]] -> [[[a]]]
 powerSeq_bylen rs ps = ps : powerSeq_bylen rs (powerSeq_next rs ps)
 powerSequences_len :: Int -> [a] -> [[a]]
 powerSequences_len len rs = powerSeq_bylen rs [[]] !! len
 
--- |Return all powersequences of indefinite length
---  Observe that any such powersequence will consist of a sequence
---  of a finite length sequence followed by an indefinite number of
---  copies of the head of the base set.  To prevent duplicates, the
---  generator constructs only sequences that do not end in the first
---  member of the base set.
-powerSequences_inf :: [a] -> [[a]]
-powerSequences_inf rs =
-    map (++pst) $ [] : concat (powerSeq_bylen rs psh)
-    where
-        psh = map (:[]) (tail rs)
-        pst = repeat $ head rs
-
-{- Powersequence tests
-t0 = [1,2,3,4,5,6]
-t1 = powerSequences t0
-t2 = take 15 t1
-t3 = powerSequences_len 3 t0
-t4 = powerSequences_inf t0
-t5 = map (take 6) $ take 15 t4
-t6 = take 15 (powerSequences_len 6 t0)
-t7 = t5 == t6
-t8 = powerSequences_len1 3 t0
-t9 = t8 == t3
--}
-
 ------------------------------------------------------------
 --  Functions, lists and monads
 ------------------------------------------------------------
 fmonadtest = fmonad [(1*),(2*),(3*)] 3 -- [3,6,9]
 -}
 
--- |Fold result from list of functions applied to some value,
---  returning the result of the fold.
---
---  This is similar to the 'ap' function in the Monad library.
---
-ffold :: (b->c->c) -> c -> [a->b] -> a -> c
-ffold rf ri fs v = foldr rf ri (flist fs v)
-
-{-
-ffoldtest0 = ffold ge4and True [(1+),(2+),(3+)] 0     -- False
-ffoldtest1 = ffold ge4and True [(1+),(2+),(3+)] 1     -- False
-ffoldtest2 = ffold ge4and True [(1+),(2+),(3+)] 2     -- False
-ffoldtest3 = ffold ge4and True [(1+),(2+),(3+)] 3     -- True
-ge4and v b = (v>=4 && b)
-ffoldtest  = and [not ffoldtest0,not ffoldtest1,not ffoldtest2,ffoldtest3]
--}
-
--- |Test if application of all functions in list to a given value
---  satisfies a given condition
---
-allf :: (b->Bool)  -> [a->b] -> a -> Bool
-allf pf fs a = all pf (flist fs a)
-
-{-
-allftest0 = allf (>=4) [(1+),(2+),(3+)] 0     -- False
-allftest1 = allf (>=4) [(1+),(2+),(3+)] 1     -- False
-allftest2 = allf (>=4) [(1+),(2+),(3+)] 2     -- False
-allftest3 = allf (>=4) [(1+),(2+),(3+)] 3     -- True
-allftest  = and [not allftest0,not allftest1,not allftest2,allftest3]
--}
-
--- |Test if application of any functions in list to a given value
---  satisfies a given condition
---
-anyf :: (b->Bool)  -> [a->b] -> a -> Bool
-anyf pf fs a = any pf (flist fs a)
-
-{-
-anyftest0 = anyf (>=4) [(1+),(2+),(3+)] 0     -- False
-anyftest1 = anyf (>=4) [(1+),(2+),(3+)] 1     -- True
-anyftest2 = anyf (>=4) [(1+),(2+),(3+)] 2     -- True
-anyftest3 = anyf (>=4) [(1+),(2+),(3+)] 3     -- True
-anyftest  = and [not anyftest0,anyftest1,anyftest2,anyftest3]
--}
-
 -- |Test if a value satisfies all predicates in a list
 --
 allp :: [a->Bool] -> a -> Bool

File Swish/Utils/LookupMap.hs

     , mapTranslateKeys, mapTranslateVals
     , mapTranslateEntries, mapTranslateEntriesM
 
-    -- * Deprecated routines
-    --
-    -- | These routines will be removed at the next minor release of
-    -- of Swish (@0.3.3@).
-    --
-    , mapSortByKey, mapSortByVal
-
     )
     where
 
                                     ++ " with " ++ show e2)
                         else e1 : merge et1 et2
 
--- |Creates a new map that is the same as the supplied map, except
---  that its entries are sorted by key value.
---
-mapSortByKey :: (LookupEntryClass a k v, Ord k) =>
-    LookupMap a -> LookupMap a
-mapSortByKey (LookupMap es) =
-    LookupMap $ L.sortBy (comparing entryKey) es
-
--- |Creates a new map that is the same as the supplied map, except
---  that its entries are sorted by key value.
---
-mapSortByVal :: (LookupEntryClass a k v, Ord v) =>
-    LookupMap a -> LookupMap a
-mapSortByVal (LookupMap es) =
-    LookupMap $ L.sortBy (comparing entryVal) es
-
 -- |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.

File Swish/Utils/MiscHelpers.hs

       ( hash -- RDFGraph, GraphMem, GraphMatch
       , hashModulus -- GraphMatch
       
-        -- * Deprecated routines
-        --
-        -- | These routines will be removed at the next minor release of
-        -- of Swish (@0.3.3@).
-        --
-      , assert -- GraphMatch QUS: can we use Control.Exception.assert?
-      , stricmp
-      , lower -- Vocabulary
-      , quote -- RDFGraph
- 
       )
 where
 
-import Data.Char (toLower)
-
-------------------------------------------------------------
---  assert test
-------------------------------------------------------------
-
-assert :: Bool -> String -> a -> a
-assert cond msg expr = if not cond then error msg else expr
-
-------------------------------------------------------------
---  Generate lowercase form of supplied string
-------------------------------------------------------------
-
-lower :: String -> String
-lower = foldr ((:) . toLower) "" 
-
-------------------------------------------------------------
---  Case insensitive compare.
-------------------------------------------------------------
---
---  Should be used only for values using just the US ASCII
---  character set.  Use with richer character sets can yield
---  surprising results.
-
-stricmp :: String -> String -> Bool
-stricmp (c1:s1) (c2:s2) = toLower c1 == toLower c2 && stricmp s1 s2
-stricmp []      []      = True
-stricmp _       _       = False
-
-------------------------------------------------------------
---  Generate quoted form of supplied string:
-------------------------------------------------------------
---
---  [[[TODO: The list of quoting options here is incomplete]]]
-
-quote :: String -> String
-quote  st = ['"'] ++ quote1 st ++ ['"']
-
-quote1 :: String -> String
-quote1 ('"': st)    = '\\':'"' : quote1 st
-quote1 ('\\':st)    = '\\':'\\': quote1 st
-quote1 ('\n':st)    = '\\':'n': quote1 st
-quote1 ('\r':st)    = '\\':'r': quote1 st
-quote1 (c:st)       = c: quote1 st
-quote1 []           = ""
-
 ------------------------------------------------------------
 --  Hash function and values
 ------------------------------------------------------------

File Swish/Utils/ShowM.hs

 --
 --------------------------------------------------------------------------------
 
-module Swish.Utils.ShowM
-    ( ShowM(..), 
-      
-      -- * Deprecated routine
-      --
-      -- | This routine will be removed at the next minor release of
-      -- of Swish (@0.3.3@).
-      --
-      showm
-    )
-where
+module Swish.Utils.ShowM (ShowM(..)) where
 
 ------------------------------------------------------------
 --  ShowM framework
     showms :: String -> sh -> ShowS
     showms _ = shows
 
--- |Return a string representation of a ShowM value.
-showm :: (ShowM sh) => String -> sh -> String
-showm linebreak val = showms linebreak val ""
-
-
 --------------------------------------------------------------------------------
 --
 --  Copyright (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011 Douglas Burke

File Swish/Utils/TraceHelpers.hs

---------------------------------------------------------------------------------
---  See end of this file for licence information.
---------------------------------------------------------------------------------
--- |
---  Module      :  TraceHelpers
---  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011 Douglas Burke
---  License     :  GPL V2
---
---  Maintainer  :  Douglas Burke
---  Stability   :  experimental
---  Portability :  H98
---
---  This module is deprecated and will be removed in the next minor
---  release of Swish (@0.3.3@).
---
---------------------------------------------------------------------------------
-
-module Swish.Utils.TraceHelpers
-    ( trace, traceShow
-    )
-where
-
-import Debug.Trace
-    ( trace )
-
-------------------------------------------------------------
---  traceShow function from older Hugs trace module
-------------------------------------------------------------
-
-traceShow :: Show a => String -> a -> a
-traceShow msg x = trace (msg ++ show x) x
-
---------------------------------------------------------------------------------
---
---  Copyright (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011 Douglas Burke
---  All rights reserved.
---
---  This file is part of Swish.
---
---  Swish is free software; you can redistribute it and/or modify
---  it under the terms of the GNU General Public License as published by
---  the Free Software Foundation; either version 2 of the License, or
---  (at your option) any later version.
---
---  Swish is distributed in the hope that it will be useful,
---  but WITHOUT ANY WARRANTY; without even the implied warranty of
---  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
---  GNU General Public License for more details.
---
---  You should have received a copy of the GNU General Public License
---  along with Swish; if not, write to:
---    The Free Software Foundation, Inc.,
---    59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
---
---------------------------------------------------------------------------------
   Changes:
   .
   [Version 0.4.0.0] Moving to using polyparse for parsing and @Text@ rather than
-  @String@ where appropriate.
+  @String@ where appropriate. Removed the Swish.Utils.DateTime and Swish.Utils.TraceHelpers
+  modules. Symbols have been removed from the export lists of the following modules:
+  Swish.Utils.LookupMap, Swish.Utils.ListHelpers, Swish.Utils.MiscHelpers,
+  Swish.Utils.ShowM.
   .
   [Version 0.3.2.1] Marked a number of routines from the Swish.Utils modules
   as deprecated. Use foldl' rather than foldl.
       parallel == 2.2.*,
       polyparse == 1.6.*,
       random == 1.0.*,
-      old-time == 1.0.*, old-locale == 1.0.*, time == 1.1.*,
+      -- old-time == 1.0.*, 
+      old-locale == 1.0.*, time == 1.1.*,
       mtl >= 1 && < 3,
       HUnit == 1.2.*,
       network >= 2.2 && < 2.4,
       Swish.RDF.SwishScript
       Swish.RDF.VarBinding
       Swish.RDF.Vocabulary
-      Swish.Utils.DateTime
       Swish.Utils.ListHelpers
       Swish.Utils.LookupMap
       Swish.Utils.MiscHelpers
       Swish.Utils.PartOrderedCollection
       Swish.Utils.QName
       Swish.Utils.ShowM
-      Swish.Utils.TraceHelpers
 
    other-modules:
       -- Paths_swish

File tests/GraphTest.hs

         graphLabels, assignLabelMap, newGenerationMap,
         graphMatch1, equivalenceClasses
       )
-import Swish.Utils.LookupMap
-      ( LookupEntryClass(..), makeLookupMap
-      , mapSortByVal
-      )
+import Swish.Utils.LookupMap (LookupEntryClass(..), makeLookupMap)
 
 default ( Int )
 
 makeEntries :: (Label lb) => [(lb,LabelIndex)] -> [LabelEntry lb]
 makeEntries = map newEntry
 
-labelMapSortByVal :: (Label lb) => LabelMap lb -> LabelMap lb
-labelMapSortByVal (LabelMap gen lm) = LabelMap gen (mapSortByVal lm)
-
 ------------------------------------------------------------
 --  Graph helper function tests
 ------------------------------------------------------------
     testSelect01, testSelect02, testSelect03, testSelect04
     ]
 
--- mapset
-
-mf   :: Int -> Char
-mf n = "_abcde" !! n
-
-testMapset :: String -> [Int] -> String -> Test
-testMapset lab l1s l2s = testeq ("Mapset"++lab ) l2s (mapset mf l1s)
-
-testMapsetSuite :: Test
-testMapsetSuite = TestList
-    [ testMapset "01" [0,1,2,3,4,5] "_abcde"
-    , testMapset "02" [1,1,3,3,5,5] "ace"
-    , testMapset "03" [5,4,3,2,1,0] "edcba_"
-    , testMapset "04" []            []
-    , testMapset "05" [1,2,3,4,5,0] "abcde_"
-    ]
-
 -- subset
 
 testSubset :: String -> Bool -> [Int] -> [Int] -> Test
 allTests :: Test
 allTests = TestList
   [ testSelectSuite
-  , testMapsetSuite
   , testSubsetSuite
   , testHashSuite
   , testLabSuite