• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-cqtcocoa誰得pythonphprubygameguibathyscaphec翻訳計画中(planning stage)omegatframeworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

A categorical programming language


Commit MetaInfo

修订版21782876c22e894e34939d075ca8e01ba655d28b (tree)
时间2022-03-17 14:10:00
作者Corbin <cds@corb...>
CommiterCorbin

Log Message

Write out some basic docs for the hive.

更改概述

差异

--- a/cammy-rpy/draw.nix
+++ b/cammy-rpy/draw.nix
@@ -1,4 +1,4 @@
11 let
22 makeBuilder = import ./builder.nix;
33 in
4- makeBuilder ./draw.py "cammy-draw" false # true
4+ makeBuilder ./draw.py "cammy-draw" true
--- a/cammy-rpy/weave.py
+++ b/cammy-rpy/weave.py
@@ -48,6 +48,14 @@ def main(argv):
4848 section = dirpath[prefix:] or "Top level"
4949 doc.append("# " + section)
5050
51+ # Optionally include section-specific information if present.
52+ aboutpath = os.path.join(dirpath, "about.md")
53+ try:
54+ with open(aboutpath, "r") as handle:
55+ doc.append(handle.read())
56+ except IOError:
57+ doc.append("(Undocumented section)")
58+
5159 for filename in filenames:
5260 if not filename.endswith(".cammy"):
5361 continue
--- /dev/null
+++ b/hive/about.md
@@ -0,0 +1,3 @@
1+This hive provides some basic tools for approximating and visualizing
2+functions on real numbers. It includes a demonstration renderer for iterated
3+fractal systems.
--- /dev/null
+++ b/hive/baire/about.md
@@ -0,0 +1,2 @@
1+The exponential type $\mathbb{N}^\mathbb{N}$ can be interpreted as [Baire
2+space](https://en.wikipedia.org/wiki/Baire_space_(set_theory)).
--- /dev/null
+++ b/hive/bool/about.md
@@ -0,0 +1 @@
1+The Boolean type $2$ contains exactly two elements.
--- /dev/null
+++ b/hive/comonads/product/about.md
@@ -0,0 +1 @@
1+The product comonad is a comonad.
--- /dev/null
+++ b/hive/comonads/store/about.md
@@ -0,0 +1 @@
1+The [store comonad](https://ncatlab.org/nlab/show/store+comonad) is a comonad.
--- /dev/null
+++ b/hive/demo/about.md
@@ -0,0 +1 @@
1+These Cammy expressions are included for demonstration purposes.
--- /dev/null
+++ b/hive/double/about.md
@@ -0,0 +1 @@
1+The double type $X + X$ is isomorphic to the Boolen tag type $X \times 2$.
--- /dev/null
+++ b/hive/f/about.md
@@ -0,0 +1,3 @@
1+The numeric type $F$ is a type of double-precision [IEEE
2+754](https://en.wikipedia.org/wiki/IEEE_754) floating-point numbers. Only
3+numbers are included; no elements of $F$ are not numbers.
--- /dev/null
+++ b/hive/fun/about.md
@@ -0,0 +1,2 @@
1+The function types ${Y}^{X}$ are the primary building blocks of Cammy
2+expressions.
--- /dev/null
+++ b/hive/int/about.md
@@ -0,0 +1,6 @@
1+The type $N + N$ can be interpreted as the type of integers. Specifically, the
2+left-hand components are positive integers, the right-hand components are
3+negative integers, and zero can be represented as either left-hand zero or
4+right-hand zero. Under the equivalence with the type $N \times 2$, the
5+representation can be viewed as a natural number with a [sign
6+bit](https://en.wikipedia.org/wiki/Sign_bit).
--- /dev/null
+++ b/hive/list/about.md
@@ -0,0 +1 @@
1+The list type $[X]$ is the free monoid over $X$.
--- /dev/null
+++ b/hive/list/horner.cammy
@@ -0,0 +1,11 @@
1+(comp
2+ (pair/mapfst list/reverse)
3+ (uncurry (fold
4+ (fun/name (fun/const zero))
5+ (curry (comp
6+ (pair (pair (comp fst fst) (fun/apppair (comp fst snd) snd)) snd)
7+ (pair/of nat/add
8+ (pair/of nat/mul (comp fst snd) snd)
9+ (comp fst fst)))))))
10+
11+Evaluate a polynomial at an input coordinate using Horner's rule.
--- /dev/null
+++ b/hive/mat2/about.md
@@ -0,0 +1,2 @@
1+The type $(X \times X) \times (X \times X)$ can be interpreted as a two-by-two
2+matrix over $X$.
--- a/hive/mat2/mul.cammy
+++ b/hive/mat2/mul.cammy
@@ -1,7 +1,3 @@
1-(comp
2- (fun/tensor id mat2/trans)
3- (pair
4- (mat2/vecpair fst (comp snd fst))
5- (mat2/vecpair fst (comp snd snd))))
1+(comp (fun/tensor id mat2/trans) (pair (mat2/vecpair fst (comp snd fst)) (mat2/vecpair fst (comp snd snd))))
62
73 Multiply two matrices.
--- /dev/null
+++ b/hive/monads/cont/about.md
@@ -0,0 +1,9 @@
1+A [continuation monad](https://ncatlab.org/nlab/show/continuation+monad) is a
2+codensity monad. The typical continuation monad arises from the
3+double-negation endofunctor
4+
5+$$
6+D : X \mapsto {R}^{{R}^{X}}
7+$$
8+
9+for some continuation type $R$.
--- /dev/null
+++ b/hive/monads/either/about.md
@@ -0,0 +1 @@
1+The either monad is a monad.
--- /dev/null
+++ b/hive/monads/maybe/about.md
@@ -0,0 +1,6 @@
1+The [maybe monad](https://ncatlab.org/nlab/show/maybe+monad) is the monad
2+carried by the endofunctor
3+
4+$$
5+M : X \mapsto X + 1
6+$$
--- /dev/null
+++ b/hive/monads/reader/about.md
@@ -0,0 +1 @@
1+The [reader monad](https://ncatlab.org/nlab/show/function+monad) is a monad.
--- /dev/null
+++ b/hive/monads/state/about.md
@@ -0,0 +1 @@
1+The [state monad](https://ncatlab.org/nlab/show/state+monad) is a monad.
--- /dev/null
+++ b/hive/nat/about.md
@@ -0,0 +1 @@
1+The elements of the type $\mathbb{N}$ are natural numbers.
--- /dev/null
+++ b/hive/nonempty/about.md
@@ -0,0 +1,2 @@
1+The type $X \times [X]$ can be interpreted as a type of nonempty lists of
2+$X$. The first component is the head of the list.
--- /dev/null
+++ b/hive/nonempty/to-list.cammy
@@ -0,0 +1,3 @@
1+cons
2+
3+A nonempty list is a list.
--- /dev/null
+++ b/hive/pair/about.md
@@ -0,0 +1,15 @@
1+The pair type $X \times Y$ is ubiquitous when programming with
2+Cartesian closed categories. Common uses for pairs include:
3+
4+* Passing multiple arguments to arrows
5+* Pairing a state with a projection or observation
6+* Placing a value to the side while performing an intermediate transformation
7+* Performing multiple transformations in parallel
8+
9+Pairs naturally form a comonad, the product comonad, carried by the endofunctor
10+
11+$$
12+P : X \mapsto X \times A
13+$$
14+
15+for some fixed type of observations $A$.
--- /dev/null
+++ b/hive/scott/about.md
@@ -0,0 +1,4 @@
1+The [Scott
2+encoding](https://en.wikipedia.org/wiki/Mogensen%E2%80%93Scott_encoding) of
3+an algebraic data type represents it as a set of arguments in a first-order
4+type signature.
--- /dev/null
+++ b/hive/scott/bool/about.md
@@ -0,0 +1,2 @@
1+The Scott encoding for Booleans is the same as the [Church encoding for
2+Booleans](https://en.wikipedia.org/wiki/Church_encoding#Church_Booleans).
--- a/hive/scott/list/cons.cammy
+++ /dev/null
@@ -1,5 +0,0 @@
1-(curry (curry (curry
2- (comp (pair
3- (comp (pair snd (comp (comp fst fst) fst)) fun/app)
4- (comp fst snd))
5- fun/app))))
--- a/hive/scott/list/nil.cammy
+++ /dev/null
@@ -1 +0,0 @@
1-(curry fst)
--- a/hive/scott/nat/pred.cammy
+++ /dev/null
@@ -1,2 +0,0 @@
1-(comp (pair (comp (pair (fun/const (fun/name scott/nat/zero)) id) fun/app)
2- (fun/name id)) fun/app)
--- a/hive/scott/nat/succ.cammy
+++ /dev/null
@@ -1 +0,0 @@
1-(curry (curry (comp (pair snd (comp fst fst)) fun/app)))
--- a/hive/scott/nat/zero.cammy
+++ /dev/null
@@ -1,3 +0,0 @@
1-(curry fst)
2-
3-The Scott-encoded version of zero.
--- /dev/null
+++ b/hive/sdf2/about.md
@@ -0,0 +1,5 @@
1+The arrow type $F \times F \to F$ can be interpreted as a type of functions
2+from points in the 2-dimensional Cartesian plane to distances. In particular,
3+it may be interpreted as a type of [signed distance
4+functions](https://en.wikipedia.org/wiki/Signed_distance_function) in the
5+Cartesian plane.
--- /dev/null
+++ b/hive/square/about.md
@@ -0,0 +1,8 @@
1+The square type $X ^ 2$ is isomorphic to the diagonal pair type $X \times X$.
2+The endofunctor
3+
4+$$
5+Sq : X \mapsto X^2
6+$$
7+
8+is a special case of the endofunctor which carries the reader monad.
--- /dev/null
+++ b/hive/subobj/about.md
@@ -0,0 +1,2 @@
1+The exponential type $2 ^ X$ can be interpreted as the type of subobjects of
2+$X$. However, $2$ is not a subobject classifier.
--- /dev/null
+++ b/hive/sum/about.md
@@ -0,0 +1 @@
1+The type $X + Y$ is a heterogenous sum type.
--- /dev/null
+++ b/hive/v2/about.md
@@ -0,0 +1,2 @@
1+The product type $X \times X$ can be interpreted as a 2-dimensional vector
2+space over $X$.
--- /dev/null
+++ b/hive/v3/about.md
@@ -0,0 +1,2 @@
1+The type $X \times ( X \times X )$ can be interpreted as a 3-dimensional
2+vector space over $X$.
--- a/todo.txt
+++ b/todo.txt
@@ -8,6 +8,8 @@
88 * list/zip : [X] × [Y] → [X × Y]
99 * list/tail : [X] → [X]
1010 * rat
11+ * Using binary quote notation?
12+ * Continued fractions?
1113 * refactoring from the bikeshed: ignore -> !
1214 * Might not be important since fun/const is the only user!
1315 * zero -> 0, f-zero -> f-0, f-one -> f-1 maybe?
@@ -30,10 +32,7 @@
3032 * Subtypes?
3133 * Interval type?
3234 * Cantor's type of bitstrings: N -> 2
33-* The square type: For a type X, 2 -> X
34- * Another special case of reader monad
35- * There's an equivalence X x X <-> [2, X]
36- * Done?
35+ * We have subobjects now, X -> 2
3736 * Moore machines: For state type Q and input type S, Q × S -> Q
3837 * Moore transducers: [Q × S, Q] -> [Q × S, Q]
3938 * Mealy machines: For state type Q, input type S, and output type L, Q × S -> Q × L
@@ -56,3 +55,4 @@
5655 * We now can iter-maybe, short-circuiting evaluation
5756 * We need to iter-maybe but also keep track of how many steps were taken
5857 * Instead of X -> [N, Y + 1], we need X -> [N, N x (Y + 1)]
58+* ulimit jellification?