Commit 1169979f by Michael Hanus

### Tools updated

parent 5a5d0e87
 ... @@ -10,6 +10,7 @@ optimize/.cpm/packages/cass-2.0.0 ... @@ -10,6 +10,7 @@ optimize/.cpm/packages/cass-2.0.0 optimize/.cpm/packages/cass-analysis-2.0.0 optimize/.cpm/packages/cass-analysis-2.0.0 optimize/.cpm/packages/csv-1.0.0 optimize/.cpm/packages/csv-1.0.0 optimize/.cpm/packages/currypath-0.0.1 optimize/.cpm/packages/currypath-0.0.1 optimize/.cpm/packages/finite-map-0.0.1 optimize/.cpm/packages/flatcurry-2.0.0 optimize/.cpm/packages/flatcurry-2.0.0 optimize/.cpm/packages/frontend-exec-0.0.1 optimize/.cpm/packages/frontend-exec-0.0.1 optimize/.cpm/packages/propertyfile-0.0.1 optimize/.cpm/packages/propertyfile-0.0.1 ... ...
 ------------------------------------------------------------------------------ --- Library defining natural numbers in Peano representation and --- some operations on this representation. --- --- @author Michael Hanus --- @version May 2017 --- @category general ------------------------------------------------------------------------------ module Nat ( Nat(..), fromNat, toNat, add, sub, mul, leq ) where --- Natural numbers defined in Peano representation. data Nat = Z | S Nat deriving (Eq,Show) --- Transforms a natural number into a standard integer. fromNat :: Nat -> Int fromNat Z = 0 fromNat (S n) = 1 + fromNat n --- Transforms a standard integer into a natural number. toNat :: Int -> Nat toNat n | n == 0 = Z | n > 0 = S (toNat (n-1)) --- Addition on natural numbers. add :: Nat -> Nat -> Nat add Z n = n add (S m) n = S(add m n) --- Subtraction defined by reversing addition. sub :: Nat -> Nat -> Nat sub x y | add y z == x = z where z free --- Multiplication on natural numbers. mul :: Nat -> Nat -> Nat mul Z _ = Z mul (S m) n = add n (mul m n) -- less-or-equal predicated on natural numbers: leq :: Nat -> Nat -> Bool leq Z _ = True leq (S _) Z = False leq (S x) (S y) = leq x y
 ... @@ -32,8 +32,10 @@ readAndTestEqualFcy mod = do ... @@ -32,8 +32,10 @@ readAndTestEqualFcy mod = do renameFile modbak modcurry renameFile modbak modcurry let abstractequal = prog1 == prog2 let abstractequal = prog1 == prog2 unless abstractequal \$ do unless abstractequal \$ do putStrLn \$ "Original AbstractCurry program: " ++ show prog1 putStrLn \$ unlines putStrLn \$ "Pretty printed AbstractCurry program: " ++ show prog2 [ "Differences in programs occurred:" , "Original AbstractCurry program:", show prog1 , "Pretty printed AbstractCurry program:", show prog2 ] return abstractequal return abstractequal -- Strictly read a AbstractCurry program in order to avoid race conditions -- Strictly read a AbstractCurry program in order to avoid race conditions ... @@ -47,4 +49,4 @@ testAbstractCurryPretty_rev = ... @@ -47,4 +49,4 @@ testAbstractCurryPretty_rev = (readAndTestEqualFcy "Rev") `returns` True (readAndTestEqualFcy "Rev") `returns` True testAbstractCurryPretty_TestAbstractCurry = testAbstractCurryPretty_TestAbstractCurry = (readAndTestEqualFcy "TestAbstractCurry") `returns` True (readAndTestEqualFcy "Nat") `returns` True
 ... @@ -9,6 +9,7 @@ ... @@ -9,6 +9,7 @@ "dependencies": { "dependencies": { "base" : ">= 1.0.0, < 2.0.0", "base" : ">= 1.0.0, < 2.0.0", "currypath" : ">= 0.0.1", "currypath" : ">= 0.0.1", "finite-map": ">= 0.0.1", "flatcurry" : ">= 2.0.0", "flatcurry" : ">= 2.0.0", "scc" : ">= 0.0.1" "scc" : ">= 0.0.1" }, }, ... ...
 ... @@ -2,7 +2,7 @@ ... @@ -2,7 +2,7 @@ --- This module defines a datatype to represent the analysis information. --- This module defines a datatype to represent the analysis information. --- --- --- @author Heiko Hoffmann, Michael Hanus --- @author Heiko Hoffmann, Michael Hanus --- @version January 2015 --- @version January 2019 ----------------------------------------------------------------------- ----------------------------------------------------------------------- module Analysis.ProgInfo module Analysis.ProgInfo ... @@ -14,8 +14,9 @@ module Analysis.ProgInfo ... @@ -14,8 +14,9 @@ module Analysis.ProgInfo ) where ) where import Directory (removeFile) import Directory (removeFile) import FiniteMap import FilePath ((<.>)) import FilePath ((<.>)) import Data.FiniteMap import FlatCurry.Types import FlatCurry.Types import XML import XML ... ...
 ... @@ -10,6 +10,7 @@ ... @@ -10,6 +10,7 @@ "base" : ">= 1.0.0, < 2.0.0", "base" : ">= 1.0.0, < 2.0.0", "cass-analysis" : ">= 2.0.0", "cass-analysis" : ">= 2.0.0", "currypath" : ">= 0.0.1", "currypath" : ">= 0.0.1", "finite-map" : ">= 0.0.1", "flatcurry" : ">= 2.0.0", "flatcurry" : ">= 2.0.0", "propertyfile" : ">= 0.0.1", "propertyfile" : ">= 0.0.1", "redblacktree" : ">= 0.0.1", "redblacktree" : ">= 0.0.1", ... ...
 ... @@ -3,12 +3,11 @@ ... @@ -3,12 +3,11 @@ --- In particular, it contains some simple fixpoint computations. --- In particular, it contains some simple fixpoint computations. --- --- --- @author Heiko Hoffmann, Michael Hanus --- @author Heiko Hoffmann, Michael Hanus --- @version December 2018 --- @version January 2019 -------------------------------------------------------------------------- -------------------------------------------------------------------------- module CASS.WorkerFunctions where module CASS.WorkerFunctions where import FiniteMap import IOExts import IOExts import List ( partition ) import List ( partition ) import Maybe ( fromJust ) import Maybe ( fromJust ) ... @@ -21,6 +20,7 @@ import Analysis.Types ( Analysis(..), isSimpleAnalysis, isCombinedAnalysis ... @@ -21,6 +20,7 @@ import Analysis.Types ( Analysis(..), isSimpleAnalysis, isCombinedAnalysis import Analysis.ProgInfo ( ProgInfo, combineProgInfo, emptyProgInfo import Analysis.ProgInfo ( ProgInfo, combineProgInfo, emptyProgInfo , publicProgInfo, lookupProgInfo, lists2ProgInfo , publicProgInfo, lookupProgInfo, lists2ProgInfo , equalProgInfo, publicListFromProgInfo, showProgInfo ) , equalProgInfo, publicListFromProgInfo, showProgInfo ) import Data.FiniteMap import FlatCurry.Types import FlatCurry.Types import FlatCurry.Files import FlatCurry.Files import FlatCurry.Goodies import FlatCurry.Goodies ... ...
 Copyright (c) 2019, 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.
 finite-map ========== This package contains the library `Data.Map` implementing finite maps, i.e., efficient purely functional data structures to store a mapping from keys to values. For compatibility reason, it also contains an old but deprecated library `Data.FiniteMap`.
 { "name": "finite-map", "version": "0.0.1", "author": "Michael Hanus ", "synopsis": "Library implementing finite maps (efficient mappings from keys to values)", "category": [ "Data" ], "license": "BSD-3-Clause", "licenseFile": "LICENSE", "dependencies": { "base" : ">= 1.0.0, < 2.0.0", "random" : ">= 0.0.1" }, "compilerCompatibility": { "pakcs": ">= 2.0.0", "kics2": ">= 2.0.0" }, "exportedModules": [ "Data.Map", "Data.FiniteMap" ], "testsuite": [ { "src-dir": "src", "modules": [ "Data.Map", "Data.FiniteMap" ] }, { "src-dir": "test", "modules": [ "TestFiniteMap" ] } ], "source": { "git": "https://git.ps.informatik.uni-kiel.de/curry-packages/finite-map.git", "tag": "\$version" } }
This diff is collapsed.
This diff is collapsed.
 import List import Sort import Maybe import System.Random import Test.Prop import Data.FiniteMap fm f = f . (listToFM (<)) . map (\x ->(x,x)) fms f = map fst . fmToList . fm f fms' f = map snd . fmToList . fm f so f = spnub . mergeSortBy (<) . f testAddToFM = eq (fms (\x-> addToFM x 73 73)) (so (73:)) testDelFromFM = test (\nums -> fms (flip delListFromFM (take 500 nums)) nums == so (drop 500) nums) testPlusFM = test (\nums -> let l=length nums (xs,ys) = splitAt (div l 2) nums in (map fst \$ fmToList \$ plusFM (fm id xs) (fm id ys)) == so id nums) testMinusFM = test (\nums -> let l = length nums (xs,ys) = splitAt (div l 2) nums in (map fst \$ fmToList \$ minusFM (fm id nums) (fm id ys)) == so id xs) testIntersectFM = test (\nums -> let l=length nums (_,ys) = splitAt (div l 2) nums in (map fst \$ fmToList \$ intersectFM (fm id nums) (fm id ys)) == so id ys) testFoldFM = eq (fm (foldFM (\x _ z->x+z) 0)) (foldl (+) 0) testMapFM = eq (fms' (mapFM (\_ z->z+1))) (so (map (+1))) testFilterFM = eq (fms (filterFM (\x _->x>0))) (so (filter (>0))) testSizeFM = eq (fm sizeFM) length testEqFM = test (\nums -> let l=length nums (xs,ys) = splitAt (div l 2) nums in eqFM (fm id nums) (fm id (ys++xs))) testElemFM_LookupFM = eq (fm (\x-> elemFM 73 (addToFM x 73 73))) (const True) testKeysFM_eltsFM = test (\nums -> let finm=fm id nums in unzip (fmToList finm)==(keysFM finm, eltsFM finm)) testFmSortBy = eq (fmSortBy (<)) (so id) testMinFM_MaxFM = eq (fm (\finm -> (fst \$ fromJust \$ minFM finm, fst \$ fromJust \$ maxFM finm))) ((\l->(head l,last l)) .so id) testUpdFM = eq (fm (\x-> lookupFM (updFM (addToFM x 73 73) 73 (+7)) 73)) (const \$ Just 80) spnub [] = [] spnub [x] = [x] spnub (x:y:xs) = if x==y then spnub (y:xs) else x:spnub (y:xs) ------------------------------------------------------------------------------ -- Random test: --- Tests a given predicate on a list of distinct random numbers. --- In case of a failure, the list of random numbers is returned --- in order to see the test cases in the CurryTest tool. test :: ([Int] -> Bool) -> PropIO test f = (rndList lenRnds >>= \xs -> return (if f xs then Nothing else Just xs)) `returns` Nothing --- Tests whether two operations return equal results --- on a list of distinct random numbers. --- In case of a failure, the list of random numbers is returned --- in order to see the test cases in the CurryTest tool. eq :: Eq a => ([Int] -> a) -> ([Int] -> a) -> PropIO eq f g = test (\x -> (f x)==(g x)) --- generate a list of at most n random numbers (without duplicated elements) rndList :: Int -> IO [Int] rndList n = getRandomSeed >>= return . nub . take n . (flip nextIntRange 100000) --- maximal length of test lists lenRnds :: Int lenRnds = 1000 ------------------------------------------------------------------------------
 ... @@ -61,6 +61,9 @@ cd .cpm/packages ... @@ -61,6 +61,9 @@ cd .cpm/packages PKGV=`ls -d currypath-*` PKGV=`ls -d currypath-*` mv \$PKGV currypath mv \$PKGV currypath ln -s currypath \$PKGV ln -s currypath \$PKGV PKGV=`ls -d finite-map-*` mv \$PKGV finite-map ln -s finite-map \$PKGV PKGV=`ls -d propertyfile-*` PKGV=`ls -d propertyfile-*` mv \$PKGV propertyfile mv \$PKGV propertyfile ln -s propertyfile \$PKGV ln -s propertyfile \$PKGV ... ...
 ... @@ -9,6 +9,7 @@ ... @@ -9,6 +9,7 @@ "dependencies": { "dependencies": { "base" : ">= 1.0.0, < 2.0.0", "base" : ">= 1.0.0, < 2.0.0", "currypath" : ">= 0.0.1", "currypath" : ">= 0.0.1", "finite-map": ">= 0.0.1", "flatcurry" : ">= 2.0.0", "flatcurry" : ">= 2.0.0", "scc" : ">= 0.0.1" "scc" : ">= 0.0.1" }, }, ... ...
 ... @@ -2,7 +2,7 @@ ... @@ -2,7 +2,7 @@ --- This module defines a datatype to represent the analysis information. --- This module defines a datatype to represent the analysis information. --- --- --- @author Heiko Hoffmann, Michael Hanus --- @author Heiko Hoffmann, Michael Hanus --- @version January 2015 --- @version January 2019 ----------------------------------------------------------------------- ----------------------------------------------------------------------- module Analysis.ProgInfo module Analysis.ProgInfo ... @@ -14,8 +14,9 @@ module Analysis.ProgInfo ... @@ -14,8 +14,9 @@ module Analysis.ProgInfo ) where ) where import Directory (removeFile) import Directory (removeFile) import FiniteMap import FilePath ((<.>)) import FilePath ((<.>)) import Data.FiniteMap import FlatCurry.Types import FlatCurry.Types import XML import XML ... ...
 ... @@ -10,6 +10,7 @@ ... @@ -10,6 +10,7 @@ "base" : ">= 1.0.0, < 2.0.0", "base" : ">= 1.0.0, < 2.0.0", "cass-analysis" : ">= 2.0.0", "cass-analysis" : ">= 2.0.0", "currypath" : ">= 0.0.1", "currypath" : ">= 0.0.1", "finite-map" : ">= 0.0.1", "flatcurry" : ">= 2.0.0", "flatcurry" : ">= 2.0.0", "propertyfile" : ">= 0.0.1", "propertyfile" : ">= 0.0.1", "redblacktree" : ">= 0.0.1", "redblacktree" : ">= 0.0.1", ... ...
 ... @@ -3,12 +3,11 @@ ... @@ -3,12 +3,11 @@ --- In particular, it contains some simple fixpoint computations. --- In particular, it contains some simple fixpoint computations. --- --- --- @author Heiko Hoffmann, Michael Hanus --- @author Heiko Hoffmann, Michael Hanus --- @version December 2018 --- @version January 2019 -------------------------------------------------------------------------- -------------------------------------------------------------------------- module CASS.WorkerFunctions where module CASS.WorkerFunctions where import FiniteMap import IOExts import IOExts import List ( partition ) import List ( partition ) import Maybe ( fromJust ) import Maybe ( fromJust ) ... @@ -21,6 +20,7 @@ import Analysis.Types ( Analysis(..), isSimpleAnalysis, isCombinedAnalysis ... @@ -21,6 +20,7 @@ import Analysis.Types ( Analysis(..), isSimpleAnalysis, isCombinedAnalysis import Analysis.ProgInfo ( ProgInfo, combineProgInfo, emptyProgInfo import Analysis.ProgInfo ( ProgInfo, combineProgInfo, emptyProgInfo , publicProgInfo, lookupProgInfo, lists2ProgInfo , publicProgInfo, lookupProgInfo, lists2ProgInfo , equalProgInfo, publicListFromProgInfo, showProgInfo ) , equalProgInfo, publicListFromProgInfo, showProgInfo ) import Data.FiniteMap import FlatCurry.Types import FlatCurry.Types import FlatCurry.Files import FlatCurry.Files import FlatCurry.Goodies import FlatCurry.Goodies ... ...
 Copyright (c) 2019, 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.
 finite-map ========== This package contains the library `Data.Map` implementing finite maps, i.e., efficient purely functional data structures to store a mapping from keys to values. For compatibility reason, it also contains an old but deprecated library `Data.FiniteMap`.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!