Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- evalScript :: Script -> (Either EvalError Script, ExBudget, [Text])
- evalScriptHuge :: Script -> (Either EvalError Script, ExBudget, [Text])
- evalScript' :: ExBudget -> Script -> (Either (CekEvaluationException NamedDeBruijn DefaultUni DefaultFun) Script, ExBudget, [Text])
- evalScriptUnlimited :: Script -> (Either (CekEvaluationException NamedDeBruijn DefaultUni DefaultFun) Script, ExBudget, [Text])
- type EvalError = CekEvaluationException NamedDeBruijn DefaultUni DefaultFun
- evalTerm :: Config -> ClosedTerm a -> Either Text (Either EvalError (ClosedTerm a), ExBudget, [Text])
- unsafeEvalTerm :: Config -> ClosedTerm a -> ClosedTerm a
- applyArguments :: Script -> [Data] -> Script
Documentation
evalScript :: Script -> (Either EvalError Script, ExBudget, [Text]) Source #
Evaluate a script with a big budget, returning the trace log and term result.
evalScriptHuge :: Script -> (Either EvalError Script, ExBudget, [Text]) Source #
Evaluate a script with a huge budget, returning the trace log and term result.
evalScript' :: ExBudget -> Script -> (Either (CekEvaluationException NamedDeBruijn DefaultUni DefaultFun) Script, ExBudget, [Text]) Source #
Evaluate a script with a specific budget, returning the trace log and term result.
evalScriptUnlimited :: Script -> (Either (CekEvaluationException NamedDeBruijn DefaultUni DefaultFun) Script, ExBudget, [Text]) Source #
Evaluate a script without budget limit
@since WIP
evalTerm :: Config -> ClosedTerm a -> Either Text (Either EvalError (ClosedTerm a), ExBudget, [Text]) Source #
Compile and evaluate term.
unsafeEvalTerm :: Config -> ClosedTerm a -> ClosedTerm a Source #
Compile and evaluate a ClosedTerm Useful for pre-evaluating terms so that they can be used as constants in an onchain script. Consider the following: _________________________________________________________________________ term :: Term _ PInteger term = unsafeEvalTerm NoTracing foo
foo :: Term s PInteger foo = (pconstant 1 #+ pconstant 5) #* pconstant 3
bar :: Term s (PInteger :--> PInteger) bar = plam x -> x + foo
bar2 :: Term s (PInteger :--> PInteger) bar2 = plam x -> x + term
PI.compile PI.NoTracing bar Right (Script {unScript = Program {_progAnn = (), _progVer = Version {_versionMajor = 1, _versionMinor = 0, _versionPatch = 0}, _progTerm = LamAbs () (DeBruijn {dbnIndex = 0}) (Apply () (Apply () (Builtin () AddInteger) (Var () (DeBruijn {dbnIndex = 1}))) (Apply () (Apply () (Builtin () MultiplyInteger) (Apply () (Apply () (Builtin () AddInteger) (Constant () (Some (ValueOf DefaultUniInteger 1)))) (Constant () (Some (ValueOf DefaultUniInteger 5))))) (Constant () (Some (ValueOf DefaultUniInteger 3)))))}}) PI.compile PI.NoTracing bar2 Right (Script {unScript = Program {_progAnn = (), _progVer = Version {_versionMajor = 1, _versionMinor = 0, _versionPatch = 0}, _progTerm = LamAbs () (DeBruijn {dbnIndex = 0}) (Apply () (Apply () (Builtin () AddInteger) (Var () (DeBruijn {dbnIndex = 1}))) (Constant () (Some (ValueOf DefaultUniInteger 18))))}}) _________________________________________________________________________
In bar, foo is an unevaluated term and thus must be evaluated. In bar2, foo has been
pre-evaluated with unsafeEvalTerm
and thus appears as a constant.
Error if the compilation or evaluation fails.