goodguide-gibbon 0.3.2 → 0.3.3

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.
@@ -1,7 +1,7 @@
1
1
  module GoodGuide
2
2
  module Gibbon
3
3
  def self.version
4
- '0.3.2'
4
+ '0.3.3'
5
5
  end
6
6
  end
7
7
  end
@@ -1569,6 +1569,7 @@ analyze = Gibbon.analyze = (function() {
1569
1569
  destructure: ['constraint', 'name', 'argnum'],
1570
1570
  "native": ['id'],
1571
1571
  param: ['name', 'constraints'],
1572
+ error: ['type', 'args'],
1572
1573
  any: []
1573
1574
  });
1574
1575
 
@@ -1719,6 +1720,23 @@ analyze = Gibbon.analyze = (function() {
1719
1720
  });
1720
1721
  };
1721
1722
 
1723
+ TypeExpr.fromType = function(t) {
1724
+ var st;
1725
+ if (t._tag === 'entity') {
1726
+ return TypeExpr["native"](t.id);
1727
+ }
1728
+ return TypeExpr.param(t._tag, (function() {
1729
+ var _i, _len, _ref4, _results;
1730
+ _ref4 = t._values;
1731
+ _results = [];
1732
+ for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
1733
+ st = _ref4[_i];
1734
+ _results.push(this.fromType(st));
1735
+ }
1736
+ return _results;
1737
+ }).call(this));
1738
+ };
1739
+
1722
1740
  TypeExpr.prototype.map = function(f) {
1723
1741
  return this.cases({
1724
1742
  param: function(name, params) {
@@ -1780,7 +1798,7 @@ analyze = Gibbon.analyze = (function() {
1780
1798
  }
1781
1799
 
1782
1800
  NativeContext.prototype.query = function(id, query, cb) {
1783
- return this.externalLookup.call(null, id, query, TypeAST, function(err, analysis) {
1801
+ return this.externalLookup.call(null, id, query, Type, function(err, analysis) {
1784
1802
  if (err) {
1785
1803
  return cb(TypeLookup.error(err));
1786
1804
  } else {
@@ -1891,7 +1909,8 @@ analyze = Gibbon.analyze = (function() {
1891
1909
  func: function(name, args) {
1892
1910
  var arg, ast, func, i, input, scope, _i, _len, _results;
1893
1911
  if (!stdlib.hasOwnProperty(name)) {
1894
- throw new Error("no such function " + name);
1912
+ push(TypeExpr.expr(flow.head), TypeExpr.error('func', [flow.head]));
1913
+ return;
1895
1914
  }
1896
1915
  func = stdlib[name];
1897
1916
  ast = func.type;
@@ -1985,7 +2004,8 @@ analyze = Gibbon.analyze = (function() {
1985
2004
  match: ['lhs', 'rhs'],
1986
2005
  destructure: ['type'],
1987
2006
  lookup: ['query', 'id', 'error'],
1988
- circular: ['crumbs']
2007
+ circular: ['crumbs'],
2008
+ func: ['node']
1989
2009
  });
1990
2010
 
1991
2011
  return TypeError;
@@ -2064,6 +2084,9 @@ analyze = Gibbon.analyze = (function() {
2064
2084
  };
2065
2085
  simplify = function(expr, cb) {
2066
2086
  return expr.cases({
2087
+ error: function(type, args) {
2088
+ return cb(error.apply(null, [type].concat(__slice.call(args))));
2089
+ },
2067
2090
  destructure: function(constraint, name, argnum) {
2068
2091
  var destructured;
2069
2092
  destructured = this;
@@ -2094,7 +2117,7 @@ analyze = Gibbon.analyze = (function() {
2094
2117
  },
2095
2118
  response: function(analysis) {
2096
2119
  semanticAccessors.set(query, Semantic.query(analysis.annotations));
2097
- return cb(TypeExpr.fromAST(analysis.type));
2120
+ return cb(TypeExpr.fromType(analysis.type));
2098
2121
  },
2099
2122
  local: function(key) {
2100
2123
  var localFrame;
@@ -2126,7 +2149,10 @@ analyze = Gibbon.analyze = (function() {
2126
2149
  var flowType, toSemanticTree;
2127
2150
  flowType = function(expr) {
2128
2151
  if (!solutions.has(TypeExpr.expr(expr))) {
2129
- throw 'unsolved!';
2152
+ if (errors.length === 0) {
2153
+ throw new Error('unsolved!');
2154
+ }
2155
+ return Type.abstract(TypeExpr.expr(expr));
2130
2156
  }
2131
2157
  return solutions.get(TypeExpr.expr(expr)).realize();
2132
2158
  };
@@ -2867,7 +2893,7 @@ Gibbon.jsonConsumer = (function() {
2867
2893
  return callback(new Error("" + id + " has no field " + accessorName));
2868
2894
  }
2869
2895
  return callback(null, {
2870
- type: t.parseUnit(fields[accessorName]),
2896
+ type: fields[accessorName],
2871
2897
  annotations: {
2872
2898
  name: accessorName,
2873
2899
  table: id
@@ -2900,7 +2926,7 @@ Gibbon.jsonConsumer = (function() {
2900
2926
  callback(new Error("wrong type " + id + " for list `" + listName + "'"));
2901
2927
  }
2902
2928
  return callback(null, {
2903
- type: t.concrete('bool'),
2929
+ type: t.bool(),
2904
2930
  annotations: {
2905
2931
  list: listName
2906
2932
  }
@@ -1563,6 +1563,7 @@ analyze = Gibbon.analyze = (function() {
1563
1563
  destructure: ['constraint', 'name', 'argnum'],
1564
1564
  "native": ['id'],
1565
1565
  param: ['name', 'constraints'],
1566
+ error: ['type', 'args'],
1566
1567
  any: []
1567
1568
  });
1568
1569
 
@@ -1713,6 +1714,23 @@ analyze = Gibbon.analyze = (function() {
1713
1714
  });
1714
1715
  };
1715
1716
 
1717
+ TypeExpr.fromType = function(t) {
1718
+ var st;
1719
+ if (t._tag === 'entity') {
1720
+ return TypeExpr["native"](t.id);
1721
+ }
1722
+ return TypeExpr.param(t._tag, (function() {
1723
+ var _i, _len, _ref4, _results;
1724
+ _ref4 = t._values;
1725
+ _results = [];
1726
+ for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
1727
+ st = _ref4[_i];
1728
+ _results.push(this.fromType(st));
1729
+ }
1730
+ return _results;
1731
+ }).call(this));
1732
+ };
1733
+
1716
1734
  TypeExpr.prototype.map = function(f) {
1717
1735
  return this.cases({
1718
1736
  param: function(name, params) {
@@ -1774,7 +1792,7 @@ analyze = Gibbon.analyze = (function() {
1774
1792
  }
1775
1793
 
1776
1794
  NativeContext.prototype.query = function(id, query, cb) {
1777
- return this.externalLookup.call(null, id, query, TypeAST, function(err, analysis) {
1795
+ return this.externalLookup.call(null, id, query, Type, function(err, analysis) {
1778
1796
  if (err) {
1779
1797
  return cb(TypeLookup.error(err));
1780
1798
  } else {
@@ -1885,7 +1903,8 @@ analyze = Gibbon.analyze = (function() {
1885
1903
  func: function(name, args) {
1886
1904
  var arg, ast, func, i, input, scope, _i, _len, _results;
1887
1905
  if (!stdlib.hasOwnProperty(name)) {
1888
- throw new Error("no such function " + name);
1906
+ push(TypeExpr.expr(flow.head), TypeExpr.error('func', [flow.head]));
1907
+ return;
1889
1908
  }
1890
1909
  func = stdlib[name];
1891
1910
  ast = func.type;
@@ -1979,7 +1998,8 @@ analyze = Gibbon.analyze = (function() {
1979
1998
  match: ['lhs', 'rhs'],
1980
1999
  destructure: ['type'],
1981
2000
  lookup: ['query', 'id', 'error'],
1982
- circular: ['crumbs']
2001
+ circular: ['crumbs'],
2002
+ func: ['node']
1983
2003
  });
1984
2004
 
1985
2005
  return TypeError;
@@ -2044,6 +2064,9 @@ analyze = Gibbon.analyze = (function() {
2044
2064
  };
2045
2065
  simplify = function(expr, cb) {
2046
2066
  return expr.cases({
2067
+ error: function(type, args) {
2068
+ return cb(error.apply(null, [type].concat(__slice.call(args))));
2069
+ },
2047
2070
  destructure: function(constraint, name, argnum) {
2048
2071
  var destructured;
2049
2072
  destructured = this;
@@ -2074,7 +2097,7 @@ analyze = Gibbon.analyze = (function() {
2074
2097
  },
2075
2098
  response: function(analysis) {
2076
2099
  semanticAccessors.set(query, Semantic.query(analysis.annotations));
2077
- return cb(TypeExpr.fromAST(analysis.type));
2100
+ return cb(TypeExpr.fromType(analysis.type));
2078
2101
  },
2079
2102
  local: function(key) {
2080
2103
  var localFrame;
@@ -2106,7 +2129,10 @@ analyze = Gibbon.analyze = (function() {
2106
2129
  var flowType, toSemanticTree;
2107
2130
  flowType = function(expr) {
2108
2131
  if (!solutions.has(TypeExpr.expr(expr))) {
2109
- throw 'unsolved!';
2132
+ if (errors.length === 0) {
2133
+ throw new Error('unsolved!');
2134
+ }
2135
+ return Type.abstract(TypeExpr.expr(expr));
2110
2136
  }
2111
2137
  return solutions.get(TypeExpr.expr(expr)).realize();
2112
2138
  };
@@ -2839,7 +2865,7 @@ Gibbon.jsonConsumer = (function() {
2839
2865
  return callback(new Error("" + id + " has no field " + accessorName));
2840
2866
  }
2841
2867
  return callback(null, {
2842
- type: t.parseUnit(fields[accessorName]),
2868
+ type: fields[accessorName],
2843
2869
  annotations: {
2844
2870
  name: accessorName,
2845
2871
  table: id
@@ -2872,7 +2898,7 @@ Gibbon.jsonConsumer = (function() {
2872
2898
  callback(new Error("wrong type " + id + " for list `" + listName + "'"));
2873
2899
  }
2874
2900
  return callback(null, {
2875
- type: t.concrete('bool'),
2901
+ type: t.bool(),
2876
2902
  annotations: {
2877
2903
  list: listName
2878
2904
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goodguide-gibbon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-01 00:00:00.000000000 Z
12
+ date: 2013-08-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  type: :runtime