Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
An interpreter operating on type-checked source Futhark terms. Relatively slow.
Synopsis
- data Ctx = Ctx {
- ctxEnv :: Env
- ctxImports :: Map ImportName Env
- data Env
- data InterpreterError
- prettyInterpreterError :: InterpreterError -> Doc AnsiStyle
- initialCtx :: Ctx
- interpretExp :: Ctx -> Exp -> F ExtOp Value
- interpretDec :: Ctx -> Dec -> F ExtOp Ctx
- interpretImport :: Ctx -> (ImportName, Prog) -> F ExtOp Ctx
- interpretFunction :: Ctx -> VName -> [Value] -> Either Text (F ExtOp Value)
- ctxWithImports :: [Env] -> Ctx -> Ctx
- data ExtOp a
- = ExtOpTrace Text (Doc ()) a
- | ExtOpBreak Loc BreakReason (NonEmpty StackFrame) a
- | ExtOpError InterpreterError
- data BreakReason
- data StackFrame = StackFrame {
- stackFrameLoc :: Loc
- stackFrameCtx :: Ctx
- typeCheckerEnv :: Env -> Env
- type Value = Value EvalM
- fromTuple :: Value m -> Maybe [Value m]
- isEmptyArray :: Value m -> Bool
- prettyEmptyArray :: TypeBase () () -> Value m -> Text
- prettyValue :: Value m -> Doc a
- valueText :: Value m -> Text
Documentation
The interpreter context. All evaluation takes place with respect to a context, and it can be extended with more definitions, which is how the REPL works.
Ctx | |
|
The actual type- and value environment.
data InterpreterError Source #
An error occurred during interpretation due to an error in the
user program. Actual interpreter errors will be signaled with an
IO exception (error
).
Instances
Show InterpreterError Source # | |
Defined in Language.Futhark.Interpreter showsPrec :: Int -> InterpreterError -> ShowS # show :: InterpreterError -> String # showList :: [InterpreterError] -> ShowS # |
prettyInterpreterError :: InterpreterError -> Doc AnsiStyle Source #
Prettyprint the error for human consumption.
initialCtx :: Ctx Source #
The initial environment contains definitions of the various intrinsic functions.
interpretImport :: Ctx -> (ImportName, Prog) -> F ExtOp Ctx Source #
interpretFunction :: Ctx -> VName -> [Value] -> Either Text (F ExtOp Value) Source #
Execute the named function on the given arguments; may fail horribly if these are ill-typed.
ctxWithImports :: [Env] -> Ctx -> Ctx Source #
Produce a context, based on the one passed in, where all of
the provided imports have been open
ened in order.
data BreakReason Source #
What is the reason for this break point?
BreakPoint | An explicit breakpoint in the program. |
BreakNaN | A |
data StackFrame Source #
Instances
Located StackFrame Source # | |
Defined in Language.Futhark.Interpreter locOf :: StackFrame -> Loc # locOfList :: [StackFrame] -> Loc # |
typeCheckerEnv :: Env -> Env Source #
Values
isEmptyArray :: Value m -> Bool Source #
Does the value correspond to an empty array?
prettyEmptyArray :: TypeBase () () -> Value m -> Text Source #
String representation of an empty array with the provided element type. This is pretty ad-hoc - don't expect good results unless the element type is a primitive.
prettyValue :: Value m -> Doc a Source #
Prettyprint value.