@@ -46,4 +46,191 @@ whose number is its bottom half. So the planet `~firbyr-napbes`,
46or `48.879`, whose parent is `~mun`, `0xef`, `239`. The parent of
46or `48.879`, whose parent is `~mun`, `0xef`, `239`. The parent of
47`~mun` and all galaxies is `~zod`, `0`.
47`~mun` and all galaxies is `~zod`, `0`.
51+>Nock is a Turing-complete, non-lambda combinator function.
53+- `noun`: an `atom` or a `cell`
54+- `atom`: any natural number
55+- `cell`: any ordered pair of `noun`s
56+- `subject`: a `noun` - the argument against which a `formula` is evaluated
57+- `formula`: a `noun` - any of the Hoon formula numbers (0-10), followed by *(TODO: ?)*
58+- `product`: a `noun` - the result of evaluating a `formula` against a `subject`
60+*See [Nock definition](../../nock/definition/)*
64+>Hoon is a strict, higher-order typed functional language which compiles itself to Nock.
66+###### `span`: an inferred type
68+A `span` defines a set (finite or infinite) of `noun`s and ascribes some semantics to it. There is no Hoon syntax for a `span`; it is always produced as the inferred range of an expression (`twig`).
70+*See [basic types](../basic)*
72+###### `mold`: a type constructor / validator
74+A mold is an idempotent `gate` (function), accepting any `noun` and normalizing it to a range.
76+- `icon`: the `span` of a `mold`
77+- `bunt`: *(TODO: ??)*
79+*See [`mold`](../twig/buc-mold/)*
81+###### `gate`: a function, lambda or closure
83+*TODO: simplify description*
85+A `gate` is a specialized `core` with only one arm (whose name is the empty string (the symbol `$`). To call a `gate` on an argument, replace the `sample` (at tree address `6` in the `core`) with the argument, and then compute the `arm`.
87+The `payload` of a `gate` has a shape of `{sample context}`.
89+- `sample`: the argument *(TODO: or plural?)* of a `gate`
90+- `context`: the subject in *(TODO: against?)* which a `gate` was defined
92+*See [basic types](../basic)*
94+###### `arm`: a named, functionally-computed attribute of a `core`
96+The `twig` of each `arm` is compiled to a Nock formula, with the enclosing `core` itself as the subject.
98+*See [basic types](../basic)*
100+###### `core`: a code-data `cell`
102+The code (`battery`) is the head, the data (`payload`) is the tail. All code-data structures in normal languages (functions, objects, modules, etc) become `core`s in Hoon.
104+- `battery`: the code of a `core`, a tree of `arm`s
105+- `payload`: the data in a `core`
107+`core`s are *polymorphic* structures; every function call (`gate`) in Hoon replaces the `payload` of a `core` with a different `noun`, and then invokes an `arm` from the `battery`.
109+- `wet`: polymorphic by means of *genericity*
113+>When we call a `wet` `arm`, we're essentially using the `twig` as a macro. We are not generating new code for every call site; we are creating a new type analysis path, which works as if we expanded the callee with the caller's context.
115+- `dry`: polymorphic by means of *variance*
117+For a `dry` `arm`, we ask, is the new `payload` compatible with the old `payload` (against which the `core` was compiled)?
119+Every `dry` `core` has a `metal` *(TODO: check)* which defines its *variance* model (ie, the properties of the `span` of a compatible `core`).
121+*TODO: is the core dry, the arm dry, or both?*
123+- `gold`: *invariant*
124+- `lead`: *bivariant*
125+- `zync`: *covariant*
126+- `iron`: *contravariant*
128+*See [advanced types](../advanced)*
130+###### `foot`: a `wet` or `dry` `twig`
132+*TODO: any `twig`, or always an `arm` within a `battery`?*
136+A Hoon `atom` is a Nock `atom`, with two additional pieces of metadata (TODO: ?): an `aura`, and a `unit`.
138+- `unit`: a nullable pointer (TODO: ?), or a Maybe
140+`atom`s are said to be `warm` or `cold` based on their `unit`
142+- `warm`: if the `unit` is `~` (null), any `atom` is in the `span`
143+- `cold`: if the `unit` is `[~ x]`, where `x` is any `atom`, its only legal value is the constant `x`. *(TODO: what does this actually mean? What is the consequence of illegality?)*
145+###### `aura`: a soft `atom` type
147+*alternately **odor***
149+*TODO: write a short summary*
151+*TODO: are `aura`s always `mold`s? just the built-in `aura`s?*
153+>Auras are a lightweight, advisory representation of the units, semantics, and/or syntax of an `atom`. An `aura` is an atomic string; two auras are compatible if one is a prefix of the other.
155+>For instance, @t means UTF-8 text (LSB low), @ta means ASCII text, and @tas means an ASCII symbol. @u means an unsigned integer, @ud an unsigned decimal, @ux an unsigned hexadecimal. You can use a @ud atom as a @u or vice versa, but not as a @tas.
157+>Auras are truly soft; you can turn any `aura` into any other, statically, by casting through the empty `aura` `@`. Hoon is not dependently typed and can't statically enforce data constraints (for example, it can't enforce that a `@tas` is really a symbol).
159+- `term` (`@tas`): a symbol - an atomic ASCII string which obeys symbol rules: lowercase and digit only, infix hyphen ("worm-case"), first character must be lowercase *(TODO: alphabetic?)*.
161+- `cord` (`@t`): UTF-8 text, least-significant-byte first
163+- `char` (`@tD`): a character, a single unicode byte (for multi-byte characters and codepoints, see `@c`)
165+- `tape` (`(list char)`): a `tape` is not an `aura`, but a `mold` for a collection where every item has an `aura` of `char` *(TODO: is this for easy indexing vs `@t`?)*
167+*See [basic types](../basic)*
169+###### `loobean`: a Hoon boolean
171+`0` (`%.y`) is *true*, `1` (`%.n`) is *false*.
173+>Why? It's fresh, it's different, it's new. And it's annoying. And it keeps you on your toes. And it's also just intuitively right.
175+###### `twig`: a Hoon expression
177+A `twig` is the name for any Hoon expression, and for the AST node representing the expression as compiled to Nock formula *(TODO: seems to be used interchangeably in the docs)*. It is a `book` with the form `{stem bulb}`.
179+- `book`: a tagged-union
180+- `page`: an item in a `book`
181+- `stem`: an atomic symbol (`@tas`) - uniquely identifies a `twig` *(TODO: ?)*
182+- `bulb`: The `bulb` for each `stem` has its own type, usually a tuple, sometimes a list or a map.
184+A `twig` is either a `moss` ("mossy") or a `seed` ("woody"):
186+- `moss`: a `twig` whose `product` is used a `mold`
187+- `seed`: a `twig` whose `product` could by anything
189+The vast majority of `twig`s have a *regular form*, beginning with either a keyword `sigil` or a digraph `rune`. Some `twig`s also have a syntactic *irregular form*, a handful have only an *irregular form*.
191+- `sigil`: a keyword used to begin a `twig`
193+Hoon does not have reserved words, but `sigil`s (prefixed with `:`), which are effectively aliases for `rune`s. For example, [`:cons` is `:-`](../twig/col-cel/hep-cons).
195+- `rune`: a pair of ASCII symbols used to begin a `twig` - the first symbol represents a family of related `twig`s. For example, the [`:` family](../twig/col-cell/) are all for cell-construction.
197+*See [`twig` concept](../concepts) and [expressions](../twig/)*
199+###### `limb`: attribute or variable reference
201+To resolve a `limb` named "foo", the `subject` is searched depth-first, head-first for either a `face` named "foo" or a `core` with an `arm` of "foo". If a `face` is found, the result is a `leg`, if a `core` is found, the result is the `product` of the `arm`.
203+- `leg`: a subexpression, or subtree of the `subject`. usually another `twig`, sometimes a symbol (`@tas`) or `wing`
204+- `wing`: a list of `limb`s
206+*See [Limbs and wings](../twig/limb)*
208+###### `face`: a named variable
210+Hoon has no scope or symbol-table; there is only the `subject`. To "declare" a "variable" is to construct a new `subject`: `[variable old-subject]`.
212+A `face` is a `span` *(TODO: ?)* with a label (`@tas`) wrapped around it.
214+- `taco`: a `symbol` (for a *type-inferred* `face`), or a `symbol` *with* a `mold` (for a *type-checked* `face`)
218+- `tune`: advanced `face`s:
219+ - `alias`: a `face` that is a lazy reference to another `face`
220+ - `bridge`: a `face` that references a `twig`, against which the `face` label is resolved
222+*See [advanced types](../advanced)*
224+###### `nest`: a type-casting operation
230+>Arvo is a nonpreemptive OS kernel, a single-threaded event interpreter.