mirror of
https://github.com/ilyakooo0/urbit.git
synced 2025-01-03 12:42:48 +03:00
Stylize layer one of hoon.hoon, make # work in most cases.
This commit is contained in:
parent
0313043caf
commit
b490c945c6
@ -671,7 +671,7 @@
|
||||
?: !=(i.t.topics u.p.p.q.i.tombs)
|
||||
:: this isn't the topic.
|
||||
$(tombs t.tombs)
|
||||
`[%chapter (trip i.t.topics) q.p.q.i.tombs p.sut q.sut p.i.tombs]
|
||||
`[%chapter (trip i.t.topics) q.p.q.i.tombs sut q.sut p.i.tombs]
|
||||
::
|
||||
{$face *}
|
||||
?. ?=(term q.p.sut)
|
||||
@ -909,7 +909,7 @@
|
||||
:> the computed arm documentation and the product documentation.
|
||||
^- {what what}
|
||||
=+ foot-span=(~(play ut sut) p.f)
|
||||
=+ raw-product=(what-from-span foot-span)
|
||||
=/ raw-product/what (what-from-span foot-span)
|
||||
=/ product-product/what
|
||||
?. ?=({$core *} foot-span)
|
||||
~
|
||||
@ -917,6 +917,8 @@
|
||||
(what-from-span inner-span)
|
||||
:-
|
||||
?~ arm-doc
|
||||
?~ raw-product
|
||||
product-product
|
||||
raw-product
|
||||
arm-doc
|
||||
?~ arm-doc
|
||||
|
165
sys/hoon.hoon
165
sys/hoon.hoon
@ -182,7 +182,7 @@
|
||||
:>
|
||||
:> a: minuend
|
||||
:> b: subtrahend
|
||||
|= {a/@ b/@}
|
||||
|= [a=@ b=@]
|
||||
~_ leaf+"subtract-underflow"
|
||||
:> difference
|
||||
^- @
|
||||
@ -193,9 +193,13 @@
|
||||
:>
|
||||
:> tree addressing
|
||||
+|
|
||||
++ cap :: fragment head
|
||||
++ cap
|
||||
~/ %cap
|
||||
|= a/@
|
||||
:> tree head
|
||||
:>
|
||||
:> tests whether an `a` is in the head or tail of a noun. produces %2 if it
|
||||
:> is within the head, or %3 if it is within the tail.
|
||||
|= a=@
|
||||
^- ?($2 $3)
|
||||
?- a
|
||||
$2 %2
|
||||
@ -204,9 +208,13 @@
|
||||
* $(a (div a 2))
|
||||
==
|
||||
::
|
||||
++ mas :: fragment body
|
||||
++ mas
|
||||
~/ %mas
|
||||
|= a/@
|
||||
:> axis within head/tail
|
||||
:>
|
||||
:> computes the axis of `a` within either the head or tail of a noun
|
||||
:> (depends whether `a` lies within the the head or tail).
|
||||
|= a=@
|
||||
^- @
|
||||
?- a
|
||||
$1 !!
|
||||
@ -215,10 +223,14 @@
|
||||
* (add (mod a 2) (mul $(a (div a 2)) 2))
|
||||
==
|
||||
::
|
||||
++ peg :: fragment compose
|
||||
++ peg
|
||||
~/ %peg
|
||||
|= {a/@ b/@}
|
||||
:> axis within axis
|
||||
:>
|
||||
:> computes the axis of {b} within axis {a}.
|
||||
|= [a=@ b=@]
|
||||
?< =(0 a)
|
||||
:> a composed axis
|
||||
^- @
|
||||
?- b
|
||||
$1 a
|
||||
@ -226,26 +238,125 @@
|
||||
$3 +((mul a 2))
|
||||
* (add (mod b 2) (mul $(b (div b 2)) 2))
|
||||
==
|
||||
:: ::
|
||||
:::: 1c: ideal containers ::
|
||||
:: ::
|
||||
::
|
||||
++ ache |*({a/mold b/mold} $%({$| p/b} {$& p/a})) :: a or b, b default
|
||||
++ bloq @ :: bitblock, eg 3=byte
|
||||
++ each |*({a/mold b/mold} $%({$& p/a} {$| p/b})) :: a or b, a default
|
||||
++ gate $-(* *) :: generic mold
|
||||
++ list |*(a/mold $@($~ {i/a t/(list a)})) :: nullterminated list
|
||||
++ lone |*(a/mold p/a) :: 1-tuple
|
||||
++ mold gate :: normalizing gate
|
||||
++ pair |*({a/mold b/mold} {p/a q/b}) :: 2-tuple
|
||||
++ pole |*(a/mold $@($~ {a (pole a)})) :: faceless list
|
||||
++ qual |* {a/mold b/mold c/mold d/mold} :: 4-tuple
|
||||
{p/a q/b r/c s/d} ::
|
||||
++ quip |*({a/mold b/mold} {(list a) b}) :: list-with for sip
|
||||
++ trap |*(a/mold _|?(*a)) :: producer
|
||||
++ tree |*(a/mold $@($~ {n/a l/(tree a) r/(tree a)})) :: binary tree
|
||||
++ trel |*({a/mold b/mold c/mold} {p/a q/b r/c}) :: 3-tuple
|
||||
++ unit |*(a/mold $@($~ {$~ u/a})) :: maybe
|
||||
::
|
||||
:> # %containers
|
||||
:>
|
||||
:> the most basic of data types
|
||||
+|
|
||||
++ bloq
|
||||
:> blocksize
|
||||
:>
|
||||
:> a blocksize is the power of 2 size of an atom. ie, 3 is a byte as 2^3 is
|
||||
:> 8 bits.
|
||||
@
|
||||
::
|
||||
++ each
|
||||
:: todo: do i add "mold generator:" to the following?
|
||||
:> either {a} or {b}, defaulting to {a}.
|
||||
:>
|
||||
:> mold generator: produces a discriminated fork between two types,
|
||||
:> defaulting to {a}.
|
||||
|*({a/mold b/mold} $%({$& p/a} {$| p/b}))
|
||||
::
|
||||
++ gate
|
||||
:> function
|
||||
:>
|
||||
:> a core with one arm, `$`--the empty name--which transforms a sample noun
|
||||
:> into a product noun. If used dryly as a type, the subject must have a
|
||||
:> sample type of `*`.
|
||||
$-(* *)
|
||||
::
|
||||
++ list
|
||||
:> null-terminated list
|
||||
:>
|
||||
:> mold generator: produces a mold of a null-terminated list of the
|
||||
:> homogeneous type {a}.
|
||||
|*(a/mold $@($~ {i/a t/(list a)}))
|
||||
::
|
||||
++ lone
|
||||
:> single item tuple
|
||||
:>
|
||||
:> mold generator: puts the face of `p` on the passed in mold.
|
||||
|*(a/mold p/a)
|
||||
::
|
||||
++ mold
|
||||
:> normalizing gate
|
||||
:>
|
||||
:> actually a type alias for gate.
|
||||
gate
|
||||
::
|
||||
++ pair
|
||||
:> dual tuple
|
||||
:>
|
||||
:> mold generator: produces a tuple of the two types passed in.
|
||||
:>
|
||||
:> a: first type, labeled {p}
|
||||
:> b: second type, labeled {q}
|
||||
|*({a/mold b/mold} {p/a q/b})
|
||||
::
|
||||
++ pole
|
||||
:> faceless list
|
||||
:>
|
||||
:> like ++list, but without the faces {i} and {t}.
|
||||
:>
|
||||
:> a: a mold for the item type.
|
||||
|*(a/mold $@($~ {a (pole a)}))
|
||||
::
|
||||
++ qual
|
||||
:> quadruple tuple
|
||||
:>
|
||||
:> mold generator: produces a tuple of the four types passed in.
|
||||
:>
|
||||
:> a: first type, labeled {p}
|
||||
:> b: second type, labeled {q}
|
||||
:> c: third type, labeled {r}
|
||||
:> d: fourth type, labeled {s}
|
||||
|* {a/mold b/mold c/mold d/mold}
|
||||
{p/a q/b r/c s/d}
|
||||
::
|
||||
++ quip
|
||||
:> pair of list of first and second
|
||||
:>
|
||||
:> a common pattern in hoon code is to return a ++list of changes, along with
|
||||
:> a new state.
|
||||
:>
|
||||
:> a: type of list item
|
||||
:> b: type of returned state
|
||||
|*({a/mold b/mold} {(list a) b})
|
||||
::
|
||||
++ trap
|
||||
:> a core with one arm `$`
|
||||
:>
|
||||
:> a: return type of the `$` arm.
|
||||
|*(a/mold _|?(*a))
|
||||
::
|
||||
++ tree
|
||||
:> tree mold generator
|
||||
:>
|
||||
:> a `++tree` can be empty, or contain a node of a type and
|
||||
:> left/right sub `++tree` of the same type. pretty-printed with `{}`.
|
||||
:>
|
||||
:> a: type of tree node
|
||||
|*(a/mold $@($~ {n/a l/(tree a) r/(tree a)})) :: binary tree
|
||||
::
|
||||
++ trel
|
||||
:> triple tuple
|
||||
:>
|
||||
:> mold generator: produces a tuple of the three types passed in.
|
||||
:>
|
||||
:> a: first type, labeled {p}
|
||||
:> b: second type, labeled {q}
|
||||
:> c: third type, labeled {r}
|
||||
|*({a/mold b/mold c/mold} {p/a q/b r/c})
|
||||
::
|
||||
++ unit
|
||||
:> maybe
|
||||
:>
|
||||
:> mold generator: either `~` or `[~ u=a]` where `a` is the
|
||||
:> type that was passed in.
|
||||
:>
|
||||
:> a: type when non-null
|
||||
|*(a/mold $@($~ {$~ u/a}))
|
||||
-- =>
|
||||
:: ::
|
||||
:::: 2: layer two ::
|
||||
|
Loading…
Reference in New Issue
Block a user