goodguide-gibbon 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/goodguide/gibbon/version.rb +1 -1
- data/vendor/gibbon/lib/gibbon.browser.dev.js +72 -31
- data/vendor/gibbon/lib/gibbon.browser.js +72 -31
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2a7dcf8d9db98045230513edc7c30ebfb44cb98
|
4
|
+
data.tar.gz: 39c2e0e633bfad5466dd430a415562074199a0ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2eb0b1a90425591ddb807cf6f7324914c7a39462972ebff03f2beb2b0dde2e305cc931510fb70b854aa05630351f1a8c2d89eec0460e04adf4546dff1dccb510
|
7
|
+
data.tar.gz: 4c0f224cb2f8c7b5a809b0e4f678b864ebb768aa439a422c93dd5cd9fa4b29564403d3bd8dced49fbdc9761162cf9d6b3fceea6f7643539feceff17f2f0105c6
|
@@ -3275,45 +3275,40 @@ Gibbon.optimize = (function() {
|
|
3275
3275
|
});
|
3276
3276
|
},
|
3277
3277
|
branch: function(cond, ifTrue, ifFalse) {
|
3278
|
-
|
3279
|
-
|
3280
|
-
|
3281
|
-
|
3282
|
-
|
3283
|
-
|
3284
|
-
|
3278
|
+
var abort;
|
3279
|
+
cond = partialEval(cond);
|
3280
|
+
abort = function() {
|
3281
|
+
ifTrue = partialEval(ifTrue);
|
3282
|
+
ifFalse = partialEval(ifFalse);
|
3283
|
+
if (ifTrue.equals(ifFalse)) {
|
3284
|
+
DEBUG.log("eliminating condition in equivalent branches: " + (this.inspect()));
|
3285
|
+
return ifTrue;
|
3286
|
+
}
|
3287
|
+
return cond.branch(ifTrue, ifFalse);
|
3288
|
+
};
|
3289
|
+
return cond.cases({
|
3285
3290
|
constant: function(value) {
|
3286
3291
|
if (value) {
|
3287
3292
|
DEBUG.log("eliminating dead false branch " + (ifFalse.inspect()));
|
3288
|
-
return ifTrue;
|
3293
|
+
return partialEval(ifTrue);
|
3289
3294
|
} else {
|
3290
3295
|
DEBUG.log("eliminating dead true branch " + (ifTrue.inspect()));
|
3291
|
-
return ifFalse;
|
3296
|
+
return partialEval(ifFalse);
|
3292
3297
|
}
|
3293
3298
|
},
|
3294
3299
|
branch: function(innerCond, innerTrue, innerFalse) {
|
3295
|
-
|
3296
|
-
|
3297
|
-
if (innerTrue.value) {
|
3298
|
-
return partialEval(innerCond.branch(ifTrue, ifFalse));
|
3299
|
-
} else {
|
3300
|
-
return partialEval(innerCond.branch(ifFalse, ifTrue));
|
3301
|
-
}
|
3302
|
-
} else {
|
3303
|
-
return this.branch(ifTrue, ifFalse);
|
3304
|
-
}
|
3300
|
+
DEBUG.log("flattening nested branch " + (this.inspect()));
|
3301
|
+
return partialEval(innerCond.branch(innerTrue.branch(ifTrue, ifFalse), innerFalse.branch(ifTrue, ifFalse)));
|
3305
3302
|
},
|
3306
3303
|
op1: function(name, arg) {
|
3307
3304
|
if (name === '!') {
|
3308
3305
|
DEBUG.log("eliminating if negation in condition " + (this.inspect()));
|
3309
3306
|
return partialEval(arg.branch(ifFalse, ifTrue));
|
3310
3307
|
} else {
|
3311
|
-
return
|
3308
|
+
return abort();
|
3312
3309
|
}
|
3313
3310
|
},
|
3314
|
-
other:
|
3315
|
-
return this.branch(ifTrue, ifFalse);
|
3316
|
-
}
|
3311
|
+
other: abort
|
3317
3312
|
});
|
3318
3313
|
},
|
3319
3314
|
app: function(block, arg) {
|
@@ -5491,11 +5486,12 @@ Gibbon.codegen = (function() {
|
|
5491
5486
|
})();
|
5492
5487
|
|
5493
5488
|
stdlib = Gibbon.stdlib = (function() {
|
5494
|
-
var FALSE, TRUE, equals, isEmpty;
|
5489
|
+
var FALSE, TRUE, ZERO, equals, isEmpty;
|
5495
5490
|
TRUE = Core.constant(true);
|
5496
5491
|
FALSE = Core.constant(false);
|
5492
|
+
ZERO = Core.constant(0);
|
5497
5493
|
isEmpty = function(list) {
|
5498
|
-
return list.len().op2('===',
|
5494
|
+
return list.len().op2('===', ZERO);
|
5499
5495
|
};
|
5500
5496
|
equals = function(x, y, type) {
|
5501
5497
|
var direct;
|
@@ -5623,7 +5619,7 @@ stdlib = Gibbon.stdlib = (function() {
|
|
5623
5619
|
compile: function(_, _arg) {
|
5624
5620
|
var ratio, totalDenom, totalNum, weights, _ref16;
|
5625
5621
|
weights = _arg[0];
|
5626
|
-
ratio = weights.foldList(Core.pair(
|
5622
|
+
ratio = weights.foldList(Core.pair(ZERO, ZERO), function(el, next) {
|
5627
5623
|
var denominator, numerator, value, weight, weighted, _ref16, _ref17;
|
5628
5624
|
_ref16 = el.depair(), value = _ref16[0], weight = _ref16[1];
|
5629
5625
|
_ref17 = next.depair(), numerator = _ref17[0], denominator = _ref17[1];
|
@@ -5632,11 +5628,22 @@ stdlib = Gibbon.stdlib = (function() {
|
|
5632
5628
|
});
|
5633
5629
|
_ref16 = ratio.depair(), totalNum = _ref16[0], totalDenom = _ref16[1];
|
5634
5630
|
totalDenom = totalDenom.failIf('weight: zero denominator', function(d) {
|
5635
|
-
return d.op2('===',
|
5631
|
+
return d.op2('===', ZERO);
|
5636
5632
|
});
|
5637
5633
|
return totalNum.op2('/', totalDenom);
|
5638
5634
|
}
|
5639
5635
|
},
|
5636
|
+
mean: {
|
5637
|
+
type: parse.type('mean = [numeric] -> numeric'),
|
5638
|
+
compile: function(list) {
|
5639
|
+
var sum;
|
5640
|
+
list = list.failIf('mean: empty list', isEmpty);
|
5641
|
+
sum = list.foldList(ZERO, function(el, next) {
|
5642
|
+
return el.op2('+', next);
|
5643
|
+
});
|
5644
|
+
return sum.op2('/', list.len());
|
5645
|
+
}
|
5646
|
+
},
|
5640
5647
|
filter: {
|
5641
5648
|
type: parse.type('filter { %a -> bool } = [%a] -> [%a]'),
|
5642
5649
|
compile: function(input, _arg) {
|
@@ -5685,7 +5692,7 @@ stdlib = Gibbon.stdlib = (function() {
|
|
5685
5692
|
sum: {
|
5686
5693
|
type: parse.type('sum = [numeric] -> numeric'),
|
5687
5694
|
compile: function(list) {
|
5688
|
-
return list.foldList(
|
5695
|
+
return list.foldList(ZERO, function(el, next) {
|
5689
5696
|
return el.op2('+', next);
|
5690
5697
|
});
|
5691
5698
|
}
|
@@ -5713,7 +5720,7 @@ stdlib = Gibbon.stdlib = (function() {
|
|
5713
5720
|
compile: function(_, _arg) {
|
5714
5721
|
var list;
|
5715
5722
|
list = _arg[0];
|
5716
|
-
return list.foldList(
|
5723
|
+
return list.foldList(ZERO, function(el, next) {
|
5717
5724
|
var cond, val;
|
5718
5725
|
cond = el.depair('first');
|
5719
5726
|
val = el.depair('second');
|
@@ -5724,7 +5731,33 @@ stdlib = Gibbon.stdlib = (function() {
|
|
5724
5731
|
first: {
|
5725
5732
|
type: parse.type('first = [%a] -> %a'),
|
5726
5733
|
compile: function(list) {
|
5727
|
-
return list.delist(
|
5734
|
+
return list.delist(ZERO);
|
5735
|
+
}
|
5736
|
+
},
|
5737
|
+
left: {
|
5738
|
+
type: parse.type('left = (%a : %b) -> %a'),
|
5739
|
+
compile: function(pair) {
|
5740
|
+
return pair.depair('first');
|
5741
|
+
}
|
5742
|
+
},
|
5743
|
+
right: {
|
5744
|
+
type: parse.type('right = (%a : %b) -> %b'),
|
5745
|
+
compile: function(pair) {
|
5746
|
+
return pair.depair('second');
|
5747
|
+
}
|
5748
|
+
},
|
5749
|
+
at: {
|
5750
|
+
type: parse.type('at numeric = [%a] -> %a'),
|
5751
|
+
compile: function(list, _arg) {
|
5752
|
+
var index;
|
5753
|
+
index = _arg[0];
|
5754
|
+
index = index.failIf('index out of bounds', function(i) {
|
5755
|
+
return list.len().op2('<=', i);
|
5756
|
+
});
|
5757
|
+
index = index.failIf('index out of bounds', function(i) {
|
5758
|
+
return i.op2('<', ZERO);
|
5759
|
+
});
|
5760
|
+
return list.delist(index);
|
5728
5761
|
}
|
5729
5762
|
},
|
5730
5763
|
"index-of": {
|
@@ -5768,7 +5801,7 @@ stdlib = Gibbon.stdlib = (function() {
|
|
5768
5801
|
var num;
|
5769
5802
|
num = _arg[0];
|
5770
5803
|
num = num.failIf('division by zero', function(n) {
|
5771
|
-
return n.op2('===',
|
5804
|
+
return n.op2('===', ZERO);
|
5772
5805
|
});
|
5773
5806
|
return input.op2('/', num);
|
5774
5807
|
}
|
@@ -6325,6 +6358,14 @@ Gibbon.CompiledCode = CompiledCode = (function() {
|
|
6325
6358
|
});
|
6326
6359
|
return out.set(k, [value, deps]);
|
6327
6360
|
});
|
6361
|
+
failures.each(function(k, v) {
|
6362
|
+
var deps;
|
6363
|
+
deps = dependencies.get(k);
|
6364
|
+
deps = uniq(deps, function(x, y) {
|
6365
|
+
return x.equals(y);
|
6366
|
+
});
|
6367
|
+
return out.set(k, [v, deps]);
|
6368
|
+
});
|
6328
6369
|
return cb(null, out);
|
6329
6370
|
});
|
6330
6371
|
return trampoline(thunk);
|
@@ -3243,45 +3243,40 @@ Gibbon.optimize = (function() {
|
|
3243
3243
|
});
|
3244
3244
|
},
|
3245
3245
|
branch: function(cond, ifTrue, ifFalse) {
|
3246
|
-
|
3247
|
-
|
3248
|
-
|
3249
|
-
|
3250
|
-
|
3251
|
-
|
3252
|
-
|
3246
|
+
var abort;
|
3247
|
+
cond = partialEval(cond);
|
3248
|
+
abort = function() {
|
3249
|
+
ifTrue = partialEval(ifTrue);
|
3250
|
+
ifFalse = partialEval(ifFalse);
|
3251
|
+
if (ifTrue.equals(ifFalse)) {
|
3252
|
+
|
3253
|
+
return ifTrue;
|
3254
|
+
}
|
3255
|
+
return cond.branch(ifTrue, ifFalse);
|
3256
|
+
};
|
3257
|
+
return cond.cases({
|
3253
3258
|
constant: function(value) {
|
3254
3259
|
if (value) {
|
3255
3260
|
|
3256
|
-
return ifTrue;
|
3261
|
+
return partialEval(ifTrue);
|
3257
3262
|
} else {
|
3258
3263
|
|
3259
|
-
return ifFalse;
|
3264
|
+
return partialEval(ifFalse);
|
3260
3265
|
}
|
3261
3266
|
},
|
3262
3267
|
branch: function(innerCond, innerTrue, innerFalse) {
|
3263
|
-
|
3264
|
-
|
3265
|
-
if (innerTrue.value) {
|
3266
|
-
return partialEval(innerCond.branch(ifTrue, ifFalse));
|
3267
|
-
} else {
|
3268
|
-
return partialEval(innerCond.branch(ifFalse, ifTrue));
|
3269
|
-
}
|
3270
|
-
} else {
|
3271
|
-
return this.branch(ifTrue, ifFalse);
|
3272
|
-
}
|
3268
|
+
|
3269
|
+
return partialEval(innerCond.branch(innerTrue.branch(ifTrue, ifFalse), innerFalse.branch(ifTrue, ifFalse)));
|
3273
3270
|
},
|
3274
3271
|
op1: function(name, arg) {
|
3275
3272
|
if (name === '!') {
|
3276
3273
|
|
3277
3274
|
return partialEval(arg.branch(ifFalse, ifTrue));
|
3278
3275
|
} else {
|
3279
|
-
return
|
3276
|
+
return abort();
|
3280
3277
|
}
|
3281
3278
|
},
|
3282
|
-
other:
|
3283
|
-
return this.branch(ifTrue, ifFalse);
|
3284
|
-
}
|
3279
|
+
other: abort
|
3285
3280
|
});
|
3286
3281
|
},
|
3287
3282
|
app: function(block, arg) {
|
@@ -5451,11 +5446,12 @@ Gibbon.codegen = (function() {
|
|
5451
5446
|
})();
|
5452
5447
|
|
5453
5448
|
stdlib = Gibbon.stdlib = (function() {
|
5454
|
-
var FALSE, TRUE, equals, isEmpty;
|
5449
|
+
var FALSE, TRUE, ZERO, equals, isEmpty;
|
5455
5450
|
TRUE = Core.constant(true);
|
5456
5451
|
FALSE = Core.constant(false);
|
5452
|
+
ZERO = Core.constant(0);
|
5457
5453
|
isEmpty = function(list) {
|
5458
|
-
return list.len().op2('===',
|
5454
|
+
return list.len().op2('===', ZERO);
|
5459
5455
|
};
|
5460
5456
|
equals = function(x, y, type) {
|
5461
5457
|
var direct;
|
@@ -5583,7 +5579,7 @@ stdlib = Gibbon.stdlib = (function() {
|
|
5583
5579
|
compile: function(_, _arg) {
|
5584
5580
|
var ratio, totalDenom, totalNum, weights, _ref16;
|
5585
5581
|
weights = _arg[0];
|
5586
|
-
ratio = weights.foldList(Core.pair(
|
5582
|
+
ratio = weights.foldList(Core.pair(ZERO, ZERO), function(el, next) {
|
5587
5583
|
var denominator, numerator, value, weight, weighted, _ref16, _ref17;
|
5588
5584
|
_ref16 = el.depair(), value = _ref16[0], weight = _ref16[1];
|
5589
5585
|
_ref17 = next.depair(), numerator = _ref17[0], denominator = _ref17[1];
|
@@ -5592,11 +5588,22 @@ stdlib = Gibbon.stdlib = (function() {
|
|
5592
5588
|
});
|
5593
5589
|
_ref16 = ratio.depair(), totalNum = _ref16[0], totalDenom = _ref16[1];
|
5594
5590
|
totalDenom = totalDenom.failIf('weight: zero denominator', function(d) {
|
5595
|
-
return d.op2('===',
|
5591
|
+
return d.op2('===', ZERO);
|
5596
5592
|
});
|
5597
5593
|
return totalNum.op2('/', totalDenom);
|
5598
5594
|
}
|
5599
5595
|
},
|
5596
|
+
mean: {
|
5597
|
+
type: parse.type('mean = [numeric] -> numeric'),
|
5598
|
+
compile: function(list) {
|
5599
|
+
var sum;
|
5600
|
+
list = list.failIf('mean: empty list', isEmpty);
|
5601
|
+
sum = list.foldList(ZERO, function(el, next) {
|
5602
|
+
return el.op2('+', next);
|
5603
|
+
});
|
5604
|
+
return sum.op2('/', list.len());
|
5605
|
+
}
|
5606
|
+
},
|
5600
5607
|
filter: {
|
5601
5608
|
type: parse.type('filter { %a -> bool } = [%a] -> [%a]'),
|
5602
5609
|
compile: function(input, _arg) {
|
@@ -5645,7 +5652,7 @@ stdlib = Gibbon.stdlib = (function() {
|
|
5645
5652
|
sum: {
|
5646
5653
|
type: parse.type('sum = [numeric] -> numeric'),
|
5647
5654
|
compile: function(list) {
|
5648
|
-
return list.foldList(
|
5655
|
+
return list.foldList(ZERO, function(el, next) {
|
5649
5656
|
return el.op2('+', next);
|
5650
5657
|
});
|
5651
5658
|
}
|
@@ -5673,7 +5680,7 @@ stdlib = Gibbon.stdlib = (function() {
|
|
5673
5680
|
compile: function(_, _arg) {
|
5674
5681
|
var list;
|
5675
5682
|
list = _arg[0];
|
5676
|
-
return list.foldList(
|
5683
|
+
return list.foldList(ZERO, function(el, next) {
|
5677
5684
|
var cond, val;
|
5678
5685
|
cond = el.depair('first');
|
5679
5686
|
val = el.depair('second');
|
@@ -5684,7 +5691,33 @@ stdlib = Gibbon.stdlib = (function() {
|
|
5684
5691
|
first: {
|
5685
5692
|
type: parse.type('first = [%a] -> %a'),
|
5686
5693
|
compile: function(list) {
|
5687
|
-
return list.delist(
|
5694
|
+
return list.delist(ZERO);
|
5695
|
+
}
|
5696
|
+
},
|
5697
|
+
left: {
|
5698
|
+
type: parse.type('left = (%a : %b) -> %a'),
|
5699
|
+
compile: function(pair) {
|
5700
|
+
return pair.depair('first');
|
5701
|
+
}
|
5702
|
+
},
|
5703
|
+
right: {
|
5704
|
+
type: parse.type('right = (%a : %b) -> %b'),
|
5705
|
+
compile: function(pair) {
|
5706
|
+
return pair.depair('second');
|
5707
|
+
}
|
5708
|
+
},
|
5709
|
+
at: {
|
5710
|
+
type: parse.type('at numeric = [%a] -> %a'),
|
5711
|
+
compile: function(list, _arg) {
|
5712
|
+
var index;
|
5713
|
+
index = _arg[0];
|
5714
|
+
index = index.failIf('index out of bounds', function(i) {
|
5715
|
+
return list.len().op2('<=', i);
|
5716
|
+
});
|
5717
|
+
index = index.failIf('index out of bounds', function(i) {
|
5718
|
+
return i.op2('<', ZERO);
|
5719
|
+
});
|
5720
|
+
return list.delist(index);
|
5688
5721
|
}
|
5689
5722
|
},
|
5690
5723
|
"index-of": {
|
@@ -5728,7 +5761,7 @@ stdlib = Gibbon.stdlib = (function() {
|
|
5728
5761
|
var num;
|
5729
5762
|
num = _arg[0];
|
5730
5763
|
num = num.failIf('division by zero', function(n) {
|
5731
|
-
return n.op2('===',
|
5764
|
+
return n.op2('===', ZERO);
|
5732
5765
|
});
|
5733
5766
|
return input.op2('/', num);
|
5734
5767
|
}
|
@@ -6285,6 +6318,14 @@ Gibbon.CompiledCode = CompiledCode = (function() {
|
|
6285
6318
|
});
|
6286
6319
|
return out.set(k, [value, deps]);
|
6287
6320
|
});
|
6321
|
+
failures.each(function(k, v) {
|
6322
|
+
var deps;
|
6323
|
+
deps = dependencies.get(k);
|
6324
|
+
deps = uniq(deps, function(x, y) {
|
6325
|
+
return x.equals(y);
|
6326
|
+
});
|
6327
|
+
return out.set(k, [v, deps]);
|
6328
|
+
});
|
6288
6329
|
return cb(null, out);
|
6289
6330
|
});
|
6290
6331
|
return trampoline(thunk);
|
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.8.
|
4
|
+
version: 0.8.2
|
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-03-
|
11
|
+
date: 2014-03-10 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:
|