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.2 to 0.5.3

dist_node/trampoline.js

9

dist_node/structure.js

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

"use strict";
var Applicative, Chain, Functor, Monad, Monoid, Semigroup;
var Applicative, Chain, Functor, Monad, Monoid, Semigroup, Transformer;
(Applicative = (function(instance, of, ap) {

@@ -67,2 +67,6 @@ (instance.of = (instance.prototype.of = of));

}));
(Transformer = (function(instance, lift) {
(instance.lift = (instance.prototype.lift = lift));
return instance;
}));
(exports["Applicative"] = Applicative);

@@ -73,2 +77,3 @@ (exports["Chain"] = Chain);

(exports["Monoid"] = Monoid);
(exports["Semigroup"] = Semigroup);
(exports["Semigroup"] = Semigroup);
(exports["Transformer"] = Transformer);

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

Monad = __o["Monad"],
Transformer = __o["Transformer"],
__o0 = require("../_tail"),

@@ -31,2 +32,11 @@ Tail = __o0["Tail"],

}));
Transformer(Instance, (function(t) {
return new(Instance)((function(k) {
return t.chain((function(f, g) {
return (function(x) {
return f(g(x));
});
})(trampoline, k));
}));
}));
(Instance.callcc = (Instance.prototype.callcc = ((reify = (function(k) {

@@ -43,11 +53,2 @@ return (function(x) {

}))));
(Instance.lift = (Instance.prototype.lift = (function(t) {
return new(Instance)((function(k) {
return t.chain((function(f, g) {
return (function(x) {
return f(g(x));
});
})(trampoline, k));
}));
})));
return Instance;

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

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

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

@@ -23,3 +26,3 @@ return ({

runEitherT = (function(m) {
return m.run();
return m.run;
});

@@ -32,21 +35,17 @@ (EitherT = (function(m) {

Monad(Instance, (function(x) {
return new(Instance)((function() {
return m.of(Right(x));
}));
return new(Instance)(Trampoline.of(m.of(Right(x))));
}), (function(c, f) {
return new(Instance)((function() {
return runEitherT(c)
.chain((function(__o) {
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)) : m.of(Left(x)));
return (right ? runEitherT(f(x)) : Trampoline.of(m.of(Left(x))));
}));
}));
})));
}));
Monoid(Instance, new(Instance)((function() {
return m.of(Left(m.zero));
})), (function(a, b) {
return new(Instance)((function() {
return runEitherT(a)
.chain((function(__o) {
Monoid(Instance, new(Instance)(Trampoline.of(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"],

@@ -56,19 +55,15 @@ x = __o["x"];

}));
}));
})));
}));
Transformer(Instance, (function(t) {
return new(Instance)(Trampoline.of(t.map(Right)));
}));
(Instance.right = (Instance.prototype.right = Instance.of));
(Instance.left = (Instance.prototype.left = (function(x) {
return new(Instance)((function() {
return m.of(Left(x));
}));
return new(Instance)(Trampoline.of(m.of(Left(x))));
})));
(Instance.lift = (function(t) {
return new(Instance)((function() {
return t.map(Right);
}));
}));
return Instance;
}));
(EitherT.eitherT = (function(m, l, r) {
return runEitherT(m)
return Trampoline.run(runEitherT(m))
.chain((function(__o) {

@@ -75,0 +70,0 @@ var right = __o["right"],

@@ -9,57 +9,10 @@ /*

Monoid = __o["Monoid"],
ErrorT, Right = (function(x) {
return ({
"right": true,
"x": x
});
}),
Left = (function(x) {
return ({
"right": false,
"x": x
});
}),
runErrorT = (function(m) {
return m.run();
});
EitherT = require("./either"),
eitherT = EitherT["eitherT"],
ErrorT;
(ErrorT = (function(m) {
var Instance = (function(run) {
var self = this;
(self.run = run);
});
Monad(Instance, (function(x) {
return new(Instance)((function() {
return m.of(Right(x));
}));
}), (function(c, f) {
return new(Instance)((function() {
return runErrorT(c)
.chain((function(__o) {
var right = __o["right"],
x = __o["x"];
return (right ? runErrorT(f(x)) : m.of(Left(x)));
}));
}));
}));
Monoid(Instance, new(Instance)((function() {
return m.of(Left(m.zero));
})), (function(a, b) {
return new(Instance)((function() {
return runErrorT(a)
.chain((function(__o) {
var right = __o["right"],
x = __o["x"];
return (right ? m.of(Right(x)) : runErrorT(b));
}));
}));
}));
(Instance.fail = (Instance.prototype.fail = (function(x) {
return new(Instance)((function() {
return m.of(Left(x));
}));
})));
var Instance = EitherT(m);
(Instance.fail = (Instance.prototype.fail = Instance.left));
(Instance.handle = (function(m, e) {
return new(Instance)((function() {
return Instance.runErrorT(m, e, m.of);
}));
return ErrorT.runErrorT(m, m.of, e);
}));

@@ -70,17 +23,7 @@ (Instance.prototype.handle = (function(e) {

}));
(Instance.lift = (function(t) {
return new(Instance)((function() {
return t.map(Right);
}));
}));
return Instance;
}));
(ErrorT.runErrorT = (function(m, ok, err) {
return runErrorT(m)
.chain((function(__o) {
var right = __o["right"],
x = __o["x"];
return (right ? ok(x) : err(x));
}));
return eitherT(m, err, ok);
}));
(module.exports = ErrorT);

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

Monoid = __o["Monoid"],
Transformer = __o["Transformer"],
Identity;

@@ -24,5 +25,5 @@ (Identity = (function(m) {

}));
(Instance.lift = (Instance.prototype.lift = (function(t) {
Transformer(Instance, (function(t) {
return new(Instance)(t);
})));
}));
return Instance;

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

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

Monad = __o0["Monad"],
Transformer = __o0["Transformer"],
ListT, foldr = (function(f, z, a) {

@@ -60,3 +61,3 @@ return Array.prototype.reduceRight.call(a, f, z);

}));
(Instance.lift = (function(t) {
Transformer(Instance, (function(t) {
return new(Instance)((function() {

@@ -63,0 +64,0 @@ return liftM((function(x) {

@@ -9,36 +9,10 @@ /*

Monoid = __o["Monoid"],
Transformer = __o["Transformer"],
Trampoline = require("../trampoline"),
thunk = Trampoline["thunk"],
run = Trampoline["run"],
__o0 = require("../base"),
concat = __o0["concat"],
chain = __o0["chain"],
StateT, K = (function(k) {
var self = this;
(self.k = k);
}),
Chain = (function(c, f) {
var self = this;
(self.c = c);
(self.f = f);
}),
Ap = (function(c, k) {
var self = this;
(self.c = c);
(self.k = k);
}),
appk = (function(k, x) {
return ((k instanceof Ap) ? new(Chain)(k.c(x), k.k) : k(x));
}),
run = (function(cont) {
var k = cont;
while (true) {
if ((k instanceof K))(k = k.k());
else if ((k instanceof Chain)) {
var __o = k,
c = __o["c"];
if ((c instanceof K))(k = new(Chain)(c.k(), k.f));
else if ((c instanceof Chain))(k = new(Chain)(c.c, new(Ap)(c.f, k.f)));
else(k = appk(k.f, k.c));
} else return k;
}
}),
Pair = (function(x, s) {
StateT, Pair = (function(x, s) {
return ({

@@ -59,15 +33,14 @@ "x": x,

return new(Instance)((function(s) {
return m.of(Pair(x, s));
return Trampoline.of(m.of(Pair(x, s)));
}));
}), (function(c, f) {
return new(Instance)((function(s) {
return new(Chain)(new(K)((function() {
return runStateT(c, s);
})), (function(t) {
return t.chain((function(__o) {
var x = __o["x"],
s = __o["s"];
return run(runStateT(f(x), s));
return thunk(c.run, s)
.chain((function(t) {
return Trampoline.of(t.chain((function(__o) {
var x = __o["x"],
s = __o["s"];
return run(runStateT(f(x), s));
})));
}));
}));
}));

@@ -79,15 +52,24 @@ }));

return new(Instance)((function(s) {
return new(Chain)(runStateT(a, s), (function(t) {
return new(Chain)(runStateT(b, s), (function(k) {
return t.concat(k);
return thunk(a.run, s)
.chain((function(t) {
return runStateT(b, s)
.chain((function(k) {
return Trampoline.of(t.concat(k));
}));
}));
}));
}));
}));
Transformer(Instance, (function(t) {
return new(Instance)((function(s) {
return Trampoline.of(t.chain((function(x) {
return m.of(Pair(x, s));
})));
}));
}));
(Instance.get = (Instance.prototype.get = new(Instance)((function(s) {
return m.of(Pair(s, s));
return Trampoline.of(m.of(Pair(s, s)));
}))));
(Instance.put = (Instance.prototype.put = (function(s) {
return new(Instance)((function(_) {
return m.of(Pair(s, s));
return Trampoline.of(m.of(Pair(s, s)));
}));

@@ -102,9 +84,2 @@ })));

})));
(Instance.lift = (Instance.prototype.lift = (function(t) {
return new(Instance)((function(s) {
return t.chain((function(x) {
return m.of(Pair(x, s));
}));
}));
})));
return Instance;

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

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

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

@@ -55,2 +55,17 @@ var Either = require('../index').either;

exports.chain_many = function(test) {
var c = Either.of(0);
for (var i = 0; i < 100000; ++i)
c = c.chain(function(x) {
return Either.of(x + 1);
});
test.deepEqual(
Either.either(c, l, r),
[true, 100000]);
test.done();
};
exports.chain_left = function(test) {

@@ -57,0 +72,0 @@ var c = Either.of(1)

@@ -65,3 +65,26 @@ var Error = require('../index').error;

exports.chain_fail_handle = function(test) {
var c = Error.of(1)
.chain(function(x) {
return Error.fail(x + 1)
})
.chain(function(x) {
return Error.of(x * 2);
})
.handle(function(e) {
return Error.of(1000);
})
.chain(function(x) {
return Error.of(x + 10);
});
test.deepEqual(
Error.tryError(c, function(x) { return x; }),
1010);
test.done();
};
exports.map_right = function(test) {

@@ -68,0 +91,0 @@ var c = Error.of(3)

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