Skip to content

Commit

Permalink
stitch: menu generation.
Browse files Browse the repository at this point in the history
Encountered another AsciiDoctor migration issue. The rules for
substitutions in passthrough blocks seem different. Instead of
trying to figure it out, we take advantage of AsciiDoctor's
concise markup for `id` and `class` attributes.

AsciiDoctor treats `xs ++ ys` differently to AsciiDoc, which
I worked aorund with by changing an example.

I've also lost syntax highlighting, but fixing this can wait.

Forgot to mention: as I was revamping the HTML anyway, I switched
the navbar arrows from Unicode 9664 and 9654 to 9204 and 9205
whose smaller size somehow caused the article heading to be
bumped to the right. I worked around it by padding the top of
the heading.
  • Loading branch information
blynn committed May 8, 2023
1 parent 0b1e428 commit cae3b9a
Show file tree
Hide file tree
Showing 19 changed files with 113 additions and 564 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ atp.c: atp.lhs precisely $(BCS_HS); (./unlit < atp.lhs && cat $(BCS_HS)) | ./pre

eq.js: eq.lhs ; -mv Main.jsmod /tmp; hastec --opt-all -Wall $^ && closure-compiler $@ > $@.clo && mv $@.clo $@

menu.html: menu; cobble menu menu
menu.html: menu; ./stitch menu menu

%.html: %.lhs menu.html; ./stitch book menu $<
%:%.c;clang -O3 $^ -o $@
Expand Down
2 changes: 0 additions & 2 deletions atp.lhs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
= Automated Theorem Proving =

[pass]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<p>
<button id='swap'>swap</button>
Expand Down Expand Up @@ -630,7 +629,6 @@ built, though has considerably more features.
https://arxiv.org/abs/1805.07518[Michael Shulman describes an intimate
connection between linear logic and constructive mathematics].

[pass]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<script>
function setup(name, t) {
Expand Down
39 changes: 4 additions & 35 deletions c.lhs
Original file line number Diff line number Diff line change
Expand Up @@ -55,46 +55,19 @@ our GC to carefully evacuate the whole stack.
It's unclear if these changes are worth the effort, especially since Haskell
code tends to avoid the IO monad as much as possible.

++++++++++
<script>
function hideshow(s) {
var x = document.getElementById(s);
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
</script>
<p><a onclick='hideshow("effectively");'>&#9654; Toggle `effectively.hs`.</a></p>
<div id='effectively' style='display:none'>
++++++++++

[#effectively.toggleshow]
------------------------------------------------------------------------
include::effectively.hs[]
------------------------------------------------------------------------

++++++++++
</div>
++++++++++

Rather than a bunch of numbers, our compiler generates C code that should be
appended to the following C implementation of the VM:

++++++++++
<p><a onclick='hideshow("rts");'>&#9654; Toggle RTS.</a></p>
<div id='rts'>
++++++++++

[source,c]
[.toggleshow,source,c,id=rts.c]
------------------------------------------------------------------------
include::rts.c[]
------------------------------------------------------------------------

++++++++++
</div>
++++++++++

We employ a stop-the-world copying garbage collector. It turns out we should
reduce projection functions (such as `fst` and `snd`) as we collect garbage.
See:
Expand Down Expand Up @@ -122,15 +95,11 @@ representing VM memory contents.

We also add support for `if` expressions and infix patterns in case expressions.

++++++++++
<p><a onclick='hideshow("lonely");'>&#9654; Toggle `lonely.hs`.</a></p>
<div id='lonely' style='display:none'>
++++++++++

[#lonely.toggleshow]
------------------------------------------------------------------------
include::lonely.hs[]
------------------------------------------------------------------------

++++++++++
</div>
include::toggleshow.js[]
++++++++++
1 change: 0 additions & 1 deletion chat.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
= ChatFP =

[pass]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<div style="display:none;" id="Map.hs">
include::inn/Map1.hs[]
Expand Down
23 changes: 0 additions & 23 deletions differ.lhs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
= Differential Lambda Calculus =

[pass]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<p>
<button id='example'>C to F</button>
Expand All @@ -22,21 +21,6 @@
How do we convert Celsius to Farenheit? For the sake of argument, suppose
we know to multiply by a constant `p` then add another constant `q`:

++++++++++
<script>
function hideshow(s) {
var x = document.getElementById(s);
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
</script>
<p><a onclick='hideshow("boilerplate");'>&#9654; Toggle boilerplate</a></p>
<div id='boilerplate' style='display:none'>
++++++++++

\begin{code}
module Main where
import Base
Expand All @@ -48,13 +32,7 @@ import Text.Megaparsec
import Text.Megaparsec.Char
type Charser = Parsec () String
-}
\end{code}
++++++++++
</div>
++++++++++

\begin{code}
type R = Double
convert:: R -> R -> R -> R
convert p q x = p * x + q
Expand Down Expand Up @@ -574,7 +552,6 @@ Automated theorem proving profits from turning this trick on its head. Early
theorem provers exhaustively tried every possible value for every variable.
Later provers improved on this by by computing with variables instead.

[pass]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<script>
function setup(name, t) {
Expand Down
2 changes: 0 additions & 2 deletions doh.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Then:

+++<pre id='line1'>take 100 primes</pre>+++

[pass]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<style type="text/css">
.term {
Expand Down Expand Up @@ -36,7 +35,6 @@ Then:

+++<pre id='line3'>fibs !! (fibs !! 11)</pre>+++

[pass]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<script src="/~blynn/termlib.js"></script>
<script defer>
Expand Down
1 change: 0 additions & 1 deletion eq.lhs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
= Fighting for Equality =

[pass]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<script src='eq.js'></script>
Demos:
Expand Down
64 changes: 11 additions & 53 deletions grind.lhs
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,23 @@ We must also prepare for an link:miranda.html[an upcoming boss battle].

Algorithm 4.1 of Kiselyov's paper; strings and character constants.

++++++++++
<script>
function hideshow(s) {
var x = document.getElementById(s);
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
</script>
<p><a onclick='hideshow("stringy");'>&#9654; Toggle Source</a></p>
<div id='stringy' style='display:none'>
++++++++++

[#stringy.toggleshow]
---------
include::stringy[]
---------

++++++++++
</div>
++++++++++

== Binary ==

Lists; binary operators on the right-hand side.

We can now write `xs ++ ys` in expressions, though the function itself must be
defined with `(++) xs ys = ...`.

++++++++++
<p><a onclick='hideshow("binary");'>&#9654; Toggle Source</a></p>
<div id='binary' style='display:none'>
++++++++++
We can now write `xs <> ys` in expressions, though the function itself must be
defined with `(<>) xs ys = ...`.

[#binary.toggleshow]
---------
include::binary[]
---------

++++++++++
</div>
++++++++++

== Algebraically ==

Algebraic data types, sections, case expressions, recursive definitions, but
Expand All @@ -68,19 +42,11 @@ copy the address of each alternative to the stack, only to eventually eliminate
all but one. Furthermore, we copy and delete these addresses by evaluating
intricate sequences of B and K combinators.

++++++++++
<p><a onclick='hideshow("algebraically");'>&#9654; Toggle Source</a></p>
<div id='algebraically' style='display:none'>
++++++++++

[#algebraically.toggleshow]
---------
include::algebraically[]
---------

++++++++++
</div>
++++++++++

== Parity ==

Achievement unlocked. GHC accepts our next compiler if we insert the following
Expand Down Expand Up @@ -116,29 +82,21 @@ This compiler supports integer constants. We've survived without them for
so long because the `succ` function has been enough for our numerical needs
so far.

++++++++++
<p><a onclick='hideshow("parity");'>&#9654; Toggle Source</a></p>
<div id='parity' style='display:none'>
++++++++++

[#parity.toggleshow]
---------
include::parity.hs[]
---------

++++++++++
</div>
++++++++++

== Fixity ==

This compiler supports `infix, infixl, infixr` declarations at the beginning of
the source.

++++++++++
<p><a onclick='hideshow("fixity");'>&#9654; Toggle Source</a></p>
<div id='fixity' style='display:none'>
++++++++++

[#fixity.toggleshow]
---------
include::fixity.hs[]
---------

++++++++++
include::toggleshow.js[]
++++++++++
1 change: 0 additions & 1 deletion index.lhs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

link:ioccc.html[An award-winning Haskell compiler], browser edition.

[pass]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<textarea id='mod_base' hidden>
include::inn/BasePrecisely.hs[]
Expand Down
21 changes: 0 additions & 21 deletions lambda.lhs
Original file line number Diff line number Diff line change
Expand Up @@ -79,31 +79,10 @@ calculus]). For our purposes, a closed lambda term is merely notation for a
_combinatory logic_ term, which is a full binary tree whose leaves can be one
of 6 different values:

++++++++++
<script>
function hideshow(s) {
var x = document.getElementById(s);
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
</script>
<p><a onclick='hideshow("ugh");'>&#9654; Toggle extensions and imports</a></p>
<div id='ugh' style='display:none'>
++++++++++

\begin{code}
{-# LANGUAGE FlexibleContexts #-}
import Control.Monad.State
\end{code}
++++++++++
</div>
++++++++++

\begin{code}
data Com = S | K | I | B | C | T
\end{code}

Expand Down
Loading

0 comments on commit cae3b9a

Please sign in to comment.