• 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

Revision140ee01ceba8e0b4ba86adf7f88b9e4fc9719c2f (tree)
Zeit2022-10-23 00:23:18
AutorCorbin <cds@corb...>
CommiterCorbin

Log Message

Don't render empty trails.

Saves a bit of screen space.

Ändern Zusammenfassung

Diff

--- a/honey/cammy.purs
+++ b/honey/cammy.purs
@@ -98,11 +98,12 @@ foreign import intSub :: Int -> Int -> Int
9898
9999 pr :: forall t. (Unit -> Tramp t) -> (t -> Tramp t) -> Int -> Tramp t
100100 pr x _ 0 = x Unit
101-pr x f n = bind f (pr x f (intSub n 1))
101+pr x f n = bind f (cont (\_ -> pr x f (intSub n 1)))
102102
103103 foreign import arrayHead :: forall t. Array t -> t
104104 foreign import arrayTail :: forall t. Array t -> Array t
105105
106106 fold :: forall s t. (Unit -> Tramp t) -> (Pair t s -> Tramp t) -> Array s -> Tramp t
107107 fold x _ [] = x Unit
108-fold x f c = bind (\t -> f (Pair t (arrayHead c))) (fold x f (arrayTail c))
108+fold x f c = bind (\t -> f (Pair t (arrayHead c)))
109+ (cont (\_ -> (fold x f (arrayTail c))))
--- a/honey/static/honey.js
+++ b/honey/static/honey.js
@@ -171,13 +171,15 @@ function drawFrame(canvas, sample, getChannels) {
171171 function tileForIndex(extractor, index, title, trail) {
172172 const div = document.createElement("div");
173173 div.setAttribute("class", "tile");
174- div.innerHTML = `
175- <h3>${title}</h3>
176- <details>
177- <summary>Trail</summary>
178- <p>${trail}</p>
179- </details>
180- `;
174+ div.innerHTML = `<h3>${title}</h3>`;
175+ if (trail) {
176+ div.innerHTML += `
177+ <details>
178+ <summary>Trail</summary>
179+ <p>${trail}</p>
180+ </details>
181+ `;
182+ }
181183 const typeInfo = document.createElement("p");
182184 typeInfo.innerHTML = "Loading type information...";
183185 div.appendChild(typeInfo);
@@ -253,7 +255,7 @@ function tileForIndex(extractor, index, title, trail) {
253255 function fetchDip(extractor, dip) {
254256 const url = "/dip/" + encodeURIComponent(dip);
255257 return fetchJSON(url).then(({expr, trail}) => {
256- return tileForIndex(extractor, expr, dip, trail);
258+ return tileForIndex(extractor, expr, dip, trail.trim());
257259 });
258260 }
259261
@@ -271,7 +273,7 @@ window.addEventListener("load", (_) => {
271273 document.getElementById("dissolve-form").addEventListener("submit", (e) => {
272274 console.log("making dissolve request");
273275 fetchJSON("/dissolve", { method: "POST", body: dissolveBox.value }).then(({expr, trail}) => {
274- const div = tileForIndex(extractor, expr, "Anonymous expression", trail);
276+ const div = tileForIndex(extractor, expr, "Anonymous expression", trail.trim());
275277 document.body.appendChild(div);
276278 });
277279 e.preventDefault();