Skip to content

Instantly share code, notes, and snippets.

View belisarius222's full-sized avatar

Ted Blackman belisarius222

View GitHub Profile
@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]
@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 / nock-cps.hoon
Last active August 26, 2018 22:42
Nock CPS transform
|%
+$ nock-func $-(subject=* result=*)
+$ cps-formula $-([subject=* next=nock-func] result=*)
--
|%
++ nock-to-cps
|= fol=nock
^- cps-formula
::
?- fol
@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 / type-no-hoons.hoon
Created August 28, 2018 08:21
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]
@belisarius222
belisarius222 / fords.hoon
Created September 7, 2018 16:05
Sketch of an interpreter for new Ford runes
|%
+$ op
$@ $? %bail :: error out
%call :: =+ gate=pop =+sample=pop (gate sample)
%cons :: =+ head=pop =+ tail=pop [head tail]
%copy :: duplicate top of stack
%done :: halt (successfully)
%eval :: eval top of stack as schematic against next top as subject
%numb :: catch error
%swap :: swaps top two elements of stack
@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 / 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)
::
@belisarius222
belisarius222 / ddp_log.js
Created January 10, 2013 07:24
patch client-side Meteor functions to print out the DDP messages. Add this somewhere in your client-side JS before Meteor.startup() and it should print out the DDP messages. Please let me know if there are some that are missing! I'm not sure I caught all of the handler functions.
var monkeyPatches = {
'_livedata_data': 'DATA',
'_livedata_error': 'ERROR',
'_livedata_nosub': 'NOSUB',
'_livedata_connected': 'CONNECTED',
'_livedata_result': 'RESULT',
};
_.each(_.keys(monkeyPatches),function(funcName){
var modifiedFunctionName = funcName+'_original';
var extension = {};
@belisarius222
belisarius222 / monads.hoon
Created February 29, 2020 00:39
monads.hoon
|%
++ mebe
|* a=mold
|%
+$ form (unit a)
++ pure
|= arg=a
^- form
`u=arg
++ bind