• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

A categorical programming language


Commit MetaInfo

修订版aefa9fce4e94ae7dc359bc4cb0ff1a6fcc4aadb1 (tree)
时间2022-10-13 12:16:41
作者Corbin <cds@corb...>
CommiterCorbin

Log Message

Expand dissolved expressions correctly.

This might be a hack.

更改概述

差异

--- a/honey/honey.py
+++ b/honey/honey.py
@@ -113,11 +113,15 @@ def sexpify(expr):
113113 @app.route("/extract/<int:token>/type")
114114 def getType(token):
115115 expr = resolve(token)
116- types = subprocess.check_output(MOVELIST + "cammy-type",
117- input=sexpify(expr).encode("utf-8")).decode("utf-8").split("\n")
118- s, _ = parse(types[0].strip())
119- t, _ = parse(types[1].strip())
120- return jsonify({"source": s, "target": t})
116+ try:
117+ types = subprocess.check_output(MOVELIST + "cammy-type",
118+ input=sexpify(expr).encode("utf-8")).decode("utf-8").split("\n")
119+ s, _ = parse(types[0].strip())
120+ t, _ = parse(types[1].strip())
121+ return jsonify({"source": s, "target": t})
122+ except subprocess.CalledProcessError:
123+ print("Couldn't typecheck", sexpify(expr))
124+ raise
121125
122126 @app.route("/dippers")
123127 def dippers():
@@ -133,12 +137,16 @@ def resolve(i):
133137 def dissolve(sexp):
134138 if isinstance(sexp, int): return sexp
135139 if isinstance(sexp, str):
140+ if sexp in symbols:
141+ return symbols[sexp][0]
136142 if sexp not in strs:
137143 strs[sexp] = len(heap)
138144 heap.append(sexp)
139145 return strs[sexp]
140146 else:
141147 merged = tuple([sexp[0]] + [dissolve(arg) for arg in sexp[1:]])
148+ if merged[0] in templates:
149+ merged = substitute(merged[1:], templates(merged[0]))
142150 if merged not in tuples:
143151 tuples[merged] = len(heap)
144152 heap.append(merged)