
Product
PHP and Composer Support Is Now in Beta
Socket’s PHP and Composer support is now in Beta for all customers, with PHP reachability analysis generally available.
Embeddable Prolog-style logic engine for JavaScript: declarative rules, unification, backtracking search, and four solver drivers (sync/async × callback/generator). Useful for pattern matching with extraction, constraint search, type inference, planners,
yopl is an ES6 mini-library that implements a Prolog-style logic solver in JavaScript. It provides:
Its only runtime dependency is deep6, itself a zero-dependency library that provides the unification engine.
yopl lets you describe a problem as a set of rules over JavaScript values and ask the solver to find values that satisfy them. You write declarative rules; the engine handles search, unification, and backtracking. You stay inside JavaScript — there is no embedded DSL to parse, no separate Prolog runtime, and rules can call back into plain JS (sync or async) whenever a piece of logic is easier to express that way.
It is useful when a problem is awkward to express as straight-line code but natural to express as constraints or relations:
If you only need single-direction pattern matching, a regex or a destructuring assignment is simpler. Reach for yopl when you need bidirectional matching (unification), backtracking across alternative rules, or enumeration of all solutions — and you want all of that without leaving your JavaScript codebase.
npm install --save yopl
import {variable} from 'deep6/env.js';
import assemble from 'deep6/traverse/assemble.js';
import solve from 'yopl';
const rules = {
member: [(V, X) => [{args: [{value: V, next: X}, V]}], (V, X) => [{args: [{next: X}, V]}, {name: 'member', args: [X, V]}]]
};
const list = {value: 1, next: {value: 2, next: {value: 3, next: null}}};
const X = variable('X');
solve(rules, 'member', [list, X], env => {
console.log('X =', assemble(X, env));
});
// X = 1
// X = 2
// X = 3
| Module | Purpose |
|---|---|
yopl (src/solve.js) | Synchronous callback solver — main entry point. |
yopl/solvers/gen.js | Synchronous generator solver. |
yopl/solvers/async.js | Async callback solver. |
yopl/solvers/asyncGen.js | Async generator solver. |
yopl/rules/system.js | Helpers + control predicates (head, term, list, cut, call, not, …). |
yopl/rules/comp.js | Comparisons: lt, le, gt, ge, nz. |
yopl/rules/math.js | Arithmetic: add, sub, mul, div, neg. |
yopl/rules/bits.js | Bitwise: bitAnd, bitOr, bitXor, bitNot. |
yopl/rules/logic.js | Boolean logic: logicalAnd, logicalOr, logicalXor, logicalNot. |
Per-module documentation lives in the wiki.
yopl ships as ESM only. CommonJS consumers can use Node's built-in dynamic import():
const {default: solve} = await import('yopl');
A full CJS interop demo lives in tests/test-cjs.cjs (run it with node tests/test-cjs.cjs).
git clone git@github.com:uhop/yopl.git
cd yopl
npm install
npm test
See CONTRIBUTING.md for the development workflow and AGENTS.md for AI-agent rules.
exports statement.FAQs
Embeddable Prolog-style logic engine for JavaScript: declarative rules, unification, backtracking search, and four solver drivers (sync/async × callback/generator). Useful for pattern matching with extraction, constraint search, type inference, planners,
The npm package yopl receives a total of 5 weekly downloads. As such, yopl popularity was classified as not popular.
We found that yopl demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Product
Socket’s PHP and Composer support is now in Beta for all customers, with PHP reachability analysis generally available.

Product
Socket is bringing experimental protection to Firefox, scanning 97,000+ extensions in Mozilla's official directory for malware and risky updates.

Research
/Security News
Three compromised Rust crates pulled in a malicious dependency that downloaded and executed cross-platform malware during Cargo builds.