Skip to content

Instantly share code, notes, and snippets.

@belisarius222
Created August 28, 2018 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save belisarius222/6fb49ef0947fd16d87e7eb85b6853b53 to your computer and use it in GitHub Desktop.
Save belisarius222/6fb49ef0947fd16d87e7eb85b6853b53 to your computer and use it in GitHub Desktop.
Hoon type that doesn't include hoon ASTs -- untested
:: $type: a hoon type, represented in noun form
::
:: Instead of lazily evaluating the type of a hoon when compiled against a
:: subject type, use the special value %loop to recurse back up to the
:: nearest %hold.
::
+$ type
$@ ?(%noun %void %loop)
$% [%atom p=term q=(unit @)]
[%cell p=type q=type]
[%core p=type q=coil]
[%face p=$@(term tune) q=type]
[%fork p=(set type)]
[%hint p=(pair type note) q=type]
[%hold p=type]
==
+$ coil $: p=[p=(unit term) q=poly r=vair]
q=type
r=[p=seminoun q=(map term tomo)]
==
:: $tomo: type of a core chapter
::
:: Arm types are stored as a map from the arm's name
:: to its product type, which might contain a %loop
:: if it produces the whole core.
::
+$ tome (pair what (map term type))
::
:: -:!>(*(list @))
::
:: ->
::
:- %hold
:- %fork
%- sy :~
[%atom %n ~]
[%cell [%face %i [%atom %$ ~]] [%face %t %loop]]
==
::
:: -:!>(*(tree @))
::
:: ->
:- %hold
:- %fork
%- sy :~
[%atom %n ~]
:+ %cell
[%face %n [%atom %$ ~]]
[%cell [%face %l %loop] [%face %r %loop]]
==
::
:: -:!>(*(list (tree @)))
::
:: ->
::
:- %hold
:- %fork
%- sy :~
[%atom %n ~]
::
:+ %cell
:+ %face %i
:- %hold
:- %fork
%- sy :~
[%atom %n ~]
:+ %cell
[%face %n [%atom %$ ~]]
[%cell [%face %l %loop] [%face %r %loop]]
==
[%face %t %loop]
==
::
++ unit
|= item=type
^- type
::
(fork [%atom %n ~] [%cell [%atom %n ~] [%face %u type]] ~)
::
++ list
|= item=type
^- type
::
:- %hold
%- fork :~
[%atom %n ~]
::
:+ %cell
[%face %i item]
[%face %t %loop]
==
::
++ lest
|= item=type
^- type
::
[%cell [%face %i item] [%face %t (list item)]]
::
++ tree
|= item=type
^- type
::
:- %hold
%- fork :~
[%atom %n ~]
::
:+ %cell
[%face %n item]
:+ %cell
[%face %l %loop]
[%face %r %loop]
==
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment