Commit 56d143ae authored by Bernd Brassel's avatar Bernd Brassel
Browse files

libraries now added to kics package

parent a3b621cb
......@@ -7,14 +7,22 @@ Homepage: http://curry-language.org
License: OtherLicense
License-File: LICENSE
Category: Compiler
build-type: Simple
build-type: Custom
Synopsis: A compiler from Curry to Haskell
Description: This package builds the Curry to Haskell compiler "kics".
Note, that you need a functional curry module
"Prelude.curry" to get started.
The standard version of that file is contained
in the package KiCS-standard-libraries.
This package also includes many Curry libraries.
Have a look at the list of modules "Curry.Module.*"
Stability: experimental
extra-source-files:
src/lib/Curry/Module/*.hs.include
Data-Dir: src/lib/Curry/Module/.curry
Data-Files: *.fcy
*.fint
*.efc
*.acy
*.uacy
*.cy
Executable kics
main-is: kics.hs
......@@ -33,27 +41,65 @@ Executable kics
curry-frontend >= 0.2.6
Library
hs-source-dirs: src
hs-source-dirs: src, src/lib
Build-Depends:
syb
base == 4.1.*,
haskell98,
directory,
old-time,
syb,
network,
process,
unix,
random
Exposed-Modules:
Curry.RunTimeSystem.Store,
Curry.RunTimeSystem.BaseCurry,
Curry.RunTimeSystem
Curry.Compiler.Config
Curry.Compiler.CurryToHaskell
Curry.Compiler.SafeCalls
Curry.Compiler.Names
Curry.Compiler.ShowFlatCurry
Curry.Files.KiCSPath
Curry.RunTimeSystem
Curry.Module.Prelude
Curry.Module.Interactive
Curry.Module.Char
Curry.Module.Dequeue
Curry.Module.Directory
Curry.Module.FileGoodies
Curry.Module.FiniteMap
Curry.Module.Float
Curry.Module.Global
Curry.Module.GraphInductive
Curry.Module.Integer
Curry.Module.IO
Curry.Module.IOExts
Curry.Module.List
Curry.Module.CSV
Curry.Module.Maybe
Curry.Module.AnsiCodes
Curry.Module.Array
Curry.Module.Parser
Curry.Module.Pretty
Curry.Module.Random
Curry.Module.RandomExternal
Curry.Module.RedBlackTree
Curry.Module.SetRBT
Curry.Module.Socket
Curry.Module.Sort
Curry.Module.StyledText
Curry.Module.System
Curry.Module.TableRBT
Curry.Module.Time
Curry.Module.ReadShowTerm
Curry.Module.Meta
Curry.Module.Read
Curry.Module.EasyCheck
Curry.Module.Assertion
Curry.Module.Traversal
Curry.Module.PropertyFile
Curry.Module.Unsafe
Other-Modules:
Paths_KiCS
Curry.Compiler.KicsSubdir
Curry.Compiler.FunctionalProg
Curry.Compiler.ShowFunctionalProg
Curry.Compiler.PreTrans
Curry.Compiler.Simplification
Curry.Compiler.Brace
Curry.RunTimeSystem.Store
Curry.RunTimeSystem.BaseCurry
......@@ -13,22 +13,20 @@ import Distribution.Verbosity
import Curry.Files.CymakePath
import Curry.Files.KiCSPath
mkProg :: Monad m => String -> m Program
mkProg call = return (simpleProgram (takeBaseName call))
{programFindLocation = \_-> return (Just call)}
kics :: IO Program
kics = getKiCS >>= mkProg
kics :: Program
kics = simpleProgram "kics"
cymake :: IO Program
cymake = getCymake >>= mkProg
cymake = do
call <- getCymake
return (simpleProgram (takeBaseName call))
{programFindLocation = \_-> return (Just call)}
main :: IO ()
main = do
kicsProg <- kics
cymakeProg <- cymake
defaultMainWithHooks simpleUserHooks
{hookedPrograms=kicsProg:cymakeProg:hookedPrograms simpleUserHooks
{hookedPrograms=kics:cymakeProg:hookedPrograms simpleUserHooks
,postConf=myPostConf
,hookedPreProcessors=[("curry",mkModule)]
}
......@@ -49,7 +47,7 @@ callProg verb lbi prog args = do
myPostConf :: Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ()
myPostConf args confFlags descrs lbi = do
let require = requireProg (configVerbosity confFlags) lbi
require kics
require (return kics)
require cymake
postConf simpleUserHooks args confFlags descrs lbi
......@@ -65,7 +63,8 @@ runKics lbi infile outfile verb = do
-- nomake not supported
mapM (\ format -> call cymake ["-e",'-':'-':format,"-i"++datadir,infile])
["flat","extended-flat","acy","uacy","parse-only"]
call kics ["-nomake","-userlibpath","Curry/Module/","-o",outfile,infile]
call (return kics) ["-nomake",--"-userlibpath","src/lib/Curry/Module/",
"-o",outfile,infile]
......@@ -11,17 +11,14 @@ import System.Directory hiding (executable)
import System.Time
import GHC.Paths
import Data.List
import Monad
import Curry.Compiler.SafeCalls
import Curry.FlatCurry.Type (readFlat)
import Curry.Compiler.Names
import Curry.Compiler.KicsSubdir
import Curry.Files.CymakePath
isModuleInstalled :: String -> IO Bool
isModuleInstalled m = do
cont <- readProcess ghc_pkg ["find-module",m] ""
return (isInfixOf "KiCS" cont)
import Curry.Files.KiCSPath
getOptions :: IO (Options,State)
getOptions = do
......@@ -31,9 +28,9 @@ getOptions = do
let parsed = parseOptions opts args
parsedOpts <- either usage return parsed
let addFiledir = case takeDirectory (filename opts) of "" -> id; dir -> (dir:)
newOpts = parsedOpts{userlibpath= addFiledir $
userlibpath parsedOpts
++ splitSearchPath cupath}
newOpts = parsedOpts{userlibpath= addFiledir $
userlibpath parsedOpts
++ splitPath cupath}
return (newOpts,state)
......@@ -98,7 +95,7 @@ usage problem = do
data Options = Opts{ cm :: ChoiceMode,
filename, mainFunc, mainModule,
frontend, ghcOpts
frontend, ghcOpts, stdLibDir
:: String,
target :: Maybe String,
userlibpath, done :: [String],
......@@ -115,11 +112,12 @@ data Options = Opts{ cm :: ChoiceMode,
data ConsUse = DataDef | InstanceDef | FunctionDef deriving (Eq,Show)
addFileDirToPath :: String -> [String] -> [String]
addFileDirToPath fn = case takeDirectory fn of "" -> id; dir -> (dir:)
libpath :: Options -> [String]
libpath opts@Opts{userlibpath=up,{-kicspath=kp,-}filename=fn}
= --(case takeDirectory fn of "" -> id; dir -> ((dir++[pathSeparator]):))
up -- ++ [unpath ["Curry","Module",""]]
libpath opts@Opts{userlibpath=up,filename=fn,stdLibDir=std} =
addFileDirToPath fn $ up ++ [std]
cmdLibpath :: Options -> String
......@@ -139,9 +137,10 @@ hasExtInsts opts =
not (null (filter (any (/=Declaration) . snd) (extInsts opts)))
hasExtFuncs opts = not (null (extFuncs opts))
defaultOpts curDir = Opts {cm=CTC,filename="", mainFunc= "main", mainModule="Main",
target = Just "request",
defaultOpts = Opts {cm=CTC,filename="", mainFunc= "main", mainModule="Main",
target = Nothing,
frontend="cymake",
stdLibDir = "",
userlibpath=[],
ghcOpts=" -fglasgow-exts -fcontext-stack=50 ",
done=[],
......@@ -275,15 +274,8 @@ prophecy opts = safeSystem (verbosity opts >= 4) $
readConfig = do
home <- getEnv "HOME"
curDir <- getCurrentDirectory
catch (readFile (kicsrc home) >>= getConfigs home)
(\_->do
let defaultsO = defaultOpts curDir
defaultsS = defaultState home
writeConfig defaultsO defaultsS
putStrLn ("The file "++kicsrc home++" has been written.")
putStrLn ("You might need to edit it.")
error "Please verify .kicsrc")
(\_ -> getConfigs home "")
writeConfig opts state = do
home <- getEnv "HOME"
......@@ -303,27 +295,24 @@ writeConfig opts state = do
entry n s = (configs!!(n-1)) ++ "="++s++"\n\n"
mkTags = [-- kicspath,
(toPathList . userlibpath),
(show . pm)]
mkTags = [(toPathList . userlibpath),(show . pm)]
getConfigs home cfgs | cfgs == cfgs = do
punkt <- getCurrentDirectory
std <- getKiCSLibDir
cymake_call <- getCymake
let readOpts = selOpts (entries cfgs)
defaultsO = defaultOpts punkt
opts = defaultsO
{cm = OrBased,
--kicspath = installDir,
userlibpath = let up = readSetting userlibpath splitSearchPath 1
in (punkt ++ [pathSeparator]) : up,
pm = readSetting pm readPMode 2,
--ghc = ghc_call,
frontend = cymake_call,
eval = readSetting eval read 3,
force = False}
readSetting f r n = maybe (f defaultsO) r (readOpts!!(n-1))
opts = defaultOpts
{cm = OrBased,
userlibpath = let up = readSetting userlibpath splitPath 1
in punkt : up,
stdLibDir = std,
pm = readSetting pm readPMode 2,
frontend = cymake_call,
eval = readSetting eval read 3,
force = False}
readSetting f r n = maybe (f defaultOpts) r (readOpts!!(n-1))
defaultsS = defaultState home
state = defaultsS
......
......@@ -127,12 +127,14 @@ getFlatCurryFileName opts@(Opts{filename=basename}) = do
let foundBasename = dropExtensions foundFile
return (opts{filename=foundBasename})
notUptodate opts@(Opts{filename=foundBasename}) = do
tSource1 <- getModTime (replaceExtension foundBasename ".fcy")
tSource2 <- getExternalSpecModTime opts foundBasename
let dest = destination True (target opts) (funcHsName foundBasename)
tDestination <- getModTime dest
return (tSource1 > tDestination || tSource2 > tDestination)
notUptodate opts@(Opts{filename=foundBasename})
| takeDirectory foundBasename == stdLibDir opts = return False
| otherwise = do
tSource1 <- getModTime (replaceExtension foundBasename ".fcy")
tSource2 <- getExternalSpecModTime opts foundBasename
let dest = destination True (target opts) (funcHsName foundBasename)
tDestination <- getModTime dest
return (tSource1 > tDestination || tSource2 > tDestination)
applyFlatTransformations opts prog = do
let auxNames = generateAuxNames (progFuncs prog)
......@@ -419,18 +421,18 @@ curryInstance opts t@(Type origName vis vars consdecls)
(map strEqRule consdecls++
[C.Rule [_x,toPVar 0,_x]
(noguard $
fapp (extInstPresym isPrelude "strEqFail")
[fapp (extInstPresym isPrelude "typeName") [toVar 0]]) []]))
fapp (cupresym "strEqFail")
[fapp (cupresym "typeName") [toVar 0]]) []]))
strEqRule (Cons cname arity _ _) =
rule [C.PComb (consName opts cname) (map toPVar [1..arity]),
C.PComb (consName opts cname) (map (toPVar' "y") [1..arity])]
(noguard $ if arity==0 then (extInstPresym isPrelude "strEqSuccess")
else foldr1 (\ e es -> fapp (extInstPresym isPrelude "concAnd")
(noguard $ if arity==0 then (cupresym "strEqSuccess")
else foldr1 (\ e es -> fapp (cupresym "concAnd")
(addStateArg [e,es]))
(map sEq [1..arity])) []
where
sEq i = fapp (extInstPresym isPrelude "genStrEq") (addStateArg [toVar i,toVar' "y" i])
sEq i = fapp (cupresym "genStrEq") (addStateArg [toVar i,toVar' "y" i])
eq = C.Func (newModName,"eq") (transvis vis) untyped
(Just
......@@ -444,7 +446,7 @@ curryInstance opts t@(Type origName vis vars consdecls)
else foldr1 (\ e es -> fapp (funcupresym "&&") (addStateArg [e,es]))
(map eqArgs [1..arity])) []
where
eqArgs i = fapp (extInstPresym isPrelude "genEq") (addStateArg [toVar i,toVar' "y" i])
eqArgs i = fapp (cupresym "genEq") (addStateArg [toVar i,toVar' "y" i])
propagate = C.Func (newModName,"propagate") (transvis vis) untyped
(Just (map propRule consdecls))
......@@ -743,7 +745,7 @@ transRule :: ([VarIndex],[VarIndex]) -> Options -> BranchExpr -> C.Rule
transRule (as,v:bs) opts (Branch (LPattern l@(Charc _)) e)
= rule ps (C.GuardedExpr [(guard,transExpr opts e)]) []
where
guard = app (extInstPresym False "isC_True")
guard = app (cupresym "isC_True")
(fapp (funcupresym "===") [toVar v,toLit opts l])
ps = map toPVar as ++ toPVar v : map toPVar bs
transRule (as,v:bs) opts (Branch (LPattern l) e)
......@@ -794,7 +796,7 @@ showFunction showQ opts t@(Type origName vis vars consdecls)
showParenArg (_,'(':_) = hasPresym "True"
showParenArg _ = if showQ then hasPresym "True" else lt (C.Var "d") app_prec
showsPrecName = if showQ then "showQ" else "showsPrec"
showsPrecSym = (if showQ then extInstPresym (fst origName=="Prelude")
showsPrecSym = (if showQ then cupresym
else hasPresym) showsPrecName
identifier (_,"()") = "()"
......@@ -1224,11 +1226,6 @@ underscores i = replicate i (_x)
qname_ (m,f) = string_ (m++'.':f)
extInstPresym _ s = sym (modName "Prelude",s)
extFuncPresym opts s = sym (modName "Prelude",s)
_x = C.PVar "_"
st = C.Var "st"
......
......@@ -126,7 +126,7 @@ findFileInPath fn path = do
if any isPathSeparator fn
then findFile fn
else do
let fs = nubBy equalFilePath $ map (++fn) path
let fs = nubBy equalFilePath $ map (</>fn) path
founds <- mapM findFile fs
return (nubBy equalFilePath $ concat founds)
......
module Curry.Files.KiCSPath (getKiCS,kicsVersion) where
module Curry.Files.KiCSPath (getKiCS,getKiCSLibDir,kicsVersion) where
import Data.Version
import System.FilePath
import Paths_KiCS
kicsVersion = versionBranch version
kicsVersion = showVersion version
getKiCS = do
kicsDir <- getBinDir
return (kicsDir </> "kics")
getKiCSLibDir = getDataDir
......@@ -6,4 +6,4 @@ import Paths_KiCS_standard_libraries
stdLibVersion = showVersion version
getStdLibPath = getDataDir
main = getStdLibPath >>= print
\ No newline at end of file
Name: KiCS-standard-libraries
Version: 0.1
Cabal-Version: >= 1.6
Author: Bernd Braßel
Maintainer: Bernd Braßel
Homepage: http://curry-language.org
License: OtherLicense
License-File: LICENSE
Category: Language
build-type: Custom
Synopsis: Standard libraries of the functional logic language Curry.
Description: This package contains the standard libraries for
the functional logic language Curry. These libraries are to be compiled
with the Curry to Haskell compiler KiCS.
Stability: experimental
extra-source-files:
Curry/Module/Prelude.hs.include
Curry/Module/Interactive.hs.include
Curry/Module/Directory.hs.include
Curry/Module/Float.hs.include
Curry/Module/Global.hs.include
Curry/Module/IO.hs.include
Curry/Module/IOExts.hs.include
Curry/Module/RandomExternal.hs.include
Curry/Module/Socket.hs.include
Curry/Module/System.hs.include
Curry/Module/Time.hs.include
Curry/Module/ReadShowTerm.hs.include
Curry/Module/Meta.hs.include
Curry/Module/Unsafe.hs.include
Data-Dir: Curry/Module/.curry
Data-Files: *.fcy
*.fint
*.efc
*.acy
*.uacy
*.cy
Library
build-depends:
base >= 4 && < 5,
haskell98,
directory,
old-time,
network,
process,
unix,
random,
KiCS >= 0.8.8
Exposed-Modules:
Curry.Files.StdLibPath
Curry.Module.Prelude
Curry.Module.Interactive
Curry.Module.Char
Curry.Module.Dequeue
Curry.Module.Directory
Curry.Module.FileGoodies
Curry.Module.FiniteMap
Curry.Module.Float
Curry.Module.Global
Curry.Module.GraphInductive
Curry.Module.Integer
Curry.Module.IO
Curry.Module.IOExts
Curry.Module.List
Curry.Module.CSV
Curry.Module.Maybe
Curry.Module.AnsiCodes
Curry.Module.Array
Curry.Module.Parser
Curry.Module.Pretty
Curry.Module.Random
Curry.Module.RandomExternal
Curry.Module.RedBlackTree
Curry.Module.SetRBT
Curry.Module.Socket
Curry.Module.Sort
Curry.Module.StyledText
Curry.Module.System
Curry.Module.TableRBT
Curry.Module.Time
Curry.Module.ReadShowTerm
Curry.Module.Meta
Curry.Module.Read
Curry.Module.EasyCheck
Curry.Module.Assertion
Curry.Module.Traversal
Curry.Module.PropertyFile
Curry.Module.Unsafe
KiCS (Kiel Curry System) License
Copyright (c) 2009, University of Kiel
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 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.
- None of the names of the copyright holders and 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
OWNER 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.
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