CurryInfo: ertools-3.0.0 / Database.ERD.ToCDBI.writeCDBI

definition:
writeCDBI :: String -> String -> String -> ERD -> String -> IO ()
writeCDBI erdfname outfile cdbimod (ERD name ents rels) dbname = do
  let imports  = [ timeMod
                 , "Database.CDBI.ER"
                 , "Database.CDBI.Criteria"
                 , "Database.CDBI.Connection"
                 , "Database.CDBI.Description"]
      typeDecls  = foldr ((++) . (genEntityTypeDecls cdbimod)) [] ents 
      funcDecls  = genDBPathFunc cdbimod dbname :
                   foldr ((++) . (genEntityFuncDecls cdbimod)) [] ents ++
                   genNewDBSchema cdbimod ents ++
                   genSaveDB cdbimod ents ++
                   genRunFuncs cdbimod
  writeFile outfile $ unlines $
    map ("--- "++)
        [ "This file has been generated from"
        , ""
        , "    " ++ erdfname
        , ""
        , "and contains definitions for all entities and relations"
        , "specified in this model.\n"] ++
    [ pPrint
       (ppCurryProg defaultOptions
         (CurryProg cdbimod imports Nothing [] [] typeDecls funcDecls [])) ]
  putStrLn $ unlines
    [ "Database operations generated into file '" ++ outfile ++ "'."
    , "NOTE: Packages 'cdbi' and 'time' are required to compile this module."
    ]
  infofilehandle <- openFile (name ++ "_SQLCode.info") WriteMode
  writeParserFile infofilehandle cdbimod ents rels dbname
  hClose infofilehandle
  dbexists <- doesFileExist dbname
  if dbexists
   then do
    putStrLn $ "Database '" ++ dbname ++ "' exists and, thus, not modified."
    putStrLn $ "Please make sure that this database is conform to the ER model!"
    -- TODO: if the database exists, check its consistency with ER model
   else do
    putStrLn $ "CREATING NEW SQLITE3 DATABASE: " ++ dbname
    exsqlite3 <- system "which sqlite3 > /dev/null"
    when (exsqlite3>0) $
      error "Database interface `sqlite3' not found. Please install package `sqlite3'!"
    db <- connectToCommand $ "sqlite3 " ++ dbname
    hPutStrLn db $ unlines (map entity2createTable ents)
    hClose db
demand:
argument 4
deterministic:
deterministic operation
documentation:
-- Write all the data so CDBI can be used, create a database (if it does
-- not exist) and a `.info` file.
-- The parameters are the name of the file containing the ERD term,
-- the name of the file to store the Curry program,
-- the module name of the generated Curry program,
-- the ER model, and the name of the SQLite3 database.
failfree:
<FAILING>
indeterministic:
referentially transparent operation
infix:
no fixity defined
iotype:
{(_,_,_,{ERD},_) |-> _}
name:
writeCDBI
precedence:
no precedence defined
result-values:
_
signature:
String -> String -> String -> Database.ERD.ERD -> String -> Prelude.IO ()
solution-complete:
operation might suspend on free variables
terminating:
possibly non-terminating
totally-defined:
possibly non-reducible on same data term