Skip to content

Instantly share code, notes, and snippets.

View belisarius222's full-sized avatar

Ted Blackman belisarius222

View GitHub Profile
@belisarius222
belisarius222 / cone.hoon
Last active May 21, 2020 23:26
$cone: a definition of type for Nock trees, surjective from hoon $type's with no cores
=>
|%
+$ cone
$@ %noun
$% [%back ix=@ud]
[%loop =cone]
[%cell p=cone q=cone]
[%face p=term q=cone]
[%atom =aura]
[%mote =aura val=@]
@belisarius222
belisarius222 / uruk.rs
Last active March 30, 2020 17:58
Uruk interpreter in Rust
extern crate num;
use num::bigint::{BigUint, ToBigUint};
use std::rc::Rc;
#[derive(Clone, Debug, Eq, PartialEq)]
enum Ur { S, K, J, D }
#[derive(Clone, Debug, Eq, PartialEq)]
enum Exp {
N(Ur),
@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
@belisarius222
belisarius222 / ford-pinto.md
Last active March 17, 2020 22:26
Ford Pinto Spec

Ford Pinto - Smaller and Less Explosive

namesake

Overview and Rationale

Ford Turbo, the current incarnation of Ford, has some exciting features. In retrospect some of those features were the result of irrational exuberance. Many have been in Ford since the beginning.

Ford Pinto is an attempt to take a more measured look at which features Ford actually needs and to support only those features. The overall plan involves passing through Ford Pinto into Ford Focus, which will include performance tuning targeted at the major Ford use cases.

What is Ford actually used for? Building files, and doing mark operations, basically. The primary simplification I'm making to Ford in this revision is to separate those two interfaces. Ford runes other than simple imports have been removed, and there is now a strict layering where building a source file does not depend on mark builds.

@belisarius222
belisarius222 / state-monad.hoon
Created February 25, 2020 09:27
state monad in hoon
=< (do-some-stack-ops ~[1 2 3])
|%
++ do-some-stack-ops
=/ liz (list @)
=/ st (stack @)
=/ m (stat liz @)
^- form:m
;< empty=? bind:m is-empty:st
?. empty
pop:st
@belisarius222
belisarius222 / static-ford.hoon
Last active April 29, 2021 03:07
Ford prototype (Fiesta-style) with !<
|%
:: $plan: ford build, at the current beak
::
+$ plan
$% [%'/.' data=vase]
[%'//' =spur] :: produces !>(*(unit [mark contents]))
[%'/*' =hoon]
[%'/=' face=@tas value=plan]
[%'/:' head=plan tail=plan]
[%'/>' with=plan rest=plan]
@belisarius222
belisarius222 / w.hoon
Created August 26, 2019 02:09
Algorithm W for Hindley-Milner type inference
=>
|%
+$ exp
$~ [%lit %int 0]
$% [%var =var]
[%lit =lit]
[%app fun=exp arg=exp]
[%abs =var bod=exp]
[%let =var val=exp bod=exp]
==
@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 / 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 / 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