module Cryptol.Prelude (writePreludeContents) where
import Cryptol.ModuleSystem.Monad
#ifdef SELF_CONTAINED
import System.Directory (getTemporaryDirectory)
import System.IO (hClose, hPutStr, openTempFile)
import Text.Heredoc (there)
preludeContents :: String
preludeContents = [there|lib/Cryptol.cry|]
writePreludeContents :: ModuleM FilePath
writePreludeContents = io $ do
tmpdir <- getTemporaryDirectory
(path, h) <- openTempFile tmpdir "Cryptol.cry"
hPutStr h preludeContents
hClose h
return path
#else
import Cryptol.Parser.AST as P
writePreludeContents :: ModuleM FilePath
writePreludeContents = moduleNotFound (P.ModName ["Cryptol"]) =<< getSearchPath
#endif