Skip to content

Instantly share code, notes, and snippets.

@mattlevan
Last active November 14, 2017 05:05
Show Gist options
  • Save mattlevan/d92c7787bc13e4336e8792933065e72f to your computer and use it in GitHub Desktop.
Save mattlevan/d92c7787bc13e4336e8792933065e72f to your computer and use it in GitHub Desktop.
Hoon Snippet Interpretation

Flow

First send text from snippet editor to ride below, using the span of whichever subject I've explicitly defined. How do I go about defining the subject which snippets are run against? Call ride, with span as *, which will produce Nock. Then take the Nock and run it with .*.

 ++  ride                                                ::  end-to-end compiler
   |=  {typ/span txt/@}
   ^-  (pair span nock)
   (~(mint ut typ) %noun (ream txt))
::

Pretty printer: text calls deal:us that takes a span and a noun and prints the noun according to the rules of span. It prints that to the printable format tank. deal:us is vase -> tank, as is cell. re core takes tank and produces a tape. ram:re and deal:us are combined in text.

Experiment with building custom subjects instead of the one that apps get by default. Maybe mimic the ones that generators get.

=rid (ride p:!>(.) '42')
(text p.rid .*(. q.rid))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment