
Is there some fundamental reason I can’t add #:methods for generics in prefab structs? I gave it a little thought and since those methods are a per-type thing, not a per-instance thing, they shouldn’t interfere with the read/write-ability of prefab structs.

@hoshom prefab structs are defined by their printed representation, and so anything that doesn’t fit in that isn’t allowed

Oh

for example, (read (open-input-string "#s(x 1 2)"))
works

and the resulting prefab struct can’t know about the methods you added to a struct
declaration

Ohhh

It isn’t even checked

especially since the struct declaration can come after you do that read

I thought if I defined struct x and gave it one field then that would fail but it doesn’t

Thanks

> (define v (read (open-input-string "#s(x 1 2)")))
> (struct x (y z) #:prefab)
> (x-y v)
1

hmm but see, similar to how that struct declaration creates accessors for the struct, can it not also create methods for it?

(All of a sudden my light-bulb moment’s gone and I’m thinking “but wait…”)

the way methods work is that they access some data on the struct type of the value provided as the argument

and then get the method implementation out of that data

that can’t work here, because the struct type is created on line 1, but the methods wouldn’t be declared until later

you could have a different implementation of methods for prefab structs but that would be very different and more like how fallbacks for methods work

Hmmm I kiiind of see, I suppose. I dunno. So it’s just really difficult to do, I guess.

Actually yes, teh fallback thing was how I imagined it would work

thanks

Does DrRacket provides any kind of quick traversing tool for scribble documents? Feel my eyes getting tired when I try to find a certain section : (

Can anyone point me to individual videos of the (eighth RacketCon)
sessions? I can only seem to find “RacketCon 2018 Morning” and “RacketCon 2018 Afternoon”. The video and audio quality of both leaves, well, everything to be desired. No offense intended.

@oldsin Well, you can search for the name of a section

@daniel I don’t think they are out yet. @leif ?

@soegaard2 Sure I can. But this requires you to type the name of sections all the time! Now I just try to put my sections into different files, just like the what’s being introduced in the tutorial — that may sounds like a acceptable compromise.

I don’t think there is a bookmarking mechanism.

Maybe there will be plugin serve this in the future…

@oldsin: There’s some basic bookmarking in quickscript-extra, it works for slideshow and custom titles, but not yet for scribble. That should be very easy to adapt though, it’s just a regexp to change.


The plugin is useful but a bit lame

(if you don’t have quickscript-extra but you have the lastest version of DrRacket which includes quickscript (not extra), you can just create a new script and copy/paste the file pointed at on github, then modify it)

Is there a way to get Typed Racket to do the type inference needed in continuation-passing style? When I try to compile code that calls the function below, the type-checker rejects the continuation for not returning type “a”.

I tried wrapping the calling code with inst
, but that didn’t work.

can you show the calling code?

Sure, here it is.

Here’s the relevant part of the error message.

ah, ok. you can’t abstract over multiple values with a single type variable that way

Oh, is the problem that the caller wants to return (Values ...)
?

yes

Is there a correct way to type bump-base
?

@greg are you around? I am having a small problem with frog.

Actually, this whole bit of code seems convoluted to me. I had another version written with call-with-values
but it was also hard to follow. The complexity comes from its updating a collection and returning a new item at the same time—hence multiple values. I do this a lot in my code, though this is the only place with CPS. Is there any common idiom for doing this kind of thing?

You could return two values with cons

does the code always return two values? if so, you can just have two type variables.

you can also make the code you originally wrote work with a bit more type complexity

I was hoping to avoid cons for speed and simplicity: no memory allocation or destructuring. Perhaps not too important.

How could I properly type the existing code? I’ll probably learn something valuable from that.

About two type variables: I’m thinking that the function that’s passed the continuation shouldn’t care what the continuation returns. “Whatever k returns, I return.” So, it shouldn’t care whether the continuation returns one or multiple values. But, in this situation, I do know. bump-base
is not provided externally.

(: bump-base (All (a ...) ((Hashof Base Suffix) Base ((Hashof Base Suffix) Id -> (Values a ...)) -> (Values a ...))))
makes the original program type check

Thanks! I just did the same thing on the other function that gets called that way, and now the whole file type-checks. That definitely shows how to do it in general: I hadn’t used the ...
before.

Hmm, under typed/rackunit, check-equal?
doesn’t report the line number of the failing test (unlike untyped rackunit). Is there an easy way to get it to show the line number?

I can’t find individual videos. It’s a shame. YouTube RacketCon views outnumber RacketCon attendees 10 to 1. On the bright side it should be pretty easy to scrub through each session video to find the ones you want. Sadly, I can’t see a programme.

In typed/racket, is it possible to create a singleton type for a struct?

What sort of singleton do you mean? Because a prefab struct is kind of like a singleton.

If you mean “a struct that may only ever have one instance” then I dunno

I guess one way to do it would be to make sure the module defining the struct doesn’t export (“provide”) the default constructor. Does typed/racket complicate that?