Urbit Developers
  • Hoon

    • Overview
    • Cheat Sheet
    • Irregular forms
    • Hoon Errors
    • Hoon Style Guide
    • Basic Types
    • Advanced Types
    • Auras
    • Standard Library

      • 1a: Basic Arithmetic
      • 1b: Tree Addressing
      • 1c: Molds and Mold-Builders
      • 2a: Unit Logic
      • 2b: List Logic
      • 2c: Bit Arithmetic
      • 2d: Bit Logic
      • 2e: Insecure Hashing
      • 2f: Noun Ordering
      • 2g: Unsigned Powers
      • 2h: Set Logic
      • 2i: Map Logic
      • 2j: Jar and Jug Logic
      • 2k: Queue Logic
      • 2l: Container from Container
      • 2m: Container from Noun
      • 2n: Functional Hacks
      • 2o: Normalizing Containers
      • 2p: Serialization
      • 2q: Molds and Mold-Builders
      • 3a: Modular and Signed Ints
      • 3b: Floating Point
      • 3c: Urbit Time
      • 3d: SHA Hash Family
      • 3e: AES encryption (Removed)
      • 3f: Scrambling
      • 3g: Molds and Mold-Builders
      • 4a: Exotic Bases
      • 4b: Text Processing
      • 4c: Tank Printer
      • 4d: Parsing (Tracing)
      • 4e: Parsing (Combinators)
      • 4f: Parsing (Rule-Builders)
      • 4g: Parsing (Outside Caller)
      • 4h: Parsing (ASCII Glyphs)
      • 4i: Parsing (Useful Idioms)
      • 4j: Parsing (Bases and Base Digits)
      • 4k: Atom Printing
      • 4l: Atom Parsing
      • 4m: Formatting Functions
      • 4n: Virtualization
      • 4o: Molds
      • 5a: Compiler Utilities
      • 5b: Macro Expansion
      • 5c: Compiler Backend & Prettyprinter
      • 5d: Parser
      • 5e: Molds and mold builders
      • 5f: Profiling support
      • Runes

        • Atoms and strings
        • Nock . ('dot')
        • Wild ! ('zap')
        • Change Subject = ('tis')
        • Conditionals ? ('wut')
        • Cores | ('bar')
        • Arms + ('lus')
        • Cells : ('col')
        • Calls % ('cen')
        • Casts ^ ('ket')
        • Structures $ ('buc')
        • Make ; ('mic')
        • Hints ~ ('sig')
        • Imports / ('fas')
        • Terminators -- and ==
        • Limbs and wings

          • Limbs
          • Wings
          • Zuse

            • Table of Contents
            • 2d(1-5): To JSON, Wains
            • 2d(6): From JSON
            • 2d(7): From JSON (unit)
            • 2e(2-3): Print & Parse JSON
          • Arvo

            • Overview
            • Ames

              • Overview
              • Cryptography
              • API Reference
              • Scry Reference
              • Data Types
              • Behn

                • Overview
                • API Reference
                • Scry Reference
                • Examples
                • Clay

                  • Overview
                  • Architecture
                  • Using Clay
                  • Data Types
                  • Scry Reference
                  • API Reference
                  • Examples
                  • Marks

                    • Overview
                    • Writing Marks
                    • Using Marks
                    • Examples
                  • Dill

                    • Overview
                    • API Reference
                    • Scry Reference
                    • Data Types
                    • Eyre

                      • Overview
                      • External API Reference
                      • Internal API Reference
                      • Scry Reference
                      • Data Types
                      • Guide
                      • Gall

                        • Overview
                        • API Reference
                        • Data Types
                        • Threads Reference
                        • Iris

                          • Overview
                          • API Reference
                          • Data Types
                          • Example
                          • Jael

                            • Overview
                            • API Reference
                            • Scry Reference
                            • Data Types
                            • Examples
                            • Threads

                              • Overview
                              • HTTP API
                              • Reference
                              • Gall

                                • Start Thread
                                • Take Result
                                • Take Facts
                                • Stop Thread
                                • Poke Thread
                                • Examples

                                  • Fetch JSON
                                  • Child Thread
                                  • Main-loop
                                  • Poke Agent
                                  • Scry
                                  • Take Fact
                                • Concepts

                                  • Scries
                                  • Subscriptions
                                  • Tutorials

                                    • Move Trace
                                    • Reference

                                      • Cryptography
                                      • Filesystem Hierarchy
                                    • Nock

                                      • Nock Definition
                                      • Explanation
                                      • Example
                                      • Implementations
                                      • Vere

                                        • C Runtime System
                                        • Land of Nouns
                                        • API overview by prefix
                                        • C in Urbit
                                        • Writing Jets
                                        • Cryptography
                                        • Azimuth

                                          • Overview
                                          • Urbit HD Wallet
                                          • Azimuth Data Flow
                                          • Azimuth.eth
                                          • Ecliptic.eth
                                          • Advanced Azimuth Tools
                                          • Life and Rift
                                          • Layer 2

                                            • Layer 2 Overview
                                            • Layer 2 Actions
                                            • Transaction Format
                                            • Rollers
                                            • Roller HTTP RPC-API
                                            • Custom Roller Tutorial
                                          • Glossary

                                            • Ames
                                            • Aqua
                                            • Arm
                                            • Arvo
                                            • Atom
                                            • Azimuth
                                            • Battery
                                            • Behn
                                            • Bridge
                                            • Censures
                                            • chat
                                            • Claims
                                            • Clay
                                            • Comet
                                            • Core
                                            • Delegated Sending
                                            • Desk
                                            • Dill
                                            • Document Proposal
                                            • Dojo
                                            • Door
                                            • Ecliptic
                                            • Event Log
                                            • Eyre
                                            • Galaxy
                                            • Gall
                                            • Gate
                                            • HD Wallet
                                            • Hoon
                                            • Invite Tree
                                            • Iris
                                            • Jael
                                            • Keyfile
                                            • Khan
                                            • Landscape
                                            • Mark
                                            • Moon
                                            • Nock
                                            • Noun
                                            • OTA Updates
                                            • Payload
                                            • pH
                                            • Pier
                                            • Pill
                                            • Planet
                                            • Proxies
                                            • Replay
                                            • Factory Reset
                                            • Naive rollups
                                            • Sail/Udon
                                            • Senate
                                            • Ship
                                            • ship.arvo.network
                                            • Star
                                            • |sync
                                            • Trap
                                            • Upgrade Proposal
                                            • Vane
                                            • Vere
                                            • Voting
                                            • Wallet-Generator
                                            • Additional

                                              • Cryptography
                                              • Software Distribution

                                                • Overview
                                                • Docket File
                                                • Glob
                                              Urbit Developers
                                              • Hoon

                                                • Overview
                                                • Cheat Sheet
                                                • Irregular forms
                                                • Hoon Errors
                                                • Hoon Style Guide
                                                • Basic Types
                                                • Advanced Types
                                                • Auras
                                                • Standard Library

                                                  • 1a: Basic Arithmetic
                                                  • 1b: Tree Addressing
                                                  • 1c: Molds and Mold-Builders
                                                  • 2a: Unit Logic
                                                  • 2b: List Logic
                                                  • 2c: Bit Arithmetic
                                                  • 2d: Bit Logic
                                                  • 2e: Insecure Hashing
                                                  • 2f: Noun Ordering
                                                  • 2g: Unsigned Powers
                                                  • 2h: Set Logic
                                                  • 2i: Map Logic
                                                  • 2j: Jar and Jug Logic
                                                  • 2k: Queue Logic
                                                  • 2l: Container from Container
                                                  • 2m: Container from Noun
                                                  • 2n: Functional Hacks
                                                  • 2o: Normalizing Containers
                                                  • 2p: Serialization
                                                  • 2q: Molds and Mold-Builders
                                                  • 3a: Modular and Signed Ints
                                                  • 3b: Floating Point
                                                  • 3c: Urbit Time
                                                  • 3d: SHA Hash Family
                                                  • 3e: AES encryption (Removed)
                                                  • 3f: Scrambling
                                                  • 3g: Molds and Mold-Builders
                                                  • 4a: Exotic Bases
                                                  • 4b: Text Processing
                                                  • 4c: Tank Printer
                                                  • 4d: Parsing (Tracing)
                                                  • 4e: Parsing (Combinators)
                                                  • 4f: Parsing (Rule-Builders)
                                                  • 4g: Parsing (Outside Caller)
                                                  • 4h: Parsing (ASCII Glyphs)
                                                  • 4i: Parsing (Useful Idioms)
                                                  • 4j: Parsing (Bases and Base Digits)
                                                  • 4k: Atom Printing
                                                  • 4l: Atom Parsing
                                                  • 4m: Formatting Functions
                                                  • 4n: Virtualization
                                                  • 4o: Molds
                                                  • 5a: Compiler Utilities
                                                  • 5b: Macro Expansion
                                                  • 5c: Compiler Backend & Prettyprinter
                                                  • 5d: Parser
                                                  • 5e: Molds and mold builders
                                                  • 5f: Profiling support
                                                  • Runes

                                                    • Atoms and strings
                                                    • Nock . ('dot')
                                                    • Wild ! ('zap')
                                                    • Change Subject = ('tis')
                                                    • Conditionals ? ('wut')
                                                    • Cores | ('bar')
                                                    • Arms + ('lus')
                                                    • Cells : ('col')
                                                    • Calls % ('cen')
                                                    • Casts ^ ('ket')
                                                    • Structures $ ('buc')
                                                    • Make ; ('mic')
                                                    • Hints ~ ('sig')
                                                    • Imports / ('fas')
                                                    • Terminators -- and ==
                                                    • Limbs and wings

                                                      • Limbs
                                                      • Wings
                                                      • Zuse

                                                        • Table of Contents
                                                        • 2d(1-5): To JSON, Wains
                                                        • 2d(6): From JSON
                                                        • 2d(7): From JSON (unit)
                                                        • 2e(2-3): Print & Parse JSON
                                                      • Arvo

                                                        • Overview
                                                        • Ames

                                                          • Overview
                                                          • Cryptography
                                                          • API Reference
                                                          • Scry Reference
                                                          • Data Types
                                                          • Behn

                                                            • Overview
                                                            • API Reference
                                                            • Scry Reference
                                                            • Examples
                                                            • Clay

                                                              • Overview
                                                              • Architecture
                                                              • Using Clay
                                                              • Data Types
                                                              • Scry Reference
                                                              • API Reference
                                                              • Examples
                                                              • Marks

                                                                • Overview
                                                                • Writing Marks
                                                                • Using Marks
                                                                • Examples
                                                              • Dill

                                                                • Overview
                                                                • API Reference
                                                                • Scry Reference
                                                                • Data Types
                                                                • Eyre

                                                                  • Overview
                                                                  • External API Reference
                                                                  • Internal API Reference
                                                                  • Scry Reference
                                                                  • Data Types
                                                                  • Guide
                                                                  • Gall

                                                                    • Overview
                                                                    • API Reference
                                                                    • Data Types
                                                                    • Threads Reference
                                                                    • Iris

                                                                      • Overview
                                                                      • API Reference
                                                                      • Data Types
                                                                      • Example
                                                                      • Jael

                                                                        • Overview
                                                                        • API Reference
                                                                        • Scry Reference
                                                                        • Data Types
                                                                        • Examples
                                                                        • Threads

                                                                          • Overview
                                                                          • HTTP API
                                                                          • Reference
                                                                          • Gall

                                                                            • Start Thread
                                                                            • Take Result
                                                                            • Take Facts
                                                                            • Stop Thread
                                                                            • Poke Thread
                                                                            • Examples

                                                                              • Fetch JSON
                                                                              • Child Thread
                                                                              • Main-loop
                                                                              • Poke Agent
                                                                              • Scry
                                                                              • Take Fact
                                                                            • Concepts

                                                                              • Scries
                                                                              • Subscriptions
                                                                              • Tutorials

                                                                                • Move Trace
                                                                                • Reference

                                                                                  • Cryptography
                                                                                  • Filesystem Hierarchy
                                                                                • Nock

                                                                                  • Nock Definition
                                                                                  • Explanation
                                                                                  • Example
                                                                                  • Implementations
                                                                                  • Vere

                                                                                    • C Runtime System
                                                                                    • Land of Nouns
                                                                                    • API overview by prefix
                                                                                    • C in Urbit
                                                                                    • Writing Jets
                                                                                    • Cryptography
                                                                                    • Azimuth

                                                                                      • Overview
                                                                                      • Urbit HD Wallet
                                                                                      • Azimuth Data Flow
                                                                                      • Azimuth.eth
                                                                                      • Ecliptic.eth
                                                                                      • Advanced Azimuth Tools
                                                                                      • Life and Rift
                                                                                      • Layer 2

                                                                                        • Layer 2 Overview
                                                                                        • Layer 2 Actions
                                                                                        • Transaction Format
                                                                                        • Rollers
                                                                                        • Roller HTTP RPC-API
                                                                                        • Custom Roller Tutorial
                                                                                      • Glossary

                                                                                        • Ames
                                                                                        • Aqua
                                                                                        • Arm
                                                                                        • Arvo
                                                                                        • Atom
                                                                                        • Azimuth
                                                                                        • Battery
                                                                                        • Behn
                                                                                        • Bridge
                                                                                        • Censures
                                                                                        • chat
                                                                                        • Claims
                                                                                        • Clay
                                                                                        • Comet
                                                                                        • Core
                                                                                        • Delegated Sending
                                                                                        • Desk
                                                                                        • Dill
                                                                                        • Document Proposal
                                                                                        • Dojo
                                                                                        • Door
                                                                                        • Ecliptic
                                                                                        • Event Log
                                                                                        • Eyre
                                                                                        • Galaxy
                                                                                        • Gall
                                                                                        • Gate
                                                                                        • HD Wallet
                                                                                        • Hoon
                                                                                        • Invite Tree
                                                                                        • Iris
                                                                                        • Jael
                                                                                        • Keyfile
                                                                                        • Khan
                                                                                        • Landscape
                                                                                        • Mark
                                                                                        • Moon
                                                                                        • Nock
                                                                                        • Noun
                                                                                        • OTA Updates
                                                                                        • Payload
                                                                                        • pH
                                                                                        • Pier
                                                                                        • Pill
                                                                                        • Planet
                                                                                        • Proxies
                                                                                        • Replay
                                                                                        • Factory Reset
                                                                                        • Naive rollups
                                                                                        • Sail/Udon
                                                                                        • Senate
                                                                                        • Ship
                                                                                        • ship.arvo.network
                                                                                        • Star
                                                                                        • |sync
                                                                                        • Trap
                                                                                        • Upgrade Proposal
                                                                                        • Vane
                                                                                        • Vere
                                                                                        • Voting
                                                                                        • Wallet-Generator
                                                                                        • Additional

                                                                                          • Cryptography
                                                                                          • Software Distribution

                                                                                            • Overview
                                                                                            • Docket File
                                                                                            • Glob
                                                                                          Reference/Hoon/Standard Library

                                                                                          5d: Parser

                                                                                          ++vang

                                                                                          Set ++vast parameters

                                                                                          Source

                                                                                          ++ vang :: set ++vast params
                                                                                          |= [bug=? wer=path] :: bug: debug mode
                                                                                          %*(. vast bug bug, wer wer) :: wer: where we are

                                                                                          ++vast

                                                                                          Main parsing core

                                                                                          Source

                                                                                          This core is too large to include here, please refer to hoon.hoon for the source.


                                                                                          ++vest

                                                                                          Parse hoon

                                                                                          Parsing rule. Parse hoon of any form.

                                                                                          Source

                                                                                          ++ vest
                                                                                          ~/ %vest
                                                                                          |= tub=nail
                                                                                          ^- (like hoon)
                                                                                          %. tub
                                                                                          %- full
                                                                                          (ifix [gay gay] tall:vast)

                                                                                          Examples

                                                                                          > (rash '(add 1 1)' vest)
                                                                                          [%cncl p=[%wing p=~[%add]] q=~[[%sand p=%ud q=1] [%sand p=%ud q=1]]]
                                                                                          > (rash '%+ add\0a 1\0a1' vest)
                                                                                          [%cnls p=[%wing p=~[%add]] q=[%sand p=%ud q=1] r=[%sand p=%ud q=1]]

                                                                                          ++vice

                                                                                          Parse wide-form hoon

                                                                                          Parse txt, a knot containing wide-form hoon, to hoon.

                                                                                          Accepts

                                                                                          txt is a @ta.

                                                                                          Produces

                                                                                          hoon.

                                                                                          Source

                                                                                          ++ vice
                                                                                          |= txt=@ta
                                                                                          ^- hoon
                                                                                          (rash txt wide:vast)

                                                                                          Examples

                                                                                          > (vice '(add 1 1)')
                                                                                          [%cncl p=[%wing p=~[%add]] q=~[[%sand p=%ud q=1] [%sand p=%ud q=1]]]
                                                                                          > (vice '%+ add\0a 1\0a1')
                                                                                          {1 3}
                                                                                          syntax error

                                                                                          ++make

                                                                                          Compile cord to nock

                                                                                          Compile txt, an atom containing hoon source code as little-endian UTF-8 text, to nock.

                                                                                          Accepts

                                                                                          txt is a @.

                                                                                          Produces

                                                                                          nock.

                                                                                          Source

                                                                                          ++ make
                                                                                          |= txt=@
                                                                                          q:(~(mint ut %noun) %noun (ream txt))

                                                                                          Examples

                                                                                          > (make '[. . .]')
                                                                                          [p=[%0 p=1] q=[p=[%0 p=1] q=[%0 p=1]]]
                                                                                          > .*(42 (make '[. . .]'))
                                                                                          [42 42 42]

                                                                                          ++rain

                                                                                          Parse with % path

                                                                                          Parse txt, an atom containing hoon source code as little-endian UTF-8 text, to hoon. Any % path short-hands are replaced with the path given in bon. If parsing fails, bon is also printed to the terminal.

                                                                                          Accepts

                                                                                          bon is a path.

                                                                                          txt is an atom.

                                                                                          Produces

                                                                                          hoon.

                                                                                          Source

                                                                                          ++ rain
                                                                                          |= [bon=path txt=@]
                                                                                          ^- hoon
                                                                                          =+ vaz=vast
                                                                                          ~| bon
                                                                                          (scan (trip txt) (full (ifix [gay gay] tall:vaz(wer bon))))

                                                                                          Examples

                                                                                          > (rain /a/b/c '%')
                                                                                          [%clsg p=~[[%sand p=%ta q=97] [%sand p=%ta q=98] [%sand p=%ta q=99]]]
                                                                                          > !<(path (slap !>(~) (rain /a/b/c '%')))
                                                                                          /a/b/c
                                                                                          > (rain / '(add 1 1)')
                                                                                          [%cncl p=[%wing p=~[%add]] q=~[[%sand p=%ud q=1] [%sand p=%ud q=1]]]
                                                                                          > !<(@ud (slap !>(add=add) (rain / '(add 1 1)')))
                                                                                          2

                                                                                          ++ream

                                                                                          Parse cord to hoon

                                                                                          Parse txt, an atom containing hoon source code as little-endian UTF-8 text, to hoon.

                                                                                          Accepts

                                                                                          txt is an atom.

                                                                                          Produces

                                                                                          hoon.

                                                                                          Source

                                                                                          ++ ream
                                                                                          |= txt=@
                                                                                          ^- hoon
                                                                                          (rash txt vest)

                                                                                          Examples

                                                                                          > !<(tape (slap !>(~) (ream '"foobar"')))
                                                                                          "foobar"

                                                                                          ++reck

                                                                                          Parse hoon file

                                                                                          Parse bon to hoon. bon is a path to a .hoon file without the mark.

                                                                                          Accepts

                                                                                          bon is a path.

                                                                                          Produces

                                                                                          hoon.

                                                                                          Source

                                                                                          ++ reck
                                                                                          |= bon=path
                                                                                          (rain bon .^(@t %cx (weld bon `path`[%hoon ~])))

                                                                                          Examples

                                                                                          > (reck %/gen/code)
                                                                                          [ %clhp
                                                                                          p=[%rock p=%tas q=7.954.803]
                                                                                          q
                                                                                          [ %brts
                                                                                          p
                                                                                          [ %bccl
                                                                                          p
                                                                                          [ i
                                                                                          [ %bccl
                                                                                          p
                                                                                          [ i
                                                                                          [%bcts p=term=%now q=[%base p=[%atom p=~.da]]]
                                                                                          t
                                                                                          ......(truncated for brevity)..........

                                                                                          ++ride

                                                                                          End-to-end compiler

                                                                                          Parse and compile cord txt, producing a pair of its type and compiled nock. The typ argument specifies the type of the subject.

                                                                                          Accepts

                                                                                          typ is a type

                                                                                          txt is an atom.

                                                                                          Produces

                                                                                          A (pair type nock).

                                                                                          Source

                                                                                          ++ ride
                                                                                          |= [typ=type txt=@]
                                                                                          ^- (pair type nock)
                                                                                          ~> %slog.[0 leaf/"ride: parsing"]
                                                                                          =/ gen (ream txt)
                                                                                          ~> %slog.[0 leaf/"ride: compiling"]
                                                                                          ~< %slog.[0 leaf/"ride: compiled"]
                                                                                          (~(mint ut typ) %noun gen)

                                                                                          Examples

                                                                                          ride: parsing
                                                                                          ride: compiling
                                                                                          ride: compiled
                                                                                          > (ride -:!>(.) '(add 2 2)')
                                                                                          [ #t/@
                                                                                          q
                                                                                          [ %8
                                                                                          p=[%9 p=36 q=[%0 p=1.023]]
                                                                                          q
                                                                                          [ %9
                                                                                          p=2
                                                                                          q
                                                                                          [ %10
                                                                                          p
                                                                                          [ p=6
                                                                                          q
                                                                                          [ p=[%7 p=[%0 p=3] q=[%1 p=2]]
                                                                                          q=[%7 p=[%0 p=3] q=[%1 p=2]]
                                                                                          ]
                                                                                          ]
                                                                                          q=[%0 p=2]
                                                                                          ]
                                                                                          ]
                                                                                          ]
                                                                                          ]
                                                                                          ride: parsing
                                                                                          ride: compiling
                                                                                          > (ride %noun '(add 2 2)')
                                                                                          -find.add
                                                                                          dojo: hoon expression failed

                                                                                          <-

                                                                                          5c: Compiler Backend & Prettyprinter

                                                                                          5e: Molds and mold builders

                                                                                          ->

                                                                                          Edit this page on GitHub