uip | title | description | author | status | type | category | created |
---|---|---|---|---|---|---|---|
0128 |
Seer |
A monadic scry interface. |
~fodwyt-ragful, ~mastyr-bottec |
Draft |
Standards Track |
Kernel, Hoon |
2023-10-04 |
Seer is a monadic scry interface which allows application developers to
read from the namespace without using dotket (.^
) or its virtual
Nock operator 12. Once we remove Nock 12, all code in the system
can take advantage of persistent memoization.
dotket and Nock 12, which dotket compiles to, makes Nock not referentially transparent. By consequence, memoization is less effective.
In the interest of removing dotket and Nock 12 in the future, a replacement must first be supplied. The replacement should attempt to be as ergonomic as dotket.
Here's a Gall agent snippet that scries with .^
:
++ on-poke
|= [m=mark v=vase]
^- (quip card _this)
=/ foo-result .^ @da /cx/(now)/foo
:: do something with foo-result...
[~ this]
Here's the same Gall agent snippet that scries with seer
in the
continuation style:
++ gear :: gall seer
|* a=mold
(seer vase a)
++ on-poke
|= [m=mark v=vase]
^- (gear (quip card _this)) :: (seer vase (quip card _this))
:+ %scry /cx/(now)/foo |= foo=vase
=/ foo-result !<(@ foo)
:: do something with foo-result...
[%done ~ this]
Here's an example of composing seer
values with monadic bind:
++ foo ^- (seer vase @) !! :: /foo
++ bar ^- (seer vase @) !! :: /bar
++ on-poke
|= [m=mark v=vase]
=* r (quip card _this)
^- (gear r)
=/ bind (rapt vase r)
;< foo=@ bind foo
;< bar=@ bind bar
[%done ~ this(some-state (add foo bar))]
A seer
is the type of programs that scry:
++ seer
|* [r=mold a=mold]
$~ [%done *a]
$% [%done p=a]
[%scry p=path k=$-(r (seer r a))]
==
See the reference implementation for the monadic bind (rapt
).
We believe seer
degrades ergonomics only slightly while removing an ugly
wart that has plagued Urbit since its birth.
12 destroys the referential transparency of Nock, making every computation dependent on a hidden context. This prevents transparent, system-wide persistent memoization (among other things).
The seer
scry system is intentionally incompatible with the .^
scry system.
We will support both scry styles for some time before deprecating and eventually
removing .^
. In the meantime, we shall provide a wrapper library which accepts
an agent written in the seer
-style and produces an agent that scries in the
.^
-style.
A simpler system is a more secure system.
Copyright and related rights waived via CC0.