1. Go to this page and download the library: Download gosuperscript/axiom-tracing library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gosuperscript / axiom-tracing example snippets
use Superscript\Axiom\Definitions;
use Superscript\Axiom\Expression;
use Superscript\Axiom\Sources\Coerce;
use Superscript\Axiom\Sources\InfixExpression;
use Superscript\Axiom\Sources\StaticSource;
use Superscript\Axiom\Sources\SymbolSource;
use Superscript\Axiom\Tracing\Tracing;
use Superscript\Axiom\Types\NumberType;
$program = (new Expression(
source: new InfixExpression(
new SymbolSource('base'),
'*',
new Coerce(new NumberType(), new StaticSource('4')),
),
definitions: new Definitions(['base' => new StaticSource(3)]),
))->compile()->unwrap();
$traced = Tracing::run($program);
$traced->result->unwrap()->unwrap(); // 12
echo $traced->dump();
$trace->get('label'); // last value for this node
$trace->all('result'); // every result annotation on this node
$trace->collect('result'); // result annotations from the whole subtree
$trace->annotations(); // globally ordered within this node
$trace->children();
use Superscript\Axiom\Tracing\TraceCollector;
$collector = new TraceCollector();
try {
$program->call($bindings, observer: $collector);
} finally {
$partialTrace = $collector->trace();
}
use Superscript\Axiom\CompiledSource;
use Superscript\Axiom\SourceCompilation;
use Superscript\Axiom\SourceEvaluation;
private function compile(MySource $source, SourceCompilation $compilation): CompiledSource
{
return $compilation->custom($returnType, function (SourceEvaluation $evaluation) use ($service) {
$value = $service->lookup();
$evaluation->annotate('cache', 'miss');
$evaluation->annotate('result', $value);
return $value;
});
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.