| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Futhark.Eval
Description
Facilities for evaluating Futhark code.
This most directly provides the building blocks for futhark eval, but this
module also contains server interaction machinery used by futhark repl and
other commands that make use of the Futhark interpreter.
Synopsis
- data EvalConfig = EvalConfig {}
- data InterpreterState
- runExpr :: (Evaluation m, MonadIO m) => InterpreterState -> Text -> m (Doc AnsiStyle)
- evalConfig :: EvalConfig
- evalServerOptions :: [FunOptDescr EvalConfig]
- runFFI :: Maybe Server -> ServerM Value -> IO (Either InterpreterError Value)
- forceValue :: Maybe Server -> Value -> IO (Either InterpreterError Value)
- externaliseLast :: Imports -> Imports
- runInterpreterWith :: MonadIO m => (Doc AnsiStyle -> m ()) -> Maybe Server -> Maybe FilePath -> F ExtOp a -> m (Either InterpreterError a)
- interpretImports :: Monad m => (F ExtOp Ctx -> m (Either InterpreterError Ctx)) -> Imports -> ExceptT (Doc AnsiStyle) m (Env, Ctx)
- initialiseInterpreter :: (Evaluation m, MonadIO m) => EvalConfig -> Maybe FilePath -> Maybe Server -> Imports -> m (Either (Doc AnsiStyle) (Maybe Server, Env, Ctx))
- newInterpreterState :: (MonadIO m, Evaluation m) => EvalConfig -> VFS -> m (Either (Doc AnsiStyle) InterpreterState)
- class Monad m => Evaluation (m :: Type -> Type) where
- data EvalRecordRef a
- runEvalRecordRef :: IORef (Seq (Doc AnsiStyle)) -> EvalRecordRef a -> IO (Either (Doc AnsiStyle) a)
Documentation
data EvalConfig Source #
Constructors
| EvalConfig | |
Fields
| |
data InterpreterState Source #
runExpr :: (Evaluation m, MonadIO m) => InterpreterState -> Text -> m (Doc AnsiStyle) Source #
Run an expression in the given interpreter state. The expression is parsed, type checked, and then run. Returns a prettyprinted result. Must be run in a monad that supports aborting and traces.
evalServerOptions :: [FunOptDescr EvalConfig] Source #
Command line options for configuring the use of an external server.
forceValue :: Maybe Server -> Value -> IO (Either InterpreterError Value) Source #
Fetch in full a value that may reside on a server, so that it can be printed or otherwise inspected.
externaliseLast :: Imports -> Imports Source #
Mark the entry points of the last import - which is the file the user actually asked us to load - as external, meaning that calls to them are dispatched to a server instead of being interpreted.
runInterpreterWith :: MonadIO m => (Doc AnsiStyle -> m ()) -> Maybe Server -> Maybe FilePath -> F ExtOp a -> m (Either InterpreterError a) Source #
Run an interpreter action non-interactively. Breakpoints are ignored, as there is no way to enter a debugging prompt. Traces, and the breakpoints that are ignored, are reported with the given function. External calls are dispatched to the given server (if any). Relative paths in IO operations are resolved relative to the given directory, if any, and otherwise relative to the working directory.
interpretImports :: Monad m => (F ExtOp Ctx -> m (Either InterpreterError Ctx)) -> Imports -> ExceptT (Doc AnsiStyle) m (Env, Ctx) Source #
Interpret the given imports in order with the provided interpreter runner, and produce the type and interpreter environment of the last one.
initialiseInterpreter :: (Evaluation m, MonadIO m) => EvalConfig -> Maybe FilePath -> Maybe Server -> Imports -> m (Either (Doc AnsiStyle) (Maybe Server, Env, Ctx)) Source #
Set up an interpreter context for the given program. If a server is provided, or a backend has been requested (in which case a server is started), then the entry points of the loaded file are marked external, such that calls to them are dispatched to the server instead of being interpreted. On failure, a server started here is shut down again, so a returned server is always one that the caller now owns (and must eventually stop). A server passed in by the caller is never shut down here.
newInterpreterState :: (MonadIO m, Evaluation m) => EvalConfig -> VFS -> m (Either (Doc AnsiStyle) InterpreterState) Source #
Type check and interpret the given program (if any), producing a state
in which expressions can be evaluated with runExpr.
class Monad m => Evaluation (m :: Type -> Type) where Source #
The class of monads that can perform expression evaluation.
Instances
| Evaluation EvalRecordRef Source # | |
Defined in Futhark.Eval | |
| Evaluation IO Source # | |
| Evaluation m => Evaluation (ExceptT (Doc AnsiStyle) m) Source # | |
data EvalRecordRef a Source #
Instances
| Evaluation EvalRecordRef Source # | |
Defined in Futhark.Eval | |
| Applicative EvalRecordRef Source # | |
Defined in Futhark.Eval Methods pure :: a -> EvalRecordRef a # (<*>) :: EvalRecordRef (a -> b) -> EvalRecordRef a -> EvalRecordRef b # liftA2 :: (a -> b -> c) -> EvalRecordRef a -> EvalRecordRef b -> EvalRecordRef c # (*>) :: EvalRecordRef a -> EvalRecordRef b -> EvalRecordRef b # (<*) :: EvalRecordRef a -> EvalRecordRef b -> EvalRecordRef a # | |
| Functor EvalRecordRef Source # | |
Defined in Futhark.Eval Methods fmap :: (a -> b) -> EvalRecordRef a -> EvalRecordRef b # (<$) :: a -> EvalRecordRef b -> EvalRecordRef a # | |
| Monad EvalRecordRef Source # | |
Defined in Futhark.Eval Methods (>>=) :: EvalRecordRef a -> (a -> EvalRecordRef b) -> EvalRecordRef b # (>>) :: EvalRecordRef a -> EvalRecordRef b -> EvalRecordRef b # return :: a -> EvalRecordRef a # | |
| MonadIO EvalRecordRef Source # | |
Defined in Futhark.Eval Methods liftIO :: IO a -> EvalRecordRef a # | |