pub const PHP_RUNTIME: &str = r#"<?php
// OxiLean PHP Runtime
// Auto-generated — do not edit.
declare(strict_types=1);
namespace OxiLean\Runtime;
/** Represents a lazy thunk (unevaluated computation). */
final class Thunk
{
private mixed $value = null;
private bool $evaluated = false;
/** @var callable */
private $thunk;
public function __construct(callable $thunk)
{
$this->thunk = $thunk;
}
public function force(): mixed
{
if (!$this->evaluated) {
$this->value = ($this->thunk)();
$this->evaluated = true;
}
return $this->value;
}
}
/** Represents an OxiLean product (pair/tuple). */
final readonly class Prod
{
public function __construct(
public readonly mixed $fst,
public readonly mixed $snd,
) {}
}
/** Represents an OxiLean sum (Either). */
abstract class Sum
{
final public static function inl(mixed $val): self
{
return new class($val) extends Sum {
public function __construct(public readonly mixed $val) {}
};
}
final public static function inr(mixed $val): self
{
return new class($val) extends Sum {
public function __construct(public readonly mixed $val) {}
};
}
}
/** Nat operations. */
final class Nat
{
public static function succ(int $n): int { return $n + 1; }
public static function pred(int $n): int { return max(0, $n - 1); }
public static function add(int $a, int $b): int { return $a + $b; }
public static function mul(int $a, int $b): int { return $a * $b; }
public static function sub(int $a, int $b): int { return max(0, $a - $b); }
}
"#;Expand description
Minimal OxiLean PHP runtime header embedded in emitted files.