New package announce: value-evt

25 views
Skip to first unread message

David Storrs

unread,
Apr 1, 2021, 12:12:51 PM4/1/21
to Racket Users
Wraps an arbitrary value into a synchronizable event. The
synchronization result of the event is the original value, with two
exceptions: procedures sync to their return value and lists sync
recursively. Both of these values can be disabled via keywords.

The package server is telling me that it needs documentation. That
confuses me since it has a .scrbl file and the .html was already
present in the repository. ISTR that the docs are only built once
every 24 hours, so presumably they will pop up at some point?

Examples:

; value-evts are both evt? and value-evt?. They sync to their argument
> (define e (value-evt 9))
> e
#<value-evt>
> (evt? e)
#t
> (value-evt? e)
#t
> (sync e)
9
;
; By default, syncing on a procedure syncs to the return value
> (define proc (lambda () (+ 2 2)))
> (sync (value-evt proc))
4
;
; You can instead get the procedure itself back
> (sync (value-evt proc #:eval-proc? #f))
#<procedure:proc>
;
; It's not a problem to specify #:eval-proc? on something that isn't a procedure
> (sync (value-evt "eval-proc? keyword is ignored for non-proc" #:eval-proc? #f))
"eval-proc? keyword is ignored for non-proc"
;
; eventify always returns an evt
; Things that are evts are unchanged
> (define ch (make-channel))
> (evt? ch)
#t
> (eq? ch (eventify ch))
#t
;
; Things that are not evts become value-evts
> (evt? 'bob)
#f
> (evt? (eventify 'bob))
#t
;
; by default, value-evts containing a list sync recursively
> (let ([result-ch (make-channel)]
[arg-ch1 (make-channel)]
[arg-ch2 (make-channel)])
(void (thread (λ () (channel-put result-ch (sync (value-evt (list
arg-ch1 arg-ch2)))))))
(channel-put arg-ch1 'arg1-ch-ok)
(channel-put arg-ch2 'arg2-ch-ok)
(sync result-ch))
'(arg1-ch-ok arg2-ch-ok)
;
; You can ask for it to return the original list
> (let ([arg-ch1 (make-channel)]
[arg-ch2 (make-channel)])
(sync (value-evt (list arg-ch1 arg-ch2) #:recurse-lists? #f)))
'(#<channel> #<channel>)
;
; all-evt is the same as value-evt but takes a rest argument
; so you don't have to supply your own list
> (let ([result-ch (make-channel)]
[arg-ch1 (make-channel)]
[arg-ch2 (make-channel)])
(define e (all-evt arg-ch1 arg-ch2))
(printf "all-evt returns: ~v" e)
(void (thread (λ () (channel-put result-ch (sync e)))))
(channel-put arg-ch1 'arg1-ch-ok)
(channel-put arg-ch2 'arg2-ch-ok)
(sync result-ch))
all-evt returns: #<value-evt>
'(arg1-ch-ok arg2-ch-ok)

Sage Gerard

unread,
Apr 1, 2021, 12:18:39 PM4/1/21
to racket...@googlegroups.com
Neat! Thanks for this. Did you make sure to list your scribble file in
`scribblings` under info.rkt?
> --
> You received this message because you are subscribed to the Google Groups "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CAE8gKocr0FbpTKwgNcseNjjA_-64f4exQDkgfPPxxvFpR16pww%40mail.gmail.com.

--
~slg


David Storrs

unread,
Apr 1, 2021, 12:32:13 PM4/1/21
to Sage Gerard, Racket Users
On Thu, Apr 1, 2021 at 12:18 PM Sage Gerard <sa...@sagegerard.com> wrote:
>
> Neat! Thanks for this. Did you make sure to list your scribble file in
> `scribblings` under info.rkt?
>

I did, yes.

Although, now that you mention it, when I do raco setup value-evt it
does all the things, says "Building documentation" but the .html file
did not appear in the directory and it's not linked into my local doc
set. I hadn't noticed because I had previously created the file
directly using 'scribble value-evt.scrbl' What might I have done
wrong?
> To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/99793234-257c-d8e5-7454-a1d911d2ab66%40sagegerard.com.

Sage Gerard

unread,
Apr 1, 2021, 12:37:44 PM4/1/21
to David Storrs, Racket Users
I compared the info.rkt files between your thread-with-id library and
value-evt. One thing that stands out is the extra empty list in
value-evt. I'm wondering if that hid defaults that would otherwise be
provided.

https://github.com/dstorrs/value-evt/blob/master/info.rkt
https://github.com/dstorrs/thread-with-id/blob/master/info.rkt

If that's not it, I'd have to take time after work to look more closely.
--
~slg


Sorawee Porncharoenwase

unread,
Apr 1, 2021, 1:10:28 PM4/1/21
to Sage Gerard, David Storrs, Racket Users
`raco setup` does render the doc on my computer. I install Racket via git, so for me, the doc is located at `/path/to/racket/racket/doc/value-evt/index.html`. Yours might be in a different location.

So I think you just need to wait for the package server to build your documentation.

Sorawee Porncharoenwase

unread,
Apr 1, 2021, 1:12:34 PM4/1/21
to Sage Gerard, David Storrs, Racket Users
Oops, accidentally submitted the email before finishing writing.

Have you tried `raco docs value-evt`?

David Storrs

unread,
Apr 1, 2021, 2:38:24 PM4/1/21
to Sage Gerard, Sorawee Porncharoenwase, Racket Users
Sorawee: Thanks, glad to hear that it worked for you.

Sage: Brilliant, that did it. In the scribblings/ directory it
created a compiled/ directory with the data instead of generating the
.html file directly, but it is in the local copy of the Reference.
Thanks very much! I've removed the '(), pushed the new version, and
asked the package server to rescan.
Reply all
Reply to author
Forward
0 new messages