Commit 68d6230a authored by Michael Hanus 's avatar Michael Hanus

tools updated

parent b0c4e678
......@@ -8,12 +8,13 @@ cpm/src/CPM/ConfigPackage.curry
*_CACHE
optimize/.cpm/packages/cass-2.0.0
optimize/.cpm/packages/cass-analysis-2.0.0
optimize/.cpm/packages/flatcurry-2.0.0
optimize/.cpm/packages/csv-1.0.0
optimize/.cpm/packages/scc-0.0.1
optimize/.cpm/packages/xml-2.0.0
optimize/.cpm/packages/currypath-0.0.1
optimize/.cpm/packages/flatcurry-2.0.0
optimize/.cpm/packages/frontend-exec-0.0.1
optimize/.cpm/packages/propertyfile-0.0.1
optimize/.cpm/packages/scc-0.0.1
optimize/.cpm/packages/xml-2.0.0
# executables
cpm/src/CPM.Main
......
......@@ -12,8 +12,6 @@ module CPM.AbstractCurry
, applyModuleRenames
) where
import Distribution ( sysLibPath, inCurrySubdir, modNameToPath
, inCurrySubdirModule, lookupModuleSource )
import List ( intercalate, nub )
import FilePath ( (</>), (<.>), takeFileName, replaceExtension )
import System
......@@ -23,6 +21,8 @@ import AbstractCurry.Pretty ( showCProg )
import AbstractCurry.Select ( imports )
import AbstractCurry.Transform
import AbstractCurry.Types
import System.CurryPath ( sysLibPath, inCurrySubdir, modNameToPath
, inCurrySubdirModule, lookupModuleSource )
import System.FrontendExec ( FrontendTarget (..), FrontendParams (..)
, defaultParams, callFrontendWithParams
, setQuiet, setFullPath )
......
......@@ -20,10 +20,10 @@ import Function ( (***) )
import IOExts ( evalCmd )
import List ( split, splitOn, intersperse )
import Maybe ( mapMaybe )
import PropertyFile ( readPropertyFile )
import Read ( readInt )
import System.Path ( getFileInPath )
import Data.PropertyFile ( readPropertyFile )
import System.Path ( getFileInPath )
import CPM.ErrorLogger
import CPM.FileUtil ( ifFileExists )
......
......@@ -19,33 +19,33 @@ module CPM.Diff.Behavior
, findFunctionsToCompare
) where
import Char ( isAlphaNum )
import Directory ( createDirectory, doesDirectoryExist, getTemporaryDirectory )
import FilePath ( (</>), joinPath )
import Function ( both )
import List ( intercalate, intersect, nub, splitOn, isPrefixOf, isInfixOf
, find, delete, (\\), nubBy )
import Maybe ( isJust, fromJust, fromMaybe, listToMaybe )
import System ( getEnviron, setEnviron, unsetEnviron )
import AbstractCurry.Build
import AbstractCurry.Pretty ( defaultOptions, ppCTypeExpr, showCProg )
import AbstractCurry.Select ( publicFuncNames, funcName, functions, funcArity
, funcType, argTypes, typeName, types, tconsOfType
, resultType, isIOType, typeOfQualType )
, tconsArgsOfType, resultType, isIOType
, typeOfQualType )
import AbstractCurry.Transform (updCFuncDecl)
import AbstractCurry.Types ( CurryProg (..), CFuncDecl (..), CVisibility (..)
, CTypeExpr (..), CPattern (..), CExpr (..)
, CTypeDecl (..), CConsDecl (..), CFieldDecl (..)
, CVarIName, QName)
import Char (isAlphaNum)
import Directory (createDirectory, doesDirectoryExist, getTemporaryDirectory)
import Distribution (lookupModuleSource)
import FilePath ((</>), joinPath)
import Function (both)
import List ( intercalate, intersect, nub, splitOn, isPrefixOf, isInfixOf
, find, delete, (\\), nubBy )
import Maybe ( isJust, fromJust, fromMaybe, listToMaybe )
import System ( getEnviron, setEnviron, unsetEnviron )
import AbstractCurry.Select ( tconsArgsOfType )
import Analysis.Types ( Analysis )
import Analysis.ProgInfo ( ProgInfo, emptyProgInfo, combineProgInfo
, lookupProgInfo)
import Analysis.Termination ( productivityAnalysis, Productivity(..) )
import Analysis.TypeUsage ( typesInValuesAnalysis )
import CASS.Server ( analyzeGeneric )
import System.CurryPath ( lookupModuleSource )
import Text.Pretty ( pPrint, text, indent, vcat, (<+>), (<$$>) )
import CPM.AbstractCurry ( readAbstractCurryFromDeps, loadPathForPackage )
......
......@@ -10,7 +10,7 @@ import Directory ( doesFileExist, getAbsolutePath, doesDirectoryExist
, getCurrentDirectory, getDirectoryContents
, getModificationTime
, renameFile, removeFile, setCurrentDirectory )
import Distribution ( installDir, stripCurrySuffix, addCurrySubdir )
import Distribution ( installDir )
import Either
import FilePath ( (</>), splitSearchPath, replaceExtension, takeExtension
, pathSeparator, isPathSeparator )
......@@ -22,10 +22,11 @@ import Sort ( sortBy )
import System ( getArgs, getEnviron, setEnviron, unsetEnviron, exitWith
, system )
import Boxes ( table, render )
import Boxes ( table, render )
import OptParse
import System.Path ( fileInPath )
import Text.CSV ( showCSV )
import System.CurryPath ( addCurrySubdir, stripCurrySuffix )
import System.Path ( fileInPath )
import Text.CSV ( showCSV )
import CPM.ErrorLogger
import CPM.FileUtil ( joinSearchPath, safeReadFile, whenFileExists
......@@ -58,7 +59,7 @@ cpmBanner :: String
cpmBanner = unlines [bannerLine,bannerText,bannerLine]
where
bannerText =
"Curry Package Manager <curry-language.org/tools/cpm> (version of 23/11/2018)"
"Curry Package Manager <curry-language.org/tools/cpm> (version of 10/12/2018)"
bannerLine = take (length bannerText) (repeat '-')
main :: IO ()
......@@ -1116,7 +1117,7 @@ linkCmd (LinkOptions src) cfg =
getLocalPackageSpec cfg "." |>= \specDir ->
cleanCurryPathCache specDir |>
log Info ("Linking '" ++ src ++ "' into local package cache...") |>
linkToLocalCache src specDir
linkToLocalCache cfg src specDir
--- `add` command:
--- Option `--package`: copy the given package to the repository index
......
......@@ -12,10 +12,10 @@ module CPM.Package.Helpers
) where
import Directory
import Distribution ( addCurrySubdir )
import FilePath
import List ( splitOn, nub )
import System.CurryPath ( addCurrySubdir )
import Text.Pretty hiding ( (</>) )
import CPM.Config ( Config, homePackageDir )
......
......@@ -138,15 +138,19 @@ installLocalDependenciesWithRepo cfg repo dir pkgSpec =
succeedIO (pkgSpec, cpkgs)
--- Links a directory into the local package cache. Used for `cypm link`.
linkToLocalCache :: String -> String -> IO (ErrorLogger ())
linkToLocalCache src pkgDir = do
linkToLocalCache :: Config -> String -> String -> IO (ErrorLogger ())
linkToLocalCache cfg src pkgDir = do
dirExists <- doesDirectoryExist src
if dirExists
then loadPackageSpec src |>= \pkgSpec ->
LocalCache.createLink pkgDir src (packageId pkgSpec) True |>
succeedIO ()
else log Critical ("Directory '" ++ src ++ "' does not exist.") |>
succeedIO ()
getPackageVersion cfg (name pkgSpec) (version pkgSpec) >>=
maybe
(log Critical
("Package '" ++ packageId pkgSpec ++ "' not in repository!\n" ++
"Note: you can only link copies of existing packages."))
(\_ -> LocalCache.createLink pkgDir src (packageId pkgSpec) True |>
succeedIO ())
else log Critical ("Directory '" ++ src ++ "' does not exist.")
--- Resolves the dependencies for a package copy and fills the package caches.
resolveAndCopyDependencies :: Config -> Repository -> GC.GlobalCache -> String
......
......@@ -81,8 +81,9 @@ showConflict (ResolutionSuccess _ _) = "Resolution succeeded."
showConflict (ResolutionFailure t) = case findRelevantConflict t of
Just c -> showConflictState c
Nothing -> case missingPackages $ clState $ findDeepestNode t of
[] -> "Conflict resolution failed for an unknown reason :(\n" ++
"Please clean your package ('cypm clean') and try again..."
[] -> "Conflict resolution failed for an unknown reason... Hint:(\n" ++
"Please clean your package ('cypm clean') and/or\n" ++
"your package index ('cypm update') and try again..."
(d@(Dependency p _):_) ->
"There seems to be no version of package " ++ p ++
" that can satisfy the constraint " ++ showDependency d
......
......@@ -7,6 +7,8 @@
"license": "BSD-3-Clause",
"licenseFile": "LICENSE",
"dependencies": {
"base" : ">= 1.0.0, < 2.0.0",
"currypath" : ">= 0.0.1",
"frontend-exec" : ">= 0.0.1",
"wl-pprint" : ">= 0.0.1"
},
......
......@@ -7,19 +7,19 @@
--- extension `.acy` in the subdirectory `.curry`
---
--- @author Michael Hanus, Bjoern Peemoeller, Jan Tikovsky, Finn Teegen
--- @version November 2018
--- @version December 2018
-- ---------------------------------------------------------------------------
module AbstractCurry.Files where
import Char ( isSpace )
import Directory ( doesFileExist, getModificationTime )
import Distribution ( getLoadPathForModule, inCurrySubdir
, lookupModuleSourceInLoadPath, stripCurrySuffix )
import FileGoodies ( getFileInPath, lookupFileInPath )
import FilePath ( takeFileName, (</>), (<.>) )
import ReadShowTerm
import System.CurryPath ( getLoadPathForModule, inCurrySubdir
, lookupModuleSourceInLoadPath, stripCurrySuffix )
import System.FrontendExec
import AbstractCurry.Select ( imports )
......
......@@ -7,8 +7,10 @@
"license": "BSD-3-Clause",
"licenseFile": "LICENSE",
"dependencies": {
"flatcurry": ">= 2.0.0",
"scc" : ">= 0.0.1"
"base" : ">= 1.0.0, < 2.0.0",
"currypath" : ">= 0.0.1",
"flatcurry" : ">= 2.0.0",
"scc" : ">= 0.0.1"
},
"compilerCompatibility": {
"pakcs": ">= 2.0.0",
......
......@@ -3,23 +3,24 @@
--- persistently in files.
---
--- @author Heiko Hoffmann, Michael Hanus
--- @version March 2017
--- @version December 2018
--------------------------------------------------------------------------
module Analysis.Files where
import Directory
import Distribution ( installDir, lookupModuleSourceInLoadPath
, stripCurrySuffix )
import FlatCurry.Files
import FlatCurry.Goodies (progImports)
import FlatCurry.Types (Prog, QName)
import Distribution ( installDir )
import FilePath
import List (isPrefixOf, isSuffixOf)
import ReadShowTerm (readQTerm, showQTerm)
import Time (ClockTime)
import List ( isPrefixOf, isSuffixOf )
import ReadShowTerm ( readQTerm, showQTerm )
import Time ( ClockTime )
import FlatCurry.Files
import FlatCurry.Goodies ( progImports )
import FlatCurry.Types ( Prog, QName )
import System.CurryPath ( lookupModuleSourceInLoadPath, stripCurrySuffix )
import Analysis.Logging (debugMessage)
import Analysis.Logging ( debugMessage )
import Analysis.ProgInfo
......
--- Analyzing the residuation behavior of a module and returns
--- some statistical information.
import List ( intercalate, partition )
import FlatCurry.Types ( QName )
import CASS.Server ( analyzeGeneric )
import Analysis.ProgInfo ( progInfo2Lists )
import Analysis.Residuation -- ( demandAnalysis )
residuationInfoOf :: String
-> IO ([(QName,ResiduationInfo)],[(QName,ResiduationInfo)])
residuationInfoOf modname = do
analyzeGeneric residuationAnalysis modname
>>= return . either progInfo2Lists error
countResOps :: String -> IO [String]
countResOps mname = do
putStrLn $ "Analyzing module " ++ mname ++ "..."
(pubres,privres) <- residuationInfoOf mname
let (resops,nonresops) = partition (\(_,i) -> i==MayResiduate || i==NoResInfo)
(pubres ++ privres)
return [mname, show (length resops), show (length nonresops)]
printCountResOps :: [String] -> IO ()
printCountResOps mname = do
stats <- mapIO countResOps mname
putStrLn $ "Module | Residuating | Non-residuating"
mapIO_ (\row -> putStrLn (intercalate "|" row)) stats
main :: IO ()
main = printCountResOps baseModules
baseModules :: [String]
baseModules = ["Prelude","List","Char"]
allBaseModules :: [String]
allBaseModules =
["AllSolutions"
,"AnsiCodes"
,"Char"
,"Combinatorial"
,"CPNS"
,"Debug"
,"Dequeue"
,"Directory"
,"Distribution"
,"Either"
,"ErrorState"
,"FileGoodies"
,"FilePath"
,"Findall"
,"FiniteMap"
,"Float"
,"Format"
,"Function"
,"FunctionInversion"
,"GetOpt"
,"Global"
,"Integer"
,"IO"
,"IOExts"
,"List"
,"Maybe"
,"NamedSocket"
,"Nat"
,"Prelude"
,"Profile"
,"PropertyFile"
,"Random"
,"Read"
,"ReadNumeric"
,"ReadShowTerm"
,"RedBlackTree"
,"SearchTree"
,"SearchTreeGenerators"
,"SearchTreeTraversal"
,"SetFunctions"
,"SetRBT"
,"ShowS"
,"Socket"
,"Sort"
,"State"
,"System"
,"TableRBT"
,"Time"
,"Traversal"
,"Unsafe"
,"ValueSequence"
]
\ No newline at end of file
......@@ -7,10 +7,13 @@
"license": "BSD-3-Clause",
"licenseFile": "LICENSE",
"dependencies": {
"cass-analysis": ">= 2.0.0",
"flatcurry" : ">= 2.0.0",
"scc" : ">= 0.0.1",
"xml" : ">= 2.0.0"
"base" : ">= 1.0.0, < 2.0.0",
"cass-analysis" : ">= 2.0.0",
"currypath" : ">= 0.0.1",
"flatcurry" : ">= 2.0.0",
"propertyfile" : ">= 0.0.1",
"scc" : ">= 0.0.1",
"xml" : ">= 2.0.0"
},
"compilerCompatibility": {
"pakcs": ">= 2.0.0",
......
......@@ -6,7 +6,7 @@
--- the analysis server (which is implicitly started if necessary).
---
--- @author Michael Hanus
--- @version September 2018
--- @version December 2018
--------------------------------------------------------------------------
module CASS.Configuration
......@@ -17,19 +17,19 @@ module CASS.Configuration
, getDefaultPath, waitTime, numberOfWorkers
) where
import System
import Distribution (curryCompiler)
import PropertyFile
import ReadNumeric
import FilePath (FilePath, (</>), (<.>))
import Char ( isSpace )
import Directory
import ReadShowTerm
import Sort (mergeSort)
import Distribution ( curryCompiler )
import FilePath ( FilePath, (</>), (<.>) )
import Global
import Char (isSpace)
import ReadNumeric
import ReadShowTerm
import Sort ( mergeSort )
import System
import Analysis.Logging (debugMessage, setDebugLevel)
import CASS.PackageConfig (packagePath, packageExecutable, packageVersion)
import Analysis.Logging ( debugMessage, setDebugLevel )
import CASS.PackageConfig ( packagePath, packageExecutable, packageVersion )
import Data.PropertyFile ( readPropertyFile, updatePropertyFile )
systemBanner :: String
systemBanner =
......
......@@ -2,28 +2,28 @@
--- This is the main module to start the executable of the analysis system.
---
--- @author Michael Hanus
--- @version March 2017
--- @version December 2018
--------------------------------------------------------------------------
module CASS.Main(main) where
module CASS.Main ( main ) where
import Char (toLower)
import Distribution (stripCurrySuffix)
import FilePath ((</>), (<.>))
import Char ( toLower )
import FilePath ( (</>), (<.>) )
import GetOpt
import List (isPrefixOf)
import ReadNumeric (readNat)
import ReadShowTerm (readQTerm)
import Sort (sort)
import System (exitWith,getArgs)
import List ( isPrefixOf )
import ReadNumeric ( readNat )
import ReadShowTerm ( readQTerm )
import Sort ( sort )
import System ( exitWith, getArgs )
import Analysis.Files (deleteAllAnalysisFiles)
import Analysis.Logging (debugMessage)
import CASS.Doc (getAnalysisDoc)
import Analysis.Files ( deleteAllAnalysisFiles )
import Analysis.Logging ( debugMessage )
import CASS.Doc ( getAnalysisDoc )
import CASS.Server
import CASS.Configuration
import CASS.Registry
import CASS.Worker (startWorker)
import CASS.Worker ( startWorker )
import System.CurryPath ( stripCurrySuffix )
--- Main function to start the analysis system.
--- With option -s or --server, the server is started on a socket.
......
Copyright (c) 2018, Michael Hanus
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the names of the copyright holders nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
currypath
=========
This package provides the library `System.CurryPath` which contains
operations to deal with module names and paths used in a Curry system,
like finding a module in the standard load path.
{
"name": "currypath",
"version": "0.0.1",
"author": "Michael Hanus <mh@informatik.uni-kiel.de>",
"synopsis": "Operations to deal with Curry module names and paths",
"category": [ "System" ],
"license": "BSD-3-Clause",
"licenseFile": "LICENSE",
"dependencies": {
"base" : ">= 1.0.0, < 2.0.0",
"propertyfile": ">= 0.0.1"
},
"compilerCompatibility": {
"pakcs": ">= 2.0.0",
"kics2": ">= 2.0.0"
},
"exportedModules": [ "System.CurryPath" ],
"source": {
"git": "https://git.ps.informatik.uni-kiel.de/curry-packages/currypath.git",
"tag": "$version"
}
}
------------------------------------------------------------------------------
--- This module contains operations related to module names and paths
--- used in Curry system.
---
--- @author Bernd Brassel, Michael Hanus, Bjoern Peemoeller, Finn Teegen
--- @version December 2018
------------------------------------------------------------------------------
module System.CurryPath
( ModuleIdent
, splitModuleFileName, splitModuleIdentifiers , joinModuleIdentifiers
, stripCurrySuffix
, ModulePath, modNameToPath
, currySubdir, inCurrySubdir, inCurrySubdirModule, addCurrySubdir
, sysLibPath, getLoadPathForModule
, lookupModuleSourceInLoadPath, lookupModuleSource
) where
import Char ( toLower )
import Directory ( doesFileExist )
import Distribution ( curryCompiler, installDir, rcFileName )
import FileGoodies ( fileSuffix, stripSuffix )
import FilePath ( FilePath, (</>), (<.>), addTrailingPathSeparator
, dropFileName, joinPath, splitDirectories
, splitExtension, splitFileName, splitSearchPath
, takeFileName
)
import List ( split )
import System ( getEnviron, system )
import Data.PropertyFile ( getPropertyFromFile )
-----------------------------------------------------------
--- Functions for handling file names of Curry modules
-----------------------------------------------------------
type ModuleIdent = String
--- Split the `FilePath` of a module into the directory prefix and the
--- `FilePath` corresponding to the module name.
--- For instance, the call `splitModuleFileName "Data.Set" "lib/Data/Set.curry"`
--- evaluates to `("lib", "Data/Set.curry")`.
--- This can be useful to compute output directories while retaining the
--- hierarchical module structure.
splitModuleFileName :: ModuleIdent -> FilePath -> (FilePath, FilePath)
splitModuleFileName mid fn = case splitModuleIdentifiers mid of
[_] -> splitFileName fn
ms -> let (base, ext) = splitExtension fn
dirs = splitDirectories base
(pre , suf) = splitAt (length dirs - length ms) dirs
path = if null pre then ""
else addTrailingPathSeparator (joinPath pre)
in (path, joinPath suf <.> ext)
--- Split up the components of a module identifier. For instance,
--- `splitModuleIdentifiers "Data.Set"` evaluates to `["Data", "Set"]`.
splitModuleIdentifiers :: ModuleIdent -> [String]
splitModuleIdentifiers = split (=='.')
--- Join the components of a module identifier. For instance,
--- `joinModuleIdentifiers ["Data", "Set"]` evaluates to `"Data.Set"`.
joinModuleIdentifiers :: [String] -> ModuleIdent
joinModuleIdentifiers = foldr1 combine
where combine xs ys = xs ++ '.' : ys
--- Strips the suffix ".curry" or ".lcurry" from a file name.
stripCurrySuffix :: String -> String
stripCurrySuffix s =
if fileSuffix s `elem` ["curry","lcurry"]
then stripSuffix s
else s
--- A module path consists of a directory prefix (which can be omitted)
--- and a module name (which can be hierarchical). For instance, the
--- following strings are module paths in Unix-based systems:
---
--- HTML
--- Data.Number.Int
--- curry/Data.Number.Int
type ModulePath = String
--- Transforms a hierarchical module name into a path name, i.e.,
--- replace the dots in the name by directory separator chars.
modNameToPath :: ModuleIdent -> String
modNameToPath = foldr1 (</>) . split (=='.')
--- Name of the sub directory where auxiliary files (.fint, .fcy, etc)
--- are stored.
currySubdir :: FilePath