CurryInfo: ertools-3.0.0 / ERD2Curry.startWithERD

definition: Info
 
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: Info
 no demanded arguments
deterministic: Info
 deterministic operation
documentation: Info
 
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: Info
 <FAILING>
indeterministic: Info
 referentially transparent operation
infix: Info
 no fixity defined
iotype: Info
 {(_,_,_) |-> _}
name: Info
 startWithERD
precedence: Info
 no precedence defined
result-values: Info
 _
signature: Info
 EROptions -> String -> Database.ERD.ERD -> Prelude.IO ()
solution-complete: Info
 operation might suspend on free variables
terminating: Info
 possibly non-terminating
totally-defined: Info
 possibly non-reducible on same data term