Re: [racket-users] TR: Occurrence Typing with custom predicate

2020-03-24 Thread mmcdan
Hello Ben, Good call. I didn't think about the mutability of the container's contents with respect to types. My goal is to create a type that represents an immutable container. After exploring, it looks like there is a workaround: In the case of Vector, I can create a struct to hold the vector

[racket-users] embedding Google Forms/YouTube/… in Scribble

2020-03-24 Thread E Comer
Thank you for your very useful and timely addition to the great Scribble functionality. In this time of great need for on-line learning, it is much appreciated. I hope other additions (e.g. Numbas quiz embedding), will follow in the near future. Congratulations for all the great work, and good

Re: [racket-users] TR: Occurrence Typing with custom predicate

2020-03-24 Thread Ben Greenman
On 3/24/20, mmcdan wrote: > Hello, > > I'm trying to use occurrence typing for (Vectorof Symbol) or (Boxof > Symbol). > > Creating a custom predicate for (Listof Symbol) seems to work: > --- > #lang typed/racket > > (: los? (-> Any Boolean : (Listof Symbol))) > (define los? > (lambda (seq) (and

[racket-users] TR: Occurrence Typing with custom predicate

2020-03-24 Thread mmcdan
Hello, I'm trying to use occurrence typing for (Vectorof Symbol) or (Boxof Symbol). Creating a custom predicate for (Listof Symbol) seems to work: --- #lang typed/racket (: los? (-> Any Boolean : (Listof Symbol))) (define los? (lambda (seq) (and (list? seq) (andmap symbol? seq --- However

Re: [racket-users] Best way to say "terminate unless received by X time"

2020-03-24 Thread David Storrs
Aha! I didn't know there was a udp-receive-evt. That's exactly what I needed, thank you. On Tue, Mar 24, 2020, 4:15 PM Jon Zeppieri wrote: > On Tue, Mar 24, 2020 at 4:03 PM David Storrs > wrote: > > > > I've got this code: > > > > (thread > > (thunk > > (let loop () > > (define-valu

Re: [racket-users] Best way to say "terminate unless received by X time"

2020-03-24 Thread Jon Zeppieri
On Tue, Mar 24, 2020 at 4:03 PM David Storrs wrote: > > I've got this code: > > (thread > (thunk > (let loop () > (define-values (len shost sport) (udp-receive! socket buffer)) > ...do stuff with the received message... > (loop > > I'd like to be able to say "If you have

Re: [racket-users] Best way to say "terminate unless received by X time"

2020-03-24 Thread Jay McCarthy
You can start a second thread that monitors the condition as well as a timer; if the timer goes off first, then you kill the first thread; if the condition happens first, then it continues. If you don't want the second thread to have to monitor the condition, then the first thread should tell the s

[racket-users] Best way to say "terminate unless received by X time"

2020-03-24 Thread David Storrs
I've got this code: (thread (thunk (let loop () (define-values (len shost sport) (udp-receive! socket buffer)) ...do stuff with the received message... (loop I'd like to be able to say "If you haven't received a message in X time, kill the thread". I'm not sure how to

Re: [racket-users] Gradual Typed Racket?

2020-03-24 Thread unlimitedscolobb
On Monday, March 23, 2020 at 9:59:22 PM UTC+1, Hendrik Boom wrote: > > On Mon, Mar 23, 2020 at 12:16:45PM -0400, Ben Greenman wrote: > > > > > Not sure about best practices, but I definitely prefer keeping typed > > and untyped code in separate modules. > > It can be veru useful to be able to

[racket-users] folding xml - reprise

2020-03-24 Thread Catonano
Hi, I'm trying to do something like a fold, but over a tree instead of a list. Is there anything like that? If it's unclear what I mean, there's a mechanism like that in guile: https://www.gnu.org/software/guile/manual/html_node/SXML-Tree-Fold.html They use it e.g. for XML transformations, but i