diff -ur HaRe_20012006_orig/StrategyLib-4.0-beta/library/MetricsTheme.hs HaRe_20012006/StrategyLib-4.0-beta/library/MetricsTheme.hs
|
old
|
new
|
|
| 13 | 13 | module MetricsTheme where |
| 14 | 14 | |
| 15 | 15 | import Monad |
| 16 | | import Data.Monoid as Monoid |
| | 16 | import Data.Monoid as Monoid |
| 17 | 17 | import StrategyPrelude |
| 18 | 18 | import OverloadingTheme |
| 19 | 19 | import FlowTheme |
| … |
… |
|
| 21 | 21 | ------------------------------------------------------------------------------ |
| 22 | 22 | -- * An abstract datatype for metrics |
| 23 | 23 | |
| 24 | | -- | The type of metrics |
| 25 | | type Metrics = MetricName -> Integer |
| | 24 | -- | The type of metrics (changed to newtype to avoid overlapping) |
| | 25 | newtype Metrics = Metrics (MetricName -> Integer) |
| 26 | 26 | |
| 27 | 27 | -- | The type of metric names |
| 28 | 28 | type MetricName = String |
| 29 | 29 | |
| 30 | 30 | -- | Create 'Metrics' with given initial value for all metrics. |
| 31 | 31 | initMetrics :: Integer -> Metrics |
| 32 | | initMetrics n = \key -> n |
| | 32 | initMetrics n = Metrics $ \key -> n |
| 33 | 33 | |
| 34 | 34 | -- | Create 'Metrics' with 0 as initial value for all metrics. |
| 35 | 35 | initMetrics0 :: Metrics |
| … |
… |
|
| 41 | 41 | |
| 42 | 42 | -- | Increment metric with the given name with the given value. |
| 43 | 43 | incMetrics :: MetricName -> Integer -> Metrics -> Metrics |
| 44 | | incMetrics key n m = \key' -> let val = m key' |
| | 44 | incMetrics key n (Metrics m) = Metrics $ \key' -> let val = m key' |
| 45 | 45 | in if key'==key then val+n else val |
| 46 | 46 | |
| 47 | 47 | -- | Increment metric with the given name by 1. |
| … |
… |
|
| 50 | 50 | |
| 51 | 51 | -- | Print value of metric with the given name. |
| 52 | 52 | putMetricLn :: MetricName -> Metrics -> IO () |
| 53 | | putMetricLn key m = putStrLn $ key++" = "++show (m key) |
| | 53 | putMetricLn key (Metrics m) = putStrLn $ key++" = "++show (m key) |
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | |
| 57 | 57 | -- * Metrics as monoids |
| 58 | 58 | instance Monoid Metrics where |
| 59 | 59 | mempty = initMetrics0 |
| 60 | | mappend m1 m2 = \s -> (m1 s) + (m2 s) |
| | 60 | mappend (Metrics m1) (Metrics m2) = Metrics $ \s -> (m1 s) + (m2 s) |
| 61 | 61 | |
| 62 | 62 | |
| 63 | 63 | ------------------------------------------------------------------------------ |
diff -ur HaRe_20012006_orig/StrategyLib-4.0-beta/models/drift-default/TermRep.hs HaRe_20012006/StrategyLib-4.0-beta/models/drift-default/TermRep.hs
|
old
|
new
|
|
| 65 | 65 | getChildren (TermRep (_,ks,_)) = ks |
| 66 | 66 | getConstr (TermRep (_,_ ,c)) = \ks -> TermRep (c ks,ks,c) |
| 67 | 67 | getTypeRep t = typeOf t |
| 68 | | hasTypeOf (TermRep (dx,_,_)) (x::t) |
| 69 | | = ((fromDynamic dx)::Maybe t) |
| | 68 | hasTypeOf :: Typeable t => TermRep -> t -> Maybe t |
| | 69 | hasTypeOf (TermRep (dx,_,_)) x |
| | 70 | = (fromDynamic dx) |
| 70 | 71 | |
| 71 | 72 | |
| 72 | 73 | --- Instances for basic types and basic type constructors -------------------- |
diff -ur HaRe_20012006_orig/diffs/tools/base/Modules/Relations.lhs HaRe_20012006/diffs/tools/base/Modules/Relations.lhs
|
old
|
new
|
|
| 1 | 1 | >module Relations where |
| 2 | 2 | |
| 3 | | >#if __GLASGOW_HASKELL__ >= 604 |
| | 3 | #if __GLASGOW_HASKELL__ >= 604 |
| 4 | 4 | >import qualified Data.Map as M |
| 5 | 5 | >import qualified Data.Set as S |
| 6 | 6 | |
| … |
… |
|
| 18 | 18 | > add fmap (key,elt) = M.insertWith combiner key elt fmap |
| 19 | 19 | |
| 20 | 20 | >findWithDefault a k fm = M.findWithDefault a k fm |
| 21 | | >#else |
| | 21 | #else |
| 22 | 22 | >import qualified Data.FiniteMap as M |
| 23 | 23 | >import qualified Sets as S |
| 24 | 24 | |
| … |
… |
|
| 32 | 32 | >difference = S.minusSet |
| 33 | 33 | >addListTo_C combiner fm key_elt_pairs = M.addListToFM_C combiner fm key_elt_pairs |
| 34 | 34 | >findWithDefault a k fm = M.lookupWithDefaultFM fm a k |
| 35 | | >#endif |
| | 35 | #endif |
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | Relations |
diff -ur HaRe_20012006_orig/diffs/tools/base/defs/UniqueNames.hs HaRe_20012006/diffs/tools/base/defs/UniqueNames.hs
|
old
|
new
|
|
| 76 | 76 | ppiOp (PN i n) = ppiOp i<>n |
| 77 | 77 | |
| 78 | 78 | instance Printable Orig where |
| 79 | | ppi (D n (N s)) = ppi (subnum n)<+>ppIfDebug ("«"<>s<>"»") |
| 80 | | ppi (S p) = ppIfDebug ("«"<>p<>"»") |
| 81 | | ppi (G m _ _) = ppIfDebug ("«"<>m<>"»") |
| 82 | | --ppi (Sn n (SrcLoc f r c)) = "«"<>r<>","<>c<>"»" |
| | 79 | ppi (D n (N s)) = ppi (subnum n)<+>ppIfDebug ("<<"<>s<>">>") |
| | 80 | ppi (S p) = ppIfDebug ("<<"<>p<>">>") |
| | 81 | ppi (G m _ _) = ppIfDebug ("<<"<>m<>">>") |
| | 82 | --ppi (Sn n (SrcLoc f r c)) = "<<"<>r<>","<>c<>">>" |
| 83 | 83 | ppi _ = empty |
| 84 | 84 | |
| 85 | 85 | subnum n = ppIfUnicode (subdigs (show n)) n |
diff -ur HaRe_20012006_orig/refactorer/EditorCommands.hs HaRe_20012006/refactorer/EditorCommands.hs
|
old
|
new
|
|
| 12 | 12 | ,Handle |
| 13 | 13 | ,stdin |
| 14 | 14 | ,stderr) |
| 15 | | import Control.Exception as Exception |
| | 15 | import Control.Exception as Exception hiding (bracketOnError) |
| 16 | 16 | import Foreign |
| 17 | 17 | import Foreign.C |
| 18 | 18 | import Network hiding (listenOn,connectTo,accept) |
diff -ur HaRe_20012006_orig/refactorer/PFE0.hs HaRe_20012006/refactorer/PFE0.hs
|
old
|
new
|
|
| 176 | 176 | sendMsg dialog msg = lift (sendEditorMsg editorCmds dialog msg) |
| 177 | 177 | sendModified f = lift (sendEditorModified editorCmds f) |
| 178 | 178 | l <- catchEnv getCmd (const $ return "stop") |
| 179 | | let cmdArgs@(cmd: ~(mod:_)) = words l |
| | 179 | let cmdArgs@(cmd: _) = case words l of ws | null ws -> ["empty"]; ws -> ws |
| 180 | 180 | sendMsg False $ "CMD:"++show cmdArgs |
| 181 | 181 | unless (cmd=="stop") $ do |
| 182 | 182 | if (cmd=="undo") then (undoLatestInHistory >> loop prg args) |
diff -ur HaRe_20012006_orig/refactorer/RefacUnGuard.hs HaRe_20012006/refactorer/RefacUnGuard.hs
|
old
|
new
|
|
| 191 | 191 | -- | Applies the transformation to a given declaration, using the auxiliary functions |
| 192 | 192 | -- defined bellow |
| 193 | 193 | replaceGuards d@(Dec (HsFunBind loc matches)) (_,_,mod) |
| 194 | | = do let newMs1 = findConsist matches --:: [(Bool,Match)] |
| | 194 | = do let newMs1 = findConsist matches -- :: [(Bool,Match)] |
| 195 | 195 | initSt = getInitSt [m | (b,m) <- newMs1, b] |
| 196 | 196 | newMs2 = map declsToLet' newMs1 |
| 197 | 197 | newMs3 = dmerge newMs2 initSt |
diff -ur HaRe_20012006_orig/refactorer/RefacUtils.hs HaRe_20012006/refactorer/RefacUtils.hs
|
old
|
new
|
|
| 50 | 50 | ,findPNT,findPN -- Try to remove this. |
| 51 | 51 | ,findPNs, findEntity |
| 52 | 52 | ,sameOccurrence |
| 53 | | ,defines,definesTypeSig, isTypeSigOf, |
| | 53 | ,defines,definesTypeSig, isTypeSigOf |
| 54 | 54 | ,HasModName(hasModName), HasNameSpace(hasNameSpace) |
| 55 | 55 | |
| 56 | 56 | |
| … |
… |
|
| 64 | 64 | -- * Program transformation |
| 65 | 65 | -- ** Adding |
| 66 | 66 | ,addDecl ,addItemsToImport, addHiding, rmItemsFromImport, addItemsToExport |
| 67 | | ,addParamsToDecls, addGuardsToRhs, addImportDecl, duplicateDecl, moveDecl, |
| | 67 | ,addParamsToDecls, addGuardsToRhs, addImportDecl, duplicateDecl, moveDecl |
| 68 | 68 | -- ** Rmoving |
| 69 | | ,rmDecl, rmTypeSig, commentOutTypeSig, rmParams, |
| | 69 | ,rmDecl, rmTypeSig, commentOutTypeSig, rmParams |
| 70 | 70 | ,rmItemsFromExport, rmSubEntsFromExport, Delete(delete) |
| 71 | 71 | -- ** Updating |
| 72 | | ,Update(update), |
| | 72 | ,Update(update) |
| 73 | 73 | ,qualifyPName,rmQualifier,renamePN,replaceNameInPN,autoRenameLocalVar |
| 74 | 74 | |
| 75 | 75 | -- * Miscellous |
| … |
… |
|
| 89 | 89 | ,mkNewName, applyRefac, applyRefacToClientMods |
| 90 | 90 | |
| 91 | 91 | -- The following functions are not in the the API yet. |
| 92 | | ,getDeclToks, causeNameClashInExports, inRegion , ghead, glast, gfromJust, unmodified, prettyprint, |
| 93 | | getDeclAndToks |
| | 92 | ,getDeclToks, causeNameClashInExports, inRegion , ghead, glast, gfromJust, unmodified, prettyprint |
| | 93 | ,getDeclAndToks |
| 94 | 94 | ) |
| 95 | 95 | where |
| 96 | 96 | import Prelude hiding (putStr,putStrLn,writeFile,readFile) |
diff -ur HaRe_20012006_orig/refactorer/myghc--make HaRe_20012006/refactorer/myghc--make
|
old
|
new
|
|
| 7 | 7 | |
| 8 | 8 | case `uname` in |
| 9 | 9 | CYGWIN*) |
| 10 | | ghc --make $GHCFLAGS -cpp -ffi -fglasgow-exts -fallow-overlapping-instances -fallow-undecidable-instances -fno-monomorphism-restriction -package lang -package network -i${SRC_DIRS} -odir odir/$SYSTEM -hidir hidir/$SYSTEM -osuf o -hisuf hi $* |
| | 10 | ghc --make $GHCFLAGS -cpp -ffi -fglasgow-exts -fallow-overlapping-instances -fallow-undecidable-instances -fno-monomorphism-restriction -i${SRC_DIRS} -odir odir/$SYSTEM -hidir hidir/$SYSTEM -osuf o -hisuf hi $* |
| 11 | 11 | ;; |
| 12 | 12 | SunOS*) |
| 13 | | ghc --make $GHCFLAGS -cpp -ffi -fglasgow-exts -fallow-overlapping-instances -fallow-undecidable-instances -fno-monomorphism-restriction -package lang -package network -i${SRC_DIRS} -odir odir/$SYSTEM -hidir hidir/$SYSTEM -osuf o -hisuf hi $* |
| | 13 | ghc --make $GHCFLAGS -cpp -ffi -fglasgow-exts -fallow-overlapping-instances -fallow-undecidable-instances -fno-monomorphism-restriction -i${SRC_DIRS} -odir odir/$SYSTEM -hidir hidir/$SYSTEM -osuf o -hisuf hi $* |
| 14 | 14 | ;; |
| 15 | 15 | *) |
| 16 | 16 | # default case for unixish systems, confirmed for Mac OS X (10.2.6), Linux (Redhat, Mandrake) |
| 17 | | ghc --make $GHCFLAGS -cpp -fglasgow-exts -fallow-overlapping-instances -fallow-undecidable-instances -fno-monomorphism-restriction -package lang -package network -i${SRC_DIRS} -odir odir/$SYSTEM -hidir hidir/$SYSTEM -osuf o -hisuf hi $* |
| | 17 | ghc --make $GHCFLAGS -cpp -fglasgow-exts -fallow-overlapping-instances -fallow-undecidable-instances -fno-monomorphism-restriction -i${SRC_DIRS} -odir odir/$SYSTEM -hidir hidir/$SYSTEM -osuf o -hisuf hi $* |
| 18 | 18 | ;; |
| 19 | 19 | esac |
| 20 | 20 | |
diff -ur HaRe_20012006_orig/tools/base/Modules/Relations.lhs HaRe_20012006/tools/base/Modules/Relations.lhs
|
old
|
new
|
|
| 1 | 1 | >module Relations where |
| 2 | 2 | |
| 3 | | >#if __GLASGOW_HASKELL__ >= 604 |
| | 3 | #if __GLASGOW_HASKELL__ >= 604 |
| 4 | 4 | >import qualified Data.Map as M |
| 5 | 5 | >import qualified Data.Set as S |
| 6 | 6 | |
| … |
… |
|
| 18 | 18 | > add fmap (key,elt) = M.insertWith combiner key elt fmap |
| 19 | 19 | |
| 20 | 20 | >findWithDefault a k fm = M.findWithDefault a k fm |
| 21 | | >#else |
| | 21 | #else |
| 22 | 22 | >import qualified Data.FiniteMap as M |
| 23 | 23 | >import qualified Sets as S |
| 24 | 24 | |
| … |
… |
|
| 32 | 32 | >difference = S.minusSet |
| 33 | 33 | >addListTo_C combiner fm key_elt_pairs = M.addListToFM_C combiner fm key_elt_pairs |
| 34 | 34 | >findWithDefault a k fm = M.lookupWithDefaultFM fm a k |
| 35 | | >#endif |
| | 35 | #endif |
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | Relations |
diff -ur HaRe_20012006_orig/tools/base/TI/OrigTiMonad.hs HaRe_20012006/tools/base/TI/OrigTiMonad.hs
|
old
|
new
|
|
| 10 | 10 | (>:),freshInt |
| 11 | 11 | ) where |
| 12 | 12 | import Prelude hiding (lookup) -- for Hugs |
| 13 | | import Monad(MonadPlus(..)) |
| | 13 | --import Monad(MonadPlus(..)) |
| | 14 | import Control.Monad |
| | 15 | import Control.Monad.Error () -- instance for Either String |
| 14 | 16 | import HsIdent(HsIdentI) |
| 15 | 17 | import HsName(ModuleName,Id,noModule) |
| 16 | 18 | import TiTypes |
diff -ur HaRe_20012006_orig/tools/base/defs/UniqueNames.hs HaRe_20012006/tools/base/defs/UniqueNames.hs
|
old
|
new
|
|
| 76 | 76 | ppiOp (PN i n) = ppiOp i<>n |
| 77 | 77 | |
| 78 | 78 | instance Printable Orig where |
| 79 | | ppi (D n (N s)) = ppi (subnum n)<+>ppIfDebug ("«"<>s<>"»") |
| 80 | | ppi (S p) = ppIfDebug ("«"<>p<>"»") |
| 81 | | ppi (G m _ _) = ppIfDebug ("«"<>m<>"»") |
| 82 | | --ppi (Sn n (SrcLoc f r c)) = "«"<>r<>","<>c<>"»" |
| | 79 | ppi (D n (N s)) = ppi (subnum n)<+>ppIfDebug ("<<"<>s<>">>") |
| | 80 | ppi (S p) = ppIfDebug ("<<"<>p<>">>") |
| | 81 | ppi (G m _ _) = ppIfDebug ("<<"<>m<>">>") |
| | 82 | --ppi (Sn n (SrcLoc f r c)) = "<<"<>r<>","<>c<>">>" |
| 83 | 83 | ppi _ = empty |
| 84 | 84 | |
| 85 | 85 | subnum n = ppIfUnicode (subdigs (show n)) n |
diff -ur HaRe_20012006_orig/tools/base/parse2/SourceNames.hs HaRe_20012006/tools/base/parse2/SourceNames.hs
|
old
|
new
|
|
| 57 | 57 | --- |
| 58 | 58 | |
| 59 | 59 | instance Printable i => Printable (SN i) where |
| 60 | | ppi (SN n p) = ppi n<>ppIfDebug ("«"<>p<>"»") |
| 61 | | wrap (SN n p) = wrap n<>ppIfDebug ("«"<>p<>"»") |
| | 60 | ppi (SN n p) = ppi n<>ppIfDebug ("<<"<>p<>">>") |
| | 61 | wrap (SN n p) = wrap n<>ppIfDebug ("<<"<>p<>">>") |
| 62 | 62 | |
| 63 | 63 | -- positions ends up outside parenthesis... |
| 64 | 64 | |
| 65 | 65 | instance PrintableOp i => PrintableOp (SN i) where |
| 66 | 66 | isOp (SN n p) = isOp n |
| 67 | | ppiOp (SN n p) = ppiOp n<>ppIfDebug ("«"<>p<>"»") |
| | 67 | ppiOp (SN n p) = ppiOp n<>ppIfDebug ("<<"<>p<>">>") |
| 68 | 68 | |
| 69 | 69 | |
| 70 | 70 | hsName2modName (SN hs loc) = |