New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

akh

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

akh - npm Package Compare versions

Comparing version 0.5.3 to 0.6.0

dist_node/free.js

8

dist_node/dcont.js

@@ -15,9 +15,3 @@ /*

});
})(Identity.runIdentity, (function(m, k) {
return runDContT(m, (function(f, g) {
return (function(x) {
return f(g(x));
});
})(Identity.of, k));
})));
})(Identity.runIdentity, runDContT));
(module.exports = DCont);
/*
* THIS FILE IS AUTO GENERATED from 'lib/list.kep'
* THIS FILE IS AUTO GENERATED FROM 'lib/list.kep'
* DO NOT EDIT
*/"use strict";
*/
"use strict";
var Identity = require("./identity"),

@@ -6,0 +7,0 @@ ListT = require("./trans/list"),

@@ -6,6 +6,6 @@ /*

"use strict";
var Identity = require("./identity"),
var Trampoline = require("./trampoline"),
StateT = require("./trans/state"),
State;
(State = StateT(Identity));
(State = StateT(Trampoline));
(State.runState = (function(f, g) {

@@ -15,3 +15,3 @@ return (function() {

});
})(Identity.runIdentity, StateT.runStateT));
})(Trampoline.run, StateT.runStateT));
(State.evalState = (function(f, g) {

@@ -21,3 +21,3 @@ return (function() {

});
})(Identity.runIdentity, StateT.evalStateT));
})(Trampoline.run, StateT.evalStateT));
(State.execState = (function(f, g) {

@@ -27,3 +27,3 @@ return (function() {

});
})(Identity.runIdentity, StateT.execStateT));
})(Trampoline.run, StateT.execStateT));
(module.exports = State);

@@ -25,8 +25,20 @@ /*

(self.f = f);
if ((!(((c instanceof Chain) || (c instanceof Thunk)) || (c instanceof Done)))) debugger;
});
(Chain.prototype = new(Trampoline)());
var Ap = (function(c, f) {
var self = this;
(self.c = c);
(self.f = f);
}),
appk = (function(f, x) {
return ((f instanceof Ap) ? new(Chain)(f.c(x), f.f) : f(x));
});
Monad(Trampoline, (function(x) {
return new(Done)(x);
}), (function(c, f) {
return new(Chain)(c, f);
return (((c instanceof Chain) && false) ? new(Chain)(c.c, (function(x) {
return c.f(x)
.chain(f);
})) : new(Chain)(c, f));
}));

@@ -36,10 +48,2 @@ (Trampoline.thunk = (function(k, x) {

}));
var Ap = (function(c, k) {
var self = this;
(self.c = c);
(self.k = k);
}),
appk = (function(f, x) {
return ((f instanceof Ap) ? new(Chain)(f.c(x), f.k) : f(x));
});
(Trampoline.run = (function(cont) {

@@ -52,6 +56,8 @@ var k = cont;

var __o = k,
c = __o["c"];
if ((c instanceof Done))(k = appk(k.f, c.x));
else if ((c instanceof Thunk))(k = new(Chain)(c.k(c.x), k.f));
else if ((c instanceof Chain))(k = new(Chain)(c.c, new(Ap)(c.f, k.f)));
c = __o["c"],
f = __o["f"];
if ((c instanceof Done))(k = appk(f, c.x));
else if ((c instanceof Thunk))(k = c.k(c.x)
.chain(f));
else if ((c instanceof Chain))(k = c.c.chain(new(Ap)(c.f, k.f)));
}

@@ -58,0 +64,0 @@ }

@@ -12,3 +12,7 @@ /*

trampoline = __o0["trampoline"],
ContT, runContT = (function(m, k) {
ContT, ContMonat = (function(instance, callcc) {
(instance.callcc = (instance.prototype.callcc = callcc));
return instance;
}),
runContT = (function(m, k) {
return new(Tail)(m.run, k);

@@ -41,3 +45,3 @@ });

}));
(Instance.callcc = (Instance.prototype.callcc = ((reify = (function(k) {
ContMonat(Instance, ((reify = (function(k) {
return (function(x) {

@@ -52,3 +56,3 @@ return new(Instance)((function(_) {

}));
}))));
})));
return Instance;

@@ -55,0 +59,0 @@ }));

@@ -6,12 +6,16 @@ /*

"use strict";
var stream = require("nu-stream")["stream"],
first = stream["first"],
rest = stream["rest"],
isEmpty = stream["isEmpty"],
Unique = require("../unique"),
__o = require("../structure"),
Monad = __o["Monad"],
__o0 = require("../_tail"),
Tail = __o0["Tail"],
trampoline = __o0["trampoline"],
var __o = require("nu-stream")["stream"],
append = __o["append"],
cons = __o["cons"],
first = __o["first"],
rest = __o["rest"],
isEmpty = __o["isEmpty"],
NIL = __o["NIL"],
UniqueT = require("./unique"),
__o0 = require("../structure"),
Monad = __o0["Monad"],
Transformer = __o0["Transformer"],
__o1 = require("../_tail"),
Tail = __o1["Tail"],
trampoline = __o1["trampoline"],
DContT, Seg = (function(f) {

@@ -25,5 +29,5 @@ var self = this;

}),
empty = stream.NIL,
push = stream.cons,
pushSeq = stream.append,
empty = NIL,
push = cons,
pushSeq = append,
pushP = (function(t, k) {

@@ -45,2 +49,22 @@ return push(new(P)(t), k);

}),
DContMonad = (function(instance, newPrompt, pushPrompt, withSubCont, pushSubCont) {
(instance.newPrompt = (instance.prototype.newPrompt = newPrompt));
(instance.pushPrompt = (instance.prototype.pushPrompt = pushPrompt));
(instance.withSubCont = (instance.prototype.withSubCont = withSubCont));
(instance.pushSubCont = (instance.prototype.pushSubCont = pushSubCont));
(instance.reset = (instance.prototype.reset = (function(f) {
return newPrompt.chain((function(p) {
return pushPrompt(p, f(p));
}));
})));
(instance.shift = (instance.prototype.shift = (function(p, f) {
var t = this;
return withSubCont(p, (function(k) {
return pushPrompt(p, f((function(c) {
return pushPrompt(p, pushSubCont(k, c));
})));
}));
})));
return instance;
}),
unDContT = (function(m, k) {

@@ -57,18 +81,19 @@ return new(Tail)(m.run, k);

});
})(Unique.runUnique, trampoline), unDContT),
appk = (function(k, x) {
var c = k;
do {
if (((typeof c) === "function")) return Unique.of(c(x));
var top = first(c);
if ((top instanceof Seg)) return unDContT(top.frame(x), rest(c));
(c = ((top instanceof P) ? rest(c) : top));
}
while (true);
});
})(UniqueT.runUniqueT, trampoline), unDContT);
(DContT = (function(m) {
var Instance = (function(run) {
var self = this;
(self.run = run);
});
var M = UniqueT(m),
Instance = (function(run) {
var self = this;
(self.run = run);
}),
appk = (function(k, x) {
var c = k;
do {
if (((typeof c) === "function")) return M.of(c(x));
var top = first(c);
if ((top instanceof Seg)) return unDContT(top.frame(x), rest(c));
(c = ((top instanceof P) ? rest(c) : top));
}
while (true);
});
Monad(Instance, (function(x) {

@@ -83,13 +108,14 @@ return new(Instance)((function(k) {

}));
(Instance.lift = (function(t) {
Transformer(Instance, (function(t) {
return new(Instance)((function(k) {
return t.chain((function(f, g) {
return (function(x) {
return f(g(x));
});
})(trampoline, appk.bind(null, k)));
return M.lift(t.map(trampoline))
.chain((function(f, g) {
return (function(x) {
return f(g(x));
});
})(trampoline, appk.bind(null, k)));
}));
}));
(Instance.newPrompt = (Instance.prototype.newPrompt = new(Instance)((function(k) {
return Unique.unique.chain((function(f, g) {
DContMonad(Instance, new(Instance)((function(k) {
return M.unique.chain((function(f, g) {
return (function(x) {

@@ -99,9 +125,7 @@ return f(g(x));

})(trampoline, appk.bind(null, k)));
}))));
(Instance.pushPrompt = (Instance.prototype.pushPrompt = (function(prompt, c) {
})), (function(prompt, c) {
return new(Instance)((function(k) {
return unDContT(c, pushP(prompt, k));
}));
})));
(Instance.withSubCont = (Instance.prototype.withSubCont = (function(prompt, f) {
}), (function(prompt, f) {
return new(Instance)((function(k) {

@@ -113,21 +137,7 @@ var __o = splitSeq(prompt, k),

}));
})));
(Instance.pushSubCont = (Instance.prototype.pushSubCont = (function(subk, c) {
}), (function(subk, c) {
return new(Instance)((function(k) {
return unDContT(c, pushSeq(subk, k));
}));
})));
(Instance.reset = (Instance.prototype.reset = (function(f) {
return Instance.newPrompt.chain((function(p) {
return Instance.pushPrompt(p, f(p));
}));
})));
(Instance.shift = (Instance.prototype.shift = (function(p, f) {
var t = this;
return t.withSubCont(p, (function(k) {
return t.pushPrompt(p, f((function(c) {
return t.pushPrompt(p, t.pushSubCont(k, c));
})));
}));
})));
}));
return Instance;

@@ -134,0 +144,0 @@ }));

@@ -10,4 +10,2 @@ /*

Transformer = __o["Transformer"],
Trampoline = require("../trampoline"),
thunk = Trampoline["thunk"],
EitherT, Right = (function(x) {

@@ -34,29 +32,27 @@ return ({

Monad(Instance, (function(x) {
return new(Instance)(Trampoline.of(m.of(Right(x))));
return new(Instance)(m.of(Right(x)));
}), (function(c, f) {
return new(Instance)(runEitherT(c)
.chain((function(t) {
return t.chain((function(__o) {
var right = __o["right"],
x = __o["x"];
return (right ? runEitherT(f(x)) : Trampoline.of(m.of(Left(x))));
}));
.chain((function(__o) {
var right = __o["right"],
x = __o["x"];
return (right ? runEitherT(f(x)) : m.of(Left(x)));
})));
}));
Monoid(Instance, new(Instance)(Trampoline.of(m.of(Left(m.zero)))), (function(a, b) {
Monoid(Instance, new(Instance)(m.of(Left(m.zero))), (function(a, b) {
return new(Instance)(runEitherT(a)
.chain((function(t) {
return t.chain((function(__o) {
var right = __o["right"],
x = __o["x"];
return (right ? m.of(Right(x)) : runEitherT(b));
}));
.chain((function(__o) {
var right = __o["right"],
x = __o["x"];
return (right ? m.of(Right(x)) : runEitherT(b));
})));
}));
Transformer(Instance, (function(t) {
return new(Instance)(Trampoline.of(t.map(Right)));
return new(Instance)(t.chain((function(x) {
return m.of(Right(x));
})));
}));
(Instance.right = (Instance.prototype.right = Instance.of));
(Instance.left = (Instance.prototype.left = (function(x) {
return new(Instance)(Trampoline.of(m.of(Left(x))));
return new(Instance)(m.of(Left(x)));
})));

@@ -66,3 +62,3 @@ return Instance;

(EitherT.eitherT = (function(m, l, r) {
return Trampoline.run(runEitherT(m))
return runEitherT(m)
.chain((function(__o) {

@@ -69,0 +65,0 @@ var right = __o["right"],

@@ -19,3 +19,8 @@ /*

}), (function(c, f) {
return new(Instance)(c.chain(f));
return new(Instance)(Identity.runIdentityT(c)
.chain((function(f, g) {
return (function(x) {
return f(g(x));
});
})(Identity.runIdentityT, f)));
}));

@@ -22,0 +27,0 @@ Monoid(Instance, new(Instance)(m.zero), (function(a, b) {

@@ -39,29 +39,19 @@ /*

})(sequence, map);
Monoid(Instance, new(Instance)((function() {
return m.of([]);
})), (function(a, b) {
return new(Instance)((function() {
return liftM2(concat, ListT.runListT(a), ListT.runListT(b));
}));
Monoid(Instance, new(Instance)(m.of([])), (function(a, b) {
return new(Instance)(liftM2(concat, ListT.runListT(a), ListT.runListT(b)));
}));
Monad(Instance, (function(x) {
return new(Instance)((function() {
return m.of([x]);
}));
return new(Instance)(m.of([x]));
}), (function(c, f) {
return new(Instance)((function() {
return flattenM(ListT.runListT(c)
.chain(mapM.bind(null, (function(f, g) {
return (function(x) {
return f(g(x));
});
})(ListT.runListT, f))));
}));
return new(Instance)(flattenM(ListT.runListT(c)
.chain(mapM.bind(null, (function(f, g) {
return (function(x) {
return f(g(x));
});
})(ListT.runListT, f)))));
}));
Transformer(Instance, (function(t) {
return new(Instance)((function() {
return liftM((function(x) {
return [x];
}), t);
}));
return new(Instance)(liftM((function(x) {
return [x];
}), t));
}));

@@ -71,4 +61,4 @@ return Instance;

(ListT.runListT = (function(m) {
return m.run();
return m.run;
}));
(module.exports = ListT);

@@ -13,5 +13,2 @@ /*

run = Trampoline["run"],
__o0 = require("../base"),
concat = __o0["concat"],
chain = __o0["chain"],
StateT, Pair = (function(x, s) {

@@ -23,2 +20,13 @@ return ({

}),
StateMonad = (function(instance, get, put) {
(instance.get = (instance.prototype.get = get));
(instance.put = (instance.prototype.put = put));
(instance.modify = (instance.prototype.modify = (function(f) {
return get.chain((function(f, g) {
return (function(x) {
return f(g(x));
});
})(put, f));
})));
}),
runStateT = (function(m, s) {

@@ -49,3 +57,3 @@ return m.run(s);

Monoid(Instance, new(Instance)((function(_) {
return m.zero;
return Trampoline.of(m.zero);
})), (function(a, b) {

@@ -69,17 +77,9 @@ return new(Instance)((function(s) {

}));
(Instance.get = (Instance.prototype.get = new(Instance)((function(s) {
StateMonad(Instance, new(Instance)((function(s) {
return Trampoline.of(m.of(Pair(s, s)));
}))));
(Instance.put = (Instance.prototype.put = (function(s) {
})), (function(s) {
return new(Instance)((function(_) {
return Trampoline.of(m.of(Pair(s, s)));
}));
})));
(Instance.modify = (Instance.prototype.modify = (function(f) {
return Instance.get.chain((function(f, g) {
return (function(x) {
return f(g(x));
});
})(Instance.put, f));
})));
}));
return Instance;

@@ -86,0 +86,0 @@ }));

{
"name": "akh",
"version": "0.5.3",
"version": "0.6.0",
"description": "Monad and Monad Transformer Collection",

@@ -5,0 +5,0 @@ "author": "Matt Bierner",

@@ -15,2 +15,3 @@ # Akh

### Monad Transformers
* IdentityT - `akh::trans::identity` - Transforms a monad to itself. (Monad, Functor, Applicative Functor)
* StateT - `akh::trans::state` - State transformer. (Monad, Monoid, Functor, Applicative Functor)

@@ -31,2 +32,3 @@ * ListT - `akh::trans::list` - List transformer. (Monad, Monoid, Functor, Applicative Functor)

* ErrorT - `akh::error` - Error computation. (Monad, Functor, Applicative Functor)
* Trampoline - `akh::trampoline` Trampolined computation (Monad, Functor, Applicative Functor)

@@ -33,0 +35,0 @@

@@ -57,2 +57,14 @@ var Cont = require('../index').cont;

exports.many_inner_chain = function(test) {
var f = function(x) {
if (x > 10000) return Cont.of(x);
return Cont.of(x + 1).chain(f);
}
test.deepEqual(
Cont.runCont(f(0), sqr),
10001 * 10001);
test.done();
};
exports.simple_callcc = function(test) {

@@ -59,0 +71,0 @@ var c = Cont.of(3)

@@ -64,2 +64,15 @@ var DCont = require('../index').dcont;

exports.many_inner_chain = function(test) {
var f = function(x) {
if (x > 10000) return DCont.of(x);
return DCont.of(x + 1).chain(f);
}
test.deepEqual(
DCont.runDCont(f(0), sqr),
10001 * 10001);
test.done();
};
exports.single_shift_reset = function(test) {

@@ -66,0 +79,0 @@ var c = DCont

@@ -8,3 +8,3 @@ var DContT = require('../index').trans.dcont;

c,
function(x) { return State.of(k(x))}),
k),
s);

@@ -27,3 +27,2 @@ };

test.done();

@@ -30,0 +29,0 @@ };

@@ -63,6 +63,7 @@ var Either = require('../index').either;

test.deepEqual(
Either.either(c, l, r),
[true, 100000]);
test.done();

@@ -69,0 +70,0 @@ };

@@ -84,3 +84,2 @@ var State = require('../index').state;

exports.many_chain = function(test) {

@@ -90,4 +89,4 @@ var c = State.of(0);

for (var i = 0; i < 100000; ++i) {
c = c.chain(function(x) {
return State.of(x + 1);
c = c.map(function(x) {
return x + 1;
});

@@ -100,2 +99,15 @@ }

test.done();
};
exports.many_chain_inner = function(test) {
var f = function(x) {
if (x > 10000) return State.of(x);
return State.of(x + 1).chain(f);
}
test.deepEqual(
State.runState(f(0), 0),
{'x': 10001, 's': 0});
test.done();
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc