Skip to content

Instantly share code, notes, and snippets.

@joemfb
Last active November 30, 2016 18:16
Show Gist options
  • Save joemfb/9fe1c76852783f74c0e8d5cb304c217c to your computer and use it in GitHub Desktop.
Save joemfb/9fe1c76852783f74c0e8d5cb304c217c to your computer and use it in GitHub Desktop.
::
:: super simple console app
::
/? 314
/+ sole
[. sole]
!:
|_ {bow/bowl $~}
::
++ poke
|= *
=+ ost=p.,:(head (prey /sole bow))
[[ost %diff %sole-effect %txt "foo"]~ +>.$]
::
++ poke-sole-action
|= act/sole-action
:: ^- {(list move) _+>.$}
:_ +>.$
:~
|^ [ost.bow %diff %sole-effect resp]
++ resp
?- act
{$det *} [%det ler.act haw.act %set ~]
{$ret *} [%txt "hi there"]
{$clr *} [%mor ~]
==
--
==
++ coup
|= {way/wire saw/(unit tang)}
~& %poke-resolved
~& way
~& ?~(saw ~ ((slog u.saw)))
[~ +>.$]
::
++ peer
|= *
~& %peer-test
:: =+ ost=p.,:(head (prey /sole bow))
=+ wel=[%txt "welcome to %test"]
=+ ins=[%txt "hit <ret> to print some foo"]
=+ pro=[%pro [& %test ":my-test-prompt:"]]
[[ost.bow %diff %sole-effect %mor ~[pro wel ins]]~ +>.$]
--
@joemfb
Copy link
Author

joemfb commented Aug 2, 2016

Copy this to %/app/test/hoon, and then run |start %test and |link %test.

Once linked, the welcome messages in ++peer will print. You can ctrl-x to switch between :talk, :dojo, and :test. Hitting return from the :test prompt with print "hi there".

You can also poke the app from :dojo: :test ~. The ++poke arm get's the bone of the sole subscriber (:hood), and sends a sole-effect to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment