sigsolve

type signature satisfiability solver under function composition

npm install sigsolve
6 downloads in the last week
10 downloads in the last month

sigsolve

find a path through a type signature pool

testling badge

build status

example

var sigsolve = require('sigsolve');
var pool = {
    f : [ 'a', 'b' ],
    g : [ 'b', 'x' ],
    h : [ 'x', 'z' ],
    i : [ 'c', 'z' ],
    j : [ 'c', 'd' ],
};

var solutions = sigsolve([ 'a', 'z' ], pool);
console.dir(solutions);

output:

[ [ 'f', 'g', 'h' ] ]

or higher-order signatures work too:

var sigsolve = require('sigsolve');
var pool = {
    f : [ [ 'a', 'b' ], 'c' ],
    g : [ 'c', 'z' ],
    h : [ 'a', 'd' ],
    i : [ 'd', 'b' ],
};
var solutions = sigsolve([ 'a', 'z' ], pool);
console.log(JSON.stringify(solutions));

output:

[[["f",["h","i"]],"g"]]

methods

var sigsolve = require('sigsolve')

var solutions = sigsolve(target, pool)

Given a type signature target and an object pool mapping function names to type signatures,

return an array of function chain arrays that when composed have the same type signature as the target.

license

MIT

npm loves you