CurryInfo: ertools-3.0.0 / Database.ERD.Goodies.readERDFromProgram

definition: Info
 
readERDFromProgram :: String -> IO ERD
readERDFromProgram progfile = do
  putStr $ "Processing ERD in program `" ++ progfile ++ "'..."
  let progname = stripCurrySuffix progfile
  prog <- runModuleActionQuiet readFlatCurry progname
  let funcs = progFuncs prog
      erdfuncs = filter hasERDType funcs
  case erdfuncs of
    []   -> error $ "No definition of ER model found in program " ++ progfile
    [fd] -> do currypath <- getEnv "CURRYPATH"
               pid <- getPID
               let tmpfile = "/tmp/ERD2CURRY_tmp_" ++ show pid
               let cmd = installDir </> "bin" </> "curry"
                   args  = [ "--nocypm"
                           , ":set","v0" ]
                   input = unlines $
                            (if null currypath
                               then []
                               else [":set path " ++ currypath] ) ++
                            [ ":load " ++ progname
                            , ":add " ++ "Database.ERD"
                            , ":eval writeFileWithERDTerm " ++
                                     show tmpfile ++ snd (funcName fd)
                            , ":quit"]
               (ecode,_,errstr) <- evalCmd cmd args input
               putStrLn "done"
               if ecode > 0
                 then error $ "ERROR in program defining ERD:\n" ++ errstr
                 else do erdtermfile <- readCompleteFile tmpfile
                         removeFile tmpfile
                         return (read erdtermfile)
    _ -> error $ "Multiple ER model definitions found in program " ++ progfile
demand: Info
 no demanded arguments
deterministic: Info
 deterministic operation
documentation: Info
 
Reads the ERD defined in a Curry program (as a top-level operation
of type `Database.ERD.ERD`).
This is done by compiling the Curry program with an auxiliary
operation and processing the output of the program.
failfree: Info
 <FAILING>
indeterministic: Info
 referentially transparent operation
infix: Info
 no fixity defined
iotype: Info
 {(_) |-> _}
name: Info
 readERDFromProgram
precedence: Info
 no precedence defined
result-values: Info
 _
signature: Info
 String -> Prelude.IO Database.ERD.ERD
solution-complete: Info
 operation might suspend on free variables
terminating: Info
 possibly non-terminating
totally-defined: Info
 possibly non-reducible on same data term