Permalink
Browse files

Codensity, state performance improvements, split specs

  • Loading branch information...
mattbierner committed Apr 13, 2014
1 parent a274996 commit e293e3208ae2181c7ba0a9d264648d37751ed639
Showing with 958 additions and 790 deletions.
  1. +1 −0 .gitignore
  2. +6 −0 CHANGELOG.md
  3. +14 −0 dist/spec/cont.js
  4. +35 −0 dist/spec/dcont.js
  5. +15 −0 dist/spec/either.js
  6. +17 −0 dist/spec/error.js
  7. +28 −0 dist/spec/state.js
  8. +5 −5 dist/state.js
  9. +11 −6 dist/structure.js
  10. +0 −66 dist/trampoline.js
  11. +60 −0 dist/trans/codensity.js
  12. +18 −22 dist/trans/cont.js
  13. +2 −28 dist/trans/dcont.js
  14. +26 −25 dist/trans/either.js
  15. +5 −9 dist/trans/error.js
  16. +17 −18 dist/trans/identity.js
  17. +11 −10 dist/trans/list.js
  18. +51 −59 dist/trans/state.js
  19. +3 −3 dist/unique.js
  20. +12 −0 dist_node/spec/cont.js
  21. +33 −0 dist_node/spec/dcont.js
  22. +13 −0 dist_node/spec/either.js
  23. +15 −0 dist_node/spec/error.js
  24. +26 −0 dist_node/spec/state.js
  25. +5 −5 dist_node/state.js
  26. +11 −6 dist_node/structure.js
  27. +0 −65 dist_node/trampoline.js
  28. +60 −0 dist_node/trans/codensity.js
  29. +19 −23 dist_node/trans/cont.js
  30. +1 −26 dist_node/trans/dcont.js
  31. +26 −24 dist_node/trans/either.js
  32. +4 −8 dist_node/trans/error.js
  33. +17 −18 dist_node/trans/identity.js
  34. +11 −10 dist_node/trans/list.js
  35. +52 −59 dist_node/trans/state.js
  36. +3 −3 dist_node/unique.js
  37. +1 −1 lib/dcont.kep
  38. +1 −1 lib/either.kep
  39. +1 −1 lib/error.kep
  40. +1 −1 lib/list.kep
  41. +20 −0 lib/spec/cont.kep
  42. +75 −0 lib/spec/dcont.kep
  43. +23 −0 lib/spec/either.kep
  44. +15 −0 lib/spec/error.kep
  45. +41 −0 lib/spec/state.kep
  46. +6 −6 lib/state.kep
  47. +16 −6 lib/structure.kep
  48. +0 −94 lib/trampoline.kep
  49. +53 −0 lib/trans/codensity.kep
  50. +6 −21 lib/trans/cont.kep
  51. +1 −71 lib/trans/dcont.kep
  52. +10 −13 lib/trans/either.kep
  53. +8 −9 lib/trans/error.kep
  54. +9 −7 lib/trans/identity.kep
  55. +10 −6 lib/trans/list.kep
  56. +25 −52 lib/trans/state.kep
  57. +3 −3 lib/unique.kep
View
@@ -3,6 +3,7 @@
.project
node_modules
_site
.settings
# OS Files #
############
View
@@ -1,5 +1,11 @@
# ChangeLog
## 2.0.0 - April XX, 2014
* Added `Codensity` monad.
* Split interfaces into own files. `akh::spec::*`.
* Autolifting of state `get` `put` and `modify` in most base types.
*
## 1.1.2 - April 10, 2014
* Performance improvements though recompile with khepri V0.23.0
View
@@ -0,0 +1,14 @@
/*
* THIS FILE IS AUTO GENERATED FROM 'lib/spec/cont.kep'
* DO NOT EDIT
*/
define(["require", "exports"], (function(require, exports) {
"use strict";
var ContMonad;
(ContMonad = (function(instance, callcc) {
(instance.prototype.callcc = callcc);
(instance.callcc = instance.prototype.callcc);
return instance;
}));
return ContMonad;
}));
View
@@ -0,0 +1,35 @@
/*
* THIS FILE IS AUTO GENERATED FROM 'lib/spec/dcont.kep'
* DO NOT EDIT
*/
define(["require", "exports"], (function(require, exports) {
"use strict";
var DContMonad;
(DContMonad = (function(instance, newPrompt, pushPrompt, withSubCont, pushSubCont) {
(instance.prototype.newPrompt = newPrompt);
(instance.newPrompt = instance.prototype.newPrompt);
(instance.prototype.pushPrompt = pushPrompt);
(instance.pushPrompt = instance.prototype.pushPrompt);
(instance.prototype.withSubCont = withSubCont);
(instance.withSubCont = instance.prototype.withSubCont);
(instance.prototype.pushSubCont = pushSubCont);
(instance.pushSubCont = instance.prototype.pushSubCont);
(instance.prototype.reset = (function(f) {
return newPrompt.chain((function(p) {
return pushPrompt(p, f(p));
}));
}));
(instance.reset = instance.prototype.reset);
(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));
})));
}));
}));
(instance.shift = instance.prototype.shift);
return instance;
}));
return DContMonad;
}));
View
@@ -0,0 +1,15 @@
/*
* THIS FILE IS AUTO GENERATED FROM 'lib/spec/either.kep'
* DO NOT EDIT
*/
define(["require", "exports"], (function(require, exports) {
"use strict";
var EitherMonad;
(EitherMonad = (function(Instance, left, right) {
(Instance.prototype.right = right);
(Instance.right = Instance.prototype.right);
(Instance.prototype.left = left);
(Instance.left = Instance.prototype.left);
}));
return EitherMonad;
}));
View
@@ -0,0 +1,17 @@
/*
* THIS FILE IS AUTO GENERATED FROM 'lib/spec/error.kep'
* DO NOT EDIT
*/
define(["require", "exports"], (function(require, exports) {
"use strict";
var ErrorMonad;
(ErrorMonad = (function(Instance, fail, handle) {
(Instance.prototype.fail = fail);
(Instance.fail = Instance.prototype.fail);
(Instance.prototype.handle = handle);
(Instance.handle = (function(m, e) {
return m.handle(e);
}));
}));
return ErrorMonad;
}));
View
@@ -0,0 +1,28 @@
/*
* THIS FILE IS AUTO GENERATED FROM 'lib/spec/state.kep'
* DO NOT EDIT
*/
define(["require", "exports"], (function(require, exports) {
"use strict";
var StateMonad;
(StateMonad = (function(Instance, get, put) {
(Instance.prototype.get = get);
(Instance.get = Instance.prototype.get);
(Instance.prototype.put = put);
(Instance.put = Instance.prototype.put);
(Instance.prototype.modify = (function(f) {
return get.chain((function(x) {
return put(f(x));
}));
}));
(Instance.modify = Instance.prototype.modify);
}));
(StateMonad.tryLiftState = (function(Instance, m) {
var x, y;
if ((m.get && m.put)) StateMonad(Instance, Instance.lift(m.get), ((x = Instance.lift), (y = m.put), (
function(x0) {
return x(y(x0));
})));
}));
return StateMonad;
}));
View
@@ -2,22 +2,22 @@
* THIS FILE IS AUTO GENERATED FROM 'lib/state.kep'
* DO NOT EDIT
*/
define(["require", "exports", "./trampoline", "./trans/state"], (function(require, exports, Trampoline, StateT) {
define(["require", "exports", "./identity", "./trans/state"], (function(require, exports, Identity, StateT) {
"use strict";
var State;
(State = StateT(Trampoline));
(State = StateT(Identity));
var x = StateT.runStateT,
y = Trampoline.run;
y = Identity.runIdentity;
(State.runState = (function() {
return y(x.apply(null, arguments));
}));
var x0 = StateT.evalStateT,
y0 = Trampoline.run;
y0 = Identity.runIdentity;
(State.evalState = (function() {
return y0(x0.apply(null, arguments));
}));
var x1 = StateT.execStateT,
y1 = Trampoline.run;
y1 = Identity.runIdentity;
(State.execState = (function() {
return y1(x1.apply(null, arguments));
}));
View
@@ -5,7 +5,7 @@
define(["require", "exports", "./base"], (function(require, exports, base) {
"use strict";
var liftA2 = base["liftA2"],
Applicative, Chain, Functor, Monad, Monoid, Semigroup, Transformer, __curry = (function(x, y) {
Applicative, Chain, Functor, Monad, Monoid, Semigroup, LiftInner, Transformer, __curry = (function(x, y) {
return x.bind(null, y);
});
(Applicative = (function(Instance, of, ap) {
@@ -73,11 +73,7 @@ define(["require", "exports", "./base"], (function(require, exports, base) {
}
return outer;
});
(Transformer = (function(Instance, m, lift) {
(Instance.prototype.inner = m);
(Instance.inner = Instance.prototype.inner);
(Instance.prototype.lift = lift);
(Instance.lift = Instance.prototype.lift);
(LiftInner = (function(Instance, m, lift) {
if (m.lift) {
var y;
(Instance.prototype.liftInner = liftInner(lift, ((y = m.lift), (function(x) {
@@ -87,11 +83,20 @@ define(["require", "exports", "./base"], (function(require, exports, base) {
}
return Instance;
}));
(Transformer = (function(Instance, m, lift) {
(Instance.prototype.inner = m);
(Instance.inner = Instance.prototype.inner);
(Instance.prototype.lift = lift);
(Instance.lift = Instance.prototype.lift);
LiftInner(Instance, m, lift);
return Instance;
}));
(exports["Applicative"] = Applicative);
(exports["Chain"] = Chain);
(exports["Functor"] = Functor);
(exports["Monad"] = Monad);
(exports["Monoid"] = Monoid);
(exports["Semigroup"] = Semigroup);
(exports["LiftInner"] = LiftInner);
(exports["Transformer"] = Transformer);
}));
View

This file was deleted.

Oops, something went wrong.
View
@@ -0,0 +1,60 @@
/*
* THIS FILE IS AUTO GENERATED FROM 'lib/trans/codensity.kep'
* DO NOT EDIT
*/
define(["require", "exports", "../structure", "../_tail", "../spec/state"], (function(require, exports, __o, __o0,
StateMonad) {
"use strict";
var Monad = __o["Monad"],
Monoid = __o["Monoid"],
Transformer = __o["Transformer"],
Tail = __o0["Tail"],
trampoline = __o0["trampoline"],
Codensity, runCodensity = (function(m, k) {
return new(Tail)(m.run, k);
});
(Codensity = (function(m) {
var Instance = (function(run) {
var self = this;
(self.run = run);
});
Monad(Instance, (function(x) {
return new(Instance)((function(k) {
return k(x);
}));
}), (function(f) {
var c = this;
return new(Instance)((function(k) {
var k0 = (function(x) {
var m0 = f(x);
return new(Tail)(m0.run, k);
});
return new(Tail)(c.run, k0);
}));
}));
Monoid(Instance, new(Instance)((function(_) {
return m.zero;
})), (function(b) {
var a = this;
return new(Instance)((function(k) {
return Codensity.runCodensity(a, k)
.concat(Codensity.runCodensity(b, k));
}));
}));
Transformer(Instance, m, (function(c) {
return new(Instance)((function(k) {
var y;
return c.chain(((y = trampoline), (function(x) {
return y(k(x));
})));
}));
}));
StateMonad.tryLiftState(Instance, m);
return Instance;
}));
var y = trampoline;
(Codensity.runCodensity = (function() {
return y(runCodensity.apply(null, arguments));
}));
return Codensity;
}));
Oops, something went wrong.

0 comments on commit e293e32

Please sign in to comment.