| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 | 
module Language.SMTLIB.Files (writeSMT, writeSMTDump) where
import Directory (createDirectoryIfMissing, getCurrentDirectory)
import FilePath  ((</>), (<.>), takeBaseName)
import Time      (getLocalTime, calendarTimeToString)
import Language.SMTLIB.Pretty (showSMT)
import Language.SMTLIB.Types
writeSMTDump :: String -> [Command] -> IO ()
writeSMTDump fn cmds = do
  cdir <- getCurrentDirectory
  let dumpDir = cdir </> ".smt"
  createDirectoryIfMissing True dumpDir
  dumpFilePath <- getUniqueFP dumpDir (takeBaseName fn) "smt2"
  writeSMT dumpFilePath cmds
writeSMT :: String -> [Command] -> IO ()
writeSMT fn cmds = writeFile fn (showSMT cmds)
getUniqueFP :: String -> String -> String -> IO String
getUniqueFP path prefix ext = do
  tstmp <- getLocalTime
  return $ path </> prefix ++ calendarTimeToString tstmp <.> ext
 |