Commit a5b5638c authored by Michael Hanus 's avatar Michael Hanus
Browse files

Tools updated

parent a99b599d
......@@ -17,6 +17,7 @@ currypp/.cpm/packages/currycheck-2.0.0
currypp/.cpm/packages/rewriting-2.0.0
currypp/.cpm/packages/abstract-curry-2.0.0
currypp/.cpm/packages/flatcurry-2.0.0
currypp/.cpm/packages/html-2.0.0
currypp/.cpm/packages/xml-2.0.0
optimize/.cpm/packages/cass-2.0.0
optimize/.cpm/packages/cass-analysis-2.0.0
......
......@@ -18,5 +18,9 @@
"source": {
"git": "https://git.ps.informatik.uni-kiel.de/curry-packages/abstract-curry.git",
"tag": "$version"
},
"testsuite": {
"src-dir": "test",
"modules": [ "TestAbstractCurry" ]
}
}
-- Concatenating two lists:
-- (predefined as `++' in the standard prelude)
append :: [t] -> [t] -> [t]
append [] x = x
append (x:xs) ys = x : append xs ys
-- Reverse the order of elements in a list:
rev :: [t] -> [t]
rev [] = []
rev (x:xs) = append (rev xs) [x]
goal1 = append [1,2] [3,4]
goal2 = rev [1,2,3,4]
-- end of program
------------------------------------------------------------------------------
--- Some tests for AbstractCurry libraries.
---
--- To run all tests automatically by the currycheck tool, use the command:
--- "curry-check testAbstractCurry"
---
--- @author Michael Hanus
--- @version September 2017
------------------------------------------------------------------------------
import AbstractCurry.Files
import AbstractCurry.Pretty
import AbstractCurry.Types
import Directory
import Test.EasyCheck
--- Test for equality of an AbstractCurry program with the same program
--- after pretty printing and reading this AbstractCurry program:
readAndTestEqualFcy :: String -> IO Bool
readAndTestEqualFcy mod = do
prog1 <- readAbstractCurryStrict mod
let modcurry = mod ++ ".curry"
modbak = mod ++ ".BAK"
renameFile modcurry modbak
copyFile modbak modcurry
let modpp = mod ++ ".PP"
readCurry mod >>= writeFile modpp . showCProg
removeFile modcurry
renameFile modpp modcurry
prog2 <- readAbstractCurryStrict mod
removeFile modcurry
renameFile modbak modcurry
let abstractequal = prog1 == prog2
unless abstractequal $ do
putStrLn $ "Original AbstractCurry program: " ++ show prog1
putStrLn $ "Pretty printed AbstractCurry program: " ++ show prog2
return abstractequal
-- Strictly read a AbstractCurry program in order to avoid race conditions
-- due to copying/moving source files:
readAbstractCurryStrict :: String -> IO CurryProg
readAbstractCurryStrict mod = do
prog <- readCurry mod
id $!! prog `seq` return prog
testAbstractCurryPretty_rev =
(readAndTestEqualFcy "Rev") `returns` True
testAbstractCurryPretty_TestAbstractCurry =
(readAndTestEqualFcy "TestAbstractCurry") `returns` True
......@@ -24,6 +24,6 @@
},
"testsuite": {
"src-dir": "test",
"modules": [ "testFlatCurryXML" ]
"modules": [ "TestFlatCurryGoodies", "TestFlatCurryXML" ]
}
}
--- Some tests for library FlatCurry.Goodies.
---
--- To run all tests automatically by the currycheck tool, use the command:
--- "curry check TestFlatCurryGoodies"
---
--- @author Sebastian Fischer
import FlatCurry.Types
import FlatCurry.Files
import FlatCurry.Goodies
import Test.EasyCheck
testIdentityTransformation = identity `returns` True
identity = do
prog <- readFlatCurry "TestFlatCurryGoodies"
return (prog == idProg prog)
idProg = trProg prog
where
prog name imps types funcs ops
= Prog name imps (map idType types) (map idFunc funcs) (map idOp ops)
idType = trType typ typesyn
where
typ name vis params cs = Type name vis params (map idCons cs)
typesyn name vis params syn = TypeSyn name vis params (idTypeExpr syn)
idCons = trCons cons
where
cons name arity vis args = Cons name arity vis (map idTypeExpr args)
idTypeExpr = trTypeExpr TVar TCons FuncType ForallType
idFunc = trFunc func
where
func name arity vis t rule = Func name arity vis (idTypeExpr t) (idRule rule)
idRule = trRule rule External
where
rule args exp = Rule args (idExpr exp)
idExpr = trExpr Var Lit Comb Let Free Or Case Branch Typed
idOp = trOp Op
......@@ -18,5 +18,9 @@
"source": {
"git": "https://git.ps.informatik.uni-kiel.de/curry-packages/abstract-curry.git",
"tag": "$version"
},
"testsuite": {
"src-dir": "test",
"modules": [ "TestAbstractCurry" ]
}
}
-- Concatenating two lists:
-- (predefined as `++' in the standard prelude)
append :: [t] -> [t] -> [t]
append [] x = x
append (x:xs) ys = x : append xs ys
-- Reverse the order of elements in a list:
rev :: [t] -> [t]
rev [] = []
rev (x:xs) = append (rev xs) [x]
goal1 = append [1,2] [3,4]
goal2 = rev [1,2,3,4]
-- end of program
------------------------------------------------------------------------------
--- Some tests for AbstractCurry libraries.
---
--- To run all tests automatically by the currycheck tool, use the command:
--- "curry-check testAbstractCurry"
---
--- @author Michael Hanus
--- @version September 2017
------------------------------------------------------------------------------
import AbstractCurry.Files
import AbstractCurry.Pretty
import AbstractCurry.Types
import Directory
import Test.EasyCheck
--- Test for equality of an AbstractCurry program with the same program
--- after pretty printing and reading this AbstractCurry program:
readAndTestEqualFcy :: String -> IO Bool
readAndTestEqualFcy mod = do
prog1 <- readAbstractCurryStrict mod
let modcurry = mod ++ ".curry"
modbak = mod ++ ".BAK"
renameFile modcurry modbak
copyFile modbak modcurry
let modpp = mod ++ ".PP"
readCurry mod >>= writeFile modpp . showCProg
removeFile modcurry
renameFile modpp modcurry
prog2 <- readAbstractCurryStrict mod
removeFile modcurry
renameFile modbak modcurry
let abstractequal = prog1 == prog2
unless abstractequal $ do
putStrLn $ "Original AbstractCurry program: " ++ show prog1
putStrLn $ "Pretty printed AbstractCurry program: " ++ show prog2
return abstractequal
-- Strictly read a AbstractCurry program in order to avoid race conditions
-- due to copying/moving source files:
readAbstractCurryStrict :: String -> IO CurryProg
readAbstractCurryStrict mod = do
prog <- readCurry mod
id $!! prog `seq` return prog
testAbstractCurryPretty_rev =
(readAndTestEqualFcy "Rev") `returns` True
testAbstractCurryPretty_TestAbstractCurry =
(readAndTestEqualFcy "TestAbstractCurry") `returns` True
......@@ -24,6 +24,6 @@
},
"testsuite": {
"src-dir": "test",
"modules": [ "testFlatCurryXML" ]
"modules": [ "TestFlatCurryGoodies", "TestFlatCurryXML" ]
}
}
--- Some tests for library FlatCurry.Goodies.
---
--- To run all tests automatically by the currycheck tool, use the command:
--- "curry check TestFlatCurryGoodies"
---
--- @author Sebastian Fischer
import FlatCurry.Types
import FlatCurry.Files
import FlatCurry.Goodies
import Test.EasyCheck
testIdentityTransformation = identity `returns` True
identity = do
prog <- readFlatCurry "TestFlatCurryGoodies"
return (prog == idProg prog)
idProg = trProg prog
where
prog name imps types funcs ops
= Prog name imps (map idType types) (map idFunc funcs) (map idOp ops)
idType = trType typ typesyn
where
typ name vis params cs = Type name vis params (map idCons cs)
typesyn name vis params syn = TypeSyn name vis params (idTypeExpr syn)
idCons = trCons cons
where
cons name arity vis args = Cons name arity vis (map idTypeExpr args)
idTypeExpr = trTypeExpr TVar TCons FuncType ForallType
idFunc = trFunc func
where
func name arity vis t rule = Func name arity vis (idTypeExpr t) (idRule rule)
idRule = trRule rule External
where
rule args exp = Rule args (idExpr exp)
idExpr = trExpr Var Lit Comb Let Free Or Case Branch Typed
idOp = trOp Op
Copyright (c) 2017, 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.
html: Support for HTML programming
==================================
This package contains libraries to support HTML programming.
--------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Example for CGI programming in Curry:
-- a form with a text input field and two event handlers
------------------------------------------------------------------------------
import HTML.Base
main :: IO HtmlForm
main = return $ form "QUESTION" $
[htxt "Enter a string: ", textfield tref "", hrule,
button "Reverse string" revhandler,
button "Duplicate string" duphandler,
hrule]
where
tref free
revhandler env = return $ form "Answer"
[h1 [htxt $ "Reversed input: " ++ reverse (env tref)]]
duphandler env = return $ form "Answer"
[h1 [htxt $ "Duplicated input: " ++ env tref ++ env tref]]
-- Install the CGI program by:
-- curry makecgi -cpm -o ~/public_html/revdup.cgi RevDup
{
"name": "html",
"version": "2.0.0",
"author": "Michael Hanus <mh@informatik.uni-kiel.de>",
"synopsis": "Libraries for HTML programming.",
"category": [ "Web" ],
"dependencies": { },
"exportedModules": [ "HTML.Base", "HTML.CgiServer",
"HTML.CategorizedList", "HTML.LaTeX",
"HTML.Parser",
"HTML.Styles.Bootstrap3" ],
"compilerCompatibility": {
"pakcs": ">= 2.0.0",
"kics2": ">= 2.0.0"
},
"license": "BSD-3-Clause",
"licenseFile": "LICENSE",
"source": {
"git": "https://git.ps.informatik.uni-kiel.de/curry-packages/html.git",
"tag": "$version"
}
}
This diff is collapsed.
------------------------------------------------------------------------------
--- This library provides functions to categorize a list of entities
--- into a HTML page with an index access (e.g., "A-Z") to these entities.
---
--- @category web
------------------------------------------------------------------------------
module HTML.CategorizedList
(list2CategorizedHtml, categorizeByItemKey, stringList2ItemList)
where
import Char
import List
import HTML.Base
--- General categorization of a list of entries.
---
--- The item will occur in every category for which the boolean function
--- categoryFun yields True.
--- @param itemL the list of key-item pairs which are supposed to be
--- categorized with respect to key
--- @param categoryL list of key-category pairs to which the items can be
--- sorted in
--- @param categoryFun uses the keys of the items and the keys of the
--- categories to distribute the items among the categories.
--- @return Html containing inner links between the categories
list2CategorizedHtml :: Show b => [(a,[HtmlExp])] -> [(b,String)] -> (a -> b -> Bool)
-> [HtmlExp]
list2CategorizedHtml itemL categoryL categoryFun =
categories2LinkList categoryL :
map (\ (categoryKey,categoryString) ->
anchor (string2urlencoded (show categoryKey))
(h2 [htxt categoryString] :
concatMap (\ (_,item)->item++[breakline])
(filter (\ (itemKey,_) ->
categoryFun itemKey categoryKey)
itemL)
++ [categories2LinkList categoryL])
)
categoryL
-- the navigation list
categories2LinkList :: Show a => [(a,String)] -> HtmlExp
categories2LinkList categoryL =
par
[center
(concatMap (\ (categoryKey,categoryString) ->
[href ('#':(string2urlencoded (show categoryKey)))
[htxt categoryString], nbsp])
categoryL)]
--- Categorize a list of entries with respect to the inial keys.
---
--- The categories are named as all initial characters of the keys of the items.
--- @param itemL the list of key-item pairs which are supposed to be
--- categorized with respect to key
--- @return Html containing inner links between the categories
categorizeByItemKey :: [(String,[HtmlExp])] -> [HtmlExp]
categorizeByItemKey itemL =
list2CategorizedHtml
itemL
(map (\c -> (toUpper c,[toUpper c])) (listHeads (map fst itemL)))
categorizeStringHead
--- Convert a string list into an key-item list
--- The strings are used as keys and for the simple text layout.
stringList2ItemList :: [String] -> [(String,[HtmlExp])]
stringList2ItemList = map (\str -> (str,[htxt str]))
-- yields every listHead only once
listHeads :: [String] -> [Char]
listHeads =
nubBy isUpperEqual . foldr (\xs ys -> if xs==[] then ys else head xs:ys) []
-- categoryFun for categorizeByItemKey
categorizeStringHead :: String -> Char -> Bool
categorizeStringHead [] _ = False
categorizeStringHead (c:_) c' = isUpperEqual c c'
isUpperEqual c c' = toUpper c == toUpper c'
-- just for testing ----------------------------------------
main = return $ form "CatTest"
(categorizeByItemKey (stringList2ItemList testList))
testList = ["bbcd",
"acde",
"ab",
"cde",
"b",
"xt",
"gbbcd",
"uacde",
"Oab",
"Qcde",
"Tb",
"mxt",
"mxtr"]
-- makecurrycgi -o ~/public_html/cat.cgi CategorizedHtmlList
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment