Skip to content

Instantly share code, notes, and snippets.

@tacryt-socryp
Last active January 11, 2024 04:00
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tacryt-socryp/b08dc66b7bcc760e914c4db5c9fd7ba7 to your computer and use it in GitHub Desktop.
Save tacryt-socryp/b08dc66b7bcc760e914c4db5c9fd7ba7 to your computer and use it in GitHub Desktop.
Hick, a more traditional lisp than Hoon. Think Clojure with Hoon backing it instead of the JVM. Or, think Hoon, but for hicks.
|%
:: ::
+$ iota :: typed path segment
$+ iota
$~ [%n ~]
$@ @tas
$% [%ub @ub] [%uc @uc] [%ud @ud] [%ui @ui]
[%ux @ux] [%uv @uv] [%uw @uw]
[%sb @sb] [%sc @sc] [%sd @sd] [%si @si]
[%sx @sx] [%sv @sv] [%sw @sw]
[%da @da] [%dr @dr]
[%f ?] [%n ~]
[%if @if] [%is @is]
[%t @t] [%ta @ta] :: @tas
[%p @p] [%q @q]
[%rs @rs] [%rd @rd] [%rh @rh] [%rq @rq]
==
::
++ spot
%+ knee *iota |. ~+
%+ sear (soft iota)
%- stew
^. stet ^. limo
:~ :- 'a'^'z' sym
:- '$' (cold %$ buc)
:- '&' (cold %.y pam)
:- '|' (cold %.n bar)
:- '0'^'9' bisk:so
:- '-' tash:so
:- '.' zust:so
:- '~' ;~(pfix sig ;~(pose crub:so (easy [%n ~])))
:- '\'' (stag %t qut)
==
::
::
+$ sexp
$+ sexp
$~ [%sexp %$ ~]
[%sexp label=@tas args=(list sast)]
::
+$ sast
$+ sast
$~ [%atom [%n ~]]
?([%atom iota] sexp)
::
++ parse
|= =tape
^- sast
|^ (scan tape main)
::(rash cord main)
::
++ main
|= tub=nail
^- (like sast)
%. tub
%- full
%+ ifix [gay gay]
all
::
++ atom
|= tub=nail
^- (like [%atom iota])
%. tub
(stag %atom spot)
::
++ all
|= tub=nail
^- (like sast)
%. tub
;~(pose atom s-exp)
::
++ wit
;~(pose gap ace)
::
++ s-exp
|= tub=nail
^- (like sexp)
%. tub
%+ stag %sexp
%+ ifix [pal par]
;~(plug ;~(sfix sym wit) (more wit all))
--
::
++ compile
|= sass=sast
^- nock
?: ?=(%atom -.sass)
?: ?=(^ +.sass)
[%1 +>.sass]
[%1 +.sass]
=* label label.sass
=* args args.sass
?+ label !!
%ffi
?> ?=([[%atom @tas] *] args)
=* arm-label +.i.args
=/ next-args=(list sast) t.args
:+ %8
q:(~(mint ut p:!>([*(map @tas *) ..zuse])) %noun (ream arm-label))
=- [%9 2 %10 [6 -] %0 2]
|-
?~ next-args !!
=/ next [%7 [%0 3] (compile i.next-args)]
?~ t.next-args next
[next $(next-args t.next-args)]
::
%put
?> ?=([[%atom @tas] * ~] args)
=* key +.i.args
=/ val=nock (compile i.t.args)
:+ %8
q:(~(mint ut p:!>([*(map @tas *) ..zuse])) %noun (ream '~(put by +2)'))
[%9 2 %10 [6 [%1 key] %7 [%0 3] val] %0 2]
::
%get
?> ?=([[%atom @tas] ~] args)
=* key +.i.args
:+ %8
q:(~(mint ut p:!>([*(map @tas *) ..zuse])) %noun (ream '~(got by +2)'))
[%9 2 %10 [6 [%1 key]] %0 2]
::
%seq
?< =(~ args)
=/ last (compile (head args))
=. args +.args
|-
?~ args last
=/ next [%7 [last [%0 3]] (compile i.args)]
?~ t.args next
$(args t.args, last next)
==
::
++ build
|= =tape
^- nock
(compile (parse tape))
::
++ execute
|= =tape
^- *
=/ program (build tape)
~& program
.*([*(map @tas *) ..zuse] program)
--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment