|
definition: |
startWithERD :: EROptions -> String -> ERD -> IO ()
startWithERD opts srcfile erd = do
let erdname = erdName erd
transerdfile = erdname ++ "_ERDT.term"
curryfile = if null (optFile opts) then erdname ++ ".curry"
else optFile opts
transerd = transform erd
opt = ( if optStorage opts == SQLite ""
then SQLite (erdname ++ ".db")
else optStorage opts
, WithConsistencyTest )
erdprog = let prog = erd2code opt (transform erd)
in if null (optModule opts)
then prog
else renameCurryModule (optModule opts) prog
writeFile transerdfile $
"{- ERD specification transformed from " ++ srcfile ++ " -}\n\n " ++
showERD 2 transerd ++ "\n"
putStrLn $ "Transformed ERD term written into file '" ++ transerdfile ++ "'."
when (optCDBI opts) $
writeCDBI srcfile curryfile
(if null (optModule opts) then erdname else optModule opts)
transerd (storagePath (fst opt))
unless (optToERDT opts || optCDBI opts) $ do
moveOldVersion curryfile
impprogs <- mapM readCurry (imports erdprog)
writeFile curryfile $
prettyCurryProg
(setOnDemandQualification (erdprog:impprogs) defaultOptions)
erdprog
putStrLn $ unlines
[ "Database operations generated into file '" ++ curryfile ++ "'"
, "with " ++ showOption opt ++ "."
, "NOTE: To compile this module, use packages " ++
"'keydb', 'ertools' and 'time'." ]
where
showOption (Files f,_) = "database files stored in directory '"++f++"'"
showOption (SQLite f,_) =
"SQLite3 database stored in file '" ++ f ++ "'"
showOption (DB,_) = "SQL database interface"
|
|
demand: |
no demanded arguments |
|
deterministic: |
deterministic operation |
|
documentation: |
Main function to invoke the ERD->Curry translator. The parameters are the tool options, the name of the Curry program containing the ERD (only used in a comment of the generated program), and the ERD definition. If not changed by specific options, the generated Curry module has the name of the ERD and is put into the current directory. |
|
failfree: |
<FAILING> |
|
indeterministic: |
referentially transparent operation |
|
infix: |
no fixity defined |
|
iotype: |
{(_,_,_) |-> _}
|
|
name: |
startWithERD |
|
precedence: |
no precedence defined |
|
result-values: |
_ |
|
signature: |
EROptions -> String -> Database.ERD.ERD -> Prelude.IO () |
|
solution-complete: |
operation might suspend on free variables |
|
terminating: |
possibly non-terminating |
|
totally-defined: |
possibly non-reducible on same data term |