• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#windowsobjective-ccocoaqtpython誰得phprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

A categorical programming language


Commit MetaInfo

修订版c49055b3f863b8ab587f40df0c787bd048d9a85c (tree)
时间2022-02-28 08:56:34
作者Corbin <cds@corb...>
CommiterCorbin

Log Message

Catch infinite types during extraction.

更改概述

差异

--- a/cammy-rpy/cammylib/types.py
+++ b/cammy-rpy/cammylib/types.py
@@ -107,6 +107,9 @@ class TypeExtractor(object):
107107 self.d[index] = LETTERS[len(self.d)]
108108
109109 def extractType(self, cs, var):
110+ return self.go(cs, var, [])
111+
112+ def go(self, cs, var, seen):
110113 sexp = cs.walk(var)
111114 if isinstance(sexp, Hole):
112115 if sexp.index not in self.d:
@@ -115,7 +118,10 @@ class TypeExtractor(object):
115118 elif isinstance(sexp, Atom):
116119 return sexp.symbol
117120 elif isinstance(sexp, Functor):
118- args = [self.extractType(cs, unhole(arg)) for arg in sexp.arguments]
121+ if var in seen:
122+ # XXX split exceptions?
123+ raise UnificationFailed("tried to extract infinite type")
124+ args = [self.go(cs, unhole(arg), seen + [var]) for arg in sexp.arguments]
119125 if sexp.constructor == "hom":
120126 return "[%s, %s]" % (args[0], args[1])
121127 elif sexp.constructor == "pair":
--- a/cammy-rpy/weave.py
+++ b/cammy-rpy/weave.py
@@ -1,5 +1,6 @@
11 import os
22 import os.path
3+import sys
34
45 from cammylib.arrows import buildArrow, BuildProblem
56 from cammylib.hive import Hive, MissingAtom
@@ -61,3 +62,6 @@ def main(argv):
6162 def target(driver, *args):
6263 driver.exe_name = "cammy-weave"
6364 return main, None
65+
66+if __name__ == "__main__":
67+ main(sys.argv)