hoshom
2019-2-12 14:19:48

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.


samth
2019-2-12 14:21:21

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


hoshom
2019-2-12 14:21:33

Oh


samth
2019-2-12 14:21:56

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


samth
2019-2-12 14:22:19

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


hoshom
2019-2-12 14:22:37

Ohhh


hoshom
2019-2-12 14:22:41

It isn’t even checked


samth
2019-2-12 14:22:47

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


hoshom
2019-2-12 14:22:56

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


hoshom
2019-2-12 14:23:02

Thanks


samth
2019-2-12 14:23:34
> (define v (read (open-input-string "#s(x 1 2)")))
> (struct x (y z) #:prefab)
> (x-y v)
1

hoshom
2019-2-12 14:24:20

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


hoshom
2019-2-12 14:24:51

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


samth
2019-2-12 14:26:26

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


samth
2019-2-12 14:26:52

and then get the method implementation out of that data


samth
2019-2-12 14:27:13

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


samth
2019-2-12 14:27:49

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


hoshom
2019-2-12 14:28:21

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


hoshom
2019-2-12 14:29:04

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


hoshom
2019-2-12 14:29:16

thanks


oldsin
2019-2-12 17:17:04

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 : (


daniel
2019-2-12 17:40:03

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.


soegaard2
2019-2-12 17:56:39

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


soegaard2
2019-2-12 17:57:06

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


oldsin
2019-2-12 18:00:15

@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.


soegaard2
2019-2-12 18:01:33

I don’t think there is a bookmarking mechanism.


oldsin
2019-2-12 18:02:40

Maybe there will be plugin serve this in the future…


laurent.orseau
2019-2-12 18:16:57

@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.



laurent.orseau
2019-2-12 18:17:53

The plugin is useful but a bit lame


laurent.orseau
2019-2-12 18:20:38

(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)


bkovitz
2019-2-12 19:41:53

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”.


bkovitz
2019-2-12 19:43:48

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


samth
2019-2-12 19:44:42

can you show the calling code?


bkovitz
2019-2-12 19:47:44

Sure, here it is.


bkovitz
2019-2-12 19:48:50

Here’s the relevant part of the error message.


samth
2019-2-12 19:57:48

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


bkovitz
2019-2-12 19:58:48

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


samth
2019-2-12 20:02:23

yes


bkovitz
2019-2-12 20:03:56

Is there a correct way to type bump-base?


pocmatos
2019-2-12 20:06:04

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


bkovitz
2019-2-12 20:06:45

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?


samth
2019-2-12 20:08:17

You could return two values with cons


samth
2019-2-12 20:08:58

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


samth
2019-2-12 20:09:15

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


bkovitz
2019-2-12 20:12:52

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


bkovitz
2019-2-12 20:13:17

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


bkovitz
2019-2-12 20:14:47

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.


samth
2019-2-12 20:34:23

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


bkovitz
2019-2-12 20:46:29

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.


bkovitz
2019-2-12 20:54:56

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?


spdegabrielle
2019-2-12 23:50:21

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.


bkovitz
2019-2-13 03:26:05

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


hoshom
2019-2-13 04:28:50

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


hoshom
2019-2-13 04:29:51

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


hoshom
2019-2-13 06:57:34

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?