goodguide-gibbon 0.11.0 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c5e884ceb34d20830bd23d03ba92bf99469da19
4
- data.tar.gz: a76825e187c534ea27d6e87b1fc5c0b2d2aed79c
3
+ metadata.gz: a4f4d30f737dd07ce9b941c45d77feaed8e2c41e
4
+ data.tar.gz: ee6720c670a7be541f895353a60eb127b8acd737
5
5
  SHA512:
6
- metadata.gz: 8b376e02bd42b7a66e90cc625ddc3f3c496305bad92916f6d2166fdcdf16d4b484535f35549f6d8c805a53b7b4a844757013cb51df449a841024d480cc3d9c1a
7
- data.tar.gz: a73558879b836d5eb0a8df2e036a09edfad92f3cb6f766802e706afb20ed69377da9cf232ecb7b43e5ae2b0b455c958f9a03096fad7fef8c88aeeaeede6dcfc2
6
+ metadata.gz: d8f48b545ccf26dc356ea1b81ba37e1ea0b6e0401dd03e9bef601d0016bf1be4909bd89ac10b045585c4bbcbd58b4c658cd94dd658f2619f75ae341cf5b359e0
7
+ data.tar.gz: 93724a37e4bee24325645697de319435d52affb51f1bd64587a67b27c6c96fd4983d88e7bcb2089660b3b26c5772a620721c40756a8875879301183e44983f0b
@@ -56,6 +56,7 @@ module GoodGuide
56
56
  raise "unknown tag #{tag}" unless names.is_a?(JSArray) or names.is_a?(Array)
57
57
 
58
58
  vals = names.map do |name|
59
+ raise "missing key #{name} in #{o}" unless o.key?(name)
59
60
  obj_to_js(o[name])
60
61
  end
61
62
 
@@ -80,7 +81,6 @@ module GoodGuide
80
81
  elsif o[:__isVariant__]
81
82
  out = {
82
83
  '__isVariant__' => true,
83
- '_names' => obj_to_ruby(o[:_names]),
84
84
  '_type' => o[:_type],
85
85
  '_tag' => o[:_tag]
86
86
  }
@@ -411,17 +411,24 @@ module GoodGuide
411
411
  def capture(&b)
412
412
  output = nil
413
413
  error = nil
414
- callback_called = false
414
+ call_count = 0
415
415
 
416
416
  b.call do |*args|
417
- callback_called = true
418
-
419
417
  # Rhino doesn't get "this", but V8 does.
420
418
  args.shift unless defined?(JRUBY_VERSION)
419
+
420
+ call_count += 1
421
+
422
+ if call_count >= 2
423
+ first = [err, output].inspect
424
+ second = args.inspect
425
+ raise "gibbon: callback called twice with #{first} and #{second}"
426
+ end
427
+
421
428
  error, output = args[0..1]
422
429
  end
423
430
 
424
- raise "callback never called" unless callback_called
431
+ raise "gibbon: callback never called" unless call_count >= 1
425
432
 
426
433
  [output, error]
427
434
  end
@@ -431,7 +431,7 @@ Parsimmon.Parser = P(function(_, _super, Parser) {
431
431
  return Parsimmon;
432
432
  })()
433
433
  // Generated by CoffeeScript 1.6.3
434
- var AST, CompiledCode, ContinuationTrace, Core, DEBUG, Dependency, Failure, Gibbon, Hash, JS, List, Map, ObjHash, RVal, Semantic, Step, Thunk, Trace, Type, TypeAST, TypeExpr, TypeLookup, Value, VarTrace, Variant, analyze, applyOp1, applyOp2, asyncMap, contIter, contMap, equalArrays, eval_, isArray, nameGen, parse, stdlib, uniq, _ref, _ref1, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref16, _ref17, _ref18, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9,
434
+ var AST, CompiledCode, Core, DEBUG, Dependency, Failure, Gibbon, Hash, JS, List, Map, ObjHash, RVal, Semantic, Step, Thunk, Trace, Type, TypeAST, TypeExpr, TypeLookup, Value, VarTrace, Variant, analyze, applyOp1, applyOp2, asyncMap, contIter, contMap, equalArrays, eval_, isArray, nameGen, parse, stdlib, uniq, _ref, _ref1, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref16, _ref17, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9,
435
435
  __slice = [].slice,
436
436
  __hasProp = {}.hasOwnProperty,
437
437
  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
@@ -770,12 +770,12 @@ List = (function(_super) {
770
770
  };
771
771
 
772
772
  List.prototype.mapArray = function(f) {
773
- var out, tr;
773
+ var cursor, out;
774
774
  out = [];
775
- tr = this;
776
- while (tr._tag === 'cons') {
777
- out.push(f(tr.head));
778
- tr = tr.tail;
775
+ cursor = this;
776
+ while (cursor._tag === 'cons') {
777
+ out.push(f(cursor.head));
778
+ cursor = cursor.tail;
779
779
  }
780
780
  return out;
781
781
  };
@@ -2363,7 +2363,7 @@ analyze = Gibbon.analyze = (function() {
2363
2363
  var flowType, toSemanticTree;
2364
2364
  flowType = function(expr) {
2365
2365
  if (!solutions.has(expr)) {
2366
- if (errors.length === 0) {
2366
+ if (errors.length === 0 && expr._tag === 'expr') {
2367
2367
  throw new Error('unsolved!');
2368
2368
  }
2369
2369
  return Type.abstract(TypeExpr.expr(expr));
@@ -3833,7 +3833,7 @@ Step = (function(_super) {
3833
3833
  fork: ['forks'],
3834
3834
  each: ['length', 'cont'],
3835
3835
  letCont: ['name', 'args', 'body', 'expr'],
3836
- letJoin: ['name', 'order', 'cont', 'expr'],
3836
+ letJoin: ['name', 'order', 'rescue', 'cont', 'expr'],
3837
3837
  next: ['cont', 'args'],
3838
3838
  app: ['fn', 'args', 'rescue', 'next'],
3839
3839
  query: ['annotations', 'arg', 'rescue', 'next'],
@@ -3864,8 +3864,8 @@ Step = (function(_super) {
3864
3864
  each: function(list, cont) {
3865
3865
  return "(EACH " + list + " ->" + cont + ")";
3866
3866
  },
3867
- letJoin: function(name, order, cont, expr) {
3868
- return "(LETJ " + name + "/" + order + " ->" + cont + " " + (expr.inspect()) + ")";
3867
+ letJoin: function(name, order, rescue, cont, expr) {
3868
+ return "(LETJ " + name + "/" + order + " !-> " + rescue + " ->" + cont + " " + (expr.inspect()) + ")";
3869
3869
  },
3870
3870
  letMap: function(name, list, joinName, arg, body, expr) {
3871
3871
  return "(LETM " + name + " " + list + " " + joinName + "<- \\" + arg + " " + (body.inspect()) + " " + (expr.inspect()) + ")";
@@ -3901,8 +3901,8 @@ Step = (function(_super) {
3901
3901
  letCont: function(name, args, body, expr) {
3902
3902
  return "" + i + name + " " + (args.join(' ')) + ":\n" + (body.inspectLines(indent + 1)) + "\n" + (expr.inspectLines(indent));
3903
3903
  },
3904
- letJoin: function(name, order, cont, expr) {
3905
- return "" + i + name + ": join/" + order + " ->" + cont + "\n" + (expr.inspectLines(indent));
3904
+ letJoin: function(name, order, rescue, cont, expr) {
3905
+ return "" + i + name + ": join/" + order + " !->" + rescue + " ->" + cont + "\n" + (expr.inspectLines(indent));
3906
3906
  },
3907
3907
  fork: function(conts) {
3908
3908
  var c;
@@ -3954,7 +3954,7 @@ Step = (function(_super) {
3954
3954
  letCont: function(_, __, body, expr) {
3955
3955
  return body.search(f) || expr.search(f);
3956
3956
  },
3957
- letJoin: function(_, __, ___, expr) {
3957
+ letJoin: function(_, __, ___, ____, expr) {
3958
3958
  return expr.search(f);
3959
3959
  },
3960
3960
  other: function() {
@@ -4001,8 +4001,8 @@ Step = (function(_super) {
4001
4001
  "if": function(cond, trueCont, falseCont) {
4002
4002
  return varName === cond || varName === trueCont || varName === falseCont;
4003
4003
  },
4004
- letJoin: function(name, order, cont) {
4005
- return varName === order || varName === cont;
4004
+ letJoin: function(name, order, rescue, cont) {
4005
+ return varName === order || varName === rescue || varName === cont;
4006
4006
  },
4007
4007
  fork: function(conts) {
4008
4008
  return __indexOf.call(conts, varName) >= 0;
@@ -4017,86 +4017,6 @@ Step = (function(_super) {
4017
4017
  });
4018
4018
  };
4019
4019
 
4020
- Step.prototype.genTrace = function(contName) {
4021
- return this.cases({
4022
- "let": function(_, __, e) {
4023
- return e.genTrace(contName);
4024
- },
4025
- letCont: function(_, __, body, expr) {
4026
- return body.genTrace(contName).concat(expr.genTrace(contName));
4027
- },
4028
- letJoin: function(_, __, cont, e) {
4029
- var calls;
4030
- calls = e.genTrace(contName);
4031
- if (cont === contName) {
4032
- return [ContinuationTrace.simple(this)].concat(calls);
4033
- } else {
4034
- return calls;
4035
- }
4036
- },
4037
- app: function(_, __, rescue, next) {
4038
- if (contName === rescue) {
4039
- return [ContinuationTrace.key(this, 'rescue')];
4040
- } else if (contName === next) {
4041
- return [ContinuationTrace.key(this, 'next')];
4042
- } else {
4043
- return [];
4044
- }
4045
- },
4046
- query: function(_, __, rescue, next) {
4047
- if (contName === rescue) {
4048
- return [ContinuationTrace.key(this, 'rescue')];
4049
- } else if (contName === next) {
4050
- return [ContinuationTrace.key(this, 'next')];
4051
- } else {
4052
- return [];
4053
- }
4054
- },
4055
- localQuery: function(_, rescue, next) {
4056
- if (contName === rescue) {
4057
- return [ContinuationTrace.key(this, 'rescue')];
4058
- } else if (contName === next) {
4059
- return [ContinuationTrace.key(this, 'next')];
4060
- } else {
4061
- return [];
4062
- }
4063
- },
4064
- next: function(name, _) {
4065
- if (contName === name) {
4066
- return [ContinuationTrace.simple(this)];
4067
- } else {
4068
- return [];
4069
- }
4070
- },
4071
- fork: function(forks) {
4072
- var fork, i, _i, _len;
4073
- for (i = _i = 0, _len = forks.length; _i < _len; i = ++_i) {
4074
- fork = forks[i];
4075
- if (contName === fork) {
4076
- return [ContinuationTrace.index(this, 'forks', i)];
4077
- }
4078
- }
4079
- return [];
4080
- },
4081
- each: function(length, cont) {
4082
- if (contName === cont) {
4083
- return [ContinuationTrace.key(this, 'cont')];
4084
- } else {
4085
- return [];
4086
- }
4087
- },
4088
- "if": function(_, trueCont, falseCont) {
4089
- if (contName === trueCont) {
4090
- return [ContinuationTrace.key(this, 'trueCont')];
4091
- } else if (contName === falseCont) {
4092
- return [ContinuationTrace.key(this, 'falseCont')];
4093
- } else {
4094
- return [];
4095
- }
4096
- }
4097
- });
4098
- };
4099
-
4100
4020
  Step.prototype.subst = function(varName, target) {
4101
4021
  return this.cases({
4102
4022
  "let": function(lval, value, expr) {
@@ -4106,15 +4026,18 @@ Step = (function(_super) {
4106
4026
  }
4107
4027
  return Step["let"](lval, value, expr.subst(varName, target));
4108
4028
  },
4109
- letJoin: function(name, order, cont, expr) {
4029
+ letJoin: function(name, order, fail, cont, expr) {
4110
4030
  if (order === varName) {
4111
4031
  order = target;
4112
4032
  }
4033
+ if (fail === varName) {
4034
+ fail = target;
4035
+ }
4113
4036
  if (cont === varName) {
4114
4037
  cont = target;
4115
4038
  }
4116
4039
  expr = expr.subst(varName, target);
4117
- return Step.letJoin(name, order, cont, expr);
4040
+ return Step.letJoin(name, order, fail, cont, expr);
4118
4041
  },
4119
4042
  next: function(cont, args) {
4120
4043
  var arg, newArgs;
@@ -4242,18 +4165,19 @@ Step = (function(_super) {
4242
4165
  return Step["let"](varName, val, f(varName));
4243
4166
  };
4244
4167
 
4245
- Step.makeJoin = function(order, outCont, f) {
4246
- var joinName, makeEach, makeEmpty;
4168
+ Step.makeJoin = function(order, rescue, outCont, f) {
4169
+ var joinName, joinRescueName, makeEach, makeEmpty;
4247
4170
  joinName = nameGen('j');
4171
+ joinRescueName = "" + joinName + "$$rescue";
4248
4172
  makeEach = function() {
4249
4173
  var mkBody;
4250
4174
  mkBody = function(index) {
4251
- return f(index, function(mappedVal) {
4175
+ return f(index, joinRescueName, function(mappedVal) {
4252
4176
  return Step.next(joinName, [index, mappedVal]);
4253
4177
  });
4254
4178
  };
4255
4179
  return Step.makeCont(1, mkBody, function(bodyCont) {
4256
- return Step.letJoin(joinName, order, outCont, Step.each(order, bodyCont));
4180
+ return Step.letJoin(joinName, order, rescue, outCont, Step.each(order, bodyCont));
4257
4181
  });
4258
4182
  };
4259
4183
  makeEmpty = function() {
@@ -4323,35 +4247,16 @@ VarTrace = (function(_super) {
4323
4247
 
4324
4248
  })(Variant);
4325
4249
 
4326
- ContinuationTrace = (function(_super) {
4327
- __extends(ContinuationTrace, _super);
4328
-
4329
- function ContinuationTrace() {
4330
- _ref12 = ContinuationTrace.__super__.constructor.apply(this, arguments);
4331
- return _ref12;
4332
- }
4333
-
4334
- ContinuationTrace.variants({
4335
- simple: ['node'],
4336
- key: ['node', 'key'],
4337
- index: ['node', 'key', 'index']
4338
- });
4339
-
4340
- return ContinuationTrace;
4341
-
4342
- })(Variant);
4343
-
4344
4250
  Trace = (function(_super) {
4345
4251
  __extends(Trace, _super);
4346
4252
 
4347
4253
  function Trace() {
4348
- _ref13 = Trace.__super__.constructor.apply(this, arguments);
4349
- return _ref13;
4254
+ _ref12 = Trace.__super__.constructor.apply(this, arguments);
4255
+ return _ref12;
4350
4256
  }
4351
4257
 
4352
4258
  Trace.variants({
4353
4259
  empty: [],
4354
- contTrace: ['parent', 'name', 'calls'],
4355
4260
  varTrace: ['parent', 'name', 'traces']
4356
4261
  });
4357
4262
 
@@ -4360,9 +4265,6 @@ Trace = (function(_super) {
4360
4265
  empty: function() {
4361
4266
  return [];
4362
4267
  },
4363
- contTrace: function(parent, name, _, __) {
4364
- return parent.boundNames().concat([name]);
4365
- },
4366
4268
  varTrace: function(parent, name, _) {
4367
4269
  return parent.boundNames().concat([name]);
4368
4270
  }
@@ -4377,16 +4279,13 @@ Trace = (function(_super) {
4377
4279
  },
4378
4280
  letCont: function(contName, argNames, body, expr) {
4379
4281
  var i, name, traced, _i, _len;
4380
- traced = _this.traceCont(contName, step.genTrace(contName));
4282
+ traced = _this;
4381
4283
  for (i = _i = 0, _len = argNames.length; _i < _len; i = ++_i) {
4382
4284
  name = argNames[i];
4383
4285
  traced = traced.traceVar(name, VarTrace.continued(contName, i));
4384
4286
  }
4385
4287
  return traced;
4386
4288
  },
4387
- letJoin: function(name) {
4388
- return _this.traceCont(step.genTrace(name));
4389
- },
4390
4289
  other: function() {
4391
4290
  return _this;
4392
4291
  }
@@ -4397,10 +4296,6 @@ Trace = (function(_super) {
4397
4296
  return "<" + (this.boundNames().join(' ')) + ">";
4398
4297
  };
4399
4298
 
4400
- Trace.prototype.traceCont = function(name, traces) {
4401
- return Trace.contTrace(this, name, traces);
4402
- };
4403
-
4404
4299
  Trace.prototype.traceVar = function(name, trace) {
4405
4300
  return Trace.varTrace(this, name, trace);
4406
4301
  };
@@ -4410,9 +4305,6 @@ Trace = (function(_super) {
4410
4305
  empty: function() {
4411
4306
  return null;
4412
4307
  },
4413
- contTrace: function(parent) {
4414
- return parent.findVarTrace(needle);
4415
- },
4416
4308
  varTrace: function(parent, name, trace) {
4417
4309
  if (needle.equals(trace)) {
4418
4310
  return name;
@@ -4428,9 +4320,6 @@ Trace = (function(_super) {
4428
4320
  empty: function() {
4429
4321
  throw "no such variable " + needle;
4430
4322
  },
4431
- contTrace: function(parent) {
4432
- return parent.getVar(needle);
4433
- },
4434
4323
  varTrace: function(parent, name, subst) {
4435
4324
  if (name === needle) {
4436
4325
  return subst;
@@ -4441,24 +4330,6 @@ Trace = (function(_super) {
4441
4330
  });
4442
4331
  };
4443
4332
 
4444
- Trace.prototype.getCont = function(needle) {
4445
- return this.cases({
4446
- empty: function() {
4447
- throw "no such continuation " + needle;
4448
- },
4449
- contTrace: function(parent, name, traces) {
4450
- if (name === needle) {
4451
- return traces;
4452
- } else {
4453
- return parent.getCont(needle);
4454
- }
4455
- },
4456
- varTrace: function(parent) {
4457
- return parent.getCont(needle);
4458
- }
4459
- });
4460
- };
4461
-
4462
4333
  return Trace;
4463
4334
 
4464
4335
  })(Variant);
@@ -4467,8 +4338,8 @@ RVal = (function(_super) {
4467
4338
  __extends(RVal, _super);
4468
4339
 
4469
4340
  function RVal() {
4470
- _ref14 = RVal.__super__.constructor.apply(this, arguments);
4471
- return _ref14;
4341
+ _ref13 = RVal.__super__.constructor.apply(this, arguments);
4342
+ return _ref13;
4472
4343
  }
4473
4344
 
4474
4345
  RVal.variants({
@@ -4680,7 +4551,7 @@ RVal = (function(_super) {
4680
4551
  Gibbon.sequence = (function() {
4681
4552
  var bindExprs, sequence, sequenceTail;
4682
4553
  bindExprs = function(exprs, rescue, f) {
4683
- var asyncExprs, asyncVars, bindAsyncVars, bound, collectionName, contName, expr, forkBodies, forks, i, idx, joinName, name, recurse, syncExprs, syncStep, syncVars, _, _i, _len;
4554
+ var asyncExprs, asyncVars, bindAsyncVars, bound, collectionName, contName, expr, forkBodies, forks, i, idx, joinName, joinRescueName, name, recurse, syncExprs, syncStep, syncVars, _, _i, _len;
4684
4555
  syncExprs = [];
4685
4556
  asyncExprs = [];
4686
4557
  bound = [];
@@ -4697,10 +4568,10 @@ Gibbon.sequence = (function() {
4697
4568
  asyncExprs = [];
4698
4569
  }
4699
4570
  syncVars = (function() {
4700
- var _j, _len1, _ref15, _results;
4571
+ var _j, _len1, _ref14, _results;
4701
4572
  _results = [];
4702
4573
  for (_j = 0, _len1 = syncExprs.length; _j < _len1; _j++) {
4703
- _ref15 = syncExprs[_j], idx = _ref15[0], expr = _ref15[1];
4574
+ _ref14 = syncExprs[_j], idx = _ref14[0], expr = _ref14[1];
4704
4575
  name = nameGen('t');
4705
4576
  bound[idx] = name;
4706
4577
  _results.push(name);
@@ -4708,20 +4579,20 @@ Gibbon.sequence = (function() {
4708
4579
  return _results;
4709
4580
  })();
4710
4581
  asyncVars = (function() {
4711
- var _j, _len1, _ref15, _results;
4582
+ var _j, _len1, _ref14, _results;
4712
4583
  _results = [];
4713
4584
  for (_j = 0, _len1 = asyncExprs.length; _j < _len1; _j++) {
4714
- _ref15 = asyncExprs[_j], idx = _ref15[0], expr = _ref15[1];
4585
+ _ref14 = asyncExprs[_j], idx = _ref14[0], expr = _ref14[1];
4715
4586
  _results.push(bound[idx] = nameGen('t'));
4716
4587
  }
4717
4588
  return _results;
4718
4589
  })();
4719
4590
  syncStep = (recurse = function(i) {
4720
- var expr_, idx_, _ref15;
4591
+ var expr_, idx_, _ref14;
4721
4592
  if (i >= syncExprs.length) {
4722
4593
  return f(bound);
4723
4594
  }
4724
- _ref15 = syncExprs[i], idx_ = _ref15[0], expr_ = _ref15[1];
4595
+ _ref14 = syncExprs[i], idx_ = _ref14[0], expr_ = _ref14[1];
4725
4596
  return sequence(expr_, rescue, function(boundExpr) {
4726
4597
  bound[idx_] = boundExpr;
4727
4598
  return recurse(i + 1);
@@ -4731,14 +4602,15 @@ Gibbon.sequence = (function() {
4731
4602
  return syncStep;
4732
4603
  }
4733
4604
  joinName = nameGen('j');
4605
+ joinRescueName = "" + joinName + "$$rescue";
4734
4606
  contName = nameGen('k');
4735
4607
  forkBodies = (function() {
4736
- var _j, _len1, _ref15, _results;
4608
+ var _j, _len1, _ref14, _results;
4737
4609
  _results = [];
4738
4610
  for (i = _j = 0, _len1 = asyncExprs.length; _j < _len1; i = ++_j) {
4739
- _ref15 = asyncExprs[i], _ = _ref15[0], expr = _ref15[1];
4611
+ _ref14 = asyncExprs[i], _ = _ref14[0], expr = _ref14[1];
4740
4612
  _results.push(Step.makeVar(RVal.constant(i), function(boundI) {
4741
- return sequence(expr, rescue, function(boundExpr) {
4613
+ return sequence(expr, joinRescueName, function(boundExpr) {
4742
4614
  return Step.next(joinName, [boundI, boundExpr]);
4743
4615
  });
4744
4616
  }));
@@ -4766,7 +4638,7 @@ Gibbon.sequence = (function() {
4766
4638
  return _results;
4767
4639
  })();
4768
4640
  return Step.letCont(contName, [collectionName], bindAsyncVars, Step.makeVar(RVal.constant(asyncExprs.length), function(order) {
4769
- return Step.letJoin(joinName, order, contName, (recurse = function(i) {
4641
+ return Step.letJoin(joinName, order, rescue, contName, (recurse = function(i) {
4770
4642
  if (i >= forkBodies.length) {
4771
4643
  return Step.fork(forks);
4772
4644
  } else {
@@ -4904,11 +4776,11 @@ Gibbon.sequence = (function() {
4904
4776
  return sequence(list, rescue, function(boundList) {
4905
4777
  return Step.makeVar(RVal.prim(1, 'length', [boundList]), function(boundLen) {
4906
4778
  return Step.makeCont(1, bind, function(outCont) {
4907
- return Step.makeJoin(boundLen, outCont, function(index, bindJoin) {
4779
+ return Step.makeJoin(boundLen, rescue, outCont, function(index, joinRescue, bindJoin) {
4908
4780
  var delistExpr, substBody;
4909
4781
  delistExpr = Core.variable(boundList).delist(Core.variable(index));
4910
4782
  substBody = body.subst(arg, delistExpr).subst(idxArg, Core.variable(index));
4911
- return sequence(substBody, rescue, bindJoin);
4783
+ return sequence(substBody, joinRescue, bindJoin);
4912
4784
  });
4913
4785
  });
4914
4786
  });
@@ -4925,17 +4797,17 @@ Gibbon.sequence = (function() {
4925
4797
  return Step.makeVar(RVal.compact(v), bind);
4926
4798
  };
4927
4799
  return Step.makeCont(1, mkCompact, function(outCont) {
4928
- return Step.makeJoin(boundLen, outCont, function(index, bindJoin) {
4800
+ return Step.makeJoin(boundLen, rescue, outCont, function(index, joinRescue, bindJoin) {
4929
4801
  var delistExpr, substBody;
4930
4802
  delistExpr = Core.variable(boundList).delist(Core.variable(index));
4931
4803
  substBody = body.subst(arg, delistExpr);
4932
- return sequence(substBody, rescue, function(mappedBool) {
4804
+ return sequence(substBody, joinRescue, function(mappedBool) {
4933
4805
  var mkDelete, mkKeep;
4934
4806
  mkDelete = function() {
4935
4807
  return bindJoin(nullName);
4936
4808
  };
4937
4809
  mkKeep = function() {
4938
- return sequence(delistExpr, rescue, bindJoin);
4810
+ return sequence(delistExpr, joinRescue, bindJoin);
4939
4811
  };
4940
4812
  return Step.makeCont(0, mkDelete, function(deleteCont) {
4941
4813
  return Step.makeCont(0, mkKeep, function(keepCont) {
@@ -5232,8 +5104,8 @@ Gibbon.JS = JS = (function(_super) {
5232
5104
  __extends(JS, _super);
5233
5105
 
5234
5106
  function JS() {
5235
- _ref15 = JS.__super__.constructor.apply(this, arguments);
5236
- return _ref15;
5107
+ _ref14 = JS.__super__.constructor.apply(this, arguments);
5108
+ return _ref14;
5237
5109
  }
5238
5110
 
5239
5111
  JS.variants({
@@ -5611,15 +5483,17 @@ Gibbon.codegen = (function() {
5611
5483
  push(JS.func(name, args, JS.block(bodyStatements)));
5612
5484
  return generate(expr, extended, push);
5613
5485
  },
5614
- letJoin: function(name, order, cont, expr) {
5615
- var counterName, resultsName;
5486
+ letJoin: function(name, order, rescue, cont, expr) {
5487
+ var counterName, rescueName, resultsName;
5616
5488
  counterName = "" + name + "$counter";
5617
5489
  resultsName = "" + name + "$results";
5490
+ rescueName = "" + name + "$$rescue";
5618
5491
  push(JS.varDecl(counterName));
5619
5492
  push(JS.varDecl(resultsName));
5620
5493
  push(JS.bind(JS.ident(counterName), varToJS(order)));
5621
5494
  push(JS.bind(JS.ident(resultsName), JS.array([])));
5622
- push(JS.func(name, ['idx', 'el'], JS.block([JS.bind(JS.access(JS.ident(resultsName), JS.ident('idx')), JS.ident('el')), JS.trap(JS.ident(counterName).op('-=', JS.literal(1)).op('>', JS.literal(0))), JS.ident(cont).tailcall([JS.ident(resultsName)])])));
5495
+ push(JS.func(name, ['idx', 'el'], JS.block([JS.bind(JS.access(JS.ident(resultsName), JS.ident('idx')), JS.ident('el')), JS.trap(JS.ident(counterName).op('-=', JS.literal(1)).op('!==', JS.literal(0))), JS.ident(cont).tailcall([JS.ident(resultsName)])])));
5496
+ push(JS.func(rescueName, ['err'], JS.block([JS.trap(JS.ident(counterName).op('<', JS.literal(0))), JS.bind(JS.ident(counterName), JS.literal(-1)), JS.ident(rescue).tailcall([JS.ident('err')])])));
5623
5497
  return generate(expr, extended, push);
5624
5498
  },
5625
5499
  fork: function(forks) {
@@ -5838,16 +5712,16 @@ stdlib = Gibbon.stdlib = (function() {
5838
5712
  weight: {
5839
5713
  type: parse.type('weight [numeric : numeric] = % -> numeric'),
5840
5714
  compile: function(_, _arg) {
5841
- var ratio, totalDenom, totalNum, weights, _ref16;
5715
+ var ratio, totalDenom, totalNum, weights, _ref15;
5842
5716
  weights = _arg[0];
5843
5717
  ratio = weights.foldList(Core.pair(ZERO, ZERO), function(el, next) {
5844
- var denominator, numerator, value, weight, weighted, _ref16, _ref17;
5845
- _ref16 = el.depair(), value = _ref16[0], weight = _ref16[1];
5846
- _ref17 = next.depair(), numerator = _ref17[0], denominator = _ref17[1];
5718
+ var denominator, numerator, value, weight, weighted, _ref15, _ref16;
5719
+ _ref15 = el.depair(), value = _ref15[0], weight = _ref15[1];
5720
+ _ref16 = next.depair(), numerator = _ref16[0], denominator = _ref16[1];
5847
5721
  weighted = value.op2('*', weight);
5848
5722
  return Core.pair(numerator.op2('+', weighted), denominator.op2('+', weight));
5849
5723
  });
5850
- _ref16 = ratio.depair(), totalNum = _ref16[0], totalDenom = _ref16[1];
5724
+ _ref15 = ratio.depair(), totalNum = _ref15[0], totalDenom = _ref15[1];
5851
5725
  totalDenom = totalDenom.failIf('weight: zero denominator', function(d) {
5852
5726
  return d.op2('===', ZERO);
5853
5727
  });
@@ -6100,8 +5974,8 @@ Value = Gibbon.Value = Value = (function(_super) {
6100
5974
  __extends(Value, _super);
6101
5975
 
6102
5976
  function Value() {
6103
- _ref16 = Value.__super__.constructor.apply(this, arguments);
6104
- return _ref16;
5977
+ _ref15 = Value.__super__.constructor.apply(this, arguments);
5978
+ return _ref15;
6105
5979
  }
6106
5980
 
6107
5981
  Value.variants({
@@ -6368,8 +6242,8 @@ Gibbon.Dependency = Dependency = (function(_super) {
6368
6242
  __extends(Dependency, _super);
6369
6243
 
6370
6244
  function Dependency() {
6371
- _ref17 = Dependency.__super__.constructor.apply(this, arguments);
6372
- return _ref17;
6245
+ _ref16 = Dependency.__super__.constructor.apply(this, arguments);
6246
+ return _ref16;
6373
6247
  }
6374
6248
 
6375
6249
  Dependency.variants({
@@ -6423,8 +6297,8 @@ Gibbon.Failure = Failure = (function(_super) {
6423
6297
  __extends(Failure, _super);
6424
6298
 
6425
6299
  function Failure() {
6426
- _ref18 = Failure.__super__.constructor.apply(this, arguments);
6427
- return _ref18;
6300
+ _ref17 = Failure.__super__.constructor.apply(this, arguments);
6301
+ return _ref17;
6428
6302
  }
6429
6303
 
6430
6304
  Failure.variants({
@@ -431,7 +431,7 @@ Parsimmon.Parser = P(function(_, _super, Parser) {
431
431
  return Parsimmon;
432
432
  })()
433
433
  // Generated by CoffeeScript 1.6.3
434
- var AST, CompiledCode, ContinuationTrace, Core, DEBUG, Dependency, Failure, Gibbon, Hash, JS, List, Map, ObjHash, RVal, Semantic, Step, Thunk, Trace, Type, TypeAST, TypeExpr, TypeLookup, Value, VarTrace, Variant, analyze, applyOp1, applyOp2, asyncMap, contIter, contMap, equalArrays, eval_, isArray, nameGen, parse, stdlib, uniq, _ref, _ref1, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref16, _ref17, _ref18, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9,
434
+ var AST, CompiledCode, Core, DEBUG, Dependency, Failure, Gibbon, Hash, JS, List, Map, ObjHash, RVal, Semantic, Step, Thunk, Trace, Type, TypeAST, TypeExpr, TypeLookup, Value, VarTrace, Variant, analyze, applyOp1, applyOp2, asyncMap, contIter, contMap, equalArrays, eval_, isArray, nameGen, parse, stdlib, uniq, _ref, _ref1, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref16, _ref17, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9,
435
435
  __slice = [].slice,
436
436
  __hasProp = {}.hasOwnProperty,
437
437
  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
@@ -760,12 +760,12 @@ List = (function(_super) {
760
760
  };
761
761
 
762
762
  List.prototype.mapArray = function(f) {
763
- var out, tr;
763
+ var cursor, out;
764
764
  out = [];
765
- tr = this;
766
- while (tr._tag === 'cons') {
767
- out.push(f(tr.head));
768
- tr = tr.tail;
765
+ cursor = this;
766
+ while (cursor._tag === 'cons') {
767
+ out.push(f(cursor.head));
768
+ cursor = cursor.tail;
769
769
  }
770
770
  return out;
771
771
  };
@@ -2335,7 +2335,7 @@ analyze = Gibbon.analyze = (function() {
2335
2335
  var flowType, toSemanticTree;
2336
2336
  flowType = function(expr) {
2337
2337
  if (!solutions.has(expr)) {
2338
- if (errors.length === 0) {
2338
+ if (errors.length === 0 && expr._tag === 'expr') {
2339
2339
  throw new Error('unsolved!');
2340
2340
  }
2341
2341
  return Type.abstract(TypeExpr.expr(expr));
@@ -3770,7 +3770,7 @@ Step = (function(_super) {
3770
3770
  fork: ['forks'],
3771
3771
  each: ['length', 'cont'],
3772
3772
  letCont: ['name', 'args', 'body', 'expr'],
3773
- letJoin: ['name', 'order', 'cont', 'expr'],
3773
+ letJoin: ['name', 'order', 'rescue', 'cont', 'expr'],
3774
3774
  next: ['cont', 'args'],
3775
3775
  app: ['fn', 'args', 'rescue', 'next'],
3776
3776
  query: ['annotations', 'arg', 'rescue', 'next'],
@@ -3801,8 +3801,8 @@ Step = (function(_super) {
3801
3801
  each: function(list, cont) {
3802
3802
  return "(EACH " + list + " ->" + cont + ")";
3803
3803
  },
3804
- letJoin: function(name, order, cont, expr) {
3805
- return "(LETJ " + name + "/" + order + " ->" + cont + " " + (expr.inspect()) + ")";
3804
+ letJoin: function(name, order, rescue, cont, expr) {
3805
+ return "(LETJ " + name + "/" + order + " !-> " + rescue + " ->" + cont + " " + (expr.inspect()) + ")";
3806
3806
  },
3807
3807
  letMap: function(name, list, joinName, arg, body, expr) {
3808
3808
  return "(LETM " + name + " " + list + " " + joinName + "<- \\" + arg + " " + (body.inspect()) + " " + (expr.inspect()) + ")";
@@ -3838,8 +3838,8 @@ Step = (function(_super) {
3838
3838
  letCont: function(name, args, body, expr) {
3839
3839
  return "" + i + name + " " + (args.join(' ')) + ":\n" + (body.inspectLines(indent + 1)) + "\n" + (expr.inspectLines(indent));
3840
3840
  },
3841
- letJoin: function(name, order, cont, expr) {
3842
- return "" + i + name + ": join/" + order + " ->" + cont + "\n" + (expr.inspectLines(indent));
3841
+ letJoin: function(name, order, rescue, cont, expr) {
3842
+ return "" + i + name + ": join/" + order + " !->" + rescue + " ->" + cont + "\n" + (expr.inspectLines(indent));
3843
3843
  },
3844
3844
  fork: function(conts) {
3845
3845
  var c;
@@ -3891,7 +3891,7 @@ Step = (function(_super) {
3891
3891
  letCont: function(_, __, body, expr) {
3892
3892
  return body.search(f) || expr.search(f);
3893
3893
  },
3894
- letJoin: function(_, __, ___, expr) {
3894
+ letJoin: function(_, __, ___, ____, expr) {
3895
3895
  return expr.search(f);
3896
3896
  },
3897
3897
  other: function() {
@@ -3938,8 +3938,8 @@ Step = (function(_super) {
3938
3938
  "if": function(cond, trueCont, falseCont) {
3939
3939
  return varName === cond || varName === trueCont || varName === falseCont;
3940
3940
  },
3941
- letJoin: function(name, order, cont) {
3942
- return varName === order || varName === cont;
3941
+ letJoin: function(name, order, rescue, cont) {
3942
+ return varName === order || varName === rescue || varName === cont;
3943
3943
  },
3944
3944
  fork: function(conts) {
3945
3945
  return __indexOf.call(conts, varName) >= 0;
@@ -3954,86 +3954,6 @@ Step = (function(_super) {
3954
3954
  });
3955
3955
  };
3956
3956
 
3957
- Step.prototype.genTrace = function(contName) {
3958
- return this.cases({
3959
- "let": function(_, __, e) {
3960
- return e.genTrace(contName);
3961
- },
3962
- letCont: function(_, __, body, expr) {
3963
- return body.genTrace(contName).concat(expr.genTrace(contName));
3964
- },
3965
- letJoin: function(_, __, cont, e) {
3966
- var calls;
3967
- calls = e.genTrace(contName);
3968
- if (cont === contName) {
3969
- return [ContinuationTrace.simple(this)].concat(calls);
3970
- } else {
3971
- return calls;
3972
- }
3973
- },
3974
- app: function(_, __, rescue, next) {
3975
- if (contName === rescue) {
3976
- return [ContinuationTrace.key(this, 'rescue')];
3977
- } else if (contName === next) {
3978
- return [ContinuationTrace.key(this, 'next')];
3979
- } else {
3980
- return [];
3981
- }
3982
- },
3983
- query: function(_, __, rescue, next) {
3984
- if (contName === rescue) {
3985
- return [ContinuationTrace.key(this, 'rescue')];
3986
- } else if (contName === next) {
3987
- return [ContinuationTrace.key(this, 'next')];
3988
- } else {
3989
- return [];
3990
- }
3991
- },
3992
- localQuery: function(_, rescue, next) {
3993
- if (contName === rescue) {
3994
- return [ContinuationTrace.key(this, 'rescue')];
3995
- } else if (contName === next) {
3996
- return [ContinuationTrace.key(this, 'next')];
3997
- } else {
3998
- return [];
3999
- }
4000
- },
4001
- next: function(name, _) {
4002
- if (contName === name) {
4003
- return [ContinuationTrace.simple(this)];
4004
- } else {
4005
- return [];
4006
- }
4007
- },
4008
- fork: function(forks) {
4009
- var fork, i, _i, _len;
4010
- for (i = _i = 0, _len = forks.length; _i < _len; i = ++_i) {
4011
- fork = forks[i];
4012
- if (contName === fork) {
4013
- return [ContinuationTrace.index(this, 'forks', i)];
4014
- }
4015
- }
4016
- return [];
4017
- },
4018
- each: function(length, cont) {
4019
- if (contName === cont) {
4020
- return [ContinuationTrace.key(this, 'cont')];
4021
- } else {
4022
- return [];
4023
- }
4024
- },
4025
- "if": function(_, trueCont, falseCont) {
4026
- if (contName === trueCont) {
4027
- return [ContinuationTrace.key(this, 'trueCont')];
4028
- } else if (contName === falseCont) {
4029
- return [ContinuationTrace.key(this, 'falseCont')];
4030
- } else {
4031
- return [];
4032
- }
4033
- }
4034
- });
4035
- };
4036
-
4037
3957
  Step.prototype.subst = function(varName, target) {
4038
3958
  return this.cases({
4039
3959
  "let": function(lval, value, expr) {
@@ -4043,15 +3963,18 @@ Step = (function(_super) {
4043
3963
  }
4044
3964
  return Step["let"](lval, value, expr.subst(varName, target));
4045
3965
  },
4046
- letJoin: function(name, order, cont, expr) {
3966
+ letJoin: function(name, order, fail, cont, expr) {
4047
3967
  if (order === varName) {
4048
3968
  order = target;
4049
3969
  }
3970
+ if (fail === varName) {
3971
+ fail = target;
3972
+ }
4050
3973
  if (cont === varName) {
4051
3974
  cont = target;
4052
3975
  }
4053
3976
  expr = expr.subst(varName, target);
4054
- return Step.letJoin(name, order, cont, expr);
3977
+ return Step.letJoin(name, order, fail, cont, expr);
4055
3978
  },
4056
3979
  next: function(cont, args) {
4057
3980
  var arg, newArgs;
@@ -4179,18 +4102,19 @@ Step = (function(_super) {
4179
4102
  return Step["let"](varName, val, f(varName));
4180
4103
  };
4181
4104
 
4182
- Step.makeJoin = function(order, outCont, f) {
4183
- var joinName, makeEach, makeEmpty;
4105
+ Step.makeJoin = function(order, rescue, outCont, f) {
4106
+ var joinName, joinRescueName, makeEach, makeEmpty;
4184
4107
  joinName = nameGen('j');
4108
+ joinRescueName = "" + joinName + "$$rescue";
4185
4109
  makeEach = function() {
4186
4110
  var mkBody;
4187
4111
  mkBody = function(index) {
4188
- return f(index, function(mappedVal) {
4112
+ return f(index, joinRescueName, function(mappedVal) {
4189
4113
  return Step.next(joinName, [index, mappedVal]);
4190
4114
  });
4191
4115
  };
4192
4116
  return Step.makeCont(1, mkBody, function(bodyCont) {
4193
- return Step.letJoin(joinName, order, outCont, Step.each(order, bodyCont));
4117
+ return Step.letJoin(joinName, order, rescue, outCont, Step.each(order, bodyCont));
4194
4118
  });
4195
4119
  };
4196
4120
  makeEmpty = function() {
@@ -4260,35 +4184,16 @@ VarTrace = (function(_super) {
4260
4184
 
4261
4185
  })(Variant);
4262
4186
 
4263
- ContinuationTrace = (function(_super) {
4264
- __extends(ContinuationTrace, _super);
4265
-
4266
- function ContinuationTrace() {
4267
- _ref12 = ContinuationTrace.__super__.constructor.apply(this, arguments);
4268
- return _ref12;
4269
- }
4270
-
4271
- ContinuationTrace.variants({
4272
- simple: ['node'],
4273
- key: ['node', 'key'],
4274
- index: ['node', 'key', 'index']
4275
- });
4276
-
4277
- return ContinuationTrace;
4278
-
4279
- })(Variant);
4280
-
4281
4187
  Trace = (function(_super) {
4282
4188
  __extends(Trace, _super);
4283
4189
 
4284
4190
  function Trace() {
4285
- _ref13 = Trace.__super__.constructor.apply(this, arguments);
4286
- return _ref13;
4191
+ _ref12 = Trace.__super__.constructor.apply(this, arguments);
4192
+ return _ref12;
4287
4193
  }
4288
4194
 
4289
4195
  Trace.variants({
4290
4196
  empty: [],
4291
- contTrace: ['parent', 'name', 'calls'],
4292
4197
  varTrace: ['parent', 'name', 'traces']
4293
4198
  });
4294
4199
 
@@ -4297,9 +4202,6 @@ Trace = (function(_super) {
4297
4202
  empty: function() {
4298
4203
  return [];
4299
4204
  },
4300
- contTrace: function(parent, name, _, __) {
4301
- return parent.boundNames().concat([name]);
4302
- },
4303
4205
  varTrace: function(parent, name, _) {
4304
4206
  return parent.boundNames().concat([name]);
4305
4207
  }
@@ -4314,16 +4216,13 @@ Trace = (function(_super) {
4314
4216
  },
4315
4217
  letCont: function(contName, argNames, body, expr) {
4316
4218
  var i, name, traced, _i, _len;
4317
- traced = _this.traceCont(contName, step.genTrace(contName));
4219
+ traced = _this;
4318
4220
  for (i = _i = 0, _len = argNames.length; _i < _len; i = ++_i) {
4319
4221
  name = argNames[i];
4320
4222
  traced = traced.traceVar(name, VarTrace.continued(contName, i));
4321
4223
  }
4322
4224
  return traced;
4323
4225
  },
4324
- letJoin: function(name) {
4325
- return _this.traceCont(step.genTrace(name));
4326
- },
4327
4226
  other: function() {
4328
4227
  return _this;
4329
4228
  }
@@ -4334,10 +4233,6 @@ Trace = (function(_super) {
4334
4233
  return "<" + (this.boundNames().join(' ')) + ">";
4335
4234
  };
4336
4235
 
4337
- Trace.prototype.traceCont = function(name, traces) {
4338
- return Trace.contTrace(this, name, traces);
4339
- };
4340
-
4341
4236
  Trace.prototype.traceVar = function(name, trace) {
4342
4237
  return Trace.varTrace(this, name, trace);
4343
4238
  };
@@ -4347,9 +4242,6 @@ Trace = (function(_super) {
4347
4242
  empty: function() {
4348
4243
  return null;
4349
4244
  },
4350
- contTrace: function(parent) {
4351
- return parent.findVarTrace(needle);
4352
- },
4353
4245
  varTrace: function(parent, name, trace) {
4354
4246
  if (needle.equals(trace)) {
4355
4247
  return name;
@@ -4365,9 +4257,6 @@ Trace = (function(_super) {
4365
4257
  empty: function() {
4366
4258
  throw "no such variable " + needle;
4367
4259
  },
4368
- contTrace: function(parent) {
4369
- return parent.getVar(needle);
4370
- },
4371
4260
  varTrace: function(parent, name, subst) {
4372
4261
  if (name === needle) {
4373
4262
  return subst;
@@ -4378,24 +4267,6 @@ Trace = (function(_super) {
4378
4267
  });
4379
4268
  };
4380
4269
 
4381
- Trace.prototype.getCont = function(needle) {
4382
- return this.cases({
4383
- empty: function() {
4384
- throw "no such continuation " + needle;
4385
- },
4386
- contTrace: function(parent, name, traces) {
4387
- if (name === needle) {
4388
- return traces;
4389
- } else {
4390
- return parent.getCont(needle);
4391
- }
4392
- },
4393
- varTrace: function(parent) {
4394
- return parent.getCont(needle);
4395
- }
4396
- });
4397
- };
4398
-
4399
4270
  return Trace;
4400
4271
 
4401
4272
  })(Variant);
@@ -4404,8 +4275,8 @@ RVal = (function(_super) {
4404
4275
  __extends(RVal, _super);
4405
4276
 
4406
4277
  function RVal() {
4407
- _ref14 = RVal.__super__.constructor.apply(this, arguments);
4408
- return _ref14;
4278
+ _ref13 = RVal.__super__.constructor.apply(this, arguments);
4279
+ return _ref13;
4409
4280
  }
4410
4281
 
4411
4282
  RVal.variants({
@@ -4617,7 +4488,7 @@ RVal = (function(_super) {
4617
4488
  Gibbon.sequence = (function() {
4618
4489
  var bindExprs, sequence, sequenceTail;
4619
4490
  bindExprs = function(exprs, rescue, f) {
4620
- var asyncExprs, asyncVars, bindAsyncVars, bound, collectionName, contName, expr, forkBodies, forks, i, idx, joinName, name, recurse, syncExprs, syncStep, syncVars, _, _i, _len;
4491
+ var asyncExprs, asyncVars, bindAsyncVars, bound, collectionName, contName, expr, forkBodies, forks, i, idx, joinName, joinRescueName, name, recurse, syncExprs, syncStep, syncVars, _, _i, _len;
4621
4492
  syncExprs = [];
4622
4493
  asyncExprs = [];
4623
4494
  bound = [];
@@ -4634,10 +4505,10 @@ Gibbon.sequence = (function() {
4634
4505
  asyncExprs = [];
4635
4506
  }
4636
4507
  syncVars = (function() {
4637
- var _j, _len1, _ref15, _results;
4508
+ var _j, _len1, _ref14, _results;
4638
4509
  _results = [];
4639
4510
  for (_j = 0, _len1 = syncExprs.length; _j < _len1; _j++) {
4640
- _ref15 = syncExprs[_j], idx = _ref15[0], expr = _ref15[1];
4511
+ _ref14 = syncExprs[_j], idx = _ref14[0], expr = _ref14[1];
4641
4512
  name = nameGen('t');
4642
4513
  bound[idx] = name;
4643
4514
  _results.push(name);
@@ -4645,20 +4516,20 @@ Gibbon.sequence = (function() {
4645
4516
  return _results;
4646
4517
  })();
4647
4518
  asyncVars = (function() {
4648
- var _j, _len1, _ref15, _results;
4519
+ var _j, _len1, _ref14, _results;
4649
4520
  _results = [];
4650
4521
  for (_j = 0, _len1 = asyncExprs.length; _j < _len1; _j++) {
4651
- _ref15 = asyncExprs[_j], idx = _ref15[0], expr = _ref15[1];
4522
+ _ref14 = asyncExprs[_j], idx = _ref14[0], expr = _ref14[1];
4652
4523
  _results.push(bound[idx] = nameGen('t'));
4653
4524
  }
4654
4525
  return _results;
4655
4526
  })();
4656
4527
  syncStep = (recurse = function(i) {
4657
- var expr_, idx_, _ref15;
4528
+ var expr_, idx_, _ref14;
4658
4529
  if (i >= syncExprs.length) {
4659
4530
  return f(bound);
4660
4531
  }
4661
- _ref15 = syncExprs[i], idx_ = _ref15[0], expr_ = _ref15[1];
4532
+ _ref14 = syncExprs[i], idx_ = _ref14[0], expr_ = _ref14[1];
4662
4533
  return sequence(expr_, rescue, function(boundExpr) {
4663
4534
  bound[idx_] = boundExpr;
4664
4535
  return recurse(i + 1);
@@ -4668,14 +4539,15 @@ Gibbon.sequence = (function() {
4668
4539
  return syncStep;
4669
4540
  }
4670
4541
  joinName = nameGen('j');
4542
+ joinRescueName = "" + joinName + "$$rescue";
4671
4543
  contName = nameGen('k');
4672
4544
  forkBodies = (function() {
4673
- var _j, _len1, _ref15, _results;
4545
+ var _j, _len1, _ref14, _results;
4674
4546
  _results = [];
4675
4547
  for (i = _j = 0, _len1 = asyncExprs.length; _j < _len1; i = ++_j) {
4676
- _ref15 = asyncExprs[i], _ = _ref15[0], expr = _ref15[1];
4548
+ _ref14 = asyncExprs[i], _ = _ref14[0], expr = _ref14[1];
4677
4549
  _results.push(Step.makeVar(RVal.constant(i), function(boundI) {
4678
- return sequence(expr, rescue, function(boundExpr) {
4550
+ return sequence(expr, joinRescueName, function(boundExpr) {
4679
4551
  return Step.next(joinName, [boundI, boundExpr]);
4680
4552
  });
4681
4553
  }));
@@ -4703,7 +4575,7 @@ Gibbon.sequence = (function() {
4703
4575
  return _results;
4704
4576
  })();
4705
4577
  return Step.letCont(contName, [collectionName], bindAsyncVars, Step.makeVar(RVal.constant(asyncExprs.length), function(order) {
4706
- return Step.letJoin(joinName, order, contName, (recurse = function(i) {
4578
+ return Step.letJoin(joinName, order, rescue, contName, (recurse = function(i) {
4707
4579
  if (i >= forkBodies.length) {
4708
4580
  return Step.fork(forks);
4709
4581
  } else {
@@ -4841,11 +4713,11 @@ Gibbon.sequence = (function() {
4841
4713
  return sequence(list, rescue, function(boundList) {
4842
4714
  return Step.makeVar(RVal.prim(1, 'length', [boundList]), function(boundLen) {
4843
4715
  return Step.makeCont(1, bind, function(outCont) {
4844
- return Step.makeJoin(boundLen, outCont, function(index, bindJoin) {
4716
+ return Step.makeJoin(boundLen, rescue, outCont, function(index, joinRescue, bindJoin) {
4845
4717
  var delistExpr, substBody;
4846
4718
  delistExpr = Core.variable(boundList).delist(Core.variable(index));
4847
4719
  substBody = body.subst(arg, delistExpr).subst(idxArg, Core.variable(index));
4848
- return sequence(substBody, rescue, bindJoin);
4720
+ return sequence(substBody, joinRescue, bindJoin);
4849
4721
  });
4850
4722
  });
4851
4723
  });
@@ -4862,17 +4734,17 @@ Gibbon.sequence = (function() {
4862
4734
  return Step.makeVar(RVal.compact(v), bind);
4863
4735
  };
4864
4736
  return Step.makeCont(1, mkCompact, function(outCont) {
4865
- return Step.makeJoin(boundLen, outCont, function(index, bindJoin) {
4737
+ return Step.makeJoin(boundLen, rescue, outCont, function(index, joinRescue, bindJoin) {
4866
4738
  var delistExpr, substBody;
4867
4739
  delistExpr = Core.variable(boundList).delist(Core.variable(index));
4868
4740
  substBody = body.subst(arg, delistExpr);
4869
- return sequence(substBody, rescue, function(mappedBool) {
4741
+ return sequence(substBody, joinRescue, function(mappedBool) {
4870
4742
  var mkDelete, mkKeep;
4871
4743
  mkDelete = function() {
4872
4744
  return bindJoin(nullName);
4873
4745
  };
4874
4746
  mkKeep = function() {
4875
- return sequence(delistExpr, rescue, bindJoin);
4747
+ return sequence(delistExpr, joinRescue, bindJoin);
4876
4748
  };
4877
4749
  return Step.makeCont(0, mkDelete, function(deleteCont) {
4878
4750
  return Step.makeCont(0, mkKeep, function(keepCont) {
@@ -5169,8 +5041,8 @@ Gibbon.JS = JS = (function(_super) {
5169
5041
  __extends(JS, _super);
5170
5042
 
5171
5043
  function JS() {
5172
- _ref15 = JS.__super__.constructor.apply(this, arguments);
5173
- return _ref15;
5044
+ _ref14 = JS.__super__.constructor.apply(this, arguments);
5045
+ return _ref14;
5174
5046
  }
5175
5047
 
5176
5048
  JS.variants({
@@ -5548,15 +5420,17 @@ Gibbon.codegen = (function() {
5548
5420
  push(JS.func(name, args, JS.block(bodyStatements)));
5549
5421
  return generate(expr, extended, push);
5550
5422
  },
5551
- letJoin: function(name, order, cont, expr) {
5552
- var counterName, resultsName;
5423
+ letJoin: function(name, order, rescue, cont, expr) {
5424
+ var counterName, rescueName, resultsName;
5553
5425
  counterName = "" + name + "$counter";
5554
5426
  resultsName = "" + name + "$results";
5427
+ rescueName = "" + name + "$$rescue";
5555
5428
  push(JS.varDecl(counterName));
5556
5429
  push(JS.varDecl(resultsName));
5557
5430
  push(JS.bind(JS.ident(counterName), varToJS(order)));
5558
5431
  push(JS.bind(JS.ident(resultsName), JS.array([])));
5559
- push(JS.func(name, ['idx', 'el'], JS.block([JS.bind(JS.access(JS.ident(resultsName), JS.ident('idx')), JS.ident('el')), JS.trap(JS.ident(counterName).op('-=', JS.literal(1)).op('>', JS.literal(0))), JS.ident(cont).tailcall([JS.ident(resultsName)])])));
5432
+ push(JS.func(name, ['idx', 'el'], JS.block([JS.bind(JS.access(JS.ident(resultsName), JS.ident('idx')), JS.ident('el')), JS.trap(JS.ident(counterName).op('-=', JS.literal(1)).op('!==', JS.literal(0))), JS.ident(cont).tailcall([JS.ident(resultsName)])])));
5433
+ push(JS.func(rescueName, ['err'], JS.block([JS.trap(JS.ident(counterName).op('<', JS.literal(0))), JS.bind(JS.ident(counterName), JS.literal(-1)), JS.ident(rescue).tailcall([JS.ident('err')])])));
5560
5434
  return generate(expr, extended, push);
5561
5435
  },
5562
5436
  fork: function(forks) {
@@ -5775,16 +5649,16 @@ stdlib = Gibbon.stdlib = (function() {
5775
5649
  weight: {
5776
5650
  type: parse.type('weight [numeric : numeric] = % -> numeric'),
5777
5651
  compile: function(_, _arg) {
5778
- var ratio, totalDenom, totalNum, weights, _ref16;
5652
+ var ratio, totalDenom, totalNum, weights, _ref15;
5779
5653
  weights = _arg[0];
5780
5654
  ratio = weights.foldList(Core.pair(ZERO, ZERO), function(el, next) {
5781
- var denominator, numerator, value, weight, weighted, _ref16, _ref17;
5782
- _ref16 = el.depair(), value = _ref16[0], weight = _ref16[1];
5783
- _ref17 = next.depair(), numerator = _ref17[0], denominator = _ref17[1];
5655
+ var denominator, numerator, value, weight, weighted, _ref15, _ref16;
5656
+ _ref15 = el.depair(), value = _ref15[0], weight = _ref15[1];
5657
+ _ref16 = next.depair(), numerator = _ref16[0], denominator = _ref16[1];
5784
5658
  weighted = value.op2('*', weight);
5785
5659
  return Core.pair(numerator.op2('+', weighted), denominator.op2('+', weight));
5786
5660
  });
5787
- _ref16 = ratio.depair(), totalNum = _ref16[0], totalDenom = _ref16[1];
5661
+ _ref15 = ratio.depair(), totalNum = _ref15[0], totalDenom = _ref15[1];
5788
5662
  totalDenom = totalDenom.failIf('weight: zero denominator', function(d) {
5789
5663
  return d.op2('===', ZERO);
5790
5664
  });
@@ -6037,8 +5911,8 @@ Value = Gibbon.Value = Value = (function(_super) {
6037
5911
  __extends(Value, _super);
6038
5912
 
6039
5913
  function Value() {
6040
- _ref16 = Value.__super__.constructor.apply(this, arguments);
6041
- return _ref16;
5914
+ _ref15 = Value.__super__.constructor.apply(this, arguments);
5915
+ return _ref15;
6042
5916
  }
6043
5917
 
6044
5918
  Value.variants({
@@ -6305,8 +6179,8 @@ Gibbon.Dependency = Dependency = (function(_super) {
6305
6179
  __extends(Dependency, _super);
6306
6180
 
6307
6181
  function Dependency() {
6308
- _ref17 = Dependency.__super__.constructor.apply(this, arguments);
6309
- return _ref17;
6182
+ _ref16 = Dependency.__super__.constructor.apply(this, arguments);
6183
+ return _ref16;
6310
6184
  }
6311
6185
 
6312
6186
  Dependency.variants({
@@ -6360,8 +6234,8 @@ Gibbon.Failure = Failure = (function(_super) {
6360
6234
  __extends(Failure, _super);
6361
6235
 
6362
6236
  function Failure() {
6363
- _ref18 = Failure.__super__.constructor.apply(this, arguments);
6364
- return _ref18;
6237
+ _ref17 = Failure.__super__.constructor.apply(this, arguments);
6238
+ return _ref17;
6365
6239
  }
6366
6240
 
6367
6241
  Failure.variants({
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gibbon",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "A data language",
5
5
  "keywords": ["language"],
6
6
  "author": "Jay Adkisson <jjmadkisson at gmail dot com>",
@@ -20,7 +20,6 @@
20
20
  "falafel": "0.2.x"
21
21
  },
22
22
  "scripts": {
23
- "install": "make",
24
23
  "test": "make test"
25
24
  }
26
25
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goodguide-gibbon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Adkisson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-24 00:00:00.000000000 Z
11
+ date: 2014-06-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Run and analyze gibbon code from ruby or a browser (via a ruby app).
14
14
  email: