Last active
August 27, 2018 23:33
-
-
Save belisarius222/ff34b493238b45661724747aa258f079 to your computer and use it in GitHub Desktop.
Ford runes as DSL for +schematic:ford
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: 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) | |
:: | |
/+ /. [a=a b=%bar] | |
:: /! evaluate a hoon against the subject (%ride / +slap) | |
:: | |
/+ /! [b b] | |
:: | |
:: now subject is [[%bar %bar] [a=2 b=%bar] <reef>] (as a vase) | |
:: | |
:: // evaluate a sub-schematic /* load a resource (scry) | |
:: | |
/+ // /* %cx /. /===/sur/hood/mail/hoon | |
:: /= wrap a face around the prepended expression | |
:: | |
/+ /= lib-mail // /* /. /===/lib/hood/mail/hoon | |
:: | |
/+ /= my-email /* /===/web/emails/last/txt | |
:: /| fallback options with error message | |
:: | |
/| [%leaf "could not find image"]~ | |
:: /^ cast marked data to another mark | |
:: | |
/+ /= img /^ /. %mime /* /===/web/private/furries/png | |
:: | |
:: evaluate source as a schematic, casting result to a different mark | |
:: | |
/+ /= fav /^ /. %mime /* /===/lib/make-favicon/hoon | |
== | |
:: /$ slam a gate against a sample | |
:: | |
/$ /! | |
:: gate to slam | |
:: | |
|= email=email-mold-from-sur | |
^- parsed-email-mold-from-sur | |
:: | |
=/ parsed-email=parsed-email-mold-from-sur | |
(parse-email:lib-mail email) | |
:: | |
=. images.parsed-email [img images.parsed-email] | |
:: | |
parsed-email | |
:: sample against which to slam gate | |
:: | |
/! my-email | |
:: toy root web request dispatcher | |
:: | |
|= [[now=@da eny=@ bek=beak] request=http-request:eyre ~] | |
^- schematic:ford | |
:: | |
=/ path-to-render=path path.request | |
:: | |
// /* `beam`[bek path-to-render] | |
:: a low-level schematic definition -- omitting all mark operations | |
|% | |
+= schematic | |
:: a pair of schematics produces a cell | |
:: | |
$^ [head=schematic tail=schematic] | |
$% :: %call: call a gate on a sample | |
:: | |
[%call gate=schematic sample=schematic] | |
:: %eval: evaluate the result of a schematic as another schematic | |
:: | |
[%eval =schematic] | |
:: %head: with :head's result in head of subject, evaluate :rest | |
:: | |
[%head head=schematic rest=schematic] | |
:: %here: produce the :literal +cage as a noop | |
:: | |
[%here literal=cage] | |
:: %load: load a resource from urbit's scry namespace | |
:: | |
[%load term=schematic beam=schematic] | |
:: %numb: if :attempt results in an error, catch and produce the error | |
:: | |
[%numb attempt=schematic] | |
:: %reef: assert standard library version | |
:: | |
[%reef version=@ud] | |
:: %ride: evaluate a +hoon against the current subject | |
:: | |
[%ride =hoon] | |
:: %with: use result of :subject to evaluate :rest | |
:: | |
[%with subject=schematic rest=schematic] | |
== | |
-- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment