~( ) sigpal
+$ lusbuc
produce a type definition / structure arm
=c |%
+$ atom-pair $:(@ @)
+$ flag-atom $:(? @)
--
$% buccen
tagged union by head atom
$% [%head-1 @d]
[%head-2 @dr @ud]
$+ buclus
shorthand type name for pretty-printer.
$+ some-alias-to-display
a-type-itself
$? bucwut
type union. for example, only unsigned aura types:
$? [@ud @ux @ub ~]
Very useful for matching only a set of @tas flags (see below).
irregular: ?(@ud @ux @ub) , ?(%red %green %blue)
/- fashep
Import structure libraries from /sur. Paths will be hepped (/sur/foo/abc.hoon == foo-abc). can be given a face xyz=foo or face stripped for direct access *foo
/+ faslus
import library file from /lib.
+* lustar
“Deferred expressions” within doors - that is, its evaluated when the name is dereferrenced. basically an alias or macro.
?- wuthep
Switch against a union. no default.
Conditional expression where type is used to determine which branch is taken.
?+ wutlus
Switch against a union with a default. (see ?- wuthep)
?= wuttis
check equality of two things.
?> wutgar
Positive assertion - used to force a crash when the first argument isn’t true.
Used with ?= wuttis to specify type of a value - type inference.
:- colhep
construct a cell (a 2-tuple).
:_ colcab
Construct a cell, inverted.
:~ colsig
Construct a null-terminated list.
:* coltar
Construct an n-tuple.
:+ collus
construct a triple/3-tuple.
|= bartis
Produce a gate - a one-armed core with a sample. a Hoon function. a “dry gate”. (A gate is a core with one arm named $ - so you can recurse with $()).
A gate is a door with only one arm - $.
|_ barcab
Produce a door - a core with a sample. one fixed argument, then a variable number of +-expressions. A general case of a gate/function (whereas a gate has only one arm, $, a door has as many arms as you define.)
|_ arg=@type
++ add-one (add arg 1)
:: arm name
:: expression that defines arm product
++ sub-one (sub arg 1)
--
|% barcen
Core builder.
++ defines arms. +$ defines types
|* bartar
produce a one-armed core with a sample (aka “[[wet-gate|wet gate]]❌”)
|$ barbuc
declares a mold builder wet gate with one or more molds as sample. (because it’s a wet gate, the types of the molds-as-samples passed in will be preserved)
|^ barket
Produce a core whose battery includes a $ arm and immediately compute the $ arm.
Used when defining a multi-armed core and a particular arm should be evaluated/called immediately.
%= centis
Resolve a wing with changes - using used to change the subject . (this is what $() resolves to)
?: wutcol
Branch on a boolan (normal “if”)
?. wutdot
Reversed wutcol
?~ wutsig
Branch on whether a wing of the subject is null. use for true nulls ~ only.
%~ censig
Evaluate an arm in a door, three arguments %~(p q r): p - wing that resolves to an arm in door q q - door itself c - sample for the door
%~(arm door sample)
(in the irregular ~(p q r1 r2 rn), r may be multiple parts, which will be formed into a cell.)
%- cenhep
Call a gate/function with its sample. (evaluates the $ arm of a gate.) %- gate sample
%. cendot
call a gate, inverted. just like %-, but reversed - argument/sample first, then gate. %. sample gate
%+ cenlus
Call a gate with a cell sample.
=+ tislus
Combine a new noun with the subject. that is, “declare a variable”, “pin a value to the head of the subject”.
=- tishep
inverse order of tislus. combine a new noun with the subject (inverted). since this is pinned to - in the subject (pre-pended to the tree), it can be accessed at - here:
%initial
=- (frond initial+a/-) :: =- pins the following to the subject and then
:: access is at the hep at the end of
:: the line
%+ turn seen.update
|= saw=saw:said :: extract to library?
%- pairs
:~ saw-id+s/(scot %uv id.saw)
url+s/(scot %t url.saw)
==
=^ tisket
pin the head of a pair, change a leg with the tail. 4 arguments.
=^ p q
r
s-
p- new name to pin to subject -
q- name of existing wing of subject -
r- expression that produces[p-value new-q-value] -
s- more hoon to run against newly-modified subject
=, tiscom
Expose namespace. in =, p q, from within q, we can access p’s b.p name as just b.
Often used with:
=, dejs:format
:: now we can access `so` rather than `so:dejs:format`
=| tisbar
pin a bunted value to the head.
=| a=@ud a
:: 0
=* tistar
Deferred expression. Gives a name to an expression which will be evaluated each place the name is called/dereferenced.
=/ tisfas
“define a variable” / combine a named noun with the subject. maybe with type annotation.
=/ a=@t 'hello' with type =/ a [1 2 3] without type
=? tiswut
conditionally change one leg in the subject =?(p q r s)
Replace value of leg p with r on condition q. “Change P (if Q) to R”
*^ tarket