• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine 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

Revisiond33882093f56758a151388896270bd7cb62539f3 (tree)
Zeit2023-01-14 09:06:27
AutorCorbin <cds@corb...>
CommiterCorbin

Log Message

Optimize dissolved expressions, always.

Similar to the old logic, but now that I have a REPL again, I can
quickly iterate.

Ändern Zusammenfassung

Diff

--- a/honey/honey.py
+++ b/honey/honey.py
@@ -242,8 +242,12 @@ def dissolveNewExpression():
242242 if isTemplate(expr):
243243 print("can't handle templates yet")
244244 abort(500)
245- # First dissolution gets the desugared input.
246- index = dissolve(expr)
245+ # It's unclear whether we should jellify here.
246+ # For learning purposes, it's important to be able to write directly to the heap...
247+ # But also, we should prize normal forms and encourage users to see them as equivalent.
248+ # For now, we'll dissolve, jellify, dissolve.
249+ sexp = jellify(sexpify(resolve(dissolve(expr))))
250+ index = dissolve(parse(sexp)[0])
247251 return jsonify({"index": index, "trail": trail})
248252
249253 if __name__ == "__main__":
--- a/new-repl.py
+++ b/new-repl.py
@@ -4,6 +4,7 @@
44 import readline
55 import sys
66 from textwrap import dedent
7+import urllib.parse
78
89 import requests
910
@@ -39,7 +40,11 @@ def sexpify(expr):
3940 else: return expr
4041
4142 def fetchDipper(base, name):
42- return getJSON(base + "/dip/" + name)
43+ component = urllib.parse.quote(name, safe="")
44+ return getJSON(base + "/dip/" + component)
45+
46+def dissolve(base, sexp):
47+ return requests.post(base + "/dissolve", data=sexp).json()
4348
4449 class DipperCompleter:
4550 def __init__(self, dippers):
@@ -63,18 +68,13 @@ def repl(base):
6368 done = True
6469 else:
6570 if line.startswith(":"):
66- print("I think it's a command")
71+ print("I don't have any commands, sorry")
6772 else:
68- print("I think it's a sugared Cammy expression")
69- if line.startswith("("):
70- print("I think it's an application")
71- else:
72- print("I'm gonna guess that it's a dip!")
73- obj = fetchDipper(base, line)
74- trail = obj.get("trail", "").strip()
75- if trail: print("Trail:", trail)
76- term = extractor.fullyExtract(obj["expr"])
77- print("Term:", sexpify(term))
73+ obj = dissolve(base, line)
74+ trail = obj.get("trail", "").strip()
75+ if trail: print("Trail:", trail)
76+ term = extractor.fullyExtract(obj["index"])
77+ print("Term:", sexpify(term))
7878
7979 def installCompletion(dippers):
8080 readline.parse_and_bind("tab: complete")
@@ -82,7 +82,7 @@ def installCompletion(dippers):
8282 readline.set_completer_delims("() ")
8383
8484 if __name__ == "__main__":
85- base = sys.argv[-1]
85+ base = sys.argv[1]
8686 dippers = fetchDippers(base)
8787 installCompletion(dippers)
8888 repl(base)
--- a/todo.txt
+++ b/todo.txt
@@ -40,10 +40,6 @@
4040 * Perhaps generate monad instances automatically?
4141 * Basic enums, for better sum types
4242 * Haskell-style ADTs are basically polynomial functors
43-* REPL improvements
44- * : commands
45- * help, describe commands
46- * edit an atom's trail
4743 * The case for trees
4844 * data Tree a = Leaf | Branch a (Tree a) (Tree a)
4945 * well-founded whenever lists are well-founded
@@ -96,8 +92,6 @@
9692 * Special case of reader monad
9793 * Distributive law: [N, X] + 1 → [N, X + 1]
9894 * Creates a stream+maybe monad: X → [N, X + 1]
99-* Subtypes?
100- * Interval type?
10195 * Moore machines: For state type Q and input type S, Q × S -> Q
10296 * Suppose we have output/observation type O and Q -> O
10397 * Then Moore machines are equivalent to compact encodings [S] -> O
@@ -130,8 +124,6 @@
130124 * https://okmij.org/ftp/continuations/undelimited.html
131125 * It's about time to rewrite the multisampling logic in Cammy
132126 * Mostly just needs pixel radius to be passed to image
133-* Use Elliott's techniques to compile to a graph?
134- * And then display the graph!
135127 * Zippers http://strictlypositive.org/diff.pdf
136128 * Zipper for lists looks like existing FIFO code, just needs the helpers
137129 * Lenses?
@@ -375,6 +367,11 @@
375367 * Let's rewrite Honey with FastAPI!
376368 * And use PyPy!
377369 * But not right now!
370+* New REPL
371+ * Not sure if there's much need for commands
372+ * Making new dippers, maybe?
373+ * Realized that ":" is not the best command-starter
374+ * Technically ")" would be the best choice since it can't start a legal term
378375 * Slogans?
379376 * Cammy is compositional
380377 * Cammy is chimeric