uhc-light-1.1.8.0: src/UHC/Light/Compiler/CoreRun/API.hs
{-# LINE 2 "src/ehc/CoreRun/API.chs" #-}
-- | CoreRun Public API
--
-- Intended for constructing basic CoreRun Programs.
--
-- CoreRun is a simplified Core intended to be used for direct interpretation/execution.
-- For semantics, see TBD
--
module UHC.Light.Compiler.CoreRun.API
(
-- * Core AST
-- | The datatypes making up a CoreRun program.
Mod
, Exp
, SExp
, Alt
-- , Pat
, Bind
-- * Utilities
, CRArray
, mkCRArray
-- * Construction functions
, mkExp
, mkVar, mkVar'
, mkInt, mkInt'
, mkChar, mkChar'
, mkInteger, mkInteger'
, mkString, mkString'
, mkDbg, mkDbg'
, mkApp, mkApp'
, mkTup, mkTup'
, mkEval
, mkTail
, mkCase
, mkLam, mkLam'
, mkLet, mkLet'
, mkFFI, mkFFI'
, mkMod, mkMod'
-- * Parsing
, parseModFromString
-- * Running
, runCoreRunIO
)
where
import UHC.Light.Compiler.Base.API
import UHC.Light.Compiler.CoreRun as CR
import UHC.Light.Compiler.CoreRun.Parser as CR
import UHC.Light.Compiler.CoreRun.Run as CR
import UHC.Light.Compiler.CoreRun.Run.Val as CR
import UHC.Light.Compiler.CoreRun.Run.Val.RunExplStk as CR
import System.IO
import Control.Exception
-- **************************************
-- Running
-- **************************************
-- | Run CoreRun in IO
-- TBD: fix dependence on whole program linked
runCoreRunIO
:: EHCOpts -- ^ options, e.g. for turning on tracing (if supported by runner)
-> Mod -- ^ the module to run
-> IO (Either Err RVal)
runCoreRunIO opts mod = do
catch
(runCoreRun opts [] mod $ cmodRun opts mod)
(\(e :: SomeException) -> hFlush stdout >> (return $ Left $ strMsg $ "cpRunCoreRun: " ++ show e))