uip | title | description | author | status | type | category | created |
---|---|---|---|---|---|---|---|
0129 |
Typed Paths with $coin Extensions |
Add %blob and %many to typed paths |
~rovnys-ricfer |
Draft |
Standards Track |
Hoon |
2024-07-25 |
Hoon's original path
data structure has syntax and parsing that allows each
element to be a $coin
data structure: either a typical string-encoded scalar
value, a %many
string-encoded list of values or a %blob
string-encoded
"jammed" (serialized) arbitrary noun. These features are useful for encoding
more complex data structures in paths in a standardized and somewhat
human-readable manner.
The latest conception of a path in Hoon -- a so-called "typed path", called a
$pith
in the standard library and introducible using provisional #/foo/bar
syntax -- lacks these extra encodings, limiting its expressiveness. This
proposal adds the $coin
encodings back into typed paths to reclaim the lost
expressivity while retaining the performance and legibility improvements of
typed paths.
This is a type definition for a typed path
with %many
and %blob
extensions. Description follows. This does not include parsing or serialization functions.
|%
+$ path (list zeta)
+$ zeta
$~ [%n ~]
$@ @tas
$% [%many p=(list zeta)]
[%blob p=*]
[%ub @ub] [%uc @uc] [%ud @ud] [%ui @ui]
[%ux @ux] [%uv @uv] [%uw @uw]
[%sb @sb] [%sc @sc] [%sd @sd] [%si @si]
[%sx @sx] [%sv @sv] [%sw @sw]
[%da @da] [%dr @dr]
[%f ?] [%n ~]
[%if @if] [%is @is]
[%t @t] [%ta @ta] :: @tas
[%p @p] [%q @q]
[%rs @rs] [%rd @rd] [%rh @rh] [%rq @rq]
==
--
A path
is a list of zeta
elements. Each zeta
can either be a @tas
, a
%many
list of elements, a %blob
arbitrary noun, or a cell of an atom aura
and value, for any aura that is understood natively by the Hoon language.
:: Just like today's typed paths, this typed path
::
#/foo/3/0x4/~2024.7.25
::
:: parses to
::
~[%foo [%ud 3] [%ux 0x4] [%da ~2024.7.25]]
::
:: This typed path takes advantage of the new %blob and %many features:
::
#/baz/~05iggq1/._foo_~~d1_.~-bar~-~-__
::
:: It parses to
::
~[%baz [%blob [33 44]] [%many ~[%foo [%dr ~d1] %many ~[%bar]]]]
Note that %many
elements can contain other %many
elements recursively,
allowing for arbitrary tree shapes of encoded path elements. This example's
final %bar
is doubly coin-encoded due to being inside two nested %many
elements. %blob
elements can also be nested inside %many
elements.
I think this new typed path should replace the existing typed path, since it just adds capability -- any typed paths in the existing system, as parsed data structures or strings, should still work.
Once these new typed paths have been demonstrated more thoroughly, the
provisional #/
syntax could be replaced by some kind of permanent syntax,
possibly replacing the original /
path syntax.
I am not aware of any security considerations to speak of. These paths would be
safer if atom sanity was enforced during ;;
, as proposed in the Aura
Renovation UIP, but that is just as true for existing typed paths.
Copyright and related rights waived via CC0.