Skip to content

Instantly share code, notes, and snippets.

View belisarius222's full-sized avatar

Ted Blackman belisarius222

View GitHub Profile
@belisarius222
belisarius222 / nock-cps.hoon
Last active August 26, 2018 03:25
Nock with continuation on scry
=> |%
+$ result
%+ each *
::
$: blocks=(set [=term =beam])
::
$= continuation
$- (map [=term =beam] (unit cage))
result
==
@belisarius222
belisarius222 / future-runes.hoon
Last active August 27, 2018 23:33
Ford runes as DSL for +schematic:ford
:: start with some data from the lexical subject
::
=/ a=@ 2
:: a ford rune produces a +schematic:ford
::
^- schematic:ford
:: /? produces a %reef at that version
::
/? 310
:: /+ prepend expression into subject (like =+ for ford)
@belisarius222
belisarius222 / turbo-cache-key.hoon
Created August 8, 2018 22:26
"super advanced" content-addressed caching for Ford-Turbo
:: +cache-key: a key for looking up a build in the cache
::
+= cache-key
$: sub-results=(list build-result)
$% [%$ literal=cage]
[%alts ~]
[%bake renderer=term query-string=coin path-to-render=rail]
[%bunt mark=term]
[%call ~]
[%cast mark=term]
:: +cache-key: a key for looking up a build in the cache
::
+= cache-key
$: sub-results=(list build-result)
$% [%$ literal=cage]
[%alts ~]
[%bake renderer=term query-string=coin path-to-render=rail]
[%bunt mark=term]
[%call ~]
[%cast mark=term]
@belisarius222
belisarius222 / differ.hoon
Last active January 1, 2019 01:10
auto-generated diffing using Hoon types
|%
:: +make-diff: create a noun representing the diff from :a to :b
::
++ make-diff
|= [a-vase=vase b-vase=vase]
^- vase
::
?> (~(nest ut p.a-vase) | p.b-vase)
?> (~(nest ut p.b-vase) | p.a-vase)
::
:: +build-status: current data for a build, including construction status
::
:: +build-status stores the construction status of a build as a finite
:: state machine (:state), and it also contains the information needed
:: to relate this build to other builds, such as clients and sub-builds.
::
+= build-status
$: :: listeners: current set of external listeners tracking this build
::
listeners=(set listener)
@belisarius222
belisarius222 / bi-heap.hoon
Last active June 4, 2018 22:22
Binomial Heap
|%
++ heap
|* a=mold
|= compare=$-([a a] ?)
=> |%
+= bi-tree [val=a rank=@ud kids=(list bi-tree)]
+= bi-heap (list bi-tree)
--
|%
::
@belisarius222
belisarius222 / nuford.hoon
Last active March 13, 2018 00:01
ford data structures
::
:: sys/ford/hoon
::
|%
::
:: +axle: overall ford state
::
+= axle
$: :: date: date at which ford's state was updated to this data structure
::
@belisarius222
belisarius222 / nock.txt
Last active October 3, 2018 22:49
nock version 4 without macros
A noun is an atom or a cell. An atom is a natural number. A cell is an ordered pair of nouns.
Reduce by the first matching pattern; variables match any noun.
nock(a) *a
[a b c] [a [b c]]
?[a b] 0
?a 1
+[a b] +[a b]
@belisarius222
belisarius222 / algo.md
Last active February 18, 2018 04:26
future Ford design

Ford rebuild algorithm

Steps

  1. Ford receives a ++sign from Clay containing the ++care of new revisions of some files we subscribed to on a ++path.
  2. Ford does a bi-jug lookup of the changed dependencies in its state's deps, which will return a set of ++build-indices whose builds they refer to may need to get rebuilt.
  3. For each of those build indices, Ford calls ++build-up.