Priors
Currently there is a lack of convention around naming, Gall agent structure, how to organize files, etc. Since Hoon is also highly irregular, this is a big roadblock to understanding other developers’ code. This is my initial take at consistent Hoon style, and will be updated over time.
Avoid means do not use.
If a rune is not mentioned, the expectation is that it will be used very rarely.
=/) for creating variables.
=+) and tishep (=-).=.) to modify existing variables.
=?) and tiscol (=:).=^), tistar (=*), and tismic (=,) are useful in specific areas.|=), barcab (|_), and barcen (|%).$:) in structure mode in either wide or tall form based on line width.$%) in tall form, bucwut ($?) in wide form. Example:+$ kv-update
$% [%set =key =value]
[%get value=?(~ json-value)]
[%allow write=?(%yes %no) admin=?(%yes %no)]
==
%~) in irregular form for calling doors i.e. (~(put by map) 'key' 'value')%-) and centis (%=) can be used in wide or tall form based on line width.%.) and cenlus (%+) should be used rarely.%_), cencol (%:), cenket (%^), and centar (%*).:-), colcab (:_), coltar (:*), and colsig (:~).:+) and colket (:^); use coltar (:*) instead..^) to scry..+) and dottis (.=) in irregular forms +(a) and =(a b) respectively./-) and faslus (/+) for sur and lib imports respectively.^-) casts liberally, in wide and irregular form like `@ud`~zod.^+) in tall form.^*) in irregular form *a.~&) and sigbar (~|).?>) and wutgal (?<) (assertions). Instead, provide an error message alongside the crash:?. =(our.bol src.bol) ~|(%no-foreign-init/act !!)
!>) and zapgal (!<) for vases.!!) to crash, including an error message.:: good
?+ pol ~|(bad-watch-path/pol !!)
[%kv ship=@ space=@ app=@ bucket=@ rest=*]
=/ ship `@p`(slav %p ship.pol)
...
==
:: bad
?+ pax ~|(bad-watch-path/pax !!)
[%kv @ @ @ @ *]
=/ ship `@p`(slav %p i.t.t.t.pax)
...
==
sur/
├─ spaces.hoon
or
sur/
├─ spaces/
├─ path.hoon
├─ store.hoon
+$ tome-action
...
+$ tome-update
...
mar/
├─ tome/
├─ action.hoon
├─ update.hoon
or
mar/
├─ tome/
├─ tome/
├─ action.hoon
├─ update.hoon
├─ kv/
├─ action.hoon
├─ update.hoon
├─ feed/
├─ action.hoon
├─ update.hoon
:: tome/action.hoon
/- *tome
/+ *tome-json
|_ act=tome-action
++ grow
|%
++ noun act
--
::
++ grab
|%
++ noun tome-action
++ json tome-action:dejs
--
++ grad %noun
::
--
:: tome/update.hoon
/- *tome
/+ *tome-json
|_ upd=tome-update
++ grow
|%
++ noun upd
++ json (tome-update:enjs upd)
--
::
++ grab
|%
++ noun tome-update
--
::
++ grad %noun
::
--
lib/
├─ tome/
├─ json.hoon
/- *tome
|%
++ dejs =, dejs:format
|%
++ tome-action
|= jon=json
^- ^tome-action
%. jon
%- of
:~ init-tome/(ot ~[ship/so space/so app/so])
init-kv/(ot ~[ship/so space/so app/so bucket/so])
init-feed/(ot ~[ship/so space/so app/so bucket/so log/bo])
==
::
--
::
++ enjs =, enjs:format
|%
++ kv-update
|= upd=^kv-update
^- json
?- -.upd
%set (frond key.upd s+value.upd)
%remove (frond key.upd ~)
%get value.upd
%all o+data.upd
==
::
--
::
--
Refer to the tome-db code for a full reference.
Inspired by Google’s Python style guide.